From 8a82048c12f7ccc401b09cc3314708b466c1c5eb Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 27 Oct 2014 10:33:46 -0600 Subject: [PATCH] Explicitly pass coordinate dimension before transforming --- src/ol/proj/proj.js | 2 +- test/spec/ol/proj/proj.test.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ol/proj/proj.js b/src/ol/proj/proj.js index 0f0f00b166..5ceccdf600 100644 --- a/src/ol/proj/proj.js +++ b/src/ol/proj/proj.js @@ -678,7 +678,7 @@ ol.proj.cloneTransform = function(input, opt_output, opt_dimension) { */ ol.proj.transform = function(coordinate, source, destination) { var transformFn = ol.proj.getTransform(source, destination); - return transformFn(coordinate); + return transformFn(coordinate, undefined, coordinate.length); }; diff --git a/test/spec/ol/proj/proj.test.js b/test/spec/ol/proj/proj.test.js index 6dcbbebf34..1b71ba6586 100644 --- a/test/spec/ol/proj/proj.test.js +++ b/test/spec/ol/proj/proj.test.js @@ -316,6 +316,34 @@ describe('ol.proj', function() { }); + describe('ol.proj.transform()', function() { + + it('transforms a 2d coordinate', function() { + var got = ol.proj.transform([-10, -20], 'EPSG:4326', 'EPSG:3857'); + expect(got).to.have.length(2); + expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3); + expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3); + }); + + it('transforms a 3d coordinate', function() { + var got = ol.proj.transform([-10, -20, 3], 'EPSG:4326', 'EPSG:3857'); + expect(got).to.have.length(3); + expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3); + expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3); + expect(got[2]).to.be(3); + }); + + it('transforms a 4d coordinate', function() { + var got = ol.proj.transform([-10, -20, 3, 4], 'EPSG:4326', 'EPSG:3857'); + expect(got).to.have.length(4); + expect(got[0]).to.roughlyEqual(-1113194.9079327357, 1e-3); + expect(got[1]).to.roughlyEqual(-2273030.92698769, 1e-3); + expect(got[2]).to.be(3); + expect(got[3]).to.be(4); + }); + + }); + describe('ol.proj.Projection.prototype.getMetersPerUnit()', function() { beforeEach(function() {