osmcode / osmium-tool

Command line tool for working with OpenStreetMap data based on the Osmium library.
https://osmcode.org/osmium-tool/
GNU General Public License v3.0
509 stars 107 forks source link

Wrong order of statements when converting .osh files to .osc #241

Closed plepe closed 2 years ago

plepe commented 2 years ago

What version of osmium-tool are you using?

What operating system version are you using?

What did you do exactly?

I have a .osh file which I convert to a .osc file (using osmium) to initialize a Overpass API database with attic data. Apparently, Overpass API expects the items to appear chronologically, with ways after nodes. If I import the .osc file, Overpass API would complain about missing nodes. If I re-order the .osc file, the import is successful.

Actually, I do not know whether the bug is with osmium or with Overpass API, so I created a bug report there too: drolbr/Overpass-API#652

These are the commands that I would use:

osmium cat bug.osh -o bug.osc
cat bug.osc | update_database --db-dir=test --keep-attic

Query an object:

echo '[out:json][date:"2011-01-01T00:00:00Z"];way(86127691);out meta geom;' | osm3s_query --db-dir=test

Result:

{
  "version": 0.6,
  "generator": "Overpass API 0.7.57.1 74a55df1",
  "osm3s": {
    "timestamp_osm_base": "",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [
{
  "type": "way",
  "id": 86127691,
  "timestamp": "2010-11-22T17:27:01Z",
  "version": 1,
  "changeset": 6432752,
  "user": "digitalhippie",
  "uid": 41463,
  "bounds": {
    "minlat": 100.0000000,
    "minlon": 200.0000000,
    "maxlat": 100.0000000,
    "maxlon": 200.0000000
  },
  "nodes": [
    999601342,
    999600632,
    999601129,
    999600521,
    999601342
  ],
  "geometry": [
  ],
  "tags": {
    "building": "yes",
    "source": "Yahoo"
  }
}
  ]
}

I modified the bug.osc and re-ordered/merged the create/modify/delete statements, see bug1.osc.

When I use this, I would get the following result:

{
  "version": 0.6,
  "generator": "Overpass API 0.7.57.1 74a55df1",
  "osm3s": {
    "timestamp_osm_base": "",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [
{
  "type": "way",
  "id": 86127691,
  "timestamp": "2010-11-22T17:27:01Z",
  "version": 1,
  "changeset": 6432752,
  "user": "digitalhippie",
  "uid": 41463,
  "bounds": {
    "minlat": 48.2028205,
    "minlon": 16.3402169,
    "maxlat": 48.2042181,
    "maxlon": 16.3416447
  },
  "nodes": [
    999601342,
    999600632,
    999601129,
    999600521,
    999601342
  ],
  "geometry": [
    { "lat": 48.2042150, "lon": 16.3402169 },
    { "lat": 48.2028205, "lon": 16.3404620 },
    { "lat": 48.2028268, "lon": 16.3416447 },
    { "lat": 48.2042181, "lon": 16.3415269 },
    { "lat": 48.2042150, "lon": 16.3402169 }
  ],
  "tags": {
    "source": "Yahoo",
    "building": "yes"
  }
}
  ]
}

Find all files in the following in this archive: bug.zip

joto commented 2 years ago

I don't think this has anything to do with Osmium and the discussion on https://github.com/drolbr/Overpass-API/issues/652 seems to agree. If there is anything that could be integrated in Osmium to help with this use case, please open a new issue describing exactly what's needed, then we can discuss whether that's something Osmium can provide. But it does look to me more like something that the Overpass importer should do.