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
483 stars 104 forks source link

Handling of bounds in OSM file headers #243

Open joto opened 2 years ago

joto commented 2 years ago

I occasionally get complaints about Osmium handling the bounds (bounding box) header in OSM files in a wrong way. Mostly Osmium doesn't set it at all. There are several reasons for that:

  1. The semantics of the bounds header field is not defined anywhere. For instance when doing an extract, should the bounds header contain the values with which the extract was made, or the actual bounds of the result? If you use complete_ways for the extract, there might well be nodes outside the box used for extracting for instance.
  2. Because the bounds header is not defined, different programs might use it in different ways, so it is unclear what they need.
  3. The bounds header is at the front of the file. When we are writing the header we might not know yet what the bounds are because we only find out while going through the data. If we want to write an accurate bounds header, processing might be more expensive.

There is no one-size-fits-all solution here. Each Osmium command that writes OSM files has different requirements regarding the bounds. This will need some careful thought and time to find the best solutions(s).