-
Notifications
You must be signed in to change notification settings - Fork 405
[Proposal] MapStore query parameters simplification
This proposal aims to review the current implementation of MS query parameters handling for easier use for not advanced users.
- Tobia Di Pisa
The proposal is for 2022.02.01
- Under Discussion
- Accepted
- In Progress
- Completed (https://github.com/geosolutions-it/MapStore2/issues/8597)
- Rejected
- Deferred
The goal is to leverage the current actions system in order to reduce the impact on the existing code base as well as to introduce a simplified mode for managing query parameters through GET requests. Therefore, the current implementation as currently described in online documentation
will remain available anyway.
The final result will allow to use a simplified set of query parameters for the purpose.
What are existing parameters that don't need to be considered for this enhancement because they are already simple to use:
- Center
- Zoom
- Marker
- Bbox
What are parameters that need to be taken into account for this task instead:
- featureInfo
Some existing actions that are effectively relevant for this work:
- Map Info (SEARCH:SEARCH_WITH_FILTER)
- Add Layers (CATALOG:ADD_LAYERS_FROM_CATALOGS)
New parameter to be added:
- background: to allow to add a map background to the map and activate it
In the simplified mode it will be possible to specify only the coordinates to be used for the Identify request.
Example:
#/viewer/openlayers/{map_id}?featureinfo={lat},{lon}
A new set of query parameters will be introduced for this. At loading time of the viewer MapStore will be able to converts those parameters in the corresponding action (SEARCH:SEARCH_WITH_FILTER) and execute it.
Example:
It will be possible to run this action:
{
"type": "SEARCH:SEARCH_WITH_FILTER",
"cql_filter": "ID=75",
"layer": "WORKSPACE:LAYER_NAME"
}
using simple query parameters like:
#/viewer/openlayers/{map_id}?mapInfo=WORKSPACE:LAYER_NAME&mapInfoFilter='ID=75'
Using the same logic as before a new set of query parameters will be introduced for this too. At loading time of the viewer MapStore will be able to converts those parameters in the corresponding action (CATALOG:ADD_LAYERS_FROM_CATALOGS) and execute it.
Example:
It will be possible to run this action:
{
"type": "CATALOG:ADD_LAYERS_FROM_CATALOGS",
"layers": ["workspace1:layer1", "workspace2:layer2", "workspace3:layer3"],
"sources": ["catalog1", "catalog2"],
"options": [{"params":{"CQL_FILTER":"NAME1='value1'"}}, {"params":{"CQL_FILTER":"NAME2='value2'"}}, {"params":{"CQL_FILTER":"NAME3='value3'"}}]
}
using simple query parameters like:
#/viewer/openlayers/{map_id}?addLayers=workspace1:layer1;catalog1,workspace2:layer2;catalog2,workspace3:layer3&layerFilters="NAME1='value1'","NAME2='value2'","NAME3='value3'"
The logic will be the same, therefore the layers present in the addLayers list will be added to the existing map as usual and CQL filters present in the layerFilters list will be applied to the corresponding layers respecting the same sequence of the addLayers list. The value after semicolon represents as usual the source ID used to load the layer; if no value is specified the usual default catalog source is used. Therefore:
- workspace1:layer1 -> NAME1='value1' -> loaded from catalog source of ID catalog1 (eg. in localConfig or context config)
- workspace2:layer2 -> NAME2='value2' -> loaded from catalog source of ID catalog2 (eg. in localConfig or context config)
- workspace3:layer3 -> NAME3='value3' -> loaded from the default catalog source (eg. as configured in localConfig or context config)
With respect to the action, this simplified method has the only limitation that it is not possible to add layers from arbitrary sources than the ones already present in the configuration. As with the action, one of the supported source type is anyway supported: WMS, WMTS and WFS.
It will be always possible to concatenate query parameters as usual, like:
#/viewer/openlayers/{map_id}?addLayers=workspace1:layer1&layerFilters="NAME1='value1'"&mapInfo=workspace1:layer1&mapInfoFilter='ID=75'
or, for example:
#/viewer/openlayers/{map_id}?addLayers=topp:states&actions=[{"type":"SEARCH:SEARCH_WITH_FILTER","cql_filter":"STATE_FIPS=34","layer":"topp:states"}
There is anyway the need to have a query parameter to be able to specify the desired background layer in the URL. The new parameter will work in the same way of addLayers to allow to specify the layer name to be loaded from one of the supported source types (as specified in the above paragraph) if that type is one of the supported for background layers: WMS or WMTS. Otherwise the parameter will be ignored.
Example:
#/viewer/openlayers/{map_id}?background=workspace:layer;catalog1
-> bg layer added from the catalog source with ID catalog1
or, following the same logic as above:
#/viewer/openlayers/{map_id}?background=workspace:layer
-> bg layer added from the default catalog source
If that parameter is specified as a query parameter in the URL the background layer will be added and activated in the Background Selector.