#6347 closed defect (fixed)

osm_id tag overrides object id, leaving duplicate ids

Reported by: kyngchaos Owned by: warmerdam
Priority: normal Milestone: 1.11.5
Component: OGR_SF Version: 1.11.3
Severity: normal Keywords:


I have a PostGIS DB setup to import OSM data into with GDAL, and I set the primary key to the osm_id that GDAL creates from the osm data. I've seen occassional duplicate keys, but have ignored them. I usually use the pbf files. As I understand it, features within each type should have unique IDs.

But looking deeper into it, in a .osm XML file, I see that those that appear as duplicate keys have a tag with an "osm_id" key in addition to the node/way/relation object "id", and it's often set to "0", and same as the osm_id that GDAL is trying to insert into PostGIS. Of course, only the first "0" gets inserted and the rest fail.

I din't see any specific code to handle the osm_id tag, so it looks like the generic tag processing is seeing "osm_id" and connecting it to GDAL's osm_id and overwriting the object "id" it already used for its osm_id.

an example from the geofabrik ethiopia extract:

<node id="1576552001" lat="7.2148449" lon="35.8516585" version="2" timestamp="2012-10-27T10:33:21Z" changeset="13647702" uid="388425" user="RasRoach">
	<tag k="name" v="Abera"/>
	<tag k="place" v="village"/>
	<tag k="osm_id" v="0"/>
<node id="1576552002" lat="7.56567" lon="36.3336127" version="2" timestamp="2012-10-27T07:41:42Z" changeset="13646252" uid="388425" user="RasRoach">
	<tag k="name" v="Abgaccio"/>
	<tag k="place" v="village"/>
	<tag k="osm_id" v="0"/>

Abera is inserted with osm_id=0, not 1576552001, Abgaccio is skipped as a duplicate key.

Change History (1)

comment:1 Changed 15 months ago by Even Rouault

Milestone: 1.11.5
Resolution: fixed
Status: newclosed

trunk r33332, branches/2.0 r33333, branches/1.11 r33334 "OSM: do not override 'our' osm_id (the node, way or relation id) with a tag named 'osm_id' (#6347)"

Note: See TracTickets for help on using tickets.