OSM XML

From OpenStreetMap Wiki
(Redirected from XML)
Jump to: navigation, search
Help
Available languages
Deutsch English Italiano 日本語

Contents

Basics

XML is a so called meta format to provide even human readable data interexchange formats. Various file formats use this HTML tree like structures to embedd their datas like SVG, ODT,...

pros cons
  • human readable because of clear structure
  • machine independent due to exact definitions, e.g. character sets, XML schema definitions, DTD,...
  • ready to use parsers for general XML that can be customized for a concrete file format
  • good compression ratio
  • very huge files
  • might need to decompress before
  • parsing takes a lot of time

OSM XML file format

The major tools in the OSM universe use an XML format following this XML schema definition [1] that was first used by the API only. Basically it is a list of instances of our data primitives (nodes, ways, and relations) that are the architecture of the OSM model.

Here is a shortened example of a complete OSM XML file:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.0.2">
 <bounds minlat="54.0889580" minlon="12.2487570" maxlat="54.0913900" maxlon="12.2524800"/>
 <node id="298884269" lat="54.0901746" lon="12.2482632" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>
 <node id="261728686" lat="54.0906309" lon="12.2441924" user="PikoWinter" uid="36744" visible="true" version="1" changeset="323878" timestamp="2008-05-03T13:39:23Z"/>
 ...
 <node id="298884272" lat="54.0901447" lon="12.2516513" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>
 <way id="26659127" user="Masch" uid="55988" visible="true" version="5" changeset="4142606" timestamp="2010-03-16T11:47:08Z">
  <nd ref="292403538"/>
  <nd ref="298884289"/>
  ...
  <nd ref="261728686"/>
  <tag k="highway" v="unclassified"/>
  <tag k="name" v="Pastower Straße"/>
 </way>
 <relation id="56688" user="kmvar" uid="56190" visible="true" version="28" changeset="6947637" timestamp="2011-01-12T14:23:49Z">
  <member type="node" ref="294942404" role=""/>
  ...
  <member type="node" ref="364933006" role=""/>
  <member type="way" ref="4579143" role=""/>
  ...
  <member type="node" ref="249673494" role=""/>
  <tag k="name" v="Küstenbus Linie 123"/>
  <tag k="network" v="VVW"/>
  <tag k="operator" v="Regionalverkehr Küste"/>
  <tag k="ref" v="123"/>
  <tag k="route" v="bus"/>
  <tag k="type" v="route"/>
 </relation>
 ...
</osm>

See Data Primitives for details of the object categories.
See Map features about how real world objects are modeled and categorized.


The structure is the following:

See the /XSD, and /DTD pages for details of attempts to define the format in those languages.

Assumptions

If you develop tools using this format, you can be sure that:

You can not be sure that:

JOSM uses an 'action' attribute instead of timestamp, version or changeset for new objects

Some #flavours might have other restrictions.

Tools

See Planet.osm and Import, Export, Convert

Flavours

There are a few different file formats currently in use, all with slightly different goals.

JOSM file format

Main article: JOSM file format

The file format was designed by the author of JOSM. It basically is a logical extension of the data sent from the server. What it adds is an indication of the origin of the data and the bounding box it comes from (if possible). It is actually more of a storage format of data downloaded along with changes made by the user.

pros cons
  • Supports placeholders
  • Indicates the source of the data
  • not streamable, must read the whole file prior to applying

Supported by:

osmChange

Main article: OsmChange

OsmChange is a file format was created by the author of osmosis and is a more general format for representing changes.

pros cons
  • Streamable

When sorted properly this file is a continuous stream of changes that can be played in order. In osmosis the option --sort-change will put the change into streamable order.

  • Doesn't indicate source of data

Placeholders are proposed as an extension though they are not widely supported.

Supported by:

planetdiff

Main article: Planetdiff

This change format was created for a single format: to reduce the download requirements of the planet dumps. As such it is aimed to be more like diff. It verifies the input it is applied against and tries to produce a canonical output that matches the original planet dump.

pros cons
  • Streamable
  • Doesn't indicate source of data
  • No placeholders

Placeholders don't really apply to this kind of patching. The form of patching is really a manipulation of texts, not intended to apply general changes to a database.

Supported by:

Technical features of change formats

This a list of things that are desirable in a change file format for exampe change sets

placeholders

Placeholders are a feature where objects that are created in the file can be used in the creation of the objects that depend on them. So a single file can create two nodes and join them with a segment without knowing beforehand the final IDs.

indication of origin

IDs used in OSM files can not be shared between servers. IDs are allocated by the server, not by clients. Thus it is useful if the change file indicates the source of any IDs used in the file.

streamable

Whether the file can normally be processed in a stream, without breaking referential integrity.

See also

Personal tools
Namespaces
Variants
Actions
site
Toolbox