osmium-tool
osmium-tool copied to clipboard
Fix ID comparison in `osmium merge` to match `osmium sort` behavior
Description
When using osmium sort, object IDs are sorted according to the following rule:
Compare two object IDs. Order is as follows:
0first, then negative IDs, then positive IDs — both ordered by their absolute values. (See object_comparisons.hpp#L83-L110)
However, in osmium merge, the order validation currently relies on a plain numerical comparison of IDs.
As a result, osmium merge may fail when merging files produced by osmium sort if negative IDs are present.
Proposed fix
This pull request addresses the mismatch by reusing the id_order comparator defined in
object_comparisons.hpp.
Specifically, it replaces the simple numeric comparison in osmium merge with id_order, ensuring consistency with osmium sort.