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

proj4

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proj4 - npm Package Compare versions

Comparing version 2.8.0 to 2.9.0

.github/workflows/build-and-test.yml

2

bower.json
{
"name": "proj4",
"version": "2.8.0",
"version": "2.9.0",
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/proj4js/proj4js",

{
"name": "proj4",
"version": "2.8.0",
"version": "2.9.0",
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",

@@ -5,0 +5,0 @@ "repo": "proj4js/proj4js",

@@ -93,2 +93,9 @@ var exports = {};

exports.clrk80ign = {
a: 6378249.2,
b: 6356515,
rf: 293.4660213,
ellipseName: "Clarke 1880 (IGN)"
};
exports.clrk58 = {

@@ -95,0 +102,0 @@ a: 6378293.645208759,

@@ -21,3 +21,3 @@ import msfnz from '../common/msfnz';

this.ms1 = msfnz(this.e3, this.sin_po, this.cos_po);
this.qs1 = qsfnz(this.e3, this.sin_po, this.cos_po);
this.qs1 = qsfnz(this.e3, this.sin_po);

@@ -28,3 +28,3 @@ this.sin_po = Math.sin(this.lat2);

this.ms2 = msfnz(this.e3, this.sin_po, this.cos_po);
this.qs2 = qsfnz(this.e3, this.sin_po, this.cos_po);
this.qs2 = qsfnz(this.e3, this.sin_po);

@@ -34,3 +34,3 @@ this.sin_po = Math.sin(this.lat0);

this.t3 = this.sin_po;
this.qs0 = qsfnz(this.e3, this.sin_po, this.cos_po);
this.qs0 = qsfnz(this.e3, this.sin_po);

@@ -57,3 +57,3 @@ if (Math.abs(this.lat1 - this.lat2) > EPSLN) {

var qs = qsfnz(this.e3, this.sin_phi, this.cos_phi);
var qs = qsfnz(this.e3, this.sin_phi);
var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0;

@@ -60,0 +60,0 @@ var theta = this.ns0 * adjust_lon(lon - this.long0);

@@ -1,2 +0,2 @@

import {D2R, R2D, PJD_3PARAM, PJD_7PARAM} from './constants/values';
import {D2R, R2D, PJD_3PARAM, PJD_7PARAM, PJD_GRIDSHIFT} from './constants/values';
import datum_transform from './datum_transform';

@@ -9,3 +9,5 @@ import adjust_axis from './adjust_axis';

function checkNotWGS(source, dest) {
return ((source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM) && dest.datumCode !== 'WGS84') || ((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM) && source.datumCode !== 'WGS84');
return (
(source.datum.datum_type === PJD_3PARAM || source.datum.datum_type === PJD_7PARAM || source.datum.datum_type === PJD_GRIDSHIFT) && dest.datumCode !== 'WGS84') ||
((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM || dest.datum.datum_type === PJD_GRIDSHIFT) && source.datumCode !== 'WGS84');
}

@@ -17,3 +19,12 @@

point = toPoint(point);
} else {
// Clone the point object so inputs don't get modified
point = {
x: point.x,
y: point.y,
z: point.z,
m: point.m
};
}
var hasZ = point.z !== undefined;
checkSanity(point);

@@ -93,3 +104,6 @@ // Workaround for datum shifts towgs84, if either source or destination projection is not wgs84

if (!hasZ) {
delete point.z;
}
return point;
}
{
"name": "proj4",
"version": "2.8.0",
"version": "2.9.0",
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
"homepage": "https://proj4js.github.io/proj4js/",
"main": "dist/proj4-src.js",

@@ -25,7 +26,7 @@ "module": "lib/index.js",

"chai": "~4.1.2",
"curl-amd": "github:cujojs/curl",
"curl-amd": "^0.8.12",
"grunt": "^1.0.1",
"grunt-cli": "~1.2.0",
"grunt-contrib-connect": "~1.0.2",
"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-jshint": "~3.2.0",
"grunt-contrib-uglify": "~3.1.0",

@@ -32,0 +33,0 @@ "grunt-mocha-phantomjs": "~4.0.0",

@@ -26,3 +26,3 @@ # PROJ4JS [![Build Status](https://api.travis-ci.org/proj4js/proj4js.svg?branch=master)](https://travis-ci.org/proj4js/proj4js)

```javascript
proj4(fromProjection[, toProjection, coordinates])
proj4([fromProjection, ]toProjection[, coordinates])
```

@@ -32,3 +32,3 @@

Coordinates may an object of the form `{x:x,y:y}` or an array of the form `[x,y]`.
Coordinates may be an object of the form `{x:x,y:y}` or an array of the form `[x,y]`.

@@ -41,6 +41,13 @@ When all 3 arguments are given, the result is that the coordinates are transformed from projection1 to projection 2. And returned in the same format that they were given in.

//I'm not going to redefine those two in latter examples.
proj4(firstProjection,secondProjection,[2,5]);
// [-2690666.2977344505, 3662659.885459918]
proj4(firstProjection,secondProjection,[-122.305887, 58.9465872]);
// [-2690575.447893817, 36622916.8071244564]
```
The library can also parse coordinates provided with an elevation and measure, again as an object of the form `{x:x,y:y,z:z,m:m}` or an array of the form `[x,y,z,m]`.
```javascript
proj4(firstProjection,secondProjection,[-122.305887, 58.9465872,10]);
// [-2690575.447893817, 36622916.8071244564, 10]
```
If only 1 projection is given then it is assumed that it is being projected *from* WGS84 (fromProjection is WGS84).

@@ -56,6 +63,6 @@

```javascript
proj4(firstProjection,secondProjection).forward([2,5]);
// [-2690666.2977344505, 3662659.885459918]
proj4(secondProjection,firstProjection).inverse([2,5]);
// [-2690666.2977344505, 3662659.885459918]
proj4(firstProjection,secondProjection).forward([-122.305887, 58.9465872]);
// [-2690575.447893817, 36622916.8071244564]
proj4(secondProjection,firstProjection).inverse([-122.305887, 58.9465872]);
// [-2690575.447893817, 36622916.8071244564]
```

@@ -69,5 +76,5 @@

proj4(firstProjection).inverse([242075.00535055372, 750123.32090043]);
//[-71, 40.99999999999986]
//the floating points to answer your question
// [-71, 40.99999999999986]
```
Note: The generation of the floating point value `40.99999999999986` in this example represents the fact that some variance in precision is involved in any conversion between one coordinate reference system and another.

@@ -159,3 +166,3 @@ ## Named Projections

To do the complete build and browser tests run:
To do the complete build and browser tests run

@@ -166,3 +173,3 @@ ```bash

To run node tests run:
To run node tests run

@@ -173,3 +180,3 @@ ```bash

To run node tests with coverage run:
To run node tests with coverage run

@@ -180,3 +187,3 @@ ```bash

To create a build with only default projections (latlon and Mercator) run:
To create a build with only default projections (latlon and Mercator) run

@@ -187,3 +194,3 @@ ```bash

To create a build with only custom projections include a comma separated list of projections codes (the file name in 'lib/projections' without the '.js') after a colon, e.g.:
To create a build with only custom projections include a comma separated list of projections codes (the file name in 'lib/projections' without the '.js') after a colon, e.g.

@@ -190,0 +197,0 @@ ```bash

@@ -170,2 +170,11 @@ // You can do this in the grunt config for each mocha task, see the `options` config

});
describe('proj coord object', function() {
it('should not be modified', function() {
var expected = {x: 100000, y: 100000};
var inpxy = {x: expected.x, y: expected.y};
proj4('EPSG:3857', proj4.WGS84, inpxy);
assert.deepEqual(inpxy, expected, "input is unmodified");
});
});
});

@@ -175,2 +184,11 @@ });

describe('points', function () {
it('should not create a z if none was provided', function() {
const result = proj4(
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]',
'PROJCS["OSGB 1936 / British National Grid",GEOGCS["OSGB 1936",DATUM["OSGB_1936",SPHEROID["Airy 1830",6377563.396,299.3249646,AUTHORITY["EPSG","7001"]],AUTHORITY["EPSG","6277"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4277"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],AUTHORITY["EPSG","27700"],AXIS["Easting",EAST],AXIS["Northing",NORTH]]',
{x: -0.12793738, y: 51.507747});
assert.closeTo(result.x, 530018.229301635, 1e-6);
assert.closeTo(result.y, 180418.4380560551, 1e-6);
assert.equal(result.z, undefined);
});
it('should ignore stuff it does not know', function () {

@@ -396,4 +414,64 @@ var sweref99tm = '+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';

describe('Nadgrids', function() {
describe('Nadgrids BETA2007', function() {
var tests = [
['EPSG:31466', 'EPSG:4326', 2559552, 5670982, 6.850861772, 51.170707759, 0.0000001, 0.01],
['EPSG:31466', 'EPSG:3857', 2559552, 5670982, 762634.443931574, 6651545.680265270, 0.01, 0.01],
['EPSG:31466', 'EPSG:25832', 2559552, 5670982, 349757.381712518, 5671004.065049540, 0.01, 0.01],
];
function initializeNadgrid(buffer) {
proj4.nadgrid('BETA2007.gsb', buffer);
proj4.defs('EPSG:31466', '+proj=tmerc +lat_0=0 +lon_0=6 +k=1 +x_0=2500000 +y_0=0 +ellps=bessel +nadgrids=BETA2007.gsb +units=m +no_defs +type=crs');
proj4.defs('EPSG:25832', '+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs');
}
before(function(done) {
if (typeof XMLHttpRequest !== 'undefined') {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'BETA2007.gsb', true);
xhr.responseType = 'arraybuffer';
xhr.addEventListener('load', function() {
initializeNadgrid(xhr.response);
done();
});
xhr.addEventListener('error', done);
xhr.send();
} else if (typeof require === 'function') {
const fs = require('fs');
const path = require('path');
fs.readFile(path.join(__dirname, 'BETA2007.gsb'), function(err, data) {
if (err) {
done(err);
} else {
initializeNadgrid(data.buffer);
done();
}
})
}
});
tests.forEach(function(test) {
var fromProj = test[0];
var toProj = test[1];
var fromX = test[2];
var fromY = test[3];
var toX = test[4];
var toY = test[5];
var fromPrecision = test[6];
var toPrecision = test[7];
it('should transform ' + fromProj + ' to ' + toProj, function () {
var transformed = proj4(fromProj, toProj, [fromX, fromY]);
assert.approximately(transformed[0], toX, fromPrecision);
assert.approximately(transformed[1], toY, fromPrecision);
});
it('should transform ' + toProj + ' to ' + fromProj, function () {
var transformed = proj4(toProj, fromProj, [toX, toY]);
assert.approximately(transformed[0], fromX, toPrecision);
assert.approximately(transformed[1], fromY, toPrecision);
});
});
});
describe('Nadgrids ntv2', function() {
var tests = [
[-44.382211538462, 40.3768, -44.380749, 40.377457], // just inside the lower limit

@@ -400,0 +478,0 @@ [-87.617788, 59.623262, -87.617659, 59.623441], // just inside the upper limit

@@ -171,6 +171,3 @@ var testPoints = [

ll:[5, 25],
xy:[-308919.1234711099, 2788738.255936392],
acc:{
ll:5
}
xy:[-308919.1234711099, 2788738.255936392]
},

@@ -180,8 +177,10 @@ {

ll:[5, 25],
xy:[-308919.1234711099, 2788738.255936392],
acc:{
ll:5
}
xy:[-308919.1234711099, 2788738.255936392]
},
{
code: '+proj=lcc +lat_1=49.5 +lat_0=49.5 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +ellps=clrk80ign +pm=paris +towgs84=-168,-60,320,0,0,0,0 +units=m +no_defs +type=crs',
ll:[2.294482, 48.859045],
xy:[596916.561147926957, 1128733.073948238511]
},
{
code:'PROJCS["S-JTSK (Ferro) / Krovak",GEOGCS["S-JTSK (Ferro)",DATUM["S_JTSK_Ferro",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],AUTHORITY["EPSG","6818"]],PRIMEM["Ferro",-17.66666666666667,AUTHORITY["EPSG","8909"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4818"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Krovak"],PARAMETER["latitude_of_center",49.5],PARAMETER["longitude_of_center",42.5],PARAMETER["azimuth",30.28813972222222],PARAMETER["pseudo_standard_parallel_1",78.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","2065"],AXIS["Y",WEST],AXIS["X",SOUTH]]',

@@ -188,0 +187,0 @@ ll:[17.323583231075897, 49.39440725405376],

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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