Skip to content

fix: guard extent reprojection against NaN for globally-advertised WM… - #1590

Open
fguirrugo wants to merge 1 commit into
geoadmin:developfrom
fguirrugo:fix/nan-extent-reprojection
Open

fix: guard extent reprojection against NaN for globally-advertised WM…#1590
fguirrugo wants to merge 1 commit into
geoadmin:developfrom
fguirrugo:fix/nan-extent-reprojection

Conversation

@fguirrugo

Copy link
Copy Markdown

…S/WMTS layers

WMS EX_GeographicBoundingBox and WMTS WGS84BoundingBox commonly advertise -180,-90,180,90 to mean "covers the whole world" (a common, spec-legal pattern used by many global raster/basemap servers). Reprojecting a latitude of +/-90 into Web Mercator is mathematically undefined, and proj4 silently returns NaN instead of throwing.

This NaN extent then flows unguarded into addLayer -> zoomToExtent (position.store.js), which commits NaN center/zoom directly to the store, bypassing the bounds validation that the normal setCenter action performs. The result is a broken map viewport (frozen/blank map) any time a user imports an external WMS/WMTS layer covering the whole globe with "zoom to extent" enabled - a common, ordinary user action.

Add a small reprojectExtent() helper in both capabilities parsers that validates the reprojected coordinates are finite before using them, falling back to null (already handled gracefully via the existing "no extent found" log/parent-lookup logic) instead of silently propagating NaN. Also harden zoomToExtent() in position.store.js as a second, independent guard against non-finite computed centers.

Covered by two new unit tests reproducing the global bounding box case for both parsers.

…S/WMTS layers

WMS EX_GeographicBoundingBox and WMTS WGS84BoundingBox commonly advertise
-180,-90,180,90 to mean "covers the whole world" (a common, spec-legal
pattern used by many global raster/basemap servers). Reprojecting a
latitude of +/-90 into Web Mercator is mathematically undefined, and
proj4 silently returns NaN instead of throwing.

This NaN extent then flows unguarded into addLayer -> zoomToExtent
(position.store.js), which commits NaN center/zoom directly to the
store, bypassing the bounds validation that the normal setCenter action
performs. The result is a broken map viewport (frozen/blank map) any
time a user imports an external WMS/WMTS layer covering the whole
globe with "zoom to extent" enabled - a common, ordinary user action.

Add a small reprojectExtent() helper in both capabilities parsers that
validates the reprojected coordinates are finite before using them,
falling back to null (already handled gracefully via the existing "no
extent found" log/parent-lookup logic) instead of silently propagating
NaN. Also harden zoomToExtent() in position.store.js as a second,
independent guard against non-finite computed centers.

Covered by two new unit tests reproducing the global bounding box case
for both parsers.
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