Skip to content

Commit

Permalink
Use the capabilities getmap / gettile url as the "base" for templates
Browse files Browse the repository at this point in the history
  • Loading branch information
prushforth committed Oct 15, 2024
1 parent d9bf776 commit e376a43
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,6 @@ private boolean canCascade(LayerInfo layerInfo) {
// Not supporting cross-requests yet:
// GetTiles against remote WMS
// GetMap against remote WMTS
String service = params.get(SERVICE);
String request = params.get(REQUEST);
if (storeInfo instanceof WMTSStoreInfo) {
if (GETMAP.equalsIgnoreCase(request)
|| (GETFEATUREINFO.equalsIgnoreCase(request)
&& WMS.equalsIgnoreCase(service))) {
return false;
}
} else if (storeInfo instanceof WMSStoreInfo) {
if (GETTILE.equalsIgnoreCase(request)
|| (GETFEATUREINFO.equalsIgnoreCase(request)
&& WMTS.equalsIgnoreCase(service))) {
return false;
}
}
return TiledCRSConstants.getSupportedOutputCRS(proj) != null;
}
return false;
Expand Down Expand Up @@ -184,6 +169,7 @@ private String generateURL(String path, HashMap<String, String> params, LayerInf
boolean isSupportedOutputCRS = outputCRS != null;
if (resourceInfo != null) {
String capabilitiesURL = null;
URL getResourceURL = null;
String tileMatrixSet = null;
StoreInfo storeInfo = resourceInfo.getStore();
String requestedCRS = isSupportedOutputCRS ? outputCRS : proj;
Expand All @@ -195,6 +181,7 @@ private String generateURL(String path, HashMap<String, String> params, LayerInf
try {
WMSCapabilities capabilities =
wmsStoreInfo.getWebMapServer(null).getCapabilities();
getResourceURL = capabilities.getRequest().getGetMap().getGet();
version = capabilities.getVersion();
List<Layer> layerList = capabilities.getLayerList();
// Check on GetFeatureInfo
Expand Down Expand Up @@ -241,6 +228,7 @@ private String generateURL(String path, HashMap<String, String> params, LayerInf
try {
WMTSCapabilities capabilities =
wmtsStoreInfo.getWebMapTileServer(null).getCapabilities();
getResourceURL = capabilities.getRequest().getGetTile().getGet();
version = capabilities.getVersion();
List<WMTSLayer> layerList = capabilities.getLayerList();
// Check on GetFeatureInfo
Expand Down Expand Up @@ -284,9 +272,16 @@ private String generateURL(String path, HashMap<String, String> params, LayerInf
if (cascadeToRemote) {
// if we reach this point, we can finally cascade.
// Let's update all the params for the cascading
String[] baseUrlAndPath = getBaseUrlAndPath(capabilitiesURL);
baseUrl = baseUrlAndPath[0];
path = baseUrlAndPath[1];
baseUrl =
getResourceURL.getProtocol()
+ "://"
+ getResourceURL.getHost()
+ (getResourceURL.getPort() == -1
? ""
: ":" + getResourceURL.getPort())
+ "/";

path = getResourceURL.getPath();
urlType = URLMangler.URLType.EXTERNAL;
updateRequestParams(
params, layerName, version, requestedCRS, tileMatrixSet, infoFormats);
Expand Down

0 comments on commit e376a43

Please sign in to comment.