[OSM-dev] Difference between osm and osmChange formats

Frederik Ramm frederik at remote.org
Wed Jun 1 14:34:13 BST 2011


Hi,

On 05/31/11 23:43, Sergey Galuzo wrote:
> Obvious differences between full and change are explicit
> create/modify/delete tags.

We have full history OSM files and normal OSM files (both use .osm 
extension and <osm>...</osm>), and we have simple diffs and replication 
diffs (both use .osc and <osmChange>...</osmChange>).

Normal OSM files never have a "visible" attribute, and they contain at 
most one version of every object.

Objects in full history OSM files contain a "visible" attribute, and 
these files may contain different versions of the same object, with at 
most one having visible=true. If there is a version with visible=true, 
it will be the highest numbered version of that object. They do not 
necessarily contain a full sequence of versions, i.e. you could have a 
full history file that only has versions 2 and 5 of something.

(There are also .osm files as written by the JOSM editor; these do not 
have a "visible" attribute but may have an "action" attribute which, if 
set to "delete", has a similar effect. This is a niche case.)

The diffs contain <delete>, <modify>, and <create> blocks. A version in 
<create> is usually 1. (Current implementation means it is *always* 1 
but this could be changed; it is not specified in the API that the first 
version of something must always be 1.) A version in <create> or 
<modify> can never have visible=false.

If you have full replication diffs then one diff can contain the same 
object multiple times, with different version numbers. It is possible 
for the same object to appear in the <create>, <modify>, and <delete> 
section of the same replication diff. Versions are not guaranteed to be 
sorted, i.e. you could first encounter version 6 in a <delete> block and 
later encounter version 5 in a <modify>.

Since multiple edits are conflated in a simple diff, it is possible that 
a simple diff contains an object as version 2 in a <modify> block but 
the consumer has never before seen that object (because the version 1 
that would have been in a <create> has happened in the same diff 
interval as the modification to version 2).

In short, your assumption

var changeTag = !Visible ? "delete" : Version == 1 ? "create" : "modify";

is mostly true but it depends very much on the context in which you want 
to use it; there's a lot of things to trip you over.

Bye
Frederik



More information about the dev mailing list