From a98da53818868f5619013fe53891afc9771f5256 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 7 Jun 2007 22:03:15 +0000 Subject: [PATCH] fix for #678 - WMS specs say that *values* and not *parameters* are case sensitive, and the parameter 'transparent' is to be interpreted as true only when its value is 'TRUE'. Previous to this patch, we were only testing if it was equal to 'true'. Now we test for both. This patch applies the same logic to WMS.js and to WMS/Untiled.js, as well as providing some tests to make sure that it works. Thanks and a shout out to gmailer kablukiw wherever s/he may be for the great bug find and report git-svn-id: http://svn.openlayers.org/trunk/openlayers@3290 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/WMS.js | 3 ++- lib/OpenLayers/Layer/WMS/Untiled.js | 3 ++- tests/Layer/test_WMS.html | 22 +++++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index efe39aadf2..0e87d27d52 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -47,7 +47,8 @@ OpenLayers.Layer.WMS.prototype = // unless explicitly set in options, if the layer is transparent, // it will be an overlay if (options == null || options.isBaseLayer == null) { - this.isBaseLayer = ((this.params.TRANSPARENT != "true") && + this.isBaseLayer = ((this.params.TRANSPARENT != "TRUE") && + (this.params.TRANSPARENT != "true") && (this.params.TRANSPARENT != true)); } }, diff --git a/lib/OpenLayers/Layer/WMS/Untiled.js b/lib/OpenLayers/Layer/WMS/Untiled.js index 04ab36fccd..2223083b25 100644 --- a/lib/OpenLayers/Layer/WMS/Untiled.js +++ b/lib/OpenLayers/Layer/WMS/Untiled.js @@ -57,7 +57,8 @@ OpenLayers.Layer.WMS.Untiled.prototype = // unless explicitly set in options, if the layer is transparent, // it will be an overlay if ((options == null) || (options.isBaseLayer == null)) { - this.isBaseLayer = ((this.params.TRANSPARENT != "true") && + this.isBaseLayer = ((this.params.TRANSPARENT != "TRUE") && + (this.params.TRANSPARENT != "true") && (this.params.TRANSPARENT != true)); } }, diff --git a/tests/Layer/test_WMS.html b/tests/Layer/test_WMS.html index 2a7588a7a1..1101e5dc71 100644 --- a/tests/Layer/test_WMS.html +++ b/tests/Layer/test_WMS.html @@ -13,7 +13,7 @@ format: 'image/png'}; function test_01_Layer_WMS_constructor (t) { - t.plan( 4 ); + t.plan( 10 ); var url = "http://octo.metacarta.com/cgi-bin/mapserv"; layer = new OpenLayers.Layer.WMS(name, url, params); @@ -23,7 +23,27 @@ t.eq( layer.params.SERVICE, "WMS", "default params correclty uppercased and copied"); + t.eq(layer.isBaseLayer, true, "no transparency setting, wms is baselayer"); + params.TRANSPARENT = "true"; + var layer2 = new OpenLayers.Layer.WMS(name, url, params); + t.eq(layer2.isBaseLayer, false, "transparency == 'true', wms is baselayer"); + + params.TRANSPARENT = "TRUE"; + var layer3 = new OpenLayers.Layer.WMS(name, url, params); + t.eq(layer3.isBaseLayer, false, "transparency == 'TRUE', wms is baselayer"); + + params.TRANSPARENT = "TRuE"; + var layer4 = new OpenLayers.Layer.WMS(name, url, params); + t.eq(layer4.isBaseLayer, true, "transparency == 'TRuE', wms is not baselayer"); + + params.TRANSPARENT = true; + var layer5 = new OpenLayers.Layer.WMS(name, url, params); + t.eq(layer5.isBaseLayer, false, "transparency == true, wms is baselayer"); + + params.TRANSPARENT = false; + var layer6 = new OpenLayers.Layer.WMS(name, url, params); + t.eq(layer6.isBaseLayer, true, "transparency == false, wms is not baselayer"); } function test_02_Layer_WMS_addtile (t) {