You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: lonlat_to_merc does not fold longitudes outside -180..180: unwrapped antimeridian longitudes project past the world edge #940
lonlat_to_merc (crates/geom/src/lib.rs) clamps latitude to ±85.05° but passes any longitude through as-is:
Coord::new(MERCATOR_R* c.x.to_radians(), …)
so a longitude outside −180..180 produces Web Mercator X metres past the ±20,037,508.34 m world edge. I verified against main (342b2b2) that:
Call
Result
lonlat_to_merc(185, 0)
x = 20,594,105.8 m (about 557 km past the world edge)
extent_to_merc(179…185)
width = 667,916.9 m, all of it east through 185°, rather than wrapped back to about 179…-175
Where such longitudes can arise in the current code: unwrapped antimeridian geometry is kept deliberately by geodesic_interpolate (it keeps its longitude next to a's) and by Aeqd::inverse (it keeps longitudes within 180° of the centre's, not folded into −180..180), which the buffer and Tissot tools use. A buffer of a point near 179.9°E that crosses the antimeridian comes back with vertices past 180, and extent_to_merc in turn produces an out-of-world extent when the result is zoomed to.
Steps to reproduce
A library test against rustgis-geom with the values in the table, or a geodesic buffer of a point at 179.9°E large enough to cross the antimeridian, then zoom-to-layer.
What I would like checked
Whether every caller either (a) never sees such longitudes, or (b) wraps them itself (rendering/mod-tile fetch handles it, so this may only affect extents, the camera and measuring). If callers do not, folding the longitude into −180..180 here — or documenting loudly that it does not — would make the extent case above stop producing past-world X metres. I am not sure which is intended, so treat this as a question first.
Activity