Skip to content

feat(core): layer coordinateSystem supports arbitrary CRS - #10874

Merged
Pessimistress merged 7 commits into
masterfrom
codex/source-crs-resolution
Oct 21, 2026
Merged

Pessimistress merged 7 commits into
masterfrom
codex/source-crs-resolution

Conversation

@Pessimistress

@Pessimistress Pessimistress commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

For #10739

Background

Major conceptual clean up of projection pipeline. Now explicitly separates:

  • Layer's data coordinate system
  • Layer's packed positions attribute coordinate system
  • View's target CRS coordinate system
  • Shaderlib's common space

For example, MVTLayer in v9.4 creates sublayers with coordinateSystem: 'cartesian' in MapView and coordinateSystem: 'lnglat' in GlobeView. After this PR, it creates sublayers with coordinateSystem: 'OSMTile512' in all viewports.

Antarctica, coordinateSystem: 'EPSG:3031' (Stereographic) + GlobeView
custom-projection-antarctica-globe

France regions, coordinateSystem: 'EPSG:2154' (Lambert-93) + MapView
custom-projection-france-map

Switzerland cantons, coordinateSystem: 'EPSG:2056' (LV95) + CustomProjectionView toCrs: 'EPSG:8857' (Equal Earth)
custom-projection-switzerland-equal-earth

Change List

  • Accept arbitrary CRS strings in Layer.coordinateSystem
  • Resolve source CRS before initializing or updating layers
  • Track per-layer preprojection and packed-coordinate CRS
  • Keep shader-supported coordinates untransformed during attribute packing
  • Load MVT geometry consistently in OSMTile512
  • Derive subdivision steps from source CRS units and viewport resolution
  • Tessellate polygons in the viewport’s target CRS
  • Unit tests, render tests, docs, and upgrade guide

Note

High Risk
Breaking v10 changes across projection, layer initialization, multi-view filtering, and exported constants, with broad impact on aggregation, picking, and tiled layers.

Overview
Layers can declare data CRS with strings (EPSG/PROJ, legacy aliases like 'meter-offsets') instead of the removed COORDINATE_SYSTEM export. The layer manager resolves CRS asynchronously, blocks init/update until ready, and tracks source vs packed attribute CRS plus CPU preproject / unpreproject when the view shader cannot consume the source CRS directly. coordinateOrigin applies in source CRS before conversion for absolute CRSs.

Projection pipeline refactor: viewport getPreprojection(sourceCrs) replaces ad-hoc preproject flags; shader uniform coordinateSystem → coordinateFrame (identity/geodetic/projected/geocentric). Multi-view: first viewport allowed by layerFilter (screen pass) seeds a layer’s projection context; draw activates viewport once per layer. resolution subdivision is earth-circumference–based (opt-in, including Globe); layers use getSubdivisionStep(sourceCrs).

Aggregation, tiles, picking: aggregation/custom-projection paths use project.isCustomProjection and layer preprojection state; hexagon pick adds position in source CRS (nullable); PickingInfo.coordinate may be null. MVT documents/uses tile-local OSMTile512; v10 examples switch to string coordinate systems.

Docs/upgrade guide cover v10 viewport CRS, Globe position, and migration from constants.

Reviewed by Cursor Bugbot for commit 248a5e0. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread modules/core/src/lib/layer.ts Resolved
Comment thread modules/core/src/viewports/viewport.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 3/5

[High impact] The changes reach deck.gl’s shared projection path across views and layer types.

Fix the stale polygon transforms and the outstanding binary globe tile winding issue before merging.

Findings

  1. P1 Polygon transforms stop working ▶

Summary

Layers can declare arbitrary source CRSs, with CPU conversion when the view cannot use those coordinates directly.

  • Layers can use a source coordinate system that differs from the viewport.
  • Viewport resolution controls geometry detail across coordinate systems.
  • MVT sublayers use tile-local coordinates in every viewport.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Source coordinates] --> B[Apply layer transforms]
  B --> C{View accepts source CRS?}
  C -->|Yes| D[Keep native attributes]
  C -->|No| E[Convert positions on CPU]
  D --> F[Triangulate with transformed coordinates]
  E --> F
  F --> G[Draw polygon]
Loading

Reviews (8) · Last reviewed commit: "Invalidate triangulation when modelMatri..." · Reviewed by Greptile

Comment thread modules/core/src/lib/layer.ts Resolved
Comment thread modules/core/src/lib/layer.ts Resolved
Comment thread modules/core/src/lib/layer.ts Resolved
@coveralls

coveralls commented Oct 15, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.132% (+0.4%) from 83.717% — codex/source-crs-resolution into master

@Pessimistress Pessimistress mentioned this pull request Oct 15, 2026
33 of 41 tasks
@kylebarron

Copy link
Copy Markdown
Collaborator
  • Accept arbitrary CRS strings in Layer.coordinateSystem

The typedef of CRS definition should at least include objects to support PROJJSON, a more modern description of CRS than the relatively fickle and outdated proj strings

@Pessimistress
Pessimistress force-pushed the codex/source-crs-resolution branch from df1769d to bbbcc9c Compare October 15, 2026 21:35
Comment thread modules/core/src/index.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread modules/core/src/lib/layer.ts Resolved
Base automatically changed from codex/crs-descriptor-integration to codex/async-view-resolution October 20, 2026 00:29
@Pessimistress
Pessimistress force-pushed the codex/source-crs-resolution branch from b0c50dc to d747d88 Compare October 20, 2026 00:49
Comment thread modules/core/src/lib/layer-manager.ts Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread modules/core/src/utils/crs.ts Resolved
@Pessimistress
Pessimistress changed the base branch from codex/async-view-resolution to master October 20, 2026 17:19
@Pessimistress
Pessimistress force-pushed the codex/source-crs-resolution branch from d747d88 to 599ff79 Compare October 20, 2026 21:58

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the substantial work on the CRS refactor. I’m requesting one correctness fix before approval: globe polygon triangulation still becomes invalid when a shader-side layer transform moves the polygon across the globe. The current code even documents this assumption, but modelMatrix and coordinateOrigin are public layer props and can change without rebuilding indices. Please make the temporary coordinates used for geocentric winding include the same transforms as rendering, and invalidate/retriangulate when those transforms change. A north-to-south move is a concrete case where triangles become inward-facing and disappear under back-face culling.

charlieforward9 added a commit that referenced this pull request Oct 26, 2026
Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
chrisgervang added a commit that referenced this pull request Nov 3, 2026
…11013)

* fix(extensions): ClipExtension geometry mode in GlobeView

In geometry (fragment) mode the extension compared `geometry.position.xy`
with `clipBounds` projected through `layer.projectPosition()`. Both are in
the active projection's common space, which under GlobeView is sphere XYZ:
comparing the x/y of a sphere position against a box has no geographic
meaning and rendered a single diagonal stripe instead of the clipped
rectangle.

Use the flat common-space helpers from the framework branch instead:
the vertex shader converts `geometry.position` with
`project_common_position_to_flat()` (identity for flat projections,
sphere -> absolute Web Mercator under GLOBE) and `draw()` produces the
bounds with `projectBoundsToFlatCommon()`, its CPU twin, so both sides
agree in every projection mode. The instance (vertex) mode compares raw
lng/lat and is untouched, as is the WebGPU path.

Tests: new render spec test/render/test-cases/clip-extension.spec.ts
renders `clip-geometry` (PolygonLayer, clipByInstance: false) and
`clip-instance` (ScatterplotLayer) under MapView, GlobeView and
OrthographicView via expandViewMatrix (6 goldens; all show the same
clipped rectangle). Unit spec asserts the `clip.bounds` uniform equals the
Mercator projection of clipBounds on both WebMercatorViewport and
GlobeViewport in geometry mode and stays raw lng/lat in instance mode.

Docs: clip-extension.md gains a Remarks section (GlobeView support,
Mercator evaluation, antimeridian, clipByInstance semantics).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* fix(extensions, layers): clip in flat space on WebGPU and across the antimeridian

The WGSL layers passed raw geometry.position.xy to clip_filterColor, which
is sphere XY under GlobeView while the bounds are now Mercator. Add
clip_getCoordinates() in the WGSL clip module and use it in
ScatterplotLayer, PathLayer and SolidPolygonLayer.

Both GLSL and WGSL now wrap the flat position around the bounds centre, so
geometry stays continuous across the antimeridian and bounds whose left
edge is east of their right edge clip the intended region instead of
needing two layers. Adds a side-by-side MapView/GlobeView render case.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* docs(extensions): ClipExtension remarks for antimeridian bounds and clipByInstance

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* test(render): ClipExtension grid cases with obvious expected results

Replace the San Francisco zip-code data with a 7 x 4 grid of squares and
dots whose bounds cut through known columns and rows, and state the
expected picture for every case in the spec.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* docs(extensions): ClipExtension GlobeView support in what's new, limitation in Remarks

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* fix(extensions): wrap clip coordinates per fragment, not per vertex

Wrapping each vertex about the bounds centre tears triangles that straddle
the point 180° from the bounds, so a polygon there leaked a stripe into the
bounds. Keep the varying continuous within each triangle (globe seam opposite
the camera) and wrap in the fragment stage, in GLSL and WGSL.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

* docs(extensions): tighten ClipExtension antimeridian note and render test comments

* docs(extensions): state the 180° condition for antimeridian clip bounds

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FyzWaF5TmQPmGjh3Zr3XL9

---------

Co-authored-by: Claude <[email protected]>

(cherry picked from commit e1d346d)
[9.4-release] Check only viewport.isGeospatial: project.isCustomProjection comes from #10874, which is not in 9.4, and 9.4 has no custom geospatial projection mode.
chrisgervang added a commit that referenced this pull request Nov 3, 2026
…lobe (#10750)

(cherry picked from commit 9b1500e)
[9.4-release] Check only PROJECTION_MODE_GLOBE: PROJECTION_MODE_GLOBE_METER_OFFSETS comes from #10874, which is not in 9.4.
chrisgervang added a commit that referenced this pull request Nov 3, 2026
…lobe (#10750) (#11014)

(cherry picked from commit 9b1500e)
[9.4-release] Check only PROJECTION_MODE_GLOBE: PROJECTION_MODE_GLOBE_METER_OFFSETS comes from #10874, which is not in 9.4.
ibgreen pushed a commit that referenced this pull request Nov 4, 2026
Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ibgreen pushed a commit that referenced this pull request Nov 4, 2026
Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ibgreen pushed a commit that referenced this pull request Nov 4, 2026
Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ibgreen pushed a commit that referenced this pull request Nov 5, 2026
Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ibgreen pushed a commit that referenced this pull request Nov 17, 2026
Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ibgreen added a commit that referenced this pull request Nov 17, 2026
…10751)

* Add WebGPU terrain height-map fitting

* Keep renderer definitions isolated between Vitest projects

* Release per-test WebGL contexts before they evict the shared test device

* Preserve billboard extrusion and translated terrain bounds

* Keep source geometry available after terrain projection

* fix(extensions): treat globe meter offsets as globe in WGSL terrain

Master's GLSL terrain module samples the Mercator height map through the
globe inverse for both PROJECTION_MODE_GLOBE and GLOBE_METER_OFFSETS
(#10874). Match it in the WGSL plugin so meter-offset layers on GlobeView
read and write the height map at the right texels.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: adapt terrain fitting to shared shader hooks

* test: cover rotated terrain bounds

* fix: keep globe terrain bounds in Mercator space

* fix: scale globe terrain heights at projected anchors

* fix(extensions): preserve perspective terrain billboard sizing

* fix(extensions): preserve terrain and clipping hook composition

* fix(extensions): preserve camera-clipped terrain path widths

* fix(extensions): exclude display bias from terrain height selection

* docs: describe extension behavior and limits

* test(extensions): run Terrain coverage in the standard GPU suite

* fix(extensions): default WebGPU terrain fitting to offset

* fix(extensions): register terrain effect when adding the extension

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Ib Green <[email protected]>
athomct pushed a commit to chesapeake-tech/deck.gl that referenced this pull request Nov 23, 2026
Resolve conflicts with the coordinate system and dependency upgrades
on master:

- wms-layer.ts: keep the fix that reads `crs` from the stored
  GetImageParameters, and use the 'lnglat' / 'cartesian' coordinate
  system strings from visgl#10874.
- wms-layer.spec.ts: keep the new URL source test from master and the
  EPSG:4326 test from this branch. Use the loaders.gl and math.gl
  subpath imports from visgl#11274, and expect 'lnglat' because
  COORDINATE_SYSTEM is no longer exported.
@chrisgervang chrisgervang mentioned this pull request Nov 24, 2026
29 tasks
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.

4 participants