Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reproject

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reproject - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

0

cli.js

@@ -0,0 +0,0 @@ #!/usr/bin/env node

@@ -0,0 +0,0 @@ {

12

index.js

@@ -104,4 +104,14 @@ 'use strict';

to = determineCrs(to, projs);
var transform = proj4(from, to).forward.bind(transform);
var transformFunc = proj4(from, to).forward.bind(transformFunc);
function transform(coords) {
var transformed = transformFunc(coords);
if (coords.length === 3 && coords[2] !== undefined && transformed[2] === undefined) {
// If the projection doesn't explicitly handle Z coordinate, retain the old one.
transformed[2] = coords[2];
}
return transformed;
}
var transformGeometryCoords = function(gj) {

@@ -108,0 +118,0 @@ // No easy way to put correct CRS info into the GeoJSON,

2

package.json
{
"name": "reproject",
"version": "1.2.2",
"version": "1.2.3",
"description": "Reproject GeoJSON from one projection/CRS to another",

@@ -5,0 +5,0 @@ "repository": "git@github.com:perliedman/reproject.git",

@@ -0,0 +0,0 @@ reproject [![Build status](https://travis-ci.org/perliedman/reproject.png)](https://travis-ci.org/perliedman/reproject) [![NPM version](https://badge.fury.io/js/reproject.png)](http://badge.fury.io/js/reproject)

@@ -26,7 +26,8 @@ 'use strict';

// Checks if `list` looks like a `[x, y]`.
function isXY(list) {
return list.length === 2 &&
// Checks if `list` looks like a `[x, y]` or `[x, y, z]`.
function isCoordinate(list) {
return (list.length === 2 || list.length === 3) &&
typeof list[0] === 'number' &&
typeof list[1] === 'number';
typeof list[1] === 'number' &&
(list.length === 3 ? typeof list[2] === 'number' : true);
}

@@ -39,3 +40,3 @@

function assertCoords(actual, expected, precision) {
if (isXY(expected)) {
if (isCoordinate(expected)) {
expect(actual).to.be.coordinate(expected, precision);

@@ -51,4 +52,4 @@ } else {

expect.Assertion.prototype.coordinate = function(obj, precision) {
this.assert(this.obj.length === 2 || this.obj.length === 3);
this.assert(
this.obj.length === 2 &&
Math.abs(this.obj[0] - obj[0]) < precision &&

@@ -58,2 +59,8 @@ Math.abs(this.obj[1] - obj[1]) < precision,

function() { return 'expected ' + this.obj + ' to not be a coordinate close to ' + obj + ' within +/-' + precision; });
if (this.obj.length === 3) {
this.assert(
Math.abs(this.obj[2] - obj[2]) < precision,
function() { return 'expected ' + this.obj[2] + ' to be an elevation close to ' + obj[2] + ' within +/-' + precision; },
function() { return 'expected ' + this.obj[2] + ' to not be an elevation close to ' + obj[2] + ' within +/-' + precision; });
}
};

@@ -320,3 +327,3 @@

it('preserves altitude', function() {
it('transforms altitude', function() {
expect(reproj.reproject({

@@ -327,6 +334,16 @@ 'type': 'Point',

'type': 'Point',
'coordinates': [1271138, 6404230, 10]
'coordinates': [1271138, 6404230, -38.2270]
}, 0.5);
});
it('preserves altitude in WGS84', function() {
expect(reproj.reproject({
'type': 'Point',
'coordinates': [319180, 6399862, 10]
}, sweref99tm, proj4.WGS84)).to.be.geojson({
'type': 'Point',
'coordinates': [11.965, 57.704, 10]
}, 0.5);
});
it('handles null geometry', function() {

@@ -333,0 +350,0 @@ var gj = {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc