making TRANSPARENT param values all UPPERCASE to conform to the WMS spec. r=bartvde (closes #3304)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11984 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-05-20 11:24:19 +00:00
parent feed7f2ed3
commit 81d6051752
2 changed files with 32 additions and 10 deletions
+4
View File
@@ -245,6 +245,10 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
} else { } else {
this.params.SRS = value; this.params.SRS = value;
} }
if (typeof this.params.TRANSPARENT == "boolean") {
newParams.TRANSPARENT = this.params.TRANSPARENT ? "TRUE" : "FALSE";
}
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply( return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(
this, arguments); this, arguments);
+28 -10
View File
@@ -80,13 +80,11 @@
var tParams = OpenLayers.Util.extend({}, var tParams = OpenLayers.Util.extend({},
OpenLayers.Util.upperCaseObject(params)); OpenLayers.Util.upperCaseObject(params));
tParams = OpenLayers.Util.extend(tParams, { tParams = OpenLayers.Util.extend(tParams, {
SERVICE: "WMS", VERSION: "1.1.1", BBOX: [1,2,3,4],
REQUEST: "GetMap", STYLES: "",
SRS: "EPSG:4326", BBOX: [1,2,3,4],
WIDTH: "256", HEIGHT: "256" WIDTH: "256", HEIGHT: "256"
}); });
t.eq( img.src, t.eq( img.src,
url + "?" + OpenLayers.Util.getParameterString(tParams), layer.getFullRequestString(tParams),
"image src is created correctly via addtile" ); "image src is created correctly via addtile" );
t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" ); t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" );
t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" ); t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" );
@@ -97,7 +95,7 @@
else else
t.ok( firstChild instanceof HTMLElement, "div first child is an image object" ); t.ok( firstChild instanceof HTMLElement, "div first child is an image object" );
t.eq( firstChild.src, t.eq( firstChild.src,
url + "?" + OpenLayers.Util.getParameterString(tParams), layer.getFullRequestString(tParams),
"div first child is correct image object" ); "div first child is correct image object" );
t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." ); t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." );
map.destroy(); map.destroy();
@@ -118,13 +116,11 @@
var tParams = OpenLayers.Util.extend({}, var tParams = OpenLayers.Util.extend({},
OpenLayers.Util.upperCaseObject(params)); OpenLayers.Util.upperCaseObject(params));
tParams = OpenLayers.Util.extend(tParams, { tParams = OpenLayers.Util.extend(tParams, {
SERVICE: "WMS", VERSION: "1.1.1", BBOX: "1,2,3,4",
REQUEST: "GetMap", STYLES: "",
SRS: "EPSG:4326", BBOX: "1,2,3,4",
WIDTH: "256", HEIGHT: "256" WIDTH: "256", HEIGHT: "256"
}); });
t.eq( img.src, t.eq( img.src,
url + "?" + OpenLayers.Util.getParameterString(tParams), layer.getFullRequestString(tParams),
"image src is created correctly via addtile" ); "image src is created correctly via addtile" );
t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" ); t.eq( tile.frame.style.top, "6px", "image top is set correctly via addtile" );
t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" ); t.eq( tile.frame.style.left, "5px", "image top is set correctly via addtile" );
@@ -135,7 +131,7 @@
else else
t.ok( firstChild instanceof HTMLElement, "div first child is an image object" ); t.ok( firstChild instanceof HTMLElement, "div first child is an image object" );
t.eq( firstChild.src, t.eq( firstChild.src,
url + "?" + OpenLayers.Util.getParameterString(tParams), layer.getFullRequestString(tParams),
"div first child is correct image object" ); "div first child is correct image object" );
t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." ); t.eq( tile.position.toString(), "x=5,y=6", "Position of tile is set correctly." );
map.destroy(); map.destroy();
@@ -544,6 +540,28 @@
map.destroy(); map.destroy();
} }
function test_transparent(t) {
t.plan(5);
var map = new OpenLayers.Map("map", {allOverlays: true});
var layer = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://myserver.org/wms?",
{layers: 'mylayer', transparent: true}
);
map.addLayer(layer);
t.eq(typeof layer.params.TRANSPARENT, "boolean", "transparent param is boolean");
t.ok(layer.getFullRequestString({}).indexOf("TRANSPARENT=TRUE") != -1, "Boolean transparent param value is uppercase TRUE");
layer.mergeNewParams({transparent: false});
t.ok(layer.getFullRequestString({}).indexOf("TRANSPARENT=FALSE") != -1, "Boolean transparent param value is uppercase FALSE");
layer.mergeNewParams({transparent: "true"});
t.eq(typeof layer.params.TRANSPARENT, "string", "transparent param is string");
t.ok(layer.getFullRequestString({}).indexOf("TRANSPARENT=true") != -1, "transparent param value passed as provided if String");
map.destroy();
}
</script> </script>