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

Fix failing assert due to off-by-one error #269

Closed ThijsdeJong-TomTom closed 10 months ago

ThijsdeJong-TomTom commented 1 year ago

While working with some OSM border data as a polygon I encountered a segmentation fault while using osmium extract.

See example values

m_dy = (y_max() - y_min()) / num_bands
3811 = (437903881 - 399786994) / 10000

In this case m_dy would be 3811.6887 if it were not an int32_t. The result of this is that m_dy can cause band_max to go over the initially set max_bands by 1.

(437903881 - 399786994) / 3811 = 10001.8071372

This fixes that by "rounding" m_dy.