diff --git a/doc/en/user/source/extensions/mapml/installation.rst b/doc/en/user/source/extensions/mapml/installation.rst
index 1922443f6c7..cf0afef466e 100644
--- a/doc/en/user/source/extensions/mapml/installation.rst
+++ b/doc/en/user/source/extensions/mapml/installation.rst
@@ -78,6 +78,20 @@ Using tiles to access the layer can increase the performance of your web map. Th
**Use Tiles**
If the "Use Tiles" checkbox is checked, by default the output MapML will define a tile-based reference to the WMS server. Otherwise, an image-based reference will be used. If one or more of the MapML-defined GridSets is referenced by the layer or layer group in its "Tile Caching" profile, GeoServer will generate tile references instead of generating WMS GetMap URLs in the MapML document body.
+Client Requests
+^^^^^^^^^^^^^^^
+
+When configuring a cascaded WMS or WMTS remote layers, a new "Client Requests" setting is available.
+
+**Remote**
+ If the "Remote" checkbox is checked, the link templates embedded in MapML will refer to the remote WMS/WMTS.
+ The MapML viewer will directly contact the remote server if certain criteria are met:
+
+- No restricting DataAccessLimit security is associated to the layer (e.g. with GeoFence integration) that will do filtering, clipping or similar operations. In that case, the MapML will point to the local GeoServer so that the param is honored.
+- No vendor parameters are used in the incoming request. If vendor parameters are used (e.g., request clipping with geometric mask) the MapML is pointing to the local GeoServer so that the vendor parameter is honored
+- The remote Server is supporting the requested CoordinateReferenceSystem for that layer.
+- GetTile requests will be sent to the remote server if there is a compatible gridset for that layer (same origin, same CRS, same tile sizes, same levels and same resolutions)
+
Vector Settings
^^^^^^^^^^^^^^^
diff --git a/src/extension/mapml/pom.xml b/src/extension/mapml/pom.xml
index 2509e66d3b5..54bcfce504d 100644
--- a/src/extension/mapml/pom.xml
+++ b/src/extension/mapml/pom.xml
@@ -114,6 +114,16 @@
0.3.6
test
+
+ com.github.tomakehurst
+ wiremock-jre8-standalone
+ test
+
+
+ org.mockito
+ mockito-core
+ test
+
diff --git a/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLConstants.java b/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLConstants.java
index 45f00f58dee..d84676ee55c 100644
--- a/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLConstants.java
+++ b/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLConstants.java
@@ -50,6 +50,9 @@ public final class MapMLConstants {
/** MapML layer metadata use tiles */
public static final String MAPML_USE_TILES = "mapml.useTiles";
+ /** MapML layer metadata remote client request */
+ public static final String MAPML_USE_REMOTE = "mapml.useRemote";
+
/** MapML layer resource metadata */
public static final String RESOURCE_METADATA = "resource.metadata";
@@ -86,6 +89,9 @@ public final class MapMLConstants {
/** USE_TILES */
public static final String USE_TILES = "useTiles";
+ /** REMOTE */
+ public static final String USE_REMOTE = "useRemote";
+
/** LICENSE_LINK */
public static final String LICENSE = "licenseLink";
diff --git a/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLDocumentBuilder.java b/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLDocumentBuilder.java
index 4159f2edf90..2fc7786a5f5 100644
--- a/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLDocumentBuilder.java
+++ b/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLDocumentBuilder.java
@@ -11,6 +11,7 @@
import static org.geoserver.mapml.MapMLConstants.MAPML_SKIP_ATTRIBUTES_FO;
import static org.geoserver.mapml.MapMLConstants.MAPML_SKIP_STYLES_FO;
import static org.geoserver.mapml.MapMLConstants.MAPML_USE_FEATURES;
+import static org.geoserver.mapml.MapMLConstants.MAPML_USE_REMOTE;
import static org.geoserver.mapml.MapMLConstants.MAPML_USE_TILES;
import static org.geoserver.mapml.MapMLHTMLOutput.PREVIEW_TCRS_MAP;
import static org.geoserver.mapml.template.MapMLMapTemplate.MAPML_PREVIEW_HEAD_FTL;
@@ -182,13 +183,6 @@ public class MapMLDocumentBuilder {
private Boolean isMultiExtent = MAPML_MULTILAYER_AS_MULTIEXTENT_DEFAULT;
private MapMLMapTemplate mapMLMapTemplate = new MapMLMapTemplate();
- static {
- PREVIEW_TCRS_MAP.put("OSMTILE", new TiledCRS("OSMTILE"));
- PREVIEW_TCRS_MAP.put("CBMTILE", new TiledCRS("CBMTILE"));
- PREVIEW_TCRS_MAP.put("APSTILE", new TiledCRS("APSTILE"));
- PREVIEW_TCRS_MAP.put("WGS84", new TiledCRS("WGS84"));
- }
-
/**
* Constructor
*
@@ -606,6 +600,7 @@ private MapMLLayerMetadata layerToMapMLLayerMetadata(RawLayer layer, String styl
.getGridSubset(projType.value())
!= null;
boolean useTiles = Boolean.TRUE.equals(layerMeta.get(MAPML_USE_TILES, Boolean.class));
+ boolean useRemote = Boolean.TRUE.equals(layerMeta.get(MAPML_USE_REMOTE, Boolean.class));
boolean useFeatures = useFeatures(layer, layerMeta);
return new MapMLLayerMetadata(
@@ -623,6 +618,7 @@ private MapMLLayerMetadata layerToMapMLLayerMetadata(RawLayer layer, String styl
styleName,
tileLayerExists,
useTiles,
+ useRemote,
useFeatures,
cqlFilter,
defaultMimeType);
@@ -1335,15 +1331,10 @@ private void generateWMTSClientLinks(MapMLLayerMetadata mapMLLayerMetadata) {
setElevationParam(mapMLLayerMetadata, params, gstl);
setCustomDimensionParam(mapMLLayerMetadata, params, gstl);
setCqlFilterParam(mapMLLayerMetadata, params);
- String urlTemplate = "";
- try {
- urlTemplate =
- URLDecoder.decode(
- ResponseUtils.buildURL(
- baseUrlPattern, path, params, URLMangler.URLType.SERVICE),
- "UTF-8");
- } catch (UnsupportedEncodingException uee) {
- }
+ MapMLRequestMangler mangler =
+ new MapMLRequestMangler(
+ mapContent, mapMLLayerMetadata, baseUrlPattern, path, params, proj);
+ String urlTemplate = mangler.getUrlTemplate();
tileLink.setTref(urlTemplate);
extentList.add(tileLink);
}
@@ -1473,15 +1464,10 @@ private void generateTiledWMSClientLinks(MapMLLayerMetadata mapMLLayerMetadata)
params.put("transparent", Boolean.toString(mapMLLayerMetadata.isTransparent()));
params.put("width", "256");
params.put("height", "256");
- String urlTemplate = "";
- try {
- urlTemplate =
- URLDecoder.decode(
- ResponseUtils.buildURL(
- baseUrlPattern, path, params, URLMangler.URLType.SERVICE),
- "UTF-8");
- } catch (UnsupportedEncodingException uee) {
- }
+ MapMLRequestMangler mangler =
+ new MapMLRequestMangler(
+ mapContent, mapMLLayerMetadata, baseUrlPattern, path, params, proj);
+ String urlTemplate = mangler.getUrlTemplate();
tileLink.setTref(urlTemplate);
extentList.add(tileLink);
}
@@ -1611,15 +1597,10 @@ public void generateWMSClientLinks(MapMLLayerMetadata mapMLLayerMetadata) {
params.put("language", this.request.getLocale().getLanguage());
params.put("width", "{w}");
params.put("height", "{h}");
- String urlTemplate = "";
- try {
- urlTemplate =
- URLDecoder.decode(
- ResponseUtils.buildURL(
- baseUrlPattern, path, params, URLMangler.URLType.SERVICE),
- "UTF-8");
- } catch (UnsupportedEncodingException uee) {
- }
+ MapMLRequestMangler mangler =
+ new MapMLRequestMangler(
+ mapContent, mapMLLayerMetadata, baseUrlPattern, path, params, proj);
+ String urlTemplate = mangler.getUrlTemplate();
imageLink.setTref(urlTemplate);
extentList.add(imageLink);
}
@@ -1695,15 +1676,10 @@ private void generateWMTSQueryClientLinks(MapMLLayerMetadata mapMLLayerMetadata)
params.put("infoformat", "text/mapml");
params.put("i", "{i}");
params.put("j", "{j}");
- String urlTemplate = "";
- try {
- urlTemplate =
- URLDecoder.decode(
- ResponseUtils.buildURL(
- baseUrlPattern, path, params, URLMangler.URLType.SERVICE),
- "UTF-8");
- } catch (UnsupportedEncodingException uee) {
- }
+ MapMLRequestMangler mangler =
+ new MapMLRequestMangler(
+ mapContent, mapMLLayerMetadata, baseUrlPattern, path, params, proj);
+ String urlTemplate = mangler.getUrlTemplate();
queryLink.setTref(urlTemplate);
extentList.add(queryLink);
}
@@ -1744,7 +1720,7 @@ private void generateWMSQueryClientLinks(MapMLLayerMetadata mapMLLayerMetadata)
params.put("layers", mapMLLayerMetadata.getLayerName());
params.put("query_layers", mapMLLayerMetadata.getLayerName());
params.put("styles", mapMLLayerMetadata.getStyleName());
- if (mapMLLayerMetadata.getCqlFilter() != null) {
+ if (StringUtils.isNotBlank(mapMLLayerMetadata.getCqlFilter())) {
params.put("cql_filter", mapMLLayerMetadata.getCqlFilter());
}
setTimeParam(mapMLLayerMetadata, params, null);
@@ -1764,15 +1740,10 @@ private void generateWMSQueryClientLinks(MapMLLayerMetadata mapMLLayerMetadata)
params.put("transparent", Boolean.toString(mapMLLayerMetadata.isTransparent()));
params.put("x", "{i}");
params.put("y", "{j}");
- String urlTemplate = "";
- try {
- urlTemplate =
- URLDecoder.decode(
- ResponseUtils.buildURL(
- baseUrlPattern, path, params, URLMangler.URLType.SERVICE),
- "UTF-8");
- } catch (UnsupportedEncodingException uee) {
- }
+ MapMLRequestMangler mangler =
+ new MapMLRequestMangler(
+ mapContent, mapMLLayerMetadata, baseUrlPattern, path, params, proj);
+ String urlTemplate = mangler.getUrlTemplate();
queryLink.setTref(urlTemplate);
extentList.add(queryLink);
}
@@ -2333,6 +2304,7 @@ static class MapMLLayerMetadata {
private boolean tileLayerExists;
private boolean useTiles;
+ private boolean useRemote;
private boolean timeEnabled;
private boolean elevationEnabled;
@@ -2395,6 +2367,7 @@ public MapMLLayerMetadata(
String styleName,
boolean tileLayerExists,
boolean useTiles,
+ boolean useRemote,
boolean useFeatures,
String cqFilter,
String defaultMimeType) {
@@ -2412,6 +2385,7 @@ public MapMLLayerMetadata(
this.isTransparent = isTransparent;
this.tileLayerExists = tileLayerExists;
this.useTiles = useTiles;
+ this.useRemote = useRemote;
this.useFeatures = useFeatures;
this.cqlFilter = cqFilter;
this.defaultMimeType = defaultMimeType;
@@ -2738,6 +2712,24 @@ public void setUseTiles(boolean useTiles) {
this.useTiles = useTiles;
}
+ /**
+ * get if the layer uses remote
+ *
+ * @return boolean
+ */
+ public boolean isUseRemote() {
+ return useRemote;
+ }
+
+ /**
+ * set if the layer uses remote
+ *
+ * @param useRemote boolean
+ */
+ public void setUseRemote(boolean useRemote) {
+ this.useRemote = useRemote;
+ }
+
/**
* get the ReferencedEnvelope object
*
diff --git a/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLLayerConfigurationPanel.html b/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLLayerConfigurationPanel.html
index 26d90499911..79381220d9e 100644
--- a/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLLayerConfigurationPanel.html
+++ b/src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLLayerConfigurationPanel.html
@@ -43,6 +43,23 @@
+
+
+
+
+