Allow testing for projection equality with string.
This commit is contained in:
@@ -101,6 +101,9 @@ OpenLayers.Projection = OpenLayers.Class({
|
|||||||
equals: function(projection) {
|
equals: function(projection) {
|
||||||
var p = projection, equals = false;
|
var p = projection, equals = false;
|
||||||
if (p) {
|
if (p) {
|
||||||
|
if (!(projection instanceof OpenLayers.Projection)) {
|
||||||
|
projection = new OpenLayers.Projection(projection);
|
||||||
|
}
|
||||||
if (window.Proj4js && this.proj.defData && p.proj.defData) {
|
if (window.Proj4js && this.proj.defData && p.proj.defData) {
|
||||||
equals = this.proj.defData.replace(this.titleRegEx, "") ==
|
equals = this.proj.defData.replace(this.titleRegEx, "") ==
|
||||||
p.proj.defData.replace(this.titleRegEx, "");
|
p.proj.defData.replace(this.titleRegEx, "");
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Projection_equals(t) {
|
function test_Projection_equals(t) {
|
||||||
t.plan(8);
|
t.plan(12);
|
||||||
var origTransforms = OpenLayers.Util.extend({}, OpenLayers.Projection.transforms);
|
var origTransforms = OpenLayers.Util.extend({}, OpenLayers.Projection.transforms);
|
||||||
OpenLayers.Projection.addTransform("EPSG:4326", "FOO", OpenLayers.Projection.nullTransform);
|
OpenLayers.Projection.addTransform("EPSG:4326", "FOO", OpenLayers.Projection.nullTransform);
|
||||||
OpenLayers.Projection.addTransform("FOO", "EPSG:4326", OpenLayers.Projection.nullTransform);
|
OpenLayers.Projection.addTransform("FOO", "EPSG:4326", OpenLayers.Projection.nullTransform);
|
||||||
@@ -57,6 +57,12 @@
|
|||||||
t.eq(proj1.equals(proj4), true, "EPSG:4326 and EPSG:4326 are equal with proj4js");
|
t.eq(proj1.equals(proj4), true, "EPSG:4326 and EPSG:4326 are equal with proj4js");
|
||||||
t.eq(proj2.equals(proj5), false, "Projection.equals() returns false for unknown projections with proj4js");
|
t.eq(proj2.equals(proj5), false, "Projection.equals() returns false for unknown projections with proj4js");
|
||||||
|
|
||||||
|
// allow comparison with identifier
|
||||||
|
t.eq(proj1.equals("EPSG:4326"), true, "EPSG:4326 equality with string");
|
||||||
|
t.eq(proj1.equals("EPSG:4327"), false, "EPSG:4326 inequality with string");
|
||||||
|
t.eq(proj1.equals("EPSG:900913"), true, "EPSG:900913 equality with string");
|
||||||
|
t.eq(proj1.equals("EPSG:900914"), false, "EPSG:900913 inequality with string");
|
||||||
|
|
||||||
if (!hasProj) {
|
if (!hasProj) {
|
||||||
window.Proj4js = undefined;
|
window.Proj4js = undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user