Skip to content

COG displayed with native resolution#1563

Open
davidoesch wants to merge 2 commits intogeoadmin:developfrom
davidoesch:develop
Open

COG displayed with native resolution#1563
davidoesch wants to merge 2 commits intogeoadmin:developfrom
davidoesch:develop

Conversation

@davidoesch
Copy link
Contributor

Description

This pull request improves the rendering of Cloud Optimized GeoTIFF (COG) layers by ensuring that the native pixel resolution is preserved and no interpolation is applied during display.

Current situation https://s.geo.admin.ch/0y1b8b1l5tlq
image

Proposed solution https://codesandbox.io/p/devbox/cog-forked-49q956
image

Changes

Disable interpolation for COG layers (WebGLTileLayer)

Interpolation is explicitly disabled to ensure that COG layers are always rendered at their native resolution.

  • The current WebGLTileLayer configuration does not set the interpolate option.
  • Interpolation is now disabled at the source level in OpenLayersCOGTiffLayer.vue.
  • This follows the vanilla OpenLayers reference implementation:
    https://codesandbox.io/p/devbox/cog-forked-49q956

This prevents unintended resampling artifacts and ensures pixel-accurate visualization.

Enable constrainResolution for map views

To further guarantee native resolution rendering, the constrainResolution: true option is added to the OpenLayers View configuration.

  • OpenLayers View instances are created per projection.
  • The option is added to:
    • the LV95 view configuration
    • the WebMercator view configuration
  • This ensures zoom levels snap to discrete resolutions, matching the behavior shown in the vanilla OpenLayers COG example.

Rationale

Both changes are required to ensure that COG layers are displayed consistently and without interpolation, aligning the map viewer behavior with standard OpenLayers COG rendering.

Disabling interpolation for COG layers: Beacuse we should always show the native resolution, and not interpoalte it.
The current WebGLTileLayer does not set the interpolate option. To disable interpolation, modify OpenLayersCOGTiffLayer.vue: You need to also disable interpolation at the source level. The vanilla OL solution : https://codesandbox.io/p/devbox/cog-forked-49q956
OpenLayers View instances are created per projection. To enable constrainResolution: true, lets add it to the LV95 view configuration  and to the WebMercator view around line . I assume this is neede to ensure native resolution displayed in the map viewer for COG as ege shown  with vanilla OL in https://codesandbox.io/p/devbox/cog-forked-49q956
@davidoesch davidoesch requested a review from pakb February 2, 2026 08:30
Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
I'm in the process of finishing a huge TypeScript migration, and will be rebasing this and merging it there as soon as I can.

@cypress
Copy link

cypress bot commented Feb 2, 2026

web-mapviewer    Run #6431

Run Properties:  status check failed Failed #6431  •  git commit f4e0166a8c: Add constrainResolution option to views for projections
Project web-mapviewer
Branch Review develop
Run status status check failed Failed #6431
Run duration 07m 54s
Commit git commit f4e0166a8c: Add constrainResolution option to views for projections
Committer David Oesch
View all properties for this run ↗︎

Test results
Tests that failed  Failures 5
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 20
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 255
View all changes introduced in this branch ↗︎

Tests for review

Failed  legacyParamImport.cy.js • 1 failed test • e2e/chrome/mobile

View Output

Test Artifacts
Test on legacy param import > Coordinates import > transfers valid params to the hash part without changing them Test Replay Screenshots
Failed  shareShortLink.cy.js • 1 failed test • e2e/chrome/mobile

View Output

Test Artifacts
Testing the share menu > iFrame snippet generation > enables the user to tick the zoom checkbox and require ctrl/cmd to zoom Test Replay Screenshots
Failed  embed.cy.js • 2 failed tests • e2e/chrome/mobile

View Output

Test Artifacts
Testing the embed view > Open in embed mode and can jump to the non embed mode Test Replay Screenshots
Testing the embed view > Open in legacy embed mode and can jump to the non embed mode Test Replay Screenshots
Failed  mouseposition.cy.js • 1 failed test • e2e/chrome/mobile

View Output

Test Artifacts
Test mouse position and interactions > Mobile only tests > shows the LocationPopUp when rightclick occurs on the map Test Replay Screenshots

@davidoesch
Copy link
Contributor Author

@pakb you have to test it, I do assume it might work

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.

2 participants