Spell projection with p and separate tests to avoid mock issues.

This commit is contained in:
tschaub
2011-11-08 11:47:59 -07:00
parent 00410cf779
commit 76bb0be254
2 changed files with 21 additions and 10 deletions

View File

@@ -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, "") ==

View File

@@ -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");
}
</script>