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
503 stars 107 forks source link

Set bounding boxes header #252

Open nicholashendrickx-tomtom opened 2 years ago

nicholashendrickx-tomtom commented 2 years ago

What version of osmium-tool are you using?

osmium version 1.14.0 libosmium version 2.18.0

What did you do exactly?

I have a valid PBF but the bounding boxes header is empty. When I run osmium fileinfo I can extract the calculated bbox from .data.bbox. I would like to give the bounding boxes header the value of .data.bbox.

The only way I found to do this so far is by calling something like this:

osmium_output=`osmium fileinfo ${output_file} -j -e`
bbox=`echo ${osmium_output} | jq '(.data.bbox | join(","))' --raw-output`
osmium extract --bbox "${bbox}" --set-bounds ${output_file} -o ${output_file} -v --overwrite

But this seems like a very memory-intensive operation just to set a header with a value I already have. Is there any other more performant way to simply set a header to an existing PBF file, and change nothing else?

Thank you

joto commented 2 years ago

I don't know of a better way. You don't say anything about why you need that bbox header in there. Maybe it is better to fix whatever program needs that header?

nicholashendrickx-tomtom commented 2 years ago

I don't know of a better way. You don't say anything about why you need that bbox header in there. Maybe it is better to fix whatever program needs that header?

I was wondering why setting "option" headers is possible but editing the other headers is not. Is there a technical reason why this is not possible?

joto commented 2 years ago

Is there a technical reason why this is not possible?

Not really. This is just something that happened over time depending on what people needed and what makes sense and how easy it is to implement. Bounding boxes in OSM files are kind of messy, because technically some file formats allow several of them and there are slightly different ways of doing them for the XML format. And it is unclear what they are even supposed to mean.