Skip to content

Commit

Permalink
Addition to proj4js#230, added support for array coords
Browse files Browse the repository at this point in the history
  • Loading branch information
gpcboekema committed Mar 26, 2019
1 parent a8815c4 commit 36ee618
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ function transformer(from, to, coords) {
if (Array.isArray(coords)) {
transformedArray = transform(from, to, coords);
if (coords.length === 3) {
return [transformedArray.x, transformedArray.y, transformedArray.z];
return [transformedArray.x, transformedArray.y, coords[2]];
}
else if (coords.length === 4) {
return [transformedArray.x, transformedArray.y, coords[2], coords[3]];
}
else {
return [transformedArray.x, transformedArray.y];
Expand Down
16 changes: 16 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ function startTests(chai, proj4, testPoints) {
assert.equal(rslt.method(), 'correct answer');
});
});
describe('points array', function () {
it('should ignore stuff it does not know', function (){
var sweref99tm = '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
var rt90 = '+lon_0=15.808277777799999 +lat_0=0.0 +k=1.0 +x_0=1500000.0 +y_0=0.0 +proj=tmerc +ellps=bessel +units=m +towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +no_defs';
var rslt = proj4(sweref99tm, rt90).forward([
319180,
6399862,
0,
1000
]);
assert.closeTo(rslt[0], 1271137.9275601401, 0.000001);
assert.closeTo(rslt[1], 6404230.291459564, 0.000001);
assert.equal(rslt[2], 0);
assert.equal(rslt[3], 1000);
});
});
describe('defs', function() {
assert.equal(proj4.defs('testmerc'), proj4.defs['testmerc']);
proj4.defs('foo', '+proj=merc +lon_0=5.937 +lat_ts=45.027 +ellps=sphere');
Expand Down

0 comments on commit 36ee618

Please sign in to comment.