Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing tiles resolutions #4627

Merged
merged 5 commits into from
Jul 17, 2024
Merged

Fixing tiles resolutions #4627

merged 5 commits into from
Jul 17, 2024

Conversation

rldhont
Copy link
Collaborator

@rldhont rldhont commented Jul 16, 2024

fixes #4332

Currently, if the map allows you to go beyond the min/zoom resolution of a WMTS or XYZ source, Lizmap won't display anything beyond this min/zoom resolution.

OpenLayers is able to do resampling. This can be seen when you zoom in progressively. OpenLayers must be forced to use the max zoom of the grid even when the user goes beyond it.

The solution is described on stackoverflow https://stackoverflow.com/questions/43538345/how-to-force-load-tiles-for-lower-resolution and is based on TileGrid's getZForResolution method https://github.com/openlayers/openlayers/blob/main/src/ol/tilegrid/TileGrid.js#L634

  getZForResolution(resolution, opt_direction) {
    const z = linearFindNearest(
      this.resolutions_,
      resolution,
      opt_direction || 0,
    );
    return clamp(z, this.minZoom, this.maxZoom);
  }

This method is based on the this.resolutions_ list of grid resolutions. The index of the resolution closest to that in parameter is then set to the min or max zoom value.

So if this.resolutions_ contains 24 values but maxZoom is 19, then when the map is at levels 20, 21, 22, 23 and 24, the grid will limit queries to zoom 19.

Funded by FM Projet

@rldhont rldhont added map viewer javascript Pull requests that update Javascript code run end2end If the PR must run end2end tests or not backport release_3_7 backport release_3_8 labels Jul 16, 2024
@rldhont rldhont requested a review from nboisteault July 16, 2024 12:47
@github-actions github-actions bot added this to the 3.9.0 milestone Jul 16, 2024
rldhont added 3 commits July 16, 2024 20:16
fixes 3liz#4332

Currently, if the map allows you to go beyond the min/zoom resolution of a WMTS or XYZ source, Lizmap won't display anything beyond this min/zoom resolution.

OpenLayers is able to do resampling. This can be seen when you zoom in progressively. OpenLayers must be forced to use the max zoom of the grid even when the user goes beyond it.

The solution is described on stackoverflow https://stackoverflow.com/questions/43538345/how-to-force-load-tiles-for-lower-resolution and is based on `TileGrid`'s `getZForResolution` method https://github.com/openlayers/openlayers/blob/main/src/ol/tilegrid/TileGrid.js#L634

```js
  getZForResolution(resolution, opt_direction) {
    const z = linearFindNearest(
      this.resolutions_,
      resolution,
      opt_direction || 0,
    );
    return clamp(z, this.minZoom, this.maxZoom);
  }
```

This method is based on the `this.resolutions_` list of grid resolutions. The index of the resolution closest to that in parameter is then set to the min or max zoom value.

So if `this.resolutions_` contains 24 values but maxZoom is 19, then when the map is at levels 20, 21, 22, 23 and 24, the grid will limit queries to zoom 19.

Funded by FM Projet
Generic method to build scales based on options config.
@rldhont rldhont force-pushed the fix-tiles-resolutions branch from 0de8798 to 3f5ae41 Compare July 16, 2024 18:17
@rldhont rldhont force-pushed the fix-tiles-resolutions branch from 3f5ae41 to 30e65c6 Compare July 16, 2024 19:47
@rldhont rldhont added the sponsored development This development has been funded label Jul 17, 2024
@rldhont rldhont merged commit 383e2ca into 3liz:master Jul 17, 2024
14 checks passed
@3liz-bot
Copy link
Contributor

The backport to release_3_7 failed:

The process '/usr/bin/git' failed with exit code 1
stderr
error: could not apply db21ff0da... Fixing tiles resolutions
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

stdout
Auto-merging assets/src/modules/config/BaseLayer.js
CONFLICT (modify/delete): assets/src/modules/map.js deleted in HEAD and modified in db21ff0da (Fixing tiles resolutions).  Version db21ff0da (Fixing tiles resolutions) of assets/src/modules/map.js left in tree.

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-release_3_7 release_3_7
# Navigate to the new working tree
cd .worktrees/backport-release_3_7
# Create a new branch
git switch --create backport-4627-to-release_3_7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick db21ff0da4b461a77d48f6a34961fc8c5976dedc,f2b6acb07a94a325785f02d150d4e429786d1064,9c0fa34da4589f744a87f7c09947c22bba7ffd69,0a7cd196f9276036d30f6681e8fd570c6de6e38d,30e65c63713b8cc4dfa9c3db47736eaa36943c38
# Push it to GitHub
git push --set-upstream origin backport-4627-to-release_3_7
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-release_3_7

Then, create a pull request where the base branch is release_3_7 and the compare/head branch is backport-4627-to-release_3_7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport release_3_7 backport release_3_8 failed backport javascript Pull requests that update Javascript code map viewer run end2end If the PR must run end2end tests or not sponsored development This development has been funded
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Baselayers are not rendered below 1:2000 scale
2 participants