Skip to content

Saved map resolutions and aligned with custom resolutions and projection of map#12443

Open
subashtiwari1010 wants to merge 5 commits into
geosolutions-it:masterfrom
subashtiwari1010:fix/projection-issue-11779
Open

Saved map resolutions and aligned with custom resolutions and projection of map#12443
subashtiwari1010 wants to merge 5 commits into
geosolutions-it:masterfrom
subashtiwari1010:fix/projection-issue-11779

Conversation

@subashtiwari1010

@subashtiwari1010 subashtiwari1010 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR reapplies the reverted fix from #11821, which prevents map freezes and OOM errors when the CRS changes while saved resolutions still belong to another projection. It also moves custom resolutions to per-CRS configuration in CRSSelector, so the CRS and its resolutions stay aligned when switching projections and when saving the map.

Changes

  • Custom Resolutions: Can define resolution lists per SRS in localConfig.json; the plugin exposes them to the map on load and when the user changes CRS.
  • Map save/load: When the CRS changes, then the map resolutions are updated and saved in the map options, so it is saved for current projections and when loading the map it is taken from saved information; regarding the custom resolutions, it is taken from plugin config when needed.
  • Migration guide: Documents moving resolutions out of new.json into CRSSelector.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix

Issue

What is the current behavior?
The OOM behavior happens if the resolutions and projection are provided in new.json file and user switch to different projection rather than the resolutions one.

#11779 (comment)

What is the new behavior?
When you change the map CRS, the custom resolutions configured for that CRS in CRSSelector is applied (or computes them if it is not set) and saves them with the map so they stay aligned on reload.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

…s MapStore causing OOM if resolutions configured in new.json file with a different projection (geosolutions-it#11788)" (geosolutions-it#11821)

This reverts commit f337dbb.
@subashtiwari1010 subashtiwari1010 force-pushed the fix/projection-issue-11779 branch from 99488fe to 07262e1 Compare May 29, 2026 08:42
@subashtiwari1010 subashtiwari1010 marked this pull request as ready for review May 29, 2026 08:59
@subashtiwari1010 subashtiwari1010 requested a review from MV88 May 29, 2026 09:00
@tdipisa tdipisa modified the milestones: 2026.01.02, 2026.02.00 Jun 3, 2026
@tdipisa

tdipisa commented Jun 17, 2026

Copy link
Copy Markdown
Member

@subashtiwari1010 can you please fix conflicts here? Thanks.

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

@subashtiwari1010 hi,

can you check this branch where i customized the cfg also check lastest commit
https://github.com/geosolutions-it/MapStore2/tree/11779_test

because when i load locally http://localhost:8081/?debug=true#/viewer/60692

then trying to select 3003 in the crs selecor app froze and idk if it is related to the values inserted or else.

can you do a check there or provide in this branch changes to config that can be used for testing ?

@subashtiwari1010

Copy link
Copy Markdown
Contributor Author

@MV88

Recommended test configuration

Use this in localConfig.json:

"CRSSelector": {
  "cfg": {
    ...,
    "availableProjections": [
      { "value": "EPSG:4326", "label": "EPSG:4326" },
      { "value": "EPSG:3857", "label": "EPSG:3857" },
      { "value": "EPSG:3003", "label": "EPSG:3003" }
    ],
    "customResolutions": {
      "EPSG:3003": [
        2366.978752455357,
        1183.4893762276786,
        591.7446881138393,
        295.87234405691964,
        147.93617202845982,
        73.96808601422991,
        36.984043007114956,
        18.492021503557478,
        9.246010751778739,
        4.623005375889369,
        2.3115026879446847,
        1.1557513439723424,
        0.5778756719861712,
        0.2889378359930856,
        0.1444689179965428,
        0.0722344589982714,
        0.0361172294991357,
        0.01805861474956785,
        0.009029307374783925,
        0.004514653687391962,
        0.002257326843695981,
        0.0011286634218479906,
        0.0005643317109239953,
        0.00028216585546199765
      ]
    }
  }
}

The localConfig.json in the branch provided above have customResolutions of:

"EPSG:3003": [
  156543.03392804097,
  78271.51696402048,
  ...
  0.29858214173896974
]

They are not valid for EPSG:3003.


Root cause: wrong resolution values

11779_test Branch config Correct for EPSG:3003
Max resolution (zoom 0) 156,543 m/px ~2,367 m/px
Ratio 66× actual resolution Derived from projection extent

Computed from the recommended projectionDefs extent [1241482, 973563, 1830078, 5215189]:

maxResolution = (extentWidth / 256) ≈ 2366.98 m/px

The maxResolution based on the extent is closer to the recommended value for the EPSG:3003 CRS.

Why this causes freeze / OOM

  1. User switches CRS → updateMapResolutionsOnCrsChangeEpic applies customResolutions['EPSG:3003'].
  2. OpenLayers builds a view with a 3857-resolution values in a 3003 map.
  3. Zoom level ↔ ground scale is wrong (up to ~66× at low zoom).
  4. WMS/tiled layers request tiles at resolutions that don’t align with the layer grid or visible extent.
  5. Result: browser lag, and eventually OOM / hang as the API calls for the tiles increases.

@subashtiwari1010 subashtiwari1010 force-pushed the fix/projection-issue-11779 branch from 1b3ad23 to 90ad5bf Compare June 19, 2026 15:40
@subashtiwari1010 subashtiwari1010 requested a review from MV88 June 19, 2026 15:43

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

@subashtiwari1010 hi

on a functionality pov it works, but i was wondering if we can avoid duplicating the projection param in the mapOptions object considering that there cannot stay resolutions that are not aligned to the current map projection

Image

can we remove this red one?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting the map projection crashes MapStore if resolutions configured in new.json file with a different projection

3 participants