Support EPSG:3857, EPSG:102113 and EPSG:102100 as additional web mercator aliases. p=tschaub, r=me (closes #2915)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10870 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -186,11 +186,32 @@ OpenLayers.Layer.SphericalMercator = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Note: Two transforms declared
|
||||
* Transforms from EPSG:4326 to EPSG:900913 and from EPSG:900913 to EPSG:4326
|
||||
* are set by this class.
|
||||
* Note: Transforms for web mercator <-> EPSG:4326
|
||||
* OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.
|
||||
* OpenLayers originally started referring to EPSG:900913 as web mercator.
|
||||
* The EPSG has declared EPSG:3857 to be web mercator.
|
||||
* ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as
|
||||
* equivalent. See http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/11/20/ArcGIS-Online-moving-to-Google-_2F00_-Bing-tiling-scheme_3A00_-What-does-this-mean-for-you_3F00_.aspx#12084
|
||||
*/
|
||||
OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:900913",
|
||||
OpenLayers.Layer.SphericalMercator.projectForward);
|
||||
OpenLayers.Projection.addTransform("EPSG:900913", "EPSG:4326",
|
||||
OpenLayers.Layer.SphericalMercator.projectInverse);
|
||||
(function() {
|
||||
|
||||
// list of equivalent codes for web mercator
|
||||
var codes = ["EPSG:900913", "EPSG:3857", "EPSG:102113", "EPSG:102100"];
|
||||
|
||||
var add = OpenLayers.Projection.addTransform;
|
||||
var merc = OpenLayers.Layer.SphericalMercator;
|
||||
var same = OpenLayers.Projection.nullTransform;
|
||||
|
||||
var i, len, code, other, j;
|
||||
for (i=0, len=codes.length; i<len; ++i) {
|
||||
code = codes[i];
|
||||
add("EPSG:4326", code, merc.projectForward);
|
||||
add(code, "EPSG:4326", merc.projectInverse);
|
||||
for (j=i+1; j<len; ++j) {
|
||||
other = codes[j];
|
||||
add(code, other, same);
|
||||
add(other, code, same);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
t.eq(strToFixed(point.toString()),
|
||||
strToFixed("POINT(10.000000828446318 20.000000618997227)"),
|
||||
"point transforms from EPSG:4326 to Spherical Mercator");
|
||||
"point transforms from Spherical Mercator to EPSG:4326");
|
||||
}
|
||||
|
||||
function test_SphericalMercator_addTransform(t) {
|
||||
@@ -88,6 +88,48 @@
|
||||
"from EPSG:900913 to EPSG:4326 correctly defined");
|
||||
}
|
||||
|
||||
function test_equivalence(t) {
|
||||
|
||||
// list of equivalent codes for web mercator
|
||||
var codes = ["EPSG:900913", "EPSG:3857", "EPSG:102113", "EPSG:102100"];
|
||||
var len = codes.length;
|
||||
|
||||
t.plan(len + (len * len));
|
||||
|
||||
var ggPoint = new OpenLayers.Geometry.Point(10, 20);
|
||||
var smPoint = new OpenLayers.Geometry.Point(1113195, 2273031);
|
||||
|
||||
var gg = new OpenLayers.Projection("EPSG:4326");
|
||||
|
||||
var i, proj, forward, inverse, other, j, equiv;
|
||||
for (i=0, len=codes.length; i<len; ++i) {
|
||||
proj = new OpenLayers.Projection(codes[i]);
|
||||
|
||||
// confirm that forward/inverse work
|
||||
forward = ggPoint.clone().transform(gg, proj);
|
||||
t.eq(
|
||||
strToFixed(forward.toString()),
|
||||
strToFixed("POINT(1113194.9077777779 2273030.9266712805)"),
|
||||
"transforms from EPSG:4326 to " + proj
|
||||
);
|
||||
inverse = smPoint.clone().transform(proj, gg);
|
||||
t.eq(
|
||||
strToFixed(inverse.toString()),
|
||||
strToFixed("POINT(10.000000828446318 20.000000618997227)"),
|
||||
"transforms from " + proj + " to EPSG:4326"
|
||||
);
|
||||
|
||||
// confirm that null transform works
|
||||
for (j=i+1; j<len; ++j) {
|
||||
other = new OpenLayers.Projection(codes[j]);
|
||||
equiv = ggPoint.clone().transform(proj, other);
|
||||
t.ok(proj.equals(other), proj + " and " + other + " are equivalent");
|
||||
t.ok(ggPoint.equals(equiv), "transform from " + proj + " to " + other + " preserves geometry");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user