osm icon indicating copy to clipboard operation
osm copied to clipboard

How to create the OSM standard (XML) format?

Open Klaus-Tockloth opened this issue 1 year ago • 2 comments
trafficstars

The OSM standard (XML) format is described here: https://wiki.openstreetmap.org/wiki/OSM_XML

Example (OSM standard):

<way id="750000000000">
 <nd ref="750000000000"/>
 <nd ref="750000000001"/>
 <nd ref="750000000002"/>
 <nd ref="750000000003"/>
 <nd ref="750000000000"/>
 <tag k="ele" v="20"/>
 <tag k="contour" v="elevation"/>
 <tag k="contour_ext" v="elevation_minor"/>
 <tag k="ed20" v="20"/>
 <tag k="ed10" v="10"/>
</way>

The Golang standard XML encoder (xml.MarshalIndent(osmWay, " ", " ") leads to this:

<way id="750000000000" user="" uid="0" visible="true" version="0" changeset="0" timestamp="1970-01-01T00:00:00Z">
 <nd ref="750000000000"></nd>
 <nd ref="750000000001"></nd>
 <nd ref="750000000002"></nd>
 <nd ref="750000000003"></nd>
 <nd ref="750000000000"></nd>
 <tag k="ele" v="20"></tag>
 <tag k="contour" v="elevation"></tag>
 <tag k="contour_ext" v="elevation_minor"></tag>
 <tag k="ed20" v="20"></tag>
 <tag k="ed10" v="10"></tag>
</way>

Some tools (e.g. osmconvert) are not working with the Golang generated XML format.

Question: How can the 'problem' with addition closing XML tags be solved?

Klaus-Tockloth avatar Aug 14 '24 08:08 Klaus-Tockloth

While @paulmach might want to accommodate this in any case, the tool in question (osmconvert) is broken, and any standard compliant XML parser should be parsing both variants.

simonpoole avatar Aug 14 '24 08:08 simonpoole

But really, stop using osmconvert... It's ancient, unmaintained and is there anything it can do that osmium can't?

tomhughes avatar Aug 14 '24 08:08 tomhughes