New OpenLayers.Projection.defaults property.

This allows us to simplify the map and layer configuration, because now the projection also defines defaults for maxExtent, maxResolution and units.
This change also adds transforms for SRS aliases for EPSG:4326 and centralizes axis order information in OpenLayers.Projection.defaults.
This commit is contained in:
ahocevar
2012-02-15 11:09:55 +01:00
parent da3dc76a6d
commit 11966d231f
11 changed files with 127 additions and 78 deletions
+8 -7
View File
@@ -290,19 +290,19 @@
function test_mixedParams(t) {
t.plan(5);
var map = new OpenLayers.Map("map", {
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));}
}
);
getExtent: function() {return(new OpenLayers.Bounds(-180,-90,180,90));},
getProjectionObject: function() {return new OpenLayers.Projection("EPSG:4326");}
});
var a = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: "a,b,c,d",
styles: "a,b,c,d"
});
}, {map: map});
var b = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: ["a","b","c","d"],
styles: ["a","b","c","d"]
});
}, {map: map});
var c = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: ["a","b","c","d"]
@@ -310,13 +310,13 @@
var d = new OpenLayers.Layer.WMS("dummy","http://localhost/wms", {
layers: "a,b,c,d"
});
}, {map: map});
var click = new OpenLayers.Control.WMSGetFeatureInfo({
featureType: 'type',
featureNS: 'ns',
layers: [a, b, c, d]
});
}, {map: map});
map.addControl(click);
@@ -399,6 +399,7 @@
var c = new OpenLayers.Layer.WMS(
null, ["http://c.mirror/wms", "http://d.mirror/wms"], {layers: "c"}
);
map.addLayers([a, b, c]);
var control = new OpenLayers.Control.WMSGetFeatureInfo({
url: "http://host/wms",
+2 -2
View File
@@ -268,10 +268,10 @@
map.destroy();
map = new OpenLayers.Map("map");
layer = new OpenLayers.Layer("test", {projection: "EPSG:4326"});
layer = new OpenLayers.Layer("test", {projection: "unknown"});
map.addLayer(layer);
t.eq(layer.alwaysInRange, true,
"alwaysInRange true if only get projection.");
"alwaysInRange true if unknown projection is set.");
map.destroy();
map = new OpenLayers.Map("map");
+2 -2
View File
@@ -178,7 +178,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.TMS("TMS", "", {
layername: "basic",
@@ -200,7 +200,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.TMS("TMS", "", {
layername: "basic",
+2 -2
View File
@@ -195,7 +195,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
map.addLayer(layer);
@@ -211,7 +211,7 @@
var map = new OpenLayers.Map({
div: "map",
maxResolution: OpenLayers.Map.prototype.maxResolution / Math.pow(2, offset)
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
});
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
map.addLayer(layer);
+2 -2
View File
@@ -302,7 +302,7 @@
function test_fromWMSLayer(t) {
t.plan(9);
var map = new OpenLayers.Map("map", {
projection: "EPSG:1234"
projection: "CRS:84"
});
var layer = new OpenLayers.Layer.WMS("foo", "htttp://foo/ows",
{layers: "topp:states"}
@@ -312,7 +312,7 @@
t.eq(protocol.url, "htttp://foo/ows", "url taken from wms layer");
t.eq(protocol.featurePrefix, "topp", "feature prefix correctly extracted");
t.eq(protocol.featureType, "states", "typeName correctly extracted");
t.eq(protocol.srsName, "EPSG:1234", "srsName set correctly");
t.eq(protocol.srsName, "CRS:84", "srsName set correctly");
t.eq(protocol.version, "1.1.0", "version set correctly");
t.eq(protocol.format.geometryName, null, "format's geometryName set to null");