From fc41d9dac14be1be249b9c7bff60679bcb933f7d Mon Sep 17 00:00:00 2001 From: euzuro Date: Mon, 17 Jul 2006 15:39:44 +0000 Subject: [PATCH] update projection processing. if a layer (or the map) declares its projection as 'none' then no SRS parameter is added to the WMS/WFS requests git-svn-id: http://svn.openlayers.org/trunk/openlayers@960 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/WFS.js | 4 +++- lib/OpenLayers/Layer/WMS.js | 4 +++- tests/test_Layer.html | 6 ++++-- tests/test_Layer_WMS.html | 9 +++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index 73653b248f..e467c27593 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -165,7 +165,9 @@ OpenLayers.Layer.WFS.prototype = * @type String */ getFullRequestString:function(newParams) { - this.params.SRS = this.map.getProjection(); + var projection = this.map.getProjection(); + this.params.SRS = (projection == "none") ? null : projection; + return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( this, arguments); }, diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index 36e0e7c37f..4960578c5a 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -132,7 +132,9 @@ OpenLayers.Layer.WMS.prototype = * @type String */ getFullRequestString:function(newParams) { - this.params.SRS = this.map.getProjection(); + var projection = this.map.getProjection(); + this.params.SRS = (projection == "none") ? null : projection; + return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( this, arguments); }, diff --git a/tests/test_Layer.html b/tests/test_Layer.html index f7fce1a73e..0bbe6d086c 100644 --- a/tests/test_Layer.html +++ b/tests/test_Layer.html @@ -5,15 +5,16 @@ var layer; function test_01_Layer_constructor (t) { - t.plan( 10 ); + t.plan( 12 ); - var options = { chicken: 151, foo: "bar" }; + var options = { chicken: 151, foo: "bar", projection: "none" }; var layer = new OpenLayers.Layer('Test Layer', options); t.ok( layer instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" ); t.eq( layer.CLASS_NAME, "OpenLayers.Layer", "CLASS_NAME variable set correctly"); t.eq( layer.name, "Test Layer", "layer.name is correct" ); + t.ok( layer.projection, "none", "default layer projection correctly set"); t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" ); t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" ); @@ -26,6 +27,7 @@ layer = new OpenLayers.Layer('Test Layer'); t.ok( layer instanceof OpenLayers.Layer, "new OpenLayers.Layer returns object" ); t.eq( layer.name, "Test Layer", "layer.name is correct" ); + t.ok( layer.projection == null, "default layer projection correctly set"); t.ok( layer.options instanceof Object, "layer.options correctly initialized as a non-null Object" ); } diff --git a/tests/test_Layer_WMS.html b/tests/test_Layer_WMS.html index 9d70ee8763..84125f1724 100644 --- a/tests/test_Layer_WMS.html +++ b/tests/test_Layer_WMS.html @@ -133,17 +133,22 @@ function test_07_Layer_WMS_getFullRequestString (t) { - t.plan( 1 ); + t.plan( 2 ); var map = new OpenLayers.Map('map'); map.projection = "xx"; tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; tParams = { layers: 'basic', format: 'image/png'}; - var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams, null); + var tLayer = new OpenLayers.Layer.WMS(name, tUrl, tParams); map.addLayer(tLayer); str = tLayer.getFullRequestString(); t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?LAYERS=basic&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=xx", "getFullRequestString() adds SRS value"); + + tLayer.projection = "none"; + str = tLayer.getFullRequestString(); + t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?LAYERS=basic&FORMAT=image/png&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage", "getFullRequestString() by default does *not* add SRS value if projection is 'none'"); + } function test_99_Layer_WMS_destroy (t) {