From 77c168462be5ade2e0e9b9fb70706243f42ac6ce Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 1 Jun 2006 11:54:31 +0000 Subject: [PATCH] need to make WMS & WFS case-independent. I dont know why I chose to move them all to uppercase instead of lowercase, but I did. This required changing the test cases and the 'srs' property which is set in Grid. Personally, I dont think that is the best place to set it, but so be it jedi. As long as I have the mic, i'd add that having 'projection' stored in both map and layer objects seems a bit redundant as well. git-svn-id: http://svn.openlayers.org/trunk/openlayers@493 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/Grid.js | 2 +- lib/OpenLayers/Layer/WFS.js | 9 +++++++-- lib/OpenLayers/Layer/WMS.js | 13 +++++++++---- tests/test_Layer_WMS.html | 10 +++++----- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index b13af4afe2..e14f700da4 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -220,7 +220,7 @@ OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), { */ getFullRequestString:function(params) { var requestString = ""; - this.params.srs = this.projection; + this.params.SRS = this.projection; // concat tile params with layer params and convert to string var allParams = Object.extend(params, this.params); var paramsString = OpenLayers.Util.getParameterString(allParams); diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index f670e22566..1d63fc5ac3 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -31,13 +31,18 @@ OpenLayers.Layer.WFS.prototype = var newArguments = new Array(); if (arguments.length > 0) { + //uppercase params + params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params); } OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments); if (arguments.length > 0) { - OpenLayers.Util.applyDefaults(this.params, this.DEFAULT_PARAMS); + OpenLayers.Util.applyDefaults( + this.params, + OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) + ); } }, @@ -78,7 +83,7 @@ OpenLayers.Layer.WFS.prototype = */ addTile:function(bounds, position) { url = this.getFullRequestString( - { bbox:bounds.toBBOX() }); + { BBOX:bounds.toBBOX() }); var tile = new OpenLayers.Tile.WFS(this, position, bounds, url, this.tileSize); tile.draw(); diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index ff4e4e31e5..db29b1c426 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -25,12 +25,17 @@ OpenLayers.Layer.WMS.prototype = initialize: function(name, url, params) { var newArguments = new Array(); if (arguments.length > 0) { + //uppercase params + params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params); } OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); if (arguments.length > 0) { - OpenLayers.Util.applyDefaults(this.params, this.DEFAULT_PARAMS); + OpenLayers.Util.applyDefaults( + this.params, + OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) + ); } }, @@ -62,9 +67,9 @@ OpenLayers.Layer.WMS.prototype = */ addTile:function(bounds,position) { url = this.getFullRequestString( - {bbox:bounds.toBBOX(), - width:this.tileSize.w, - height:this.tileSize.h}); + {BBOX:bounds.toBBOX(), + WIDTH:this.tileSize.w, + HEIGHT:this.tileSize.h}); var tile = new OpenLayers.Tile.Image(this, position, bounds, url, this.tileSize); tile.draw(); diff --git a/tests/test_Layer_WMS.html b/tests/test_Layer_WMS.html index 940934c2aa..440cffff1a 100644 --- a/tests/test_Layer_WMS.html +++ b/tests/test_Layer_WMS.html @@ -12,9 +12,9 @@ t.ok( layer instanceof OpenLayers.Layer.WMS, "new OpenLayers.Layer.WMS returns object" ); t.eq( layer.name, "Test Layer", "layer.name is correct" ); t.eq( layer.url, "http://octo.metacarta.com/cgi-bin/mapserv", "layer.url is correct" ); - t.eq( layer.params.map, "/mapdata/vmap_wms.map", "layer.params.map is correct" ); - t.eq( layer.params.format, "image/png", "layer.params.format is correctly overridden" ); - t.eq( layer.params.exceptions, "application/vnd.ogc.se_inimage", + t.eq( layer.params.MAP, "/mapdata/vmap_wms.map", "layer.params.map is correct" ); + t.eq( layer.params.FORMAT, "image/png", "layer.params.format is correctly overridden" ); + t.eq( layer.params.EXCEPTIONS, "application/vnd.ogc.se_inimage", "other default layer.params are set correctly" ); } function test_02_Layer_WMS_addtile (t) { @@ -24,14 +24,14 @@ map.addLayer(layer); var pixel = new OpenLayers.Pixel(5,6); var tile = layer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); - t.eq( tile.img.src, "http://octo.metacarta.com/cgi-bin/mapserv?bbox=1,2,3,4&width=256&height=256&map=/mapdata/vmap_wms.map&layers=basic&format=image/jpeg&service=WMS&version=1.1.1&request=GetMap&styles=&exceptions=application/vnd.ogc.se_inimage&srs=EPSG:4326", "image src is created correctly via addtile" ); + t.eq( tile.img.src, "http://octo.metacarta.com/cgi-bin/mapserv?BBOX=1,2,3,4&WIDTH=256&HEIGHT=256&MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326", "image src is created correctly via addtile" ); t.eq( tile.img.style.top, "6px", "image top is set correctly via addtile" ); t.eq( tile.img.style.left, "5px", "image top is set correctly via addtile" ); if (!isMozilla) t.ok( true, "skipping element test outside of Mozilla"); else t.ok( layer.div.firstChild instanceof HTMLImageElement, "div first child is an image object" ); - t.eq( layer.div.firstChild.src, "http://octo.metacarta.com/cgi-bin/mapserv?bbox=1,2,3,4&width=256&height=256&map=/mapdata/vmap_wms.map&layers=basic&format=image/jpeg&service=WMS&version=1.1.1&request=GetMap&styles=&exceptions=application/vnd.ogc.se_inimage&srs=EPSG:4326", "div first child is correct image object" ); + t.eq( layer.div.firstChild.src, "http://octo.metacarta.com/cgi-bin/mapserv?BBOX=1,2,3,4&WIDTH=256&HEIGHT=256&MAP=/mapdata/vmap_wms.map&LAYERS=basic&FORMAT=image/jpeg&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application/vnd.ogc.se_inimage&SRS=EPSG:4326", "div first child is correct image object" ); var pos = tile.getPosition(); t.eq( pos.toString(), "x=5,y=6", "Position of tile is set correctly." ); }