Skip to content

fix: fetch both sides when viewport crosses antimeridian in untiled mode#65

Open
egagli wants to merge 2 commits into
carbonplan:mainfrom
egagli:main
Open

fix: fetch both sides when viewport crosses antimeridian in untiled mode#65
egagli wants to merge 2 commits into
carbonplan:mainfrom
egagli:main

Conversation

@egagli

@egagli egagli commented May 19, 2026

Copy link
Copy Markdown

Fixes #64

Hoping this fixes data missing on one side of the antimeridian in both Globe and Mercator projections for untiled datasets. When the viewport extends past 180 degrees, geoToArrayIndex clamps coords to the dataset edge, so the region range only covers the side of the antimeridian already in view. The other side is never fetched.

Here we detect the crossing with east > xMax || west < xMin and fetch two narrow strips instead: the trailing edge of the dataset and the leading edge on the wrapped side. The wrapped coordinate is found by subtracting or adding the full longitudinal extent before passing to geoToArrayIndex.

Seems to be working on my side!!

When the viewport extends past 180 degrees, getBounds returns east > xMax
(e.g. east=185). geoToArrayIndex clamps that to the dataset edge, so the
region range only covers the side of the antimeridian already in view.
The other side is never fetched.

Detect the crossing with east > xMax || west < xMin and fetch two narrow
strips instead: the trailing edge of the dataset and the leading edge on
the wrapped side. The wrapped coordinate is found by subtracting or adding
the full longitudinal extent before passing to geoToArrayIndex.

Fixes data missing on one side of the antimeridian in both Globe and
Mercator projections for untiled datasets.
@vercel

vercel Bot commented May 19, 2026

Copy link
Copy Markdown

@egagli is attempting to deploy a commit to the carbonplan Team on Vercel.

A member of the Team first needs to authorize it.

…en bbox corners are outside CRS domain

For projections like MODIS sinusoidal, the rectangular bounding box corners
can be outside the valid CRS domain (near-polar latitudes give out-of-domain
longitude values), causing the projected Mercator width to be NaN or > full
world width. This makes worldFraction incorrect, forcing the finest pyramid
level at all zoom levels.

Fix: detect dataWidthMeters that is non-finite or > fullWorldMeters, then
re-project using y=0 (equatorial strip) which is always in-domain. Also
clamp worldFraction to [0, 1] as a safety net.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Shane98c added a commit that referenced this pull request Jun 16, 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.

UntiledMode.getVisibleRegions skips regions on one side of the antimeridian when viewport crosses ±180°

1 participant