Changeset 5622
- Timestamp:
- 01/02/08 10:23:45 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/MapServer.js (modified) (2 diffs)
- trunk/openlayers/tests/Layer/test_MapServer.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/MapServer.js
r5614 r5622 145 145 var url = (altUrl == null) ? this.url : altUrl; 146 146 147 // if url is not a string, it should be an array of strings,148 // in which case we will randomly select one of them in order149 // to evenly distribute requests to different urls.150 if (typeof url == "object") {151 url = url[Math.floor(Math.random()*url.length)];152 }153 // requestString always starts with url154 var requestString = url;155 156 147 // create a new params hashtable with all the layer params and the 157 148 // new params together. then convert to string 158 149 var allParams = OpenLayers.Util.extend({}, this.params); 159 150 allParams = OpenLayers.Util.extend(allParams, newParams); 151 var paramsString = OpenLayers.Util.getParameterString(allParams); 152 153 // if url is not a string, it should be an array of strings, 154 // in which case we will deterministically select one of them in 155 // order to evenly distribute requests to different urls. 156 if (url instanceof Array) { 157 url = this.selectUrl(paramsString, url); 158 } 159 160 160 // ignore parameters that are already in the url search string 161 161 var urlParams = OpenLayers.Util.upperCaseObject( … … 166 166 } 167 167 } 168 var paramsString = OpenLayers.Util.getParameterString(allParams); 169 168 paramsString = OpenLayers.Util.getParameterString(allParams); 169 170 // requestString always starts with url 171 var requestString = url; 172 170 173 // MapServer needs '+' seperating things like bounds/height/width. 171 174 // Since typically this is URL encoded, we use a slight hack: we trunk/openlayers/tests/Layer/test_MapServer.html
r5524 r5622 157 157 158 158 function test_07_Layer_MapServer_getFullRequestString (t) { 159 160 161 t.plan( 1 ); 159 t.plan( 3 ); 162 160 var map = new OpenLayers.Map('map'); 163 161 tUrl = "http://labs.metacarta.com/cgi-bin/mapserv"; … … 179 177 t.eq(str, sStr , "getFullRequestString() works"); 180 178 map.destroy(); 179 180 tUrl = ["http://octo.metacarta.com/cgi-bin/mapserv","http://labs.metacarta.com/cgi-bin/mapserv"]; 181 layer = new OpenLayers.Layer.MapServer(name, tUrl, tParams, null); 182 str = layer.getFullRequestString({'c':'d'}); 183 t.eq(str, tUrl[1] + '?' + OpenLayers.Util.getParameterString(OpenLayers.Util.extend(tParams,{'c':'d'})), "getFullRequestString() works for list of two urls and is deterministic"); 184 layer.destroy(); 185 var tParams = { 186 layers: 'basic', 187 format: 'png', 188 mode: 'map', 189 map_imagetype: 'png' 190 }; 191 tUrl = ["http://octo.metacarta.com/cgi-bin/mapserv","http://labs.metacarta.com/cgi-bin/mapserv"]; 192 layer = new OpenLayers.Layer.MapServer(name, tUrl, tParams, null); 193 str = layer.getFullRequestString({'a':'b'}); 194 t.eq(str, tUrl[0] + '?' + OpenLayers.Util.getParameterString(OpenLayers.Util.extend(tParams,{'a':'b'})), "getFullRequestString() works for list of two urls and is deterministic"); 195 layer.destroy(); 181 196 182 197 }
