zerebubuth/openstreetmap-cgimap

Last digit missing in bbox coordinate of changeset JSON call

Closed this issue · 5 comments

The minlon and maxlon properties in the JSON response of the metadata API call for changeset 146899741 (node 11572546705 v1) are missing the last digit, the XML response has it:

Actual : -117.067166 - https://www.openstreetmap.org/api/0.6/changeset/146899741.json
Expected: -117.0671669 - https://www.openstreetmap.org/api/0.6/changeset/146899741

This was noticed because the adiff query with that bbox in OSMCha fails to load the node, as reported on Slack.

Posting the full response data here for future reference:

{"version":"0.6","generator":"CGImap 0.8.10 (2938081 spike-07.openstreetmap.org)","copyright":"OpenStreetMap and contributors","attribution":"http://www.openstreetmap.org/copyright","license":"http://opendatacommons.org/licenses/odbl/1-0/","elements":[{"type":"changeset","id":146899741,"created_at":"2024-01-31T11:17:34Z","closed_at":"2024-01-31T11:17:36Z","open":false,"user":"newportequipmentwa1","uid":20953528,"minlat":48.1730392,"minlon":-117.067166,"maxlat":48.1730392,"maxlon":-117.067166,"comments_count":0,"changes_count":1,"tags":{"changesets_count":"1","comment":"Excavating Contractor","created_by":"iD 2.27.3","host":"https://www.openstreetmap.org/edit","imagery_used":"Bing Maps Aerial","locale":"en-US"}}]}
<osm version="0.6" generator="CGImap 0.8.10 (2351905 spike-07.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<changeset id="146899741" created_at="2024-01-31T11:17:34Z" closed_at="2024-01-31T11:17:36Z" open="false" user="newportequipmentwa1" uid="20953528" min_lat="48.1730392" min_lon="-117.0671669" max_lat="48.1730392" max_lon="-117.0671669" comments_count="0" changes_count="1">
<tag k="changesets_count" v="1"/>
<tag k="comment" v="Excavating Contractor"/>
<tag k="created_by" v="iD 2.27.3"/>
<tag k="host" v="https://www.openstreetmap.org/edit"/>
<tag k="imagery_used" v="Bing Maps Aerial"/>
<tag k="locale" v="en-US"/>
</changeset>
</osm>

It seemingly looks like only negative lat/lon values are affected. "minlat":48.1730392 has the full 7 digits while "minlon":-117.067166 only has 6.

The json formatter uses a 12 byte buffer to convert the double value to string, which is not enough to hold the full string when it has a minus sign in front so the last digit gets cut off.
https://github.com/zerebubuth/openstreetmap-cgimap/blob/master/src/json_writer.cpp#L115-L116

Thanks! I have merged the fix to make it available on the dev instance at least. Due to limited bandwidth it might take a bit of time to move this to production, likely not before mid-March.

I released version 0.9.0 earlier today and triggered the Ubuntu package build on https://launchpad.net/~mmd-osm/+archive/ubuntu/cgimap-900-jammy

Still pending are local tests that the resulting package is working ok, then we'll raise an issue for osm operations to deploy the new version.

Fix is in production now.