Description
GeoServer allows to use tile cache for WMS using the cache generated by GWC. If a request in WMS is aligned to one of the gridsets defined in GeoServer for the given layer/projection, than the tile is returned.
MapStore partially allows to use tile cache for WMS by generating a gridset aligned to the map resolutions (exponential by default) and using as origin (top-left corner) as the origin of the extent of the current projection.
This allows to match the gridsets of GeoServer only if the scales/resolutions of MapStore/Tileset are exponential (default for both MapStore and GeoServer).
Anyway, when defining custom scales for the map, this reflects on the layer and aligning the 2 tilesets becomes impossible.
Even defining a custom tileset the on GeoServer with the same scales do not work
This because the fixed-origin used by GeoServer to generate the tilegrid starts from the bottom left corner, while Openlayers starts from the top-left corner. While in exponential resolutions there was no problem (because we have exactly 1-tile - 2-tiles - 4-tiles -8tiles on the Y axis), and so the top-left origin will be exactly at the top-left corner of a tile, in the case of custom scales/resolutions the top-left corner vary for each zoom level, so having only one origin is not sufficient anymore.
Proposed solution
There are several use cases:
- Map and GeoServer with exponential resolutions (same origin)
- Map with custom resolutions, standard exponential resolution on GeoServer (generated by default)
- Map with custom resolutions, custom resolutions on GeoServer.
Openlayers allows to have a set of resolutions different from the current scales of the map (leaflet do not allow this). Openlayers gets automatically the nearest resolutions to render, scaling the tiles accordingly.
For this reason I propose to detouch the tilegrid resolutions from the map resolutions.
We should generate resolutions for the layer by default exponentially, checking the map resolutions only to calculate automatically when to stop. (to fit the minmum the resolutions of the map) this strategy need to be investigated more
This allows to generate resolutions on GeoServer exponentially, too and they should always match by default.
If we want a better quality and corrispondence between the map scales on the map and the ones on the server, we can allow from layer settings to customize tilegrid settings, Customizing origin(s) and resolutions of the gridset) sizes, tileSizes.
This solution offers:
- The same behivior by the default
- Fast configurability and caching also when using custom scales
- The possibility to customize the gridset for fine work
### Tasks
- [x] Align default projection EPSG:4326, EPSG:3857 extent definitions to the GeoServer one. Allow to overrides extent of default projections from localConfig.json inside the projectioDefinitions property.
- [x] Review the default tile grid created for the WMS layers in the OpenLayers library using the MapUtils [getResolutionsForProjection](https://github.com/geosolutions-it/MapStore2/blob/master/web/client/utils/MapUtils.js#L218)
- [x] Allow to use a WMTS strategy to create the TileGrid for WMS layer
Acceptance criteria
Other useful information
WMS tile caching in GeoServer is based on TMS standard, starting from the bottom left corner of the gridset extension, keeping the origin fixed for all the resolutions configured.
WMTS instead uses the top-left corner as reference, but allows to define an origin coordinate from all the scales.
Description
GeoServer allows to use tile cache for WMS using the cache generated by GWC. If a request in WMS is aligned to one of the gridsets defined in GeoServer for the given layer/projection, than the tile is returned.
MapStore partially allows to use tile cache for WMS by generating a gridset aligned to the map resolutions (exponential by default) and using as origin (top-left corner) as the origin of the extent of the current projection.
This allows to match the gridsets of GeoServer only if the scales/resolutions of MapStore/Tileset are exponential (default for both MapStore and GeoServer).
Anyway, when defining custom scales for the map, this reflects on the layer and aligning the 2 tilesets becomes impossible.
Even defining a custom tileset the on GeoServer with the same scales do not work
This because the fixed-origin used by GeoServer to generate the tilegrid starts from the bottom left corner, while Openlayers starts from the top-left corner. While in exponential resolutions there was no problem (because we have exactly 1-tile - 2-tiles - 4-tiles -8tiles on the Y axis), and so the top-left origin will be exactly at the top-left corner of a tile, in the case of custom scales/resolutions the top-left corner vary for each zoom level, so having only one origin is not sufficient anymore.
Proposed solution
There are several use cases:
Openlayers allows to have a set of resolutions different from the current scales of the map (leaflet do not allow this). Openlayers gets automatically the nearest resolutions to render, scaling the tiles accordingly.
For this reason I propose to detouch the tilegrid resolutions from the map resolutions.
We should generate resolutions for the layer by default exponentially, checking the map resolutions only to calculate automatically when to stop. (to fit the minmum the resolutions of the map) this strategy need to be investigated more
This allows to generate resolutions on GeoServer exponentially, too and they should always match by default.
If we want a better quality and corrispondence between the map scales on the map and the ones on the server, we can allow from layer settings to customize tilegrid settings, Customizing origin(s) and resolutions of the gridset) sizes, tileSizes.
This solution offers:
- The same behivior by the default
- Fast configurability and caching also when using custom scales
- The possibility to customize the gridset for fine work
Acceptance criteria
Other useful information
WMS tile caching in GeoServer is based on TMS standard, starting from the bottom left corner of the gridset extension, keeping the origin fixed for all the resolutions configured.
WMTS instead uses the top-left corner as reference, but allows to define an origin coordinate from all the scales.