Skip to content

fix(plugins): keep globe projection when adding a Zarr layer via addZarrLayer - #1470

Merged
giswqs merged 1 commit into
opengeos:mainfrom
MasterMaps:fix/addzarrlayer-preserve-globe
Jul 27, 2026
Merged

fix(plugins): keep globe projection when adding a Zarr layer via addZarrLayer#1470
giswqs merged 1 commit into
opengeos:mainfrom
MasterMaps:fix/addzarrlayer-preserve-globe

Conversation

@turban

@turban turban commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What

addZarrLayerExclusively (the code path behind the addZarrLayer plugin API added in #1447) called ensureMercatorProjection(app.getMap?.()), which snapped the map out of globe and pinned it in Web Mercator whenever a plugin added a Zarr layer. This PR removes that call.

Why

The Add Data → Zarr panel renders through the same ZarrLayerControl and never switches projection — so a projected Zarr renders fine in globe there. @carbonplan/zarr-layer reprojects on the GPU (via proj4js), and it renders projected data correctly in globe. So forcing Mercator on the addZarrLayer path was both unnecessary and inconsistent with the panel: the same store rendered in globe via Add Data but snapped to Mercator via a plugin.

The old comment ("the untiled Zarr renderer draws in Web Mercator") is disproven by the panel path and by external use of the same stack (@carbonplan/zarr-layer + MapLibre 6 in globe, rendering EPSG:32633 data via proj4).

Scope

  • Only the Zarr addZarrLayer path changes. The COG / cloud-NetCDF / LiDAR deck.gl paths keep their own ensureMercatorProjection calls (deck.gl genuinely needs Mercator), so the import stays in use.
  • No test referenced the removed call.

Validation

Tested locally against a projected Zarr (seNorge, EPSG:32633, via proj4) added through a plugin while the map was in globe: it now renders in globe and stays there, matching the Add Data → Zarr panel. No regression on the other raster paths.

Fixes #1466 (as discussed there — thanks for the go-ahead 🙌).

Summary by CodeRabbit

  • Bug Fixes
    • Improved Zarr layer behavior in globe view by preserving the selected map projection.
    • Ensured Zarr layers remain consistent with the Add Data → Zarr panel across projection modes.

…arrLayer

addZarrLayerExclusively called ensureMercatorProjection, snapping the map out of
globe whenever a plugin added a Zarr layer through addZarrLayer — while the
Add Data → Zarr panel (same renderer) kept globe. @carbonplan/zarr-layer
reprojects on the GPU and renders projected data correctly in globe, so the
switch was unnecessary and made the two Zarr entry points inconsistent. Remove
it; the COG / cloud-NetCDF / LiDAR deck.gl paths keep their own
ensureMercatorProjection calls.

Fixes opengeos#1466
Copilot AI review requested due to automatic review settings July 27, 2026 15:46
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d48a774-7c42-4b31-b58e-2b4232cd0f91

📥 Commits

Reviewing files that changed from the base of the PR and between a76bbbf and 69e8011.

📒 Files selected for processing (1)
  • packages/plugins/src/plugins/maplibre-components.ts

📝 Walkthrough

Walkthrough

Zarr layer mounting no longer forces Mercator projection. The updated comment documents globe compatibility and aligns the plugin path with the Zarr panel behavior.

Changes

Zarr projection behavior

Layer / File(s) Summary
Preserve globe projection for Zarr layers
packages/plugins/src/plugins/maplibre-components.ts
addZarrLayerExclusively no longer calls ensureMercatorProjection, allowing Zarr layers to remain in globe mode.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: copilot, giswqs

Poem

A bunny hops where globes turn bright,
Zarr stays round in gentle light.
No Mercator snap, no forced disguise,
Projections dance beneath the skies.
Hop, hop—globe rendering flies!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preserving globe projection when adding a Zarr layer.
Linked Issues check ✅ Passed The Zarr plugin path now avoids forcing Mercator, which satisfies the linked issue's globe-projection requirement.
Out of Scope Changes check ✅ Passed The changes stay focused on the Zarr projection behavior and a related comment update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes the forced Web Mercator projection switch when adding Zarr layers via the plugin addZarrLayer API, keeping the map’s current projection (including globe) consistent with the built-in Add Data → Zarr panel behavior.

Changes:

  • Removed the ensureMercatorProjection(app.getMap?.()) call from the addZarrLayerExclusively path.
  • Updated the inline rationale comment to reflect that Zarr rendering works correctly in globe and to document the intended consistency (ref #1466).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giswqs
giswqs merged commit 4d034d5 into opengeos:main Jul 27, 2026
20 checks passed
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.

Don't force Mercator for Zarr layers — zarr-layer supports MapLibre globe

3 participants