Fix comparison of projections with same code but different units

This commit is contained in:
Andreas Hocevar
2015-10-05 22:52:14 +02:00
parent 4784b7f2e2
commit 66338a662d
2 changed files with 15 additions and 1 deletions

View File

@@ -677,7 +677,8 @@ ol.proj.get = function(projectionLike) {
ol.proj.equivalent = function(projection1, projection2) {
if (projection1 === projection2) {
return true;
} else if (projection1.getCode() === projection2.getCode()) {
} else if (projection1.getCode() === projection2.getCode() &&
projection1.getUnits() === projection2.getUnits()) {
return true;
} else if (projection1.getUnits() != projection2.getUnits()) {
return false;

View File

@@ -56,6 +56,19 @@ describe('ol.proj', function() {
'EPSG:4326'
]);
});
it('requires code and units to be equal for projection evquivalence',
function() {
var proj1 = new ol.proj.Projection({
code: 'EPSG:3857',
units: 'm'
});
var proj2 = new ol.proj.Projection({
code: 'EPSG:3857',
units: 'tile-pixels'
});
expect(ol.proj.equivalent(proj1, proj2)).to.not.be.ok();
});
});
describe('identify transform', function() {