From 6204fe50c6be3ca7bfc382a86ff00b2dccf1b273 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 5 Mar 2012 09:56:31 +0100 Subject: [PATCH 1/2] GetFeatureInfo requests should take EXCEPTIONS parameter from the WMS layer --- lib/OpenLayers/Control/WMSGetFeatureInfo.js | 1 + tests/Control/WMSGetFeatureInfo.html | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Control/WMSGetFeatureInfo.js b/lib/OpenLayers/Control/WMSGetFeatureInfo.js index 9348a9d542..86e9423060 100644 --- a/lib/OpenLayers/Control/WMSGetFeatureInfo.js +++ b/lib/OpenLayers/Control/WMSGetFeatureInfo.js @@ -341,6 +341,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, { service: "WMS", version: firstLayer.params.VERSION, request: "GetFeatureInfo", + exceptions: firstLayer.params.EXCEPTIONS, bbox: this.map.getExtent().toBBOX(null, firstLayer.reverseAxisOrder()), feature_count: this.maxFeatures, diff --git a/tests/Control/WMSGetFeatureInfo.html b/tests/Control/WMSGetFeatureInfo.html index 5e7801b036..e7575fa163 100644 --- a/tests/Control/WMSGetFeatureInfo.html +++ b/tests/Control/WMSGetFeatureInfo.html @@ -476,7 +476,7 @@ } function test_drillDown(t) { - t.plan(6); + t.plan(7); var map = new OpenLayers.Map("map", { getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));} } @@ -493,6 +493,7 @@ // this service does not support application/vnd.ogc.gml for GetFeatureInfo, only text/xml var c = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", { layers: "x", + exceptions: "text/xml", info_format: "text/xml" }); @@ -515,6 +516,7 @@ t.eq(options.url, "http://localhost/wms", "Correct url used for second request"); } else if (count == 1) { t.eq(options.params["INFO_FORMAT"], "text/xml", "Overridden info format is used instead of the control's infoFormat"); + t.eq(options.params["EXCEPTIONS"], "text/xml", "Exceptions parameter is used from the WMS layer"); t.eq(options.url, "http://myhost/wms", "Correct url used for first request"); } }; From 17f7b2feab49766da3a836062ed9be03a6047bf1 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 5 Mar 2012 10:04:15 +0100 Subject: [PATCH 2/2] use separate testcase as suggested by @ahocevar --- tests/Control/WMSGetFeatureInfo.html | 33 +++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/Control/WMSGetFeatureInfo.html b/tests/Control/WMSGetFeatureInfo.html index e7575fa163..b5e6d5db80 100644 --- a/tests/Control/WMSGetFeatureInfo.html +++ b/tests/Control/WMSGetFeatureInfo.html @@ -475,8 +475,37 @@ } + function test_exceptions(t) { + t.plan(1); + var map = new OpenLayers.Map("map", { + getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));} + } + ); + + var a = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", { + layers: "x", + exceptions: "text/xml" + }); + + map.addLayer(a); + + var click = new OpenLayers.Control.WMSGetFeatureInfo({ + }); + + map.addControl(click); + + var _request = OpenLayers.Request.GET; + OpenLayers.Request.GET = function(options) { + t.eq(options.params["EXCEPTIONS"], "text/xml", "Exceptions parameter taken from the WMS layer if provided"); + }; + click.activate(); + click.getInfoForClick({xy: {x: 50, y: 50}}); + OpenLayers.Request.GET = _request; + map.destroy(); + } + function test_drillDown(t) { - t.plan(7); + t.plan(6); var map = new OpenLayers.Map("map", { getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));} } @@ -493,7 +522,6 @@ // this service does not support application/vnd.ogc.gml for GetFeatureInfo, only text/xml var c = new OpenLayers.Layer.WMS("dummy","http://myhost/wms", { layers: "x", - exceptions: "text/xml", info_format: "text/xml" }); @@ -516,7 +544,6 @@ t.eq(options.url, "http://localhost/wms", "Correct url used for second request"); } else if (count == 1) { t.eq(options.params["INFO_FORMAT"], "text/xml", "Overridden info format is used instead of the control's infoFormat"); - t.eq(options.params["EXCEPTIONS"], "text/xml", "Exceptions parameter is used from the WMS layer"); t.eq(options.url, "http://myhost/wms", "Correct url used for first request"); } };