Skip to content

Clamp vector geometry latitudes for Mercator projection#266

Closed
frewsxcv wants to merge 2 commits intomainfrom
fix/clamp-vector-geometry-mercator-latitudes
Closed

Clamp vector geometry latitudes for Mercator projection#266
frewsxcv wants to merge 2 commits intomainfrom
fix/clamp-vector-geometry-mercator-latitudes

Conversation

@frewsxcv
Copy link
Copy Markdown
Collaborator

@frewsxcv frewsxcv commented Mar 9, 2026

Summary

  • The raster extent reprojection path already clamped latitudes to ±85.06° for Mercator targets, but the vector geometry reprojection path (ReprojectGeometryJob) had no clamping — causing near-pole vertices (e.g. Antarctica at ~-90°) to produce extreme Y values in Web Mercator, making Antarctica appear enormous
  • Extract is_geographic(), is_mercator(), and MERCATOR_LAT_LIMIT to module-level shared helpers so both raster and vector paths use the same logic
  • Add latitude clamping via map_coords on vector geometries before Mercator projection, clamping Y coordinates to ±85.06° (the defined area of use for EPSG:3857)

Relates to #186

Test plan

  • Load a world map GeoJSON (e.g. Natural Earth countries) and verify Antarctica no longer appears disproportionately large
  • Verify other near-pole features (e.g. Arctic regions) render at reasonable sizes
  • Confirm non-Mercator target projections are unaffected (clamping only triggers for Mercator targets)

@frewsxcv frewsxcv enabled auto-merge March 9, 2026 10:54
The raster extent reprojection path already clamped latitudes to ±85.06°
for Mercator targets, but the vector geometry reprojection path had no
clamping. This caused near-pole vertices (e.g. Antarctica at ~-90°) to
produce extreme Y values in Web Mercator, making Antarctica appear huge.

Extract is_geographic(), is_mercator(), and MERCATOR_LAT_LIMIT to
module-level shared helpers and add latitude clamping via map_coords on
vector geometries before Mercator projection.

Relates to #186
@frewsxcv frewsxcv force-pushed the fix/clamp-vector-geometry-mercator-latitudes branch from 134430b to 9714835 Compare March 10, 2026 02:25
@frewsxcv frewsxcv disabled auto-merge March 10, 2026 02:28
@frewsxcv
Copy link
Copy Markdown
Collaborator Author

Superseded by #272, which generalizes this to all CRS area-of-use bounds.

@frewsxcv frewsxcv closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant