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.0.3 to 2.1.0

changelog.md

2

bower.json
{
"name": "proj4",
"version": "2.0.3",
"version": "2.1.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.0.3",
"version": "2.1.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",

@@ -0,1 +1,25 @@

var projs = [
'tmerc',
'utm',
'sterea',
'stere',
'somerc',
'omerc',
'lcc',
'krovak',
'cass',
'laea',
'aea',
'gnom',
'cea',
'eqc',
'poly',
'nzmg',
'mill',
'sinu',
'moll',
'eqdc',
'vandg',
'aeqd'
];
module.exports = function(grunt) {

@@ -34,3 +58,6 @@ grunt.initConfig({

options: {
standalone: 'proj4'
standalone: 'proj4',
alias: [
'./projs:./includedProjections'
]
}

@@ -60,3 +87,28 @@ }

});
grunt.registerTask('default', ['version', 'jshint', 'browserify', 'uglify', 'connect','mocha_phantomjs']);
grunt.registerTask('custom',function(){
grunt.task.run('browserify', 'uglify');
var projections = this.args;
if(projections[0]==='default'){
grunt.file.write('./projs.js','module.exports = function(){}');
return;
}
if(projections[0]==='all'){
projections = projs;
}
grunt.file.write('./projs.js',[
"var projs = [",
" require('./lib/projections/"+projections.join("'),\n\trequire('./lib/projections/")+"')",
"];",
"module.exports = function(proj4){",
" projs.forEach(function(proj){",
" proj4.Proj.projections.add(proj);",
" });",
"}"
].join("\n"));
});
grunt.registerTask('build',function(){
var args = this.args.length?this.args[0].split(','):['default'];
grunt.task.run('version', 'jshint', 'custom:'+args.join(':'));
});
grunt.registerTask('default', ['build:all', 'connect','mocha_phantomjs']);
};

@@ -10,2 +10,3 @@ var proj4 = require('./core');

proj4.version = require('./version');
require('./includedProjections')(proj4);
module.exports = proj4;

@@ -0,141 +1,33 @@

var parseCode = require("./parseCode");
var extend = require('./extend');
var defs = require('./defs');
var constants = {};
constants.grids = require('./constants/grids');
constants.Datum = require('./constants/Datum');
constants.Ellipsoid = require('./constants/Ellipsoid');
var datum = require('./datum');
var projections = require('./projections/index');
var wkt = require('./wkt');
var projStr = require('./projString');
var EPSLN = 1.0e-10;
// ellipoid pj_set_ell.c
var SIXTH = 0.1666666666666666667;
/* 1/6 */
var RA4 = 0.04722222222222222222;
/* 17/360 */
var RA6 = 0.02215608465608465608;
function Projection(srsCode) {
var projections = require('./projections');
var deriveConstants = require('./deriveConstants');
function Projection(srsCode,callback) {
if (!(this instanceof Projection)) {
return new Projection(srsCode);
}
this.srsCodeInput = srsCode;
this.x0 = 0;
this.y0 = 0;
var obj;
if (typeof srsCode === 'string') {
//check to see if this is a WKT string
if (srsCode in defs) {
this.deriveConstants(defs[srsCode]);
extend(this, defs[srsCode]);
callback = callback || function(error){
if(error){
throw error;
}
else if ((srsCode.indexOf('GEOGCS') >= 0) || (srsCode.indexOf('GEOCCS') >= 0) || (srsCode.indexOf('PROJCS') >= 0) || (srsCode.indexOf('LOCAL_CS') >= 0)) {
obj = wkt(srsCode);
this.deriveConstants(obj);
extend(this, obj);
//this.loadProjCode(this.projName);
}
else if (srsCode[0] === '+') {
obj = projStr(srsCode);
this.deriveConstants(obj);
extend(this, obj);
}
};
var json = parseCode(srsCode);
if(typeof json !== 'object'){
callback(srsCode);
return;
}
else {
this.deriveConstants(srsCode);
extend(this, srsCode);
var modifiedJSON = deriveConstants(json);
var ourProj = Projection.projections.get(modifiedJSON.projName);
if(ourProj){
extend(this, modifiedJSON);
extend(this, ourProj);
this.init();
callback(null, this);
}else{
callback(srsCode);
}
this.initTransforms(this.projName);
}
Projection.projections = projections;
Projection.projections.start();
Projection.prototype = {
/**
* Function: initTransforms
* Finalize the initialization of the Proj object
*
*/
initTransforms: function(projName) {
var ourProj = Projection.projections.get(projName);
if (ourProj) {
extend(this, ourProj);
this.init();
}
else {
throw ("unknown projection " + projName);
}
},
deriveConstants: function(self) {
// DGR 2011-03-20 : nagrids -> nadgrids
if (self.nadgrids && self.nadgrids.length === 0) {
self.nadgrids = null;
}
if (self.nadgrids) {
self.grids = self.nadgrids.split(",");
var g = null,
l = self.grids.length;
if (l > 0) {
for (var i = 0; i < l; i++) {
g = self.grids[i];
var fg = g.split("@");
if (fg[fg.length - 1] === "") {
//..reportError("nadgrids syntax error '" + self.nadgrids + "' : empty grid found");
continue;
}
self.grids[i] = {
mandatory: fg.length === 1, //@=> optional grid (no error if not found)
name: fg[fg.length - 1],
grid: constants.grids[fg[fg.length - 1]] //FIXME: grids loading ...
};
if (self.grids[i].mandatory && !self.grids[i].grid) {
//..reportError("Missing '" + self.grids[i].name + "'");
}
}
}
// DGR, 2011-03-20: grids is an array of objects that hold
// the loaded grids, its name and the mandatory informations of it.
}
if (self.datumCode && self.datumCode !== 'none') {
var datumDef = constants.Datum[self.datumCode];
if (datumDef) {
self.datum_params = datumDef.towgs84 ? datumDef.towgs84.split(',') : null;
self.ellps = datumDef.ellipse;
self.datumName = datumDef.datumName ? datumDef.datumName : self.datumCode;
}
}
if (!self.a) { // do we have an ellipsoid?
var ellipse = constants.Ellipsoid[self.ellps] ? constants.Ellipsoid[self.ellps] : constants.Ellipsoid.WGS84;
extend(self, ellipse);
}
if (self.rf && !self.b) {
self.b = (1.0 - 1.0 / self.rf) * self.a;
}
if (self.rf === 0 || Math.abs(self.a - self.b) < EPSLN) {
self.sphere = true;
self.b = self.a;
}
self.a2 = self.a * self.a; // used in geocentric
self.b2 = self.b * self.b; // used in geocentric
self.es = (self.a2 - self.b2) / self.a2; // e ^ 2
self.e = Math.sqrt(self.es); // eccentricity
if (self.R_A) {
self.a *= 1 - self.es * (SIXTH + self.es * (RA4 + self.es * RA6));
self.a2 = self.a * self.a;
self.b2 = self.b * self.b;
self.es = 0;
}
self.ep2 = (self.a2 - self.b2) / self.b2; // used in geocentric
if (!self.k0) {
self.k0 = 1.0; //default value
}
//DGR 2010-11-12: axis
if (!self.axis) {
self.axis = "enu";
}
self.datum = datum(self);
}
};
module.exports = Projection;

@@ -12,2 +12,8 @@ var msfnz = require('../common/msfnz');

this.es = 1 - con * con;
if(!('x0' in this)){
this.x0 = 0;
}
if(!('y0' in this)){
this.y0 = 0;
}
this.e = Math.sqrt(this.es);

@@ -14,0 +20,0 @@ if (this.lat_ts) {

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

module.exports = '2.0.3';
module.exports = '2.1.0';
{
"name": "proj4",
"version": "2.0.3",
"version": "2.1.0",
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -70,8 +70,37 @@ #PROJ4JS

##Developing
to set up build tools make sure you have node installed and run `npm install`
to set up build tools make sure you have node and grunt-cli installed and then run `npm install`
to build run `grunt` if that doesn't work try:
to do the complete build and browser tests run
```bash
npm install -g grunt-cli #you may need a sudo in front of that
grunt
```
to run node tests run
```bash
npm test
```
to run node tests with coverage run
```bash
node test --coverage
```
to create a build with only default projections (latlon and Mercator) run
```bash
grunt build
```
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.
```bash
grunt build:tmerc
#includes transverse Mercator
grunt build:lcc
#includes lambert conformal conic
grunt build:omerc,moll
#includes oblique Mercator and Mollweide
```

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

new proj4.Proj('fake one');
}, 'unknown projection', 'should work');
}, 'fake one', 'should work');
});

@@ -169,0 +169,0 @@ })

Sorry, the diff of this file is not supported yet

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