diff --git a/lib/OpenLayers/Projection.js b/lib/OpenLayers/Projection.js index 97eb2f63ba..f30f679081 100644 --- a/lib/OpenLayers/Projection.js +++ b/lib/OpenLayers/Projection.js @@ -101,8 +101,8 @@ OpenLayers.Projection = OpenLayers.Class({ equals: function(projection) { var p = projection, equals = false; if (p) { - if (!(projection instanceof OpenLayers.Projection)) { - projection = new OpenLayers.Projection(projection); + if (!(p instanceof OpenLayers.Projection)) { + p = new OpenLayers.Projection(p); } if (window.Proj4js && this.proj.defData && p.proj.defData) { equals = this.proj.defData.replace(this.titleRegEx, "") == diff --git a/tests/Projection.html b/tests/Projection.html index bb458b6f17..236871ab76 100644 --- a/tests/Projection.html +++ b/tests/Projection.html @@ -24,7 +24,7 @@ } function test_Projection_equals(t) { - t.plan(12); + t.plan(8); var origTransforms = OpenLayers.Util.extend({}, OpenLayers.Projection.transforms); OpenLayers.Projection.addTransform("EPSG:4326", "FOO", OpenLayers.Projection.nullTransform); OpenLayers.Projection.addTransform("FOO", "EPSG:4326", OpenLayers.Projection.nullTransform); @@ -57,16 +57,27 @@ 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"); - // 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) { window.Proj4js = undefined; } - + + } + + function test_equals_string(t) { + + t.plan(7); + var gg = new OpenLayers.Projection("EPSG:4326"); + var sm = new OpenLayers.Projection("EPSG:900913"); + + // allow comparison with identifier + t.eq(gg.equals("EPSG:4326"), true, "EPSG:4326 equality with string"); + t.eq(gg.equals("EPSG:4327"), false, "EPSG:4326 inequality with string"); + t.eq(sm.equals("EPSG:900913"), true, "EPSG:900913 equality with string"); + t.eq(sm.equals("EPSG:900914"), false, "EPSG:900913 inequality with string"); + t.eq(sm.equals("EPSG:3857"), true, "EPSG:900913 equality with EPSG:3857"); + t.eq(sm.equals("EPSG:102113"), true, "EPSG:900913 equality with EPSG:102113"); + t.eq(sm.equals("EPSG:102100"), true, "EPSG:900913 equality with EPSG:102100"); + }