OsmChange

From OpenStreetMap

Jump to: navigation, search

osmChange is the file format used by osmosis to describe differences between two dumps of OSM data. However, if can also be used as the basis for anything that needs to represent changes. For example, bulk uploads/deletes/changes are also changesets and they can also be described using this format.

For otherways of describing differences between datasets, see planetdiff and the JOSM file format.

Example

<osmChange version="0.3" generator="Osmosis">
   <modify version="0.3" generator="Osmosis">
       <node id="12050350" timestamp="2007-01-02T00:00:00.0+11:00" lat="-33.9133118622908" lon="151.117335519304">
           <tag k="created_by" v="JOSM"/>
       </node>
   </modify>
</osmChange>

This is the changeset to modify that single node. The outermost tag is osmChange. Within that are three possible types of nodes:

  • create
  • modify
  • delete

The contents of these nodes are the same as the contents of the osm tag returned from the server. It may be any collection of nodes, segments or ways. Obviously for deletions only the node is necessary but traditionally the actual data is included to make it more obvious to humans reading the file what is actually being deleted.

Note: The create/modify/delete "action" is applied at the node/way/relation level. There is no way of applying changes at a tag level. So in other words if you wish to add tags you need to include all existing tags in your modified entry.

Placeholders

One common issue when uploading new data to the server is that IDs are allocated by the server and thus are not known at the time the file is created. The way to deal with this is to use numbers less than zero. These function as placeholders and when the node/segment/way is created, for the rest of the file the placeholder is replaced by the ID of the node created.

The JOSM file format has a similar feature, planetdiff is purely designed to diff/patch planet files and does not support this. As of this writing osmosis does not support this feature when applying changes to a database, all other tasks should support negative identifiers. However, there is a bulk uploader (bulk_import.pl) that does.

A quick example of how this works is a simple extension of the above example.

<osmChange version="0.3" generator="Osmosis">
   <create version="0.3" generator="Osmosis">
       <node id="-1" timestamp="2007-01-02T00:00:00.0+11:00" lat="-33.9133118622908" lon="151.117335519304">
           <tag k="created_by" v="JOSM"/>
       </node>
       <node id="-2" timestamp="2007-01-02T00:00:00.0+11:00" lat="-33.9233118622908" lon="151.117335519304">
           <tag k="created_by" v="JOSM"/>
       </node>
       <way id="-3" timestamp="2007-01-02T00:00:00.0+11:00">
           <nd ref="-1"/>
           <nd ref="-2"/>
           <tag k="created_by" v="JOSM"/>
       </way>
   </create>
</osmChange>

This creates two nodes at the specified positions and joins them with a way. This will never clash with any existing data.

To implement this programs need a cache file to track what has been uploaded and what hasn't.

Personal tools
recent changes