From 855ec2516935a75c293a3ec6acd8960fb610da16 Mon Sep 17 00:00:00 2001 From: Matthew Fullerton Date: Thu, 13 Aug 2015 13:37:13 +0000 Subject: [PATCH] Preserve extra URL arguments The WFS and WMS parts of the extension add or don't things to the url as required. Often this means that only the endpoint is needed as the resource URL but sometimes some extra parameters are needed and these get removed. This commit prevents that from happening but is only well tested for cases where the resource proxy is in use. --- ckanext/geoview/public/js/ol2_preview.js | 37 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/ckanext/geoview/public/js/ol2_preview.js b/ckanext/geoview/public/js/ol2_preview.js index d7dd4b97..1674fca8 100644 --- a/ckanext/geoview/public/js/ol2_preview.js +++ b/ckanext/geoview/public/js/ol2_preview.js @@ -129,20 +129,29 @@ }, 'wfs': function(resource, proxyUrl, proxyServiceUrl, layerProcessor) { var parsedUrl = resource.url.split('#'); - var url = proxyServiceUrl || parsedUrl[0]; - + var simpleUrl = parsedUrl[0].split('?'); + var directUrl = simpleUrl[0].toString(); // Without query + var keepArgs = simpleUrl.length > 1 && reduceWMSWFSArguments(simpleUrl[1]); + if (keepArgs) { + if (proxyServiceUrl) proxyServiceUrl += keepArgs; + directUrl += keepArgs; + } + var url = proxyServiceUrl || directUrl; var ftName = parsedUrl.length > 1 && parsedUrl[1]; OL_HELPERS.withFeatureTypesLayers(url, layerProcessor, ftName); }, 'wms' : function(resource, proxyUrl, proxyServiceUrl, layerProcessor) { var parsedUrl = resource.url.split('#'); - // use the original URL for the getMap, as there's no need for a proxy for image requests - var getMapUrl = parsedUrl[0].split('?')[0]; // remove query if any - - var url = proxyServiceUrl || getMapUrl; - + var simpleUrl = parsedUrl[0].split('?'); + var directUrl = simpleUrl[0]; // Without query and using the original URL for the getMap, as there's no need for a proxy for image requests + var keepArgs = simpleUrl.length > 1 && reduceWMSWFSArguments(simpleUrl[1]); + if (keepArgs) { + if (proxyServiceUrl) proxyServiceUrl += keepArgs; + directUrl += keepArgs; + } + var url = proxyServiceUrl || directUrl; var layerName = parsedUrl.length > 1 && parsedUrl[1]; - OL_HELPERS.withWMSLayers(url, getMapUrl, layerProcessor, layerName); + OL_HELPERS.withWMSLayers(url, directUrl, layerProcessor, layerName); }, 'esrigeojson': function (resource, proxyUrl, proxyServiceUrl, layerProcessor) { var url = proxyUrl || resource.url; @@ -161,6 +170,18 @@ layerProcessor(OL_HELPERS.createGFTLayer(tableId, ckan.geoview.gapi_key)); } } + + var reduceWMSWFSArguments = function(input) { + var args = input.split('&'); + output = '?'; + for (i=0;i