Make WMS server selection deterministic, by using a real number hashing algorithm on the parameter string to select the server URL. Also, patch TMS since it doesn't use getFullParameterString(). Passes all tests. Fixes #410.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2821 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -89,7 +89,7 @@
|
||||
tParams = { layers: 'basic',
|
||||
format: 'image/png'};
|
||||
|
||||
t.plan( 9 );
|
||||
t.plan( 12 );
|
||||
|
||||
// without ?
|
||||
tUrl = "http://octo.metacarta.com/cgi-bin/mapserv";
|
||||
@@ -147,9 +147,35 @@
|
||||
layer = new OpenLayers.Layer.HTTPRequest(name, "chicken", tParams, null);
|
||||
str = layer.getFullRequestString(null, tUrl);
|
||||
t.eq(str, tUrl + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for url sans ?");
|
||||
|
||||
// single url object
|
||||
tUrl = ["http://octo.metacarta.com/cgi-bin/mapserv"];
|
||||
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
|
||||
str = layer.getFullRequestString();
|
||||
t.eq(str, tUrl[0] + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for list of one url");
|
||||
|
||||
// two url object
|
||||
tUrl = ["http://octo.metacarta.com/cgi-bin/mapserv","http://labs.metacarta.com/cgi-bin/mapserv"];
|
||||
layer = new OpenLayers.Layer.HTTPRequest(name, tUrl, tParams, null);
|
||||
str = layer.getFullRequestString();
|
||||
t.eq(str, tUrl[0] + '?' + OpenLayers.Util.getParameterString(tParams), "getFullRequestString() works for list of two urls");
|
||||
str = layer.getFullRequestString({'a':'f'});
|
||||
t.eq(str, tUrl[1] + '?' + OpenLayers.Util.getParameterString(OpenLayers.Util.extend(tParams,{'a':'f'})), "getFullRequestString() works for list of two urls and is deterministic");
|
||||
|
||||
}
|
||||
|
||||
function test_04_Layer_HTTPRequest_selectUrl (t) {
|
||||
t.plan( 4 );
|
||||
|
||||
layer = new OpenLayers.Layer.HTTPRequest(name, url, params, options);
|
||||
|
||||
urls = ["wms1", "wms2", "wms3", "wms4"];
|
||||
t.eq( layer.selectUrl("bbox=-180,0,0,90", urls), "wms4", "selectUrl(-90,-180) returns 4" );
|
||||
t.eq( layer.selectUrl("bbox=-180,-90,0,0", urls), "wms3", "selectUrl(90,-180) returns 3" );
|
||||
t.eq( layer.selectUrl("bbox=0,90,180,0", urls), "wms1", "selectUrl(-90,180) returns 1" );
|
||||
t.eq( layer.selectUrl("bbox=0,0,180,90", urls), "wms2", "selectUrl(90,180) returns 2" );
|
||||
}
|
||||
|
||||
function test_99_Layer_HTTPRequest_destroy (t) {
|
||||
t.plan( 6 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user