Fix: ReverseGeocoder sends coordinates near zero in scientific notation, rejected by Nominatim - #40
Merged
f1ana merged 2 commits intoSep 2, 2026
Conversation
f1ana
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReverseGeocoder.buildQueryStringconverts theLatitude/Longitudevalues fromReverseGeocodeRequestto strings using a bare.ToString(CultureInfo.InvariantCulture.NumberFormat)call, without an explicit numeric format specifier. .NET's default ("G") format switches to scientific/exponential notation for values close to zero (e.g.0.0000093becomes"9.3E-06").This affects any coordinate close to the equator (latitude ≈ 0) or the prime meridian (longitude ≈ 0). A concrete repro is the Prime Meridian marker at the Arora Ballroom & Conference Centre, Greater London:
lat=51.5028298, lon=0.0000093. Thelonvalue gets serialized as"9.3E-06", which the Nominatim HTTP API does not accept as a valid coordinate, resulting in a failed or incorrect request.Pre-formatting the
doublebefore constructing the request has no effect, sinceLatitude/Longitudeare stored as rawdouble?and re-converted to string internally by the library — any caller-side formatting is discarded.Fix: format
Latitude/Longitudewith an explicit fixed-point format string (e.g."0.0000000") instead of the defaultToString(), so coordinates near zero are always serialized in decimal notation.Test added:
ReverseGeocoderTests.ReverseGeocodeAsync_NearPrimeMeridian_DoesNotSendCoordinatesInScientificNotation, using the Greenwich coordinates above and a mockedINominatimWebInterfaceto assert the outgoing query string never contains scientific notation forlat/lon.