Skip to content

Support prepared CRS descriptors in CustomProjectionView - #11106

Open
ibgreen wants to merge 2 commits into
masterfrom
codex/prepared-crs
Open

ibgreen wants to merge 2 commits into
masterfrom
codex/prepared-crs

Conversation

@ibgreen

@ibgreen ibgreen commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

For visgl/math.gl#525

Background

Centered Oblique Mercator in math.gl runs one PROJ definition through either math.gl or proj4js. Passing that definition to _CustomProjectionView asks deck.gl to resolve it with its own engine, losing the selected converter and local rendering bounds. Accepting a prepared CRSDescriptor preserves that backend comparison without adding a proj4js dependency to deck.gl.

Explicit execution identities distinguish converters for the same CRS definition. Descriptors without execution metadata use object identity, so unrelated callbacks cannot share cached projection results. Callers keep descriptors immutable and provide a new execution identity when execution changes; camera navigation can reuse the same descriptor.

Change List

  • Accept prepared descriptors synchronously in CustomProjectionView
  • Preserve asynchronous resolution for CRS definitions
  • Compare execution identities and rendering bounds in view equality
  • Include execution identities in viewport, scale, and preprojection caches
  • Declare stable execution identities in reusable test fixtures
  • Unit tests cover passthrough, backend changes, and unknown identities
  • Documentation explains prepared descriptors and their immutability contract

Verification: the full package build, lint, and 83 focused Chromium tests passed after rebasing onto current master, including all four original CI failures. The fixture-fix commit also passed 123 pre-commit Node tests; all latest CI jobs passed, including WebGPU, coverage, website, Python, and the projection-domains example.

The companion math.gl draft records Fiji parity with an unpublished build: for each backend, all 3,281 orange boundary pixels matched within two pixels in both directions, and viewport coordinates agreed within 3.3e-10 meters after unit conversion. That draft remains blocked on an upstream release containing this API and a clean-install recheck.


Note

Low Risk
Changes are confined to the experimental custom projection view and viewport system without impacting standard map projections.

Overview
Adds support for passing prepared math.gl CRSDescriptor objects directly to CustomProjectionView alongside existing CRS definitions. When a prepared descriptor is provided, view initialization completes synchronously without invoking external CRS resolution.

To handle caching and view equality across different converter backends (such as proj4js vs. math.gl), CustomProjectionView, CustomProjectionViewport, and layer preprojection now identify projections using descriptor execution keys and rendering bounds, falling back to object identity when no execution identity is defined.

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

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-13T21:10:47.271206Z
We couldn’t complete this review. Comment @codex review to try again.
9329c2a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were established.

Summary

CustomProjectionView now accepts prepared descriptors without resolving them again.

  • CustomProjectionView uses a prepared CRS descriptor directly.
  • Projection caches distinguish different converter executions.

Review covered the full PR because the previous and current revisions have different merge bases. No actionable issues were established. Tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[CustomProjectionView crs] --> B{Prepared descriptor?}
  B -->|Yes| C[Use supplied descriptor]
  B -->|No| D[Resolve CRS definition]
  D --> C
  C --> E[Create CustomProjectionViewport]
  E --> F[Execution-aware projection key]
  E --> G[Execution and bounds size-sampling key]
  F --> H[Refresh layer preprojection]
Loading

Reviews (2) · Last reviewed commit: "Declare execution identities for reusabl..." · Reviewed by Greptile

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 83.339% (+0.01%) from 83.328% — codex/prepared-crs into master

ibgreen commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

Projection-engine injection is now implemented in #11112, stacked on this PR. It preserves prepared CRSDescriptor passthrough, adds Deck({projectionEngine}) with the existing engine as the default, and namespaces resolved-definition caches/execution keys by engine identity. Prepared descriptors still bypass the selected resolver. Suggested merge order: this descriptor PR, then #11112; no additional API changes are needed here.

@athomct athomct 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.

Thank you. This is a clean way to keep the selected converter without a proj4js dependency in deck.gl. The tests cover passthrough, a backend change and unkeyed descriptors. The focused specs pass for me (45 tests). I have two documentation points.

  1. Unkeyed descriptors now key by object identity. math.gl's default engine does not set executionIdentity (I checked @math.gl/[email protected]). So a standalone CustomProjectionViewport user who spreads or rebuilds the descriptor on each frame gets a new projectionSignature on each frame. Then layers preproject again on each frame. Your fixture change in test-crs.ts shows the same effect. Please add one line to whats-new.md or the upgrade guide. It can tell users to reuse one descriptor object or to set executionIdentity.
  2. crs.signature no longer identifies the execution. Two prepared descriptors can share a signature and use different converters, as in your new test. A layer that caches CPU-converted positions by crs.signature does not see the backend change. I did not run this case. A short note in the CustomProjectionView docs can tell layer authors to key such caches on viewport.projectionSignature.

Small item: one sentence in the docs says "deck". The other docs say "deck.gl".

The view resolves its CRS descriptor asynchronously using `projectionEngine.getCRS(crs)`. Deck waits for the descriptor before creating its viewport and controller. Resolution errors reach Deck's `onError` callback. For standalone viewport creation, see [CustomProjectionViewport](./custom-projection-viewport.md#usage).
For a CRS definition, the view resolves its descriptor asynchronously using `projectionEngine.getCRS(crs)`. Deck waits for the descriptor before creating its viewport and controller. Resolution errors reach Deck's `onError` callback. For standalone viewport creation, see [CustomProjectionViewport](./custom-projection-viewport.md#usage).

Pass a prepared math.gl `CRSDescriptor` as `crs` to use an application-supplied converter, such as proj4js. The descriptor must describe a projected CRS with linear axes and a WGS84 converter. Deck uses the descriptor directly, including its rendering bounds. Treat descriptors as immutable and provide an execution identity that distinguishes backend, version, operation, and relevant resources. Without an identity, deck only reuses the same descriptor object.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggest one more sentence: "Layers that cache CPU-converted positions should key them on viewport.projectionSignature, not on crs.signature." Also "deck" -> "deck.gl".

this.isGeospatial = true;
this.signature = JSON.stringify([crs.signature, this.resolution]);
this.sizeScaleSignature = JSON.stringify([crs.signature, crs.renderingBounds]);
const executionKey = getProjectionExecutionKey(crs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This changes the behavior for unkeyed descriptors that an app makes again on each frame. They now get a new signature on each frame. Please mention it in whats-new.md.

@athomct

athomct commented Nov 24, 2026

Copy link
Copy Markdown

This is a reminder about my review of 16 November. The two documentation threads above have no answer yet:

  • custom-projection-view.md:24: tell layer authors to key CPU caches on viewport.projectionSignature, not on crs.signature. Also change "deck" to "deck.gl".
  • custom-projection-viewport.ts:100: add a line to whats-new.md. An unkeyed descriptor that the app makes again on each frame now gets a new signature on each frame. Tell users to reuse one descriptor object or to set executionIdentity.

The PR now has merge conflicts with master in modules/core/src/lib/layer.ts and modules/core/src/views/custom-projection-view.ts.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants