Osm-data

From OpenStreetMap Wiki
Jump to navigation Jump to search

information sign

Software described on this page or in this section is unlikely to be compatible with API v0.5, and API v0.6 (current version) deployed in 2007 and 2009.
If you have fixed the software, or concluded that this notice does not apply, remove it.

OSM-Data is an old ruby library öpcated in subversion path util/osm-data/lib for easier handling with the osm data objects. I extracted this from little-osm.

It is currently used in little-osm, the testserver.rb script and planet2mysql.rb


To use it, include the util/osm-data/lib directory to your include path and then require "osm/data" or "osm/rexml" (if you want to/from XML support). Look for one of the scripts mentioned above for an example.

Some examples:

node = Node.new :id => 23, :lat => 51, :lon => 11, :timestamp => Time.now
puts node.to_xml # prints: <node id='23' lat='51' lon='11' />
puts node.to_uid # prints an id, that is unique among all osm 
                 # primitives, not only all nodes
node["name"] = "Baker Street" # access to tags via []
puts node.timestamp  # prints the creation time

Documentation can be generated by calling to "rdoc" within the osm-data subdirectory.