First commit

This commit is contained in:
Thomas Fuhrmann 2023-10-02 15:04:02 +02:00
commit 87d22a4516
235 changed files with 51802 additions and 0 deletions

129
node_modules/proj4/lib/projections/aea.js generated vendored Normal file
View file

@ -0,0 +1,129 @@
import msfnz from '../common/msfnz';
import qsfnz from '../common/qsfnz';
import adjust_lon from '../common/adjust_lon';
import asinz from '../common/asinz';
import {EPSLN} from '../constants/values';
export function init() {
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
return;
}
this.temp = this.b / this.a;
this.es = 1 - Math.pow(this.temp, 2);
this.e3 = Math.sqrt(this.es);
this.sin_po = Math.sin(this.lat1);
this.cos_po = Math.cos(this.lat1);
this.t1 = this.sin_po;
this.con = this.sin_po;
this.ms1 = msfnz(this.e3, this.sin_po, this.cos_po);
this.qs1 = qsfnz(this.e3, this.sin_po);
this.sin_po = Math.sin(this.lat2);
this.cos_po = Math.cos(this.lat2);
this.t2 = this.sin_po;
this.ms2 = msfnz(this.e3, this.sin_po, this.cos_po);
this.qs2 = qsfnz(this.e3, this.sin_po);
this.sin_po = Math.sin(this.lat0);
this.cos_po = Math.cos(this.lat0);
this.t3 = this.sin_po;
this.qs0 = qsfnz(this.e3, this.sin_po);
if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1);
}
else {
this.ns0 = this.con;
}
this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;
this.rh = this.a * Math.sqrt(this.c - this.ns0 * this.qs0) / this.ns0;
}
/* Albers Conical Equal Area forward equations--mapping lat,long to x,y
-------------------------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
this.sin_phi = Math.sin(lat);
this.cos_phi = Math.cos(lat);
var qs = qsfnz(this.e3, this.sin_phi);
var rh1 = this.a * Math.sqrt(this.c - this.ns0 * qs) / this.ns0;
var theta = this.ns0 * adjust_lon(lon - this.long0);
var x = rh1 * Math.sin(theta) + this.x0;
var y = this.rh - rh1 * Math.cos(theta) + this.y0;
p.x = x;
p.y = y;
return p;
}
export function inverse(p) {
var rh1, qs, con, theta, lon, lat;
p.x -= this.x0;
p.y = this.rh - p.y + this.y0;
if (this.ns0 >= 0) {
rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
con = 1;
}
else {
rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
con = -1;
}
theta = 0;
if (rh1 !== 0) {
theta = Math.atan2(con * p.x, con * p.y);
}
con = rh1 * this.ns0 / this.a;
if (this.sphere) {
lat = Math.asin((this.c - con * con) / (2 * this.ns0));
}
else {
qs = (this.c - con * con) / this.ns0;
lat = this.phi1z(this.e3, qs);
}
lon = adjust_lon(theta / this.ns0 + this.long0);
p.x = lon;
p.y = lat;
return p;
}
/* Function to compute phi1, the latitude for the inverse of the
Albers Conical Equal-Area projection.
-------------------------------------------*/
export function phi1z(eccent, qs) {
var sinphi, cosphi, con, com, dphi;
var phi = asinz(0.5 * qs);
if (eccent < EPSLN) {
return phi;
}
var eccnts = eccent * eccent;
for (var i = 1; i <= 25; i++) {
sinphi = Math.sin(phi);
cosphi = Math.cos(phi);
con = eccent * sinphi;
com = 1 - con * con;
dphi = 0.5 * com * com / cosphi * (qs / (1 - eccnts) - sinphi / com + 0.5 / eccent * Math.log((1 - con) / (1 + con)));
phi = phi + dphi;
if (Math.abs(dphi) <= 1e-7) {
return phi;
}
}
return null;
}
export var names = ["Albers_Conic_Equal_Area", "Albers", "aea"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names,
phi1z: phi1z
};

208
node_modules/proj4/lib/projections/aeqd.js generated vendored Normal file
View file

@ -0,0 +1,208 @@
import adjust_lon from '../common/adjust_lon';
import {HALF_PI, EPSLN} from '../constants/values';
import mlfn from '../common/mlfn';
import e0fn from '../common/e0fn';
import e1fn from '../common/e1fn';
import e2fn from '../common/e2fn';
import e3fn from '../common/e3fn';
import gN from '../common/gN';
import asinz from '../common/asinz';
import imlfn from '../common/imlfn';
export function init() {
this.sin_p12 = Math.sin(this.lat0);
this.cos_p12 = Math.cos(this.lat0);
}
export function forward(p) {
var lon = p.x;
var lat = p.y;
var sinphi = Math.sin(p.y);
var cosphi = Math.cos(p.y);
var dlon = adjust_lon(lon - this.long0);
var e0, e1, e2, e3, Mlp, Ml, tanphi, Nl1, Nl, psi, Az, G, H, GH, Hs, c, kp, cos_c, s, s2, s3, s4, s5;
if (this.sphere) {
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
//North Pole case
p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon);
p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon);
return p;
}
else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
//South Pole case
p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon);
p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon);
return p;
}
else {
//default case
cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon);
c = Math.acos(cos_c);
kp = c ? c / Math.sin(c) : 1;
p.x = this.x0 + this.a * kp * cosphi * Math.sin(dlon);
p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon));
return p;
}
}
else {
e0 = e0fn(this.es);
e1 = e1fn(this.es);
e2 = e2fn(this.es);
e3 = e3fn(this.es);
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
//North Pole case
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
Ml = this.a * mlfn(e0, e1, e2, e3, lat);
p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon);
p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon);
return p;
}
else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
//South Pole case
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
Ml = this.a * mlfn(e0, e1, e2, e3, lat);
p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon);
p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon);
return p;
}
else {
//Default case
tanphi = sinphi / cosphi;
Nl1 = gN(this.a, this.e, this.sin_p12);
Nl = gN(this.a, this.e, sinphi);
psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi));
Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon));
if (Az === 0) {
s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
}
else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) {
s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
}
else {
s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az));
}
G = this.e * this.sin_p12 / Math.sqrt(1 - this.es);
H = this.e * this.cos_p12 * Math.cos(Az) / Math.sqrt(1 - this.es);
GH = G * H;
Hs = H * H;
s2 = s * s;
s3 = s2 * s;
s4 = s3 * s;
s5 = s4 * s;
c = Nl1 * s * (1 - s2 * Hs * (1 - Hs) / 6 + s3 / 8 * GH * (1 - 2 * Hs) + s4 / 120 * (Hs * (4 - 7 * Hs) - 3 * G * G * (1 - 7 * Hs)) - s5 / 48 * GH);
p.x = this.x0 + c * Math.sin(Az);
p.y = this.y0 + c * Math.cos(Az);
return p;
}
}
}
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, N1, psi, Az, cosAz, tmp, A, B, D, Ee, F, sinpsi;
if (this.sphere) {
rh = Math.sqrt(p.x * p.x + p.y * p.y);
if (rh > (2 * HALF_PI * this.a)) {
return;
}
z = rh / this.a;
sinz = Math.sin(z);
cosz = Math.cos(z);
lon = this.long0;
if (Math.abs(rh) <= EPSLN) {
lat = this.lat0;
}
else {
lat = asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh);
con = Math.abs(this.lat0) - HALF_PI;
if (Math.abs(con) <= EPSLN) {
if (this.lat0 >= 0) {
lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));
}
else {
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
}
}
else {
/*con = cosz - this.sin_p12 * Math.sin(lat);
if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
//no-op, just keep the lon value as is
} else {
var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
}*/
lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
}
}
p.x = lon;
p.y = lat;
return p;
}
else {
e0 = e0fn(this.es);
e1 = e1fn(this.es);
e2 = e2fn(this.es);
e3 = e3fn(this.es);
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
//North pole case
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
rh = Math.sqrt(p.x * p.x + p.y * p.y);
M = Mlp - rh;
lat = imlfn(M / this.a, e0, e1, e2, e3);
lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));
p.x = lon;
p.y = lat;
return p;
}
else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
//South pole case
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
rh = Math.sqrt(p.x * p.x + p.y * p.y);
M = rh - Mlp;
lat = imlfn(M / this.a, e0, e1, e2, e3);
lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
p.x = lon;
p.y = lat;
return p;
}
else {
//default case
rh = Math.sqrt(p.x * p.x + p.y * p.y);
Az = Math.atan2(p.x, p.y);
N1 = gN(this.a, this.e, this.sin_p12);
cosAz = Math.cos(Az);
tmp = this.e * this.cos_p12 * cosAz;
A = -tmp * tmp / (1 - this.es);
B = 3 * this.es * (1 - A) * this.sin_p12 * this.cos_p12 * cosAz / (1 - this.es);
D = rh / N1;
Ee = D - A * (1 + A) * Math.pow(D, 3) / 6 - B * (1 + 3 * A) * Math.pow(D, 4) / 24;
F = 1 - A * Ee * Ee / 2 - D * Ee * Ee * Ee / 6;
psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz);
lon = adjust_lon(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi)));
sinpsi = Math.sin(psi);
lat = Math.atan2((sinpsi - this.es * F * this.sin_p12) * Math.tan(psi), sinpsi * (1 - this.es));
p.x = lon;
p.y = lat;
return p;
}
}
}
export var names = ["Azimuthal_Equidistant", "aeqd"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

108
node_modules/proj4/lib/projections/cass.js generated vendored Normal file
View file

@ -0,0 +1,108 @@
import mlfn from '../common/mlfn';
import e0fn from '../common/e0fn';
import e1fn from '../common/e1fn';
import e2fn from '../common/e2fn';
import e3fn from '../common/e3fn';
import gN from '../common/gN';
import adjust_lon from '../common/adjust_lon';
import adjust_lat from '../common/adjust_lat';
import imlfn from '../common/imlfn';
import {HALF_PI, EPSLN} from '../constants/values';
export function init() {
if (!this.sphere) {
this.e0 = e0fn(this.es);
this.e1 = e1fn(this.es);
this.e2 = e2fn(this.es);
this.e3 = e3fn(this.es);
this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
}
}
/* Cassini forward equations--mapping lat,long to x,y
-----------------------------------------------------------------------*/
export function forward(p) {
/* Forward equations
-----------------*/
var x, y;
var lam = p.x;
var phi = p.y;
lam = adjust_lon(lam - this.long0);
if (this.sphere) {
x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));
y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);
}
else {
//ellipsoid
var sinphi = Math.sin(phi);
var cosphi = Math.cos(phi);
var nl = gN(this.a, this.e, sinphi);
var tl = Math.tan(phi) * Math.tan(phi);
var al = lam * Math.cos(phi);
var asq = al * al;
var cl = this.es * cosphi * cosphi / (1 - this.es);
var ml = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));
y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);
}
p.x = x + this.x0;
p.y = y + this.y0;
return p;
}
/* Inverse equations
-----------------*/
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var x = p.x / this.a;
var y = p.y / this.a;
var phi, lam;
if (this.sphere) {
var dd = y + this.lat0;
phi = Math.asin(Math.sin(dd) * Math.cos(x));
lam = Math.atan2(Math.tan(x), Math.cos(dd));
}
else {
/* ellipsoid */
var ml1 = this.ml0 / this.a + y;
var phi1 = imlfn(ml1, this.e0, this.e1, this.e2, this.e3);
if (Math.abs(Math.abs(phi1) - HALF_PI) <= EPSLN) {
p.x = this.long0;
p.y = HALF_PI;
if (y < 0) {
p.y *= -1;
}
return p;
}
var nl1 = gN(this.a, this.e, Math.sin(phi1));
var rl1 = nl1 * nl1 * nl1 / this.a / this.a * (1 - this.es);
var tl1 = Math.pow(Math.tan(phi1), 2);
var dl = x * this.a / nl1;
var dsq = dl * dl;
phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24);
lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1);
}
p.x = adjust_lon(lam + this.long0);
p.y = adjust_lat(phi);
return p;
}
export var names = ["Cassini", "Cassini_Soldner", "cass"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

70
node_modules/proj4/lib/projections/cea.js generated vendored Normal file
View file

@ -0,0 +1,70 @@
import adjust_lon from '../common/adjust_lon';
import qsfnz from '../common/qsfnz';
import msfnz from '../common/msfnz';
import iqsfnz from '../common/iqsfnz';
/*
reference:
"Cartographic Projection Procedures for the UNIX Environment-
A User's Manual" by Gerald I. Evenden,
USGS Open File Report 90-284and Release 4 Interim Reports (2003)
*/
export function init() {
//no-op
if (!this.sphere) {
this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
}
}
/* Cylindrical Equal Area forward equations--mapping lat,long to x,y
------------------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
var x, y;
/* Forward equations
-----------------*/
var dlon = adjust_lon(lon - this.long0);
if (this.sphere) {
x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
}
else {
var qs = qsfnz(this.e, Math.sin(lat));
x = this.x0 + this.a * this.k0 * dlon;
y = this.y0 + this.a * qs * 0.5 / this.k0;
}
p.x = x;
p.y = y;
return p;
}
/* Cylindrical Equal Area inverse equations--mapping x,y to lat/long
------------------------------------------------------------*/
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var lon, lat;
if (this.sphere) {
lon = adjust_lon(this.long0 + (p.x / this.a) / Math.cos(this.lat_ts));
lat = Math.asin((p.y / this.a) * Math.cos(this.lat_ts));
}
else {
lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);
lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["cea"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

48
node_modules/proj4/lib/projections/eqc.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
import adjust_lon from '../common/adjust_lon';
import adjust_lat from '../common/adjust_lat';
export function init() {
this.x0 = this.x0 || 0;
this.y0 = this.y0 || 0;
this.lat0 = this.lat0 || 0;
this.long0 = this.long0 || 0;
this.lat_ts = this.lat_ts || 0;
this.title = this.title || "Equidistant Cylindrical (Plate Carre)";
this.rc = Math.cos(this.lat_ts);
}
// forward equations--mapping lat,long to x,y
// -----------------------------------------------------------------
export function forward(p) {
var lon = p.x;
var lat = p.y;
var dlon = adjust_lon(lon - this.long0);
var dlat = adjust_lat(lat - this.lat0);
p.x = this.x0 + (this.a * dlon * this.rc);
p.y = this.y0 + (this.a * dlat);
return p;
}
// inverse equations--mapping x,y to lat/long
// -----------------------------------------------------------------
export function inverse(p) {
var x = p.x;
var y = p.y;
p.x = adjust_lon(this.long0 + ((x - this.x0) / (this.a * this.rc)));
p.y = adjust_lat(this.lat0 + ((y - this.y0) / (this.a)));
return p;
}
export var names = ["Equirectangular", "Equidistant_Cylindrical", "eqc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

117
node_modules/proj4/lib/projections/eqdc.js generated vendored Normal file
View file

@ -0,0 +1,117 @@
import e0fn from '../common/e0fn';
import e1fn from '../common/e1fn';
import e2fn from '../common/e2fn';
import e3fn from '../common/e3fn';
import msfnz from '../common/msfnz';
import mlfn from '../common/mlfn';
import adjust_lon from '../common/adjust_lon';
import adjust_lat from '../common/adjust_lat';
import imlfn from '../common/imlfn';
import {EPSLN} from '../constants/values';
export function init() {
/* Place parameters in static storage for common use
-------------------------------------------------*/
// Standard Parallels cannot be equal and on opposite sides of the equator
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
return;
}
this.lat2 = this.lat2 || this.lat1;
this.temp = this.b / this.a;
this.es = 1 - Math.pow(this.temp, 2);
this.e = Math.sqrt(this.es);
this.e0 = e0fn(this.es);
this.e1 = e1fn(this.es);
this.e2 = e2fn(this.es);
this.e3 = e3fn(this.es);
this.sinphi = Math.sin(this.lat1);
this.cosphi = Math.cos(this.lat1);
this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);
this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
this.ns = this.sinphi;
}
else {
this.sinphi = Math.sin(this.lat2);
this.cosphi = Math.cos(this.lat2);
this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);
this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
}
this.g = this.ml1 + this.ms1 / this.ns;
this.ml0 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0);
this.rh = this.a * (this.g - this.ml0);
}
/* Equidistant Conic forward equations--mapping lat,long to x,y
-----------------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
var rh1;
/* Forward equations
-----------------*/
if (this.sphere) {
rh1 = this.a * (this.g - lat);
}
else {
var ml = mlfn(this.e0, this.e1, this.e2, this.e3, lat);
rh1 = this.a * (this.g - ml);
}
var theta = this.ns * adjust_lon(lon - this.long0);
var x = this.x0 + rh1 * Math.sin(theta);
var y = this.y0 + this.rh - rh1 * Math.cos(theta);
p.x = x;
p.y = y;
return p;
}
/* Inverse equations
-----------------*/
export function inverse(p) {
p.x -= this.x0;
p.y = this.rh - p.y + this.y0;
var con, rh1, lat, lon;
if (this.ns >= 0) {
rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
con = 1;
}
else {
rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
con = -1;
}
var theta = 0;
if (rh1 !== 0) {
theta = Math.atan2(con * p.x, con * p.y);
}
if (this.sphere) {
lon = adjust_lon(this.long0 + theta / this.ns);
lat = adjust_lat(this.g - rh1 / this.a);
p.x = lon;
p.y = lat;
return p;
}
else {
var ml = this.g - rh1 / this.a;
lat = imlfn(ml, this.e0, this.e1, this.e2, this.e3);
lon = adjust_lon(this.long0 + theta / this.ns);
p.x = lon;
p.y = lat;
return p;
}
}
export var names = ["Equidistant_Conic", "eqdc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

48
node_modules/proj4/lib/projections/equi.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
import adjust_lon from '../common/adjust_lon';
export function init() {
this.x0 = this.x0 || 0;
this.y0 = this.y0 || 0;
this.lat0 = this.lat0 || 0;
this.long0 = this.long0 || 0;
///this.t2;
}
/* Equirectangular forward equations--mapping lat,long to x,y
---------------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
var dlon = adjust_lon(lon - this.long0);
var x = this.x0 + this.a * dlon * Math.cos(this.lat0);
var y = this.y0 + this.a * lat;
this.t1 = x;
this.t2 = Math.cos(this.lat0);
p.x = x;
p.y = y;
return p;
}
/* Equirectangular inverse equations--mapping x,y to lat/long
---------------------------------------------------------*/
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var lat = p.y / this.a;
var lon = adjust_lon(this.long0 + p.x / (this.a * Math.cos(this.lat0)));
p.x = lon;
p.y = lat;
}
export var names = ["equi"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

172
node_modules/proj4/lib/projections/etmerc.js generated vendored Normal file
View file

@ -0,0 +1,172 @@
// Heavily based on this etmerc projection implementation
// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/etmerc.js
import tmerc from '../projections/tmerc';
import sinh from '../common/sinh';
import hypot from '../common/hypot';
import asinhy from '../common/asinhy';
import gatg from '../common/gatg';
import clens from '../common/clens';
import clens_cmplx from '../common/clens_cmplx';
import adjust_lon from '../common/adjust_lon';
export function init() {
if (!this.approx && (isNaN(this.es) || this.es <= 0)) {
throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');
}
if (this.approx) {
// When '+approx' is set, use tmerc instead
tmerc.init.apply(this);
this.forward = tmerc.forward;
this.inverse = tmerc.inverse;
}
this.x0 = this.x0 !== undefined ? this.x0 : 0;
this.y0 = this.y0 !== undefined ? this.y0 : 0;
this.long0 = this.long0 !== undefined ? this.long0 : 0;
this.lat0 = this.lat0 !== undefined ? this.lat0 : 0;
this.cgb = [];
this.cbg = [];
this.utg = [];
this.gtu = [];
var f = this.es / (1 + Math.sqrt(1 - this.es));
var n = f / (2 - f);
var np = n;
this.cgb[0] = n * (2 + n * (-2 / 3 + n * (-2 + n * (116 / 45 + n * (26 / 45 + n * (-2854 / 675 ))))));
this.cbg[0] = n * (-2 + n * ( 2 / 3 + n * ( 4 / 3 + n * (-82 / 45 + n * (32 / 45 + n * (4642 / 4725))))));
np = np * n;
this.cgb[1] = np * (7 / 3 + n * (-8 / 5 + n * (-227 / 45 + n * (2704 / 315 + n * (2323 / 945)))));
this.cbg[1] = np * (5 / 3 + n * (-16 / 15 + n * ( -13 / 9 + n * (904 / 315 + n * (-1522 / 945)))));
np = np * n;
this.cgb[2] = np * (56 / 15 + n * (-136 / 35 + n * (-1262 / 105 + n * (73814 / 2835))));
this.cbg[2] = np * (-26 / 15 + n * (34 / 21 + n * (8 / 5 + n * (-12686 / 2835))));
np = np * n;
this.cgb[3] = np * (4279 / 630 + n * (-332 / 35 + n * (-399572 / 14175)));
this.cbg[3] = np * (1237 / 630 + n * (-12 / 5 + n * ( -24832 / 14175)));
np = np * n;
this.cgb[4] = np * (4174 / 315 + n * (-144838 / 6237));
this.cbg[4] = np * (-734 / 315 + n * (109598 / 31185));
np = np * n;
this.cgb[5] = np * (601676 / 22275);
this.cbg[5] = np * (444337 / 155925);
np = Math.pow(n, 2);
this.Qn = this.k0 / (1 + n) * (1 + np * (1 / 4 + np * (1 / 64 + np / 256)));
this.utg[0] = n * (-0.5 + n * ( 2 / 3 + n * (-37 / 96 + n * ( 1 / 360 + n * (81 / 512 + n * (-96199 / 604800))))));
this.gtu[0] = n * (0.5 + n * (-2 / 3 + n * (5 / 16 + n * (41 / 180 + n * (-127 / 288 + n * (7891 / 37800))))));
this.utg[1] = np * (-1 / 48 + n * (-1 / 15 + n * (437 / 1440 + n * (-46 / 105 + n * (1118711 / 3870720)))));
this.gtu[1] = np * (13 / 48 + n * (-3 / 5 + n * (557 / 1440 + n * (281 / 630 + n * (-1983433 / 1935360)))));
np = np * n;
this.utg[2] = np * (-17 / 480 + n * (37 / 840 + n * (209 / 4480 + n * (-5569 / 90720 ))));
this.gtu[2] = np * (61 / 240 + n * (-103 / 140 + n * (15061 / 26880 + n * (167603 / 181440))));
np = np * n;
this.utg[3] = np * (-4397 / 161280 + n * (11 / 504 + n * (830251 / 7257600)));
this.gtu[3] = np * (49561 / 161280 + n * (-179 / 168 + n * (6601661 / 7257600)));
np = np * n;
this.utg[4] = np * (-4583 / 161280 + n * (108847 / 3991680));
this.gtu[4] = np * (34729 / 80640 + n * (-3418889 / 1995840));
np = np * n;
this.utg[5] = np * (-20648693 / 638668800);
this.gtu[5] = np * (212378941 / 319334400);
var Z = gatg(this.cbg, this.lat0);
this.Zb = -this.Qn * (Z + clens(this.gtu, 2 * Z));
}
export function forward(p) {
var Ce = adjust_lon(p.x - this.long0);
var Cn = p.y;
Cn = gatg(this.cbg, Cn);
var sin_Cn = Math.sin(Cn);
var cos_Cn = Math.cos(Cn);
var sin_Ce = Math.sin(Ce);
var cos_Ce = Math.cos(Ce);
Cn = Math.atan2(sin_Cn, cos_Ce * cos_Cn);
Ce = Math.atan2(sin_Ce * cos_Cn, hypot(sin_Cn, cos_Cn * cos_Ce));
Ce = asinhy(Math.tan(Ce));
var tmp = clens_cmplx(this.gtu, 2 * Cn, 2 * Ce);
Cn = Cn + tmp[0];
Ce = Ce + tmp[1];
var x;
var y;
if (Math.abs(Ce) <= 2.623395162778) {
x = this.a * (this.Qn * Ce) + this.x0;
y = this.a * (this.Qn * Cn + this.Zb) + this.y0;
}
else {
x = Infinity;
y = Infinity;
}
p.x = x;
p.y = y;
return p;
}
export function inverse(p) {
var Ce = (p.x - this.x0) * (1 / this.a);
var Cn = (p.y - this.y0) * (1 / this.a);
Cn = (Cn - this.Zb) / this.Qn;
Ce = Ce / this.Qn;
var lon;
var lat;
if (Math.abs(Ce) <= 2.623395162778) {
var tmp = clens_cmplx(this.utg, 2 * Cn, 2 * Ce);
Cn = Cn + tmp[0];
Ce = Ce + tmp[1];
Ce = Math.atan(sinh(Ce));
var sin_Cn = Math.sin(Cn);
var cos_Cn = Math.cos(Cn);
var sin_Ce = Math.sin(Ce);
var cos_Ce = Math.cos(Ce);
Cn = Math.atan2(sin_Cn * cos_Ce, hypot(sin_Ce, cos_Ce * cos_Cn));
Ce = Math.atan2(sin_Ce, cos_Ce * cos_Cn);
lon = adjust_lon(Ce + this.long0);
lat = gatg(this.cgb, Cn);
}
else {
lon = Infinity;
lat = Infinity;
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Extended_Transverse_Mercator", "Extended Transverse Mercator", "etmerc", "Transverse_Mercator", "Transverse Mercator", "tmerc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

52
node_modules/proj4/lib/projections/gauss.js generated vendored Normal file
View file

@ -0,0 +1,52 @@
import srat from '../common/srat';
var MAX_ITER = 20;
import {HALF_PI, FORTPI} from '../constants/values';
export function init() {
var sphi = Math.sin(this.lat0);
var cphi = Math.cos(this.lat0);
cphi *= cphi;
this.rc = Math.sqrt(1 - this.es) / (1 - this.es * sphi * sphi);
this.C = Math.sqrt(1 + this.es * cphi * cphi / (1 - this.es));
this.phic0 = Math.asin(sphi / this.C);
this.ratexp = 0.5 * this.C * this.e;
this.K = Math.tan(0.5 * this.phic0 + FORTPI) / (Math.pow(Math.tan(0.5 * this.lat0 + FORTPI), this.C) * srat(this.e * sphi, this.ratexp));
}
export function forward(p) {
var lon = p.x;
var lat = p.y;
p.y = 2 * Math.atan(this.K * Math.pow(Math.tan(0.5 * lat + FORTPI), this.C) * srat(this.e * Math.sin(lat), this.ratexp)) - HALF_PI;
p.x = this.C * lon;
return p;
}
export function inverse(p) {
var DEL_TOL = 1e-14;
var lon = p.x / this.C;
var lat = p.y;
var num = Math.pow(Math.tan(0.5 * lat + FORTPI) / this.K, 1 / this.C);
for (var i = MAX_ITER; i > 0; --i) {
lat = 2 * Math.atan(num * srat(this.e * Math.sin(p.y), - 0.5 * this.e)) - HALF_PI;
if (Math.abs(lat - p.y) < DEL_TOL) {
break;
}
p.y = lat;
}
/* convergence failed */
if (!i) {
return null;
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["gauss"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

27
node_modules/proj4/lib/projections/geocent.js generated vendored Normal file
View file

@ -0,0 +1,27 @@
import {
geodeticToGeocentric,
geocentricToGeodetic
} from '../datumUtils';
export function init() {
this.name = 'geocent';
}
export function forward(p) {
var point = geodeticToGeocentric(p, this.es, this.a);
return point;
}
export function inverse(p) {
var point = geocentricToGeodetic(p, this.es, this.a, this.b);
return point;
}
export var names = ["Geocentric", 'geocentric', "geocent", "Geocent"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

159
node_modules/proj4/lib/projections/geos.js generated vendored Normal file
View file

@ -0,0 +1,159 @@
import hypot from '../common/hypot';
export function init() {
this.flip_axis = (this.sweep === 'x' ? 1 : 0);
this.h = Number(this.h);
this.radius_g_1 = this.h / this.a;
if (this.radius_g_1 <= 0 || this.radius_g_1 > 1e10) {
throw new Error();
}
this.radius_g = 1.0 + this.radius_g_1;
this.C = this.radius_g * this.radius_g - 1.0;
if (this.es !== 0.0) {
var one_es = 1.0 - this.es;
var rone_es = 1 / one_es;
this.radius_p = Math.sqrt(one_es);
this.radius_p2 = one_es;
this.radius_p_inv2 = rone_es;
this.shape = 'ellipse'; // Use as a condition in the forward and inverse functions.
} else {
this.radius_p = 1.0;
this.radius_p2 = 1.0;
this.radius_p_inv2 = 1.0;
this.shape = 'sphere'; // Use as a condition in the forward and inverse functions.
}
if (!this.title) {
this.title = "Geostationary Satellite View";
}
}
function forward(p) {
var lon = p.x;
var lat = p.y;
var tmp, v_x, v_y, v_z;
lon = lon - this.long0;
if (this.shape === 'ellipse') {
lat = Math.atan(this.radius_p2 * Math.tan(lat));
var r = this.radius_p / hypot(this.radius_p * Math.cos(lat), Math.sin(lat));
v_x = r * Math.cos(lon) * Math.cos(lat);
v_y = r * Math.sin(lon) * Math.cos(lat);
v_z = r * Math.sin(lat);
if (((this.radius_g - v_x) * v_x - v_y * v_y - v_z * v_z * this.radius_p_inv2) < 0.0) {
p.x = Number.NaN;
p.y = Number.NaN;
return p;
}
tmp = this.radius_g - v_x;
if (this.flip_axis) {
p.x = this.radius_g_1 * Math.atan(v_y / hypot(v_z, tmp));
p.y = this.radius_g_1 * Math.atan(v_z / tmp);
} else {
p.x = this.radius_g_1 * Math.atan(v_y / tmp);
p.y = this.radius_g_1 * Math.atan(v_z / hypot(v_y, tmp));
}
} else if (this.shape === 'sphere') {
tmp = Math.cos(lat);
v_x = Math.cos(lon) * tmp;
v_y = Math.sin(lon) * tmp;
v_z = Math.sin(lat);
tmp = this.radius_g - v_x;
if (this.flip_axis) {
p.x = this.radius_g_1 * Math.atan(v_y / hypot(v_z, tmp));
p.y = this.radius_g_1 * Math.atan(v_z / tmp);
} else {
p.x = this.radius_g_1 * Math.atan(v_y / tmp);
p.y = this.radius_g_1 * Math.atan(v_z / hypot(v_y, tmp));
}
}
p.x = p.x * this.a;
p.y = p.y * this.a;
return p;
}
function inverse(p) {
var v_x = -1.0;
var v_y = 0.0;
var v_z = 0.0;
var a, b, det, k;
p.x = p.x / this.a;
p.y = p.y / this.a;
if (this.shape === 'ellipse') {
if (this.flip_axis) {
v_z = Math.tan(p.y / this.radius_g_1);
v_y = Math.tan(p.x / this.radius_g_1) * hypot(1.0, v_z);
} else {
v_y = Math.tan(p.x / this.radius_g_1);
v_z = Math.tan(p.y / this.radius_g_1) * hypot(1.0, v_y);
}
var v_zp = v_z / this.radius_p;
a = v_y * v_y + v_zp * v_zp + v_x * v_x;
b = 2 * this.radius_g * v_x;
det = (b * b) - 4 * a * this.C;
if (det < 0.0) {
p.x = Number.NaN;
p.y = Number.NaN;
return p;
}
k = (-b - Math.sqrt(det)) / (2.0 * a);
v_x = this.radius_g + k * v_x;
v_y *= k;
v_z *= k;
p.x = Math.atan2(v_y, v_x);
p.y = Math.atan(v_z * Math.cos(p.x) / v_x);
p.y = Math.atan(this.radius_p_inv2 * Math.tan(p.y));
} else if (this.shape === 'sphere') {
if (this.flip_axis) {
v_z = Math.tan(p.y / this.radius_g_1);
v_y = Math.tan(p.x / this.radius_g_1) * Math.sqrt(1.0 + v_z * v_z);
} else {
v_y = Math.tan(p.x / this.radius_g_1);
v_z = Math.tan(p.y / this.radius_g_1) * Math.sqrt(1.0 + v_y * v_y);
}
a = v_y * v_y + v_z * v_z + v_x * v_x;
b = 2 * this.radius_g * v_x;
det = (b * b) - 4 * a * this.C;
if (det < 0.0) {
p.x = Number.NaN;
p.y = Number.NaN;
return p;
}
k = (-b - Math.sqrt(det)) / (2.0 * a);
v_x = this.radius_g + k * v_x;
v_y *= k;
v_z *= k;
p.x = Math.atan2(v_y, v_x);
p.y = Math.atan(v_z * Math.cos(p.x) / v_x);
}
p.x = p.x + this.long0;
return p;
}
export var names = ["Geostationary Satellite View", "Geostationary_Satellite", "geos"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names,
};

104
node_modules/proj4/lib/projections/gnom.js generated vendored Normal file
View file

@ -0,0 +1,104 @@
import adjust_lon from '../common/adjust_lon';
import asinz from '../common/asinz';
import {EPSLN} from '../constants/values';
/*
reference:
Wolfram Mathworld "Gnomonic Projection"
http://mathworld.wolfram.com/GnomonicProjection.html
Accessed: 12th November 2009
*/
export function init() {
/* Place parameters in static storage for common use
-------------------------------------------------*/
this.sin_p14 = Math.sin(this.lat0);
this.cos_p14 = Math.cos(this.lat0);
// Approximation for projecting points to the horizon (infinity)
this.infinity_dist = 1000 * this.a;
this.rc = 1;
}
/* Gnomonic forward equations--mapping lat,long to x,y
---------------------------------------------------*/
export function forward(p) {
var sinphi, cosphi; /* sin and cos value */
var dlon; /* delta longitude value */
var coslon; /* cos of longitude */
var ksp; /* scale factor */
var g;
var x, y;
var lon = p.x;
var lat = p.y;
/* Forward equations
-----------------*/
dlon = adjust_lon(lon - this.long0);
sinphi = Math.sin(lat);
cosphi = Math.cos(lat);
coslon = Math.cos(dlon);
g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;
ksp = 1;
if ((g > 0) || (Math.abs(g) <= EPSLN)) {
x = this.x0 + this.a * ksp * cosphi * Math.sin(dlon) / g;
y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon) / g;
}
else {
// Point is in the opposing hemisphere and is unprojectable
// We still need to return a reasonable point, so we project
// to infinity, on a bearing
// equivalent to the northern hemisphere equivalent
// This is a reasonable approximation for short shapes and lines that
// straddle the horizon.
x = this.x0 + this.infinity_dist * cosphi * Math.sin(dlon);
y = this.y0 + this.infinity_dist * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
}
p.x = x;
p.y = y;
return p;
}
export function inverse(p) {
var rh; /* Rho */
var sinc, cosc;
var c;
var lon, lat;
/* Inverse equations
-----------------*/
p.x = (p.x - this.x0) / this.a;
p.y = (p.y - this.y0) / this.a;
p.x /= this.k0;
p.y /= this.k0;
if ((rh = Math.sqrt(p.x * p.x + p.y * p.y))) {
c = Math.atan2(rh, this.rc);
sinc = Math.sin(c);
cosc = Math.cos(c);
lat = asinz(cosc * this.sin_p14 + (p.y * sinc * this.cos_p14) / rh);
lon = Math.atan2(p.x * sinc, rh * this.cos_p14 * cosc - p.y * this.sin_p14 * sinc);
lon = adjust_lon(this.long0 + lon);
}
else {
lat = this.phic0;
lon = 0;
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["gnom"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

63
node_modules/proj4/lib/projections/gstmerc.js generated vendored Normal file
View file

@ -0,0 +1,63 @@
import latiso from '../common/latiso';
import sinh from '../common/sinh';
import cosh from '../common/cosh';
import invlatiso from '../common/invlatiso';
export function init() {
// array of: a, b, lon0, lat0, k0, x0, y0
var temp = this.b / this.a;
this.e = Math.sqrt(1 - temp * temp);
this.lc = this.long0;
this.rs = Math.sqrt(1 + this.e * this.e * Math.pow(Math.cos(this.lat0), 4) / (1 - this.e * this.e));
var sinz = Math.sin(this.lat0);
var pc = Math.asin(sinz / this.rs);
var sinzpc = Math.sin(pc);
this.cp = latiso(0, pc, sinzpc) - this.rs * latiso(this.e, this.lat0, sinz);
this.n2 = this.k0 * this.a * Math.sqrt(1 - this.e * this.e) / (1 - this.e * this.e * sinz * sinz);
this.xs = this.x0;
this.ys = this.y0 - this.n2 * pc;
if (!this.title) {
this.title = "Gauss Schreiber transverse mercator";
}
}
// forward equations--mapping lat,long to x,y
// -----------------------------------------------------------------
export function forward(p) {
var lon = p.x;
var lat = p.y;
var L = this.rs * (lon - this.lc);
var Ls = this.cp + (this.rs * latiso(this.e, lat, Math.sin(lat)));
var lat1 = Math.asin(Math.sin(L) / cosh(Ls));
var Ls1 = latiso(0, lat1, Math.sin(lat1));
p.x = this.xs + (this.n2 * Ls1);
p.y = this.ys + (this.n2 * Math.atan(sinh(Ls) / Math.cos(L)));
return p;
}
// inverse equations--mapping x,y to lat/long
// -----------------------------------------------------------------
export function inverse(p) {
var x = p.x;
var y = p.y;
var L = Math.atan(sinh((x - this.xs) / this.n2) / Math.cos((y - this.ys) / this.n2));
var lat1 = Math.asin(Math.sin((y - this.ys) / this.n2) / cosh((x - this.xs) / this.n2));
var LC = latiso(0, lat1, Math.sin(lat1));
p.x = this.lc + L / this.rs;
p.y = invlatiso(this.e, (LC - this.cp) / this.rs);
return p;
}
export var names = ["gstmerg", "gstmerc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

106
node_modules/proj4/lib/projections/krovak.js generated vendored Normal file
View file

@ -0,0 +1,106 @@
import adjust_lon from '../common/adjust_lon';
export function init() {
this.a = 6377397.155;
this.es = 0.006674372230614;
this.e = Math.sqrt(this.es);
if (!this.lat0) {
this.lat0 = 0.863937979737193;
}
if (!this.long0) {
this.long0 = 0.7417649320975901 - 0.308341501185665;
}
/* if scale not set default to 0.9999 */
if (!this.k0) {
this.k0 = 0.9999;
}
this.s45 = 0.785398163397448; /* 45 */
this.s90 = 2 * this.s45;
this.fi0 = this.lat0;
this.e2 = this.es;
this.e = Math.sqrt(this.e2);
this.alfa = Math.sqrt(1 + (this.e2 * Math.pow(Math.cos(this.fi0), 4)) / (1 - this.e2));
this.uq = 1.04216856380474;
this.u0 = Math.asin(Math.sin(this.fi0) / this.alfa);
this.g = Math.pow((1 + this.e * Math.sin(this.fi0)) / (1 - this.e * Math.sin(this.fi0)), this.alfa * this.e / 2);
this.k = Math.tan(this.u0 / 2 + this.s45) / Math.pow(Math.tan(this.fi0 / 2 + this.s45), this.alfa) * this.g;
this.k1 = this.k0;
this.n0 = this.a * Math.sqrt(1 - this.e2) / (1 - this.e2 * Math.pow(Math.sin(this.fi0), 2));
this.s0 = 1.37008346281555;
this.n = Math.sin(this.s0);
this.ro0 = this.k1 * this.n0 / Math.tan(this.s0);
this.ad = this.s90 - this.uq;
}
/* ellipsoid */
/* calculate xy from lat/lon */
/* Constants, identical to inverse transform function */
export function forward(p) {
var gfi, u, deltav, s, d, eps, ro;
var lon = p.x;
var lat = p.y;
var delta_lon = adjust_lon(lon - this.long0);
/* Transformation */
gfi = Math.pow(((1 + this.e * Math.sin(lat)) / (1 - this.e * Math.sin(lat))), (this.alfa * this.e / 2));
u = 2 * (Math.atan(this.k * Math.pow(Math.tan(lat / 2 + this.s45), this.alfa) / gfi) - this.s45);
deltav = -delta_lon * this.alfa;
s = Math.asin(Math.cos(this.ad) * Math.sin(u) + Math.sin(this.ad) * Math.cos(u) * Math.cos(deltav));
d = Math.asin(Math.cos(u) * Math.sin(deltav) / Math.cos(s));
eps = this.n * d;
ro = this.ro0 * Math.pow(Math.tan(this.s0 / 2 + this.s45), this.n) / Math.pow(Math.tan(s / 2 + this.s45), this.n);
p.y = ro * Math.cos(eps) / 1;
p.x = ro * Math.sin(eps) / 1;
if (!this.czech) {
p.y *= -1;
p.x *= -1;
}
return (p);
}
/* calculate lat/lon from xy */
export function inverse(p) {
var u, deltav, s, d, eps, ro, fi1;
var ok;
/* Transformation */
/* revert y, x*/
var tmp = p.x;
p.x = p.y;
p.y = tmp;
if (!this.czech) {
p.y *= -1;
p.x *= -1;
}
ro = Math.sqrt(p.x * p.x + p.y * p.y);
eps = Math.atan2(p.y, p.x);
d = eps / Math.sin(this.s0);
s = 2 * (Math.atan(Math.pow(this.ro0 / ro, 1 / this.n) * Math.tan(this.s0 / 2 + this.s45)) - this.s45);
u = Math.asin(Math.cos(this.ad) * Math.sin(s) - Math.sin(this.ad) * Math.cos(s) * Math.cos(d));
deltav = Math.asin(Math.cos(s) * Math.sin(d) / Math.cos(u));
p.x = this.long0 - deltav / this.alfa;
fi1 = u;
ok = 0;
var iter = 0;
do {
p.y = 2 * (Math.atan(Math.pow(this.k, - 1 / this.alfa) * Math.pow(Math.tan(u / 2 + this.s45), 1 / this.alfa) * Math.pow((1 + this.e * Math.sin(fi1)) / (1 - this.e * Math.sin(fi1)), this.e / 2)) - this.s45);
if (Math.abs(fi1 - p.y) < 0.0000000001) {
ok = 1;
}
fi1 = p.y;
iter += 1;
} while (ok === 0 && iter < 15);
if (iter >= 15) {
return null;
}
return (p);
}
export var names = ["Krovak", "krovak"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

298
node_modules/proj4/lib/projections/laea.js generated vendored Normal file
View file

@ -0,0 +1,298 @@
import {HALF_PI, EPSLN, FORTPI} from '../constants/values';
import qsfnz from '../common/qsfnz';
import adjust_lon from '../common/adjust_lon';
/*
reference
"New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
*/
export var S_POLE = 1;
export var N_POLE = 2;
export var EQUIT = 3;
export var OBLIQ = 4;
/* Initialize the Lambert Azimuthal Equal Area projection
------------------------------------------------------*/
export function init() {
var t = Math.abs(this.lat0);
if (Math.abs(t - HALF_PI) < EPSLN) {
this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE;
}
else if (Math.abs(t) < EPSLN) {
this.mode = this.EQUIT;
}
else {
this.mode = this.OBLIQ;
}
if (this.es > 0) {
var sinphi;
this.qp = qsfnz(this.e, 1);
this.mmf = 0.5 / (1 - this.es);
this.apa = authset(this.es);
switch (this.mode) {
case this.N_POLE:
this.dd = 1;
break;
case this.S_POLE:
this.dd = 1;
break;
case this.EQUIT:
this.rq = Math.sqrt(0.5 * this.qp);
this.dd = 1 / this.rq;
this.xmf = 1;
this.ymf = 0.5 * this.qp;
break;
case this.OBLIQ:
this.rq = Math.sqrt(0.5 * this.qp);
sinphi = Math.sin(this.lat0);
this.sinb1 = qsfnz(this.e, sinphi) / this.qp;
this.cosb1 = Math.sqrt(1 - this.sinb1 * this.sinb1);
this.dd = Math.cos(this.lat0) / (Math.sqrt(1 - this.es * sinphi * sinphi) * this.rq * this.cosb1);
this.ymf = (this.xmf = this.rq) / this.dd;
this.xmf *= this.dd;
break;
}
}
else {
if (this.mode === this.OBLIQ) {
this.sinph0 = Math.sin(this.lat0);
this.cosph0 = Math.cos(this.lat0);
}
}
}
/* Lambert Azimuthal Equal Area forward equations--mapping lat,long to x,y
-----------------------------------------------------------------------*/
export function forward(p) {
/* Forward equations
-----------------*/
var x, y, coslam, sinlam, sinphi, q, sinb, cosb, b, cosphi;
var lam = p.x;
var phi = p.y;
lam = adjust_lon(lam - this.long0);
if (this.sphere) {
sinphi = Math.sin(phi);
cosphi = Math.cos(phi);
coslam = Math.cos(lam);
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
y = (this.mode === this.EQUIT) ? 1 + cosphi * coslam : 1 + this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;
if (y <= EPSLN) {
return null;
}
y = Math.sqrt(2 / y);
x = y * cosphi * Math.sin(lam);
y *= (this.mode === this.EQUIT) ? sinphi : this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;
}
else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
if (this.mode === this.N_POLE) {
coslam = -coslam;
}
if (Math.abs(phi + this.lat0) < EPSLN) {
return null;
}
y = FORTPI - phi * 0.5;
y = 2 * ((this.mode === this.S_POLE) ? Math.cos(y) : Math.sin(y));
x = y * Math.sin(lam);
y *= coslam;
}
}
else {
sinb = 0;
cosb = 0;
b = 0;
coslam = Math.cos(lam);
sinlam = Math.sin(lam);
sinphi = Math.sin(phi);
q = qsfnz(this.e, sinphi);
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
sinb = q / this.qp;
cosb = Math.sqrt(1 - sinb * sinb);
}
switch (this.mode) {
case this.OBLIQ:
b = 1 + this.sinb1 * sinb + this.cosb1 * cosb * coslam;
break;
case this.EQUIT:
b = 1 + cosb * coslam;
break;
case this.N_POLE:
b = HALF_PI + phi;
q = this.qp - q;
break;
case this.S_POLE:
b = phi - HALF_PI;
q = this.qp + q;
break;
}
if (Math.abs(b) < EPSLN) {
return null;
}
switch (this.mode) {
case this.OBLIQ:
case this.EQUIT:
b = Math.sqrt(2 / b);
if (this.mode === this.OBLIQ) {
y = this.ymf * b * (this.cosb1 * sinb - this.sinb1 * cosb * coslam);
}
else {
y = (b = Math.sqrt(2 / (1 + cosb * coslam))) * sinb * this.ymf;
}
x = this.xmf * b * cosb * sinlam;
break;
case this.N_POLE:
case this.S_POLE:
if (q >= 0) {
x = (b = Math.sqrt(q)) * sinlam;
y = coslam * ((this.mode === this.S_POLE) ? b : -b);
}
else {
x = y = 0;
}
break;
}
}
p.x = this.a * x + this.x0;
p.y = this.a * y + this.y0;
return p;
}
/* Inverse equations
-----------------*/
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var x = p.x / this.a;
var y = p.y / this.a;
var lam, phi, cCe, sCe, q, rho, ab;
if (this.sphere) {
var cosz = 0,
rh, sinz = 0;
rh = Math.sqrt(x * x + y * y);
phi = rh * 0.5;
if (phi > 1) {
return null;
}
phi = 2 * Math.asin(phi);
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
sinz = Math.sin(phi);
cosz = Math.cos(phi);
}
switch (this.mode) {
case this.EQUIT:
phi = (Math.abs(rh) <= EPSLN) ? 0 : Math.asin(y * sinz / rh);
x *= sinz;
y = cosz * rh;
break;
case this.OBLIQ:
phi = (Math.abs(rh) <= EPSLN) ? this.lat0 : Math.asin(cosz * this.sinph0 + y * sinz * this.cosph0 / rh);
x *= sinz * this.cosph0;
y = (cosz - Math.sin(phi) * this.sinph0) * rh;
break;
case this.N_POLE:
y = -y;
phi = HALF_PI - phi;
break;
case this.S_POLE:
phi -= HALF_PI;
break;
}
lam = (y === 0 && (this.mode === this.EQUIT || this.mode === this.OBLIQ)) ? 0 : Math.atan2(x, y);
}
else {
ab = 0;
if (this.mode === this.OBLIQ || this.mode === this.EQUIT) {
x /= this.dd;
y *= this.dd;
rho = Math.sqrt(x * x + y * y);
if (rho < EPSLN) {
p.x = this.long0;
p.y = this.lat0;
return p;
}
sCe = 2 * Math.asin(0.5 * rho / this.rq);
cCe = Math.cos(sCe);
x *= (sCe = Math.sin(sCe));
if (this.mode === this.OBLIQ) {
ab = cCe * this.sinb1 + y * sCe * this.cosb1 / rho;
q = this.qp * ab;
y = rho * this.cosb1 * cCe - y * this.sinb1 * sCe;
}
else {
ab = y * sCe / rho;
q = this.qp * ab;
y = rho * cCe;
}
}
else if (this.mode === this.N_POLE || this.mode === this.S_POLE) {
if (this.mode === this.N_POLE) {
y = -y;
}
q = (x * x + y * y);
if (!q) {
p.x = this.long0;
p.y = this.lat0;
return p;
}
ab = 1 - q / this.qp;
if (this.mode === this.S_POLE) {
ab = -ab;
}
}
lam = Math.atan2(x, y);
phi = authlat(Math.asin(ab), this.apa);
}
p.x = adjust_lon(this.long0 + lam);
p.y = phi;
return p;
}
/* determine latitude from authalic latitude */
var P00 = 0.33333333333333333333;
var P01 = 0.17222222222222222222;
var P02 = 0.10257936507936507936;
var P10 = 0.06388888888888888888;
var P11 = 0.06640211640211640211;
var P20 = 0.01641501294219154443;
function authset(es) {
var t;
var APA = [];
APA[0] = es * P00;
t = es * es;
APA[0] += t * P01;
APA[1] = t * P10;
t *= es;
APA[0] += t * P02;
APA[1] += t * P11;
APA[2] = t * P20;
return APA;
}
function authlat(beta, APA) {
var t = beta + beta;
return (beta + APA[0] * Math.sin(t) + APA[1] * Math.sin(t + t) + APA[2] * Math.sin(t + t + t));
}
export var names = ["Lambert Azimuthal Equal Area", "Lambert_Azimuthal_Equal_Area", "laea"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names,
S_POLE: S_POLE,
N_POLE: N_POLE,
EQUIT: EQUIT,
OBLIQ: OBLIQ
};

150
node_modules/proj4/lib/projections/lcc.js generated vendored Normal file
View file

@ -0,0 +1,150 @@
import msfnz from '../common/msfnz';
import tsfnz from '../common/tsfnz';
import sign from '../common/sign';
import adjust_lon from '../common/adjust_lon';
import phi2z from '../common/phi2z';
import {HALF_PI, EPSLN} from '../constants/values';
export function init() {
//double lat0; /* the reference latitude */
//double long0; /* the reference longitude */
//double lat1; /* first standard parallel */
//double lat2; /* second standard parallel */
//double r_maj; /* major axis */
//double r_min; /* minor axis */
//double false_east; /* x offset in meters */
//double false_north; /* y offset in meters */
//the above value can be set with proj4.defs
//example: proj4.defs("EPSG:2154","+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
if (!this.lat2) {
this.lat2 = this.lat1;
} //if lat2 is not defined
if (!this.k0) {
this.k0 = 1;
}
this.x0 = this.x0 || 0;
this.y0 = this.y0 || 0;
// Standard Parallels cannot be equal and on opposite sides of the equator
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
return;
}
var temp = this.b / this.a;
this.e = Math.sqrt(1 - temp * temp);
var sin1 = Math.sin(this.lat1);
var cos1 = Math.cos(this.lat1);
var ms1 = msfnz(this.e, sin1, cos1);
var ts1 = tsfnz(this.e, this.lat1, sin1);
var sin2 = Math.sin(this.lat2);
var cos2 = Math.cos(this.lat2);
var ms2 = msfnz(this.e, sin2, cos2);
var ts2 = tsfnz(this.e, this.lat2, sin2);
var ts0 = tsfnz(this.e, this.lat0, Math.sin(this.lat0));
if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
this.ns = Math.log(ms1 / ms2) / Math.log(ts1 / ts2);
}
else {
this.ns = sin1;
}
if (isNaN(this.ns)) {
this.ns = sin1;
}
this.f0 = ms1 / (this.ns * Math.pow(ts1, this.ns));
this.rh = this.a * this.f0 * Math.pow(ts0, this.ns);
if (!this.title) {
this.title = "Lambert Conformal Conic";
}
}
// Lambert Conformal conic forward equations--mapping lat,long to x,y
// -----------------------------------------------------------------
export function forward(p) {
var lon = p.x;
var lat = p.y;
// singular cases :
if (Math.abs(2 * Math.abs(lat) - Math.PI) <= EPSLN) {
lat = sign(lat) * (HALF_PI - 2 * EPSLN);
}
var con = Math.abs(Math.abs(lat) - HALF_PI);
var ts, rh1;
if (con > EPSLN) {
ts = tsfnz(this.e, lat, Math.sin(lat));
rh1 = this.a * this.f0 * Math.pow(ts, this.ns);
}
else {
con = lat * this.ns;
if (con <= 0) {
return null;
}
rh1 = 0;
}
var theta = this.ns * adjust_lon(lon - this.long0);
p.x = this.k0 * (rh1 * Math.sin(theta)) + this.x0;
p.y = this.k0 * (this.rh - rh1 * Math.cos(theta)) + this.y0;
return p;
}
// Lambert Conformal Conic inverse equations--mapping x,y to lat/long
// -----------------------------------------------------------------
export function inverse(p) {
var rh1, con, ts;
var lat, lon;
var x = (p.x - this.x0) / this.k0;
var y = (this.rh - (p.y - this.y0) / this.k0);
if (this.ns > 0) {
rh1 = Math.sqrt(x * x + y * y);
con = 1;
}
else {
rh1 = -Math.sqrt(x * x + y * y);
con = -1;
}
var theta = 0;
if (rh1 !== 0) {
theta = Math.atan2((con * x), (con * y));
}
if ((rh1 !== 0) || (this.ns > 0)) {
con = 1 / this.ns;
ts = Math.pow((rh1 / (this.a * this.f0)), con);
lat = phi2z(this.e, ts);
if (lat === -9999) {
return null;
}
}
else {
lat = -HALF_PI;
}
lon = adjust_lon(theta / this.ns + this.long0);
p.x = lon;
p.y = lat;
return p;
}
export var names = [
"Lambert Tangential Conformal Conic Projection",
"Lambert_Conformal_Conic",
"Lambert_Conformal_Conic_1SP",
"Lambert_Conformal_Conic_2SP",
"lcc",
"Lambert Conic Conformal (1SP)",
"Lambert Conic Conformal (2SP)"
];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

16
node_modules/proj4/lib/projections/longlat.js generated vendored Normal file
View file

@ -0,0 +1,16 @@
export function init() {
//no-op for longlat
}
function identity(pt) {
return pt;
}
export {identity as forward};
export {identity as inverse};
export var names = ["longlat", "identity"];
export default {
init: init,
forward: identity,
inverse: identity,
names: names
};

100
node_modules/proj4/lib/projections/merc.js generated vendored Normal file
View file

@ -0,0 +1,100 @@
import msfnz from '../common/msfnz';
import adjust_lon from '../common/adjust_lon';
import tsfnz from '../common/tsfnz';
import phi2z from '../common/phi2z';
import {FORTPI, R2D, EPSLN, HALF_PI} from '../constants/values';
export function init() {
var con = this.b / this.a;
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);
if (this.lat_ts) {
if (this.sphere) {
this.k0 = Math.cos(this.lat_ts);
}
else {
this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
}
}
else {
if (!this.k0) {
if (this.k) {
this.k0 = this.k;
}
else {
this.k0 = 1;
}
}
}
}
/* Mercator forward equations--mapping lat,long to x,y
--------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
// convert to radians
if (lat * R2D > 90 && lat * R2D < -90 && lon * R2D > 180 && lon * R2D < -180) {
return null;
}
var x, y;
if (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN) {
return null;
}
else {
if (this.sphere) {
x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
y = this.y0 + this.a * this.k0 * Math.log(Math.tan(FORTPI + 0.5 * lat));
}
else {
var sinphi = Math.sin(lat);
var ts = tsfnz(this.e, lat, sinphi);
x = this.x0 + this.a * this.k0 * adjust_lon(lon - this.long0);
y = this.y0 - this.a * this.k0 * Math.log(ts);
}
p.x = x;
p.y = y;
return p;
}
}
/* Mercator inverse equations--mapping x,y to lat/long
--------------------------------------------------*/
export function inverse(p) {
var x = p.x - this.x0;
var y = p.y - this.y0;
var lon, lat;
if (this.sphere) {
lat = HALF_PI - 2 * Math.atan(Math.exp(-y / (this.a * this.k0)));
}
else {
var ts = Math.exp(-y / (this.a * this.k0));
lat = phi2z(this.e, ts);
if (lat === -9999) {
return null;
}
}
lon = adjust_lon(this.long0 + x / (this.a * this.k0));
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Mercator", "Popular Visualisation Pseudo Mercator", "Mercator_1SP", "Mercator_Auxiliary_Sphere", "merc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

52
node_modules/proj4/lib/projections/mill.js generated vendored Normal file
View file

@ -0,0 +1,52 @@
import adjust_lon from '../common/adjust_lon';
/*
reference
"New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
*/
/* Initialize the Miller Cylindrical projection
-------------------------------------------*/
export function init() {
//no-op
}
/* Miller Cylindrical forward equations--mapping lat,long to x,y
------------------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
/* Forward equations
-----------------*/
var dlon = adjust_lon(lon - this.long0);
var x = this.x0 + this.a * dlon;
var y = this.y0 + this.a * Math.log(Math.tan((Math.PI / 4) + (lat / 2.5))) * 1.25;
p.x = x;
p.y = y;
return p;
}
/* Miller Cylindrical inverse equations--mapping x,y to lat/long
------------------------------------------------------------*/
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var lon = adjust_lon(this.long0 + p.x / this.a);
var lat = 2.5 * (Math.atan(Math.exp(0.8 * p.y / this.a)) - Math.PI / 4);
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Miller_Cylindrical", "mill"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

83
node_modules/proj4/lib/projections/moll.js generated vendored Normal file
View file

@ -0,0 +1,83 @@
import adjust_lon from '../common/adjust_lon';
export function init() {}
import {EPSLN} from '../constants/values';
/* Mollweide forward equations--mapping lat,long to x,y
----------------------------------------------------*/
export function forward(p) {
/* Forward equations
-----------------*/
var lon = p.x;
var lat = p.y;
var delta_lon = adjust_lon(lon - this.long0);
var theta = lat;
var con = Math.PI * Math.sin(lat);
/* Iterate using the Newton-Raphson method to find theta
-----------------------------------------------------*/
while (true) {
var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta));
theta += delta_theta;
if (Math.abs(delta_theta) < EPSLN) {
break;
}
}
theta /= 2;
/* If the latitude is 90 deg, force the x coordinate to be "0 + false easting"
this is done here because of precision problems with "cos(theta)"
--------------------------------------------------------------------------*/
if (Math.PI / 2 - Math.abs(lat) < EPSLN) {
delta_lon = 0;
}
var x = 0.900316316158 * this.a * delta_lon * Math.cos(theta) + this.x0;
var y = 1.4142135623731 * this.a * Math.sin(theta) + this.y0;
p.x = x;
p.y = y;
return p;
}
export function inverse(p) {
var theta;
var arg;
/* Inverse equations
-----------------*/
p.x -= this.x0;
p.y -= this.y0;
arg = p.y / (1.4142135623731 * this.a);
/* Because of division by zero problems, 'arg' can not be 1. Therefore
a number very close to one is used instead.
-------------------------------------------------------------------*/
if (Math.abs(arg) > 0.999999999999) {
arg = 0.999999999999;
}
theta = Math.asin(arg);
var lon = adjust_lon(this.long0 + (p.x / (0.900316316158 * this.a * Math.cos(theta))));
if (lon < (-Math.PI)) {
lon = -Math.PI;
}
if (lon > Math.PI) {
lon = Math.PI;
}
arg = (2 * theta + Math.sin(2 * theta)) / Math.PI;
if (Math.abs(arg) > 1) {
arg = 1;
}
var lat = Math.asin(arg);
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Mollweide", "moll"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

226
node_modules/proj4/lib/projections/nzmg.js generated vendored Normal file
View file

@ -0,0 +1,226 @@
import {SEC_TO_RAD} from '../constants/values';
/*
reference
Department of Land and Survey Technical Circular 1973/32
http://www.linz.govt.nz/docs/miscellaneous/nz-map-definition.pdf
OSG Technical Report 4.1
http://www.linz.govt.nz/docs/miscellaneous/nzmg.pdf
*/
/**
* iterations: Number of iterations to refine inverse transform.
* 0 -> km accuracy
* 1 -> m accuracy -- suitable for most mapping applications
* 2 -> mm accuracy
*/
export var iterations = 1;
export function init() {
this.A = [];
this.A[1] = 0.6399175073;
this.A[2] = -0.1358797613;
this.A[3] = 0.063294409;
this.A[4] = -0.02526853;
this.A[5] = 0.0117879;
this.A[6] = -0.0055161;
this.A[7] = 0.0026906;
this.A[8] = -0.001333;
this.A[9] = 0.00067;
this.A[10] = -0.00034;
this.B_re = [];
this.B_im = [];
this.B_re[1] = 0.7557853228;
this.B_im[1] = 0;
this.B_re[2] = 0.249204646;
this.B_im[2] = 0.003371507;
this.B_re[3] = -0.001541739;
this.B_im[3] = 0.041058560;
this.B_re[4] = -0.10162907;
this.B_im[4] = 0.01727609;
this.B_re[5] = -0.26623489;
this.B_im[5] = -0.36249218;
this.B_re[6] = -0.6870983;
this.B_im[6] = -1.1651967;
this.C_re = [];
this.C_im = [];
this.C_re[1] = 1.3231270439;
this.C_im[1] = 0;
this.C_re[2] = -0.577245789;
this.C_im[2] = -0.007809598;
this.C_re[3] = 0.508307513;
this.C_im[3] = -0.112208952;
this.C_re[4] = -0.15094762;
this.C_im[4] = 0.18200602;
this.C_re[5] = 1.01418179;
this.C_im[5] = 1.64497696;
this.C_re[6] = 1.9660549;
this.C_im[6] = 2.5127645;
this.D = [];
this.D[1] = 1.5627014243;
this.D[2] = 0.5185406398;
this.D[3] = -0.03333098;
this.D[4] = -0.1052906;
this.D[5] = -0.0368594;
this.D[6] = 0.007317;
this.D[7] = 0.01220;
this.D[8] = 0.00394;
this.D[9] = -0.0013;
}
/**
New Zealand Map Grid Forward - long/lat to x/y
long/lat in radians
*/
export function forward(p) {
var n;
var lon = p.x;
var lat = p.y;
var delta_lat = lat - this.lat0;
var delta_lon = lon - this.long0;
// 1. Calculate d_phi and d_psi ... // and d_lambda
// For this algorithm, delta_latitude is in seconds of arc x 10-5, so we need to scale to those units. Longitude is radians.
var d_phi = delta_lat / SEC_TO_RAD * 1E-5;
var d_lambda = delta_lon;
var d_phi_n = 1; // d_phi^0
var d_psi = 0;
for (n = 1; n <= 10; n++) {
d_phi_n = d_phi_n * d_phi;
d_psi = d_psi + this.A[n] * d_phi_n;
}
// 2. Calculate theta
var th_re = d_psi;
var th_im = d_lambda;
// 3. Calculate z
var th_n_re = 1;
var th_n_im = 0; // theta^0
var th_n_re1;
var th_n_im1;
var z_re = 0;
var z_im = 0;
for (n = 1; n <= 6; n++) {
th_n_re1 = th_n_re * th_re - th_n_im * th_im;
th_n_im1 = th_n_im * th_re + th_n_re * th_im;
th_n_re = th_n_re1;
th_n_im = th_n_im1;
z_re = z_re + this.B_re[n] * th_n_re - this.B_im[n] * th_n_im;
z_im = z_im + this.B_im[n] * th_n_re + this.B_re[n] * th_n_im;
}
// 4. Calculate easting and northing
p.x = (z_im * this.a) + this.x0;
p.y = (z_re * this.a) + this.y0;
return p;
}
/**
New Zealand Map Grid Inverse - x/y to long/lat
*/
export function inverse(p) {
var n;
var x = p.x;
var y = p.y;
var delta_x = x - this.x0;
var delta_y = y - this.y0;
// 1. Calculate z
var z_re = delta_y / this.a;
var z_im = delta_x / this.a;
// 2a. Calculate theta - first approximation gives km accuracy
var z_n_re = 1;
var z_n_im = 0; // z^0
var z_n_re1;
var z_n_im1;
var th_re = 0;
var th_im = 0;
for (n = 1; n <= 6; n++) {
z_n_re1 = z_n_re * z_re - z_n_im * z_im;
z_n_im1 = z_n_im * z_re + z_n_re * z_im;
z_n_re = z_n_re1;
z_n_im = z_n_im1;
th_re = th_re + this.C_re[n] * z_n_re - this.C_im[n] * z_n_im;
th_im = th_im + this.C_im[n] * z_n_re + this.C_re[n] * z_n_im;
}
// 2b. Iterate to refine the accuracy of the calculation
// 0 iterations gives km accuracy
// 1 iteration gives m accuracy -- good enough for most mapping applications
// 2 iterations bives mm accuracy
for (var i = 0; i < this.iterations; i++) {
var th_n_re = th_re;
var th_n_im = th_im;
var th_n_re1;
var th_n_im1;
var num_re = z_re;
var num_im = z_im;
for (n = 2; n <= 6; n++) {
th_n_re1 = th_n_re * th_re - th_n_im * th_im;
th_n_im1 = th_n_im * th_re + th_n_re * th_im;
th_n_re = th_n_re1;
th_n_im = th_n_im1;
num_re = num_re + (n - 1) * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
num_im = num_im + (n - 1) * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
}
th_n_re = 1;
th_n_im = 0;
var den_re = this.B_re[1];
var den_im = this.B_im[1];
for (n = 2; n <= 6; n++) {
th_n_re1 = th_n_re * th_re - th_n_im * th_im;
th_n_im1 = th_n_im * th_re + th_n_re * th_im;
th_n_re = th_n_re1;
th_n_im = th_n_im1;
den_re = den_re + n * (this.B_re[n] * th_n_re - this.B_im[n] * th_n_im);
den_im = den_im + n * (this.B_im[n] * th_n_re + this.B_re[n] * th_n_im);
}
// Complex division
var den2 = den_re * den_re + den_im * den_im;
th_re = (num_re * den_re + num_im * den_im) / den2;
th_im = (num_im * den_re - num_re * den_im) / den2;
}
// 3. Calculate d_phi ... // and d_lambda
var d_psi = th_re;
var d_lambda = th_im;
var d_psi_n = 1; // d_psi^0
var d_phi = 0;
for (n = 1; n <= 9; n++) {
d_psi_n = d_psi_n * d_psi;
d_phi = d_phi + this.D[n] * d_psi_n;
}
// 4. Calculate latitude and longitude
// d_phi is calcuated in second of arc * 10^-5, so we need to scale back to radians. d_lambda is in radians.
var lat = this.lat0 + (d_phi * SEC_TO_RAD * 1E5);
var lon = this.long0 + d_lambda;
p.x = lon;
p.y = lat;
return p;
}
export var names = ["New_Zealand_Map_Grid", "nzmg"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

241
node_modules/proj4/lib/projections/omerc.js generated vendored Normal file
View file

@ -0,0 +1,241 @@
import tsfnz from '../common/tsfnz';
import adjust_lon from '../common/adjust_lon';
import phi2z from '../common/phi2z';
import { D2R, EPSLN, HALF_PI, TWO_PI, FORTPI } from '../constants/values';
var TOL = 1e-7;
function isTypeA(P) {
var typeAProjections = ['Hotine_Oblique_Mercator','Hotine_Oblique_Mercator_Azimuth_Natural_Origin'];
var projectionName = typeof P.PROJECTION === "object" ? Object.keys(P.PROJECTION)[0] : P.PROJECTION;
return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1;
}
/* Initialize the Oblique Mercator projection
------------------------------------------*/
export function init() {
var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0,
gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0, AB;
// only Type A uses the no_off or no_uoff property
// https://github.com/OSGeo/proj.4/issues/104
this.no_off = isTypeA(this);
this.no_rot = 'no_rot' in this;
var alp = false;
if ("alpha" in this) {
alp = true;
}
var gam = false;
if ("rectified_grid_angle" in this) {
gam = true;
}
if (alp) {
alpha_c = this.alpha;
}
if (gam) {
gamma = (this.rectified_grid_angle * D2R);
}
if (alp || gam) {
lamc = this.longc;
} else {
lam1 = this.long1;
phi1 = this.lat1;
lam2 = this.long2;
phi2 = this.lat2;
if (Math.abs(phi1 - phi2) <= TOL || (con = Math.abs(phi1)) <= TOL ||
Math.abs(con - HALF_PI) <= TOL || Math.abs(Math.abs(this.lat0) - HALF_PI) <= TOL ||
Math.abs(Math.abs(phi2) - HALF_PI) <= TOL) {
throw new Error();
}
}
var one_es = 1.0 - this.es;
com = Math.sqrt(one_es);
if (Math.abs(this.lat0) > EPSLN) {
sinph0 = Math.sin(this.lat0);
cosph0 = Math.cos(this.lat0);
con = 1 - this.es * sinph0 * sinph0;
this.B = cosph0 * cosph0;
this.B = Math.sqrt(1 + this.es * this.B * this.B / one_es);
this.A = this.B * this.k0 * com / con;
D = this.B * com / (cosph0 * Math.sqrt(con));
F = D * D -1;
if (F <= 0) {
F = 0;
} else {
F = Math.sqrt(F);
if (this.lat0 < 0) {
F = -F;
}
}
this.E = F += D;
this.E *= Math.pow(tsfnz(this.e, this.lat0, sinph0), this.B);
} else {
this.B = 1 / com;
this.A = this.k0;
this.E = D = F = 1;
}
if (alp || gam) {
if (alp) {
gamma0 = Math.asin(Math.sin(alpha_c) / D);
if (!gam) {
gamma = alpha_c;
}
} else {
gamma0 = gamma;
alpha_c = Math.asin(D * Math.sin(gamma0));
}
this.lam0 = lamc - Math.asin(0.5 * (F - 1 / F) * Math.tan(gamma0)) / this.B;
} else {
H = Math.pow(tsfnz(this.e, phi1, Math.sin(phi1)), this.B);
L = Math.pow(tsfnz(this.e, phi2, Math.sin(phi2)), this.B);
F = this.E / H;
p = (L - H) / (L + H);
J = this.E * this.E;
J = (J - L * H) / (J + L * H);
con = lam1 - lam2;
if (con < -Math.pi) {
lam2 -=TWO_PI;
} else if (con > Math.pi) {
lam2 += TWO_PI;
}
this.lam0 = adjust_lon(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B);
gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon(lam1 - this.lam0)) / (F - 1 / F));
gamma = alpha_c = Math.asin(D * Math.sin(gamma0));
}
this.singam = Math.sin(gamma0);
this.cosgam = Math.cos(gamma0);
this.sinrot = Math.sin(gamma);
this.cosrot = Math.cos(gamma);
this.rB = 1 / this.B;
this.ArB = this.A * this.rB;
this.BrA = 1 / this.ArB;
AB = this.A * this.B;
if (this.no_off) {
this.u_0 = 0;
} else {
this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(D * D - 1) / Math.cos(alpha_c)));
if (this.lat0 < 0) {
this.u_0 = - this.u_0;
}
}
F = 0.5 * gamma0;
this.v_pole_n = this.ArB * Math.log(Math.tan(FORTPI - F));
this.v_pole_s = this.ArB * Math.log(Math.tan(FORTPI + F));
}
/* Oblique Mercator forward equations--mapping lat,long to x,y
----------------------------------------------------------*/
export function forward(p) {
var coords = {};
var S, T, U, V, W, temp, u, v;
p.x = p.x - this.lam0;
if (Math.abs(Math.abs(p.y) - HALF_PI) > EPSLN) {
W = this.E / Math.pow(tsfnz(this.e, p.y, Math.sin(p.y)), this.B);
temp = 1 / W;
S = 0.5 * (W - temp);
T = 0.5 * (W + temp);
V = Math.sin(this.B * p.x);
U = (S * this.singam - V * this.cosgam) / T;
if (Math.abs(Math.abs(U) - 1.0) < EPSLN) {
throw new Error();
}
v = 0.5 * this.ArB * Math.log((1 - U)/(1 + U));
temp = Math.cos(this.B * p.x);
if (Math.abs(temp) < TOL) {
u = this.A * p.x;
} else {
u = this.ArB * Math.atan2((S * this.cosgam + V * this.singam), temp);
}
} else {
v = p.y > 0 ? this.v_pole_n : this.v_pole_s;
u = this.ArB * p.y;
}
if (this.no_rot) {
coords.x = u;
coords.y = v;
} else {
u -= this.u_0;
coords.x = v * this.cosrot + u * this.sinrot;
coords.y = u * this.cosrot - v * this.sinrot;
}
coords.x = (this.a * coords.x + this.x0);
coords.y = (this.a * coords.y + this.y0);
return coords;
}
export function inverse(p) {
var u, v, Qp, Sp, Tp, Vp, Up;
var coords = {};
p.x = (p.x - this.x0) * (1.0 / this.a);
p.y = (p.y - this.y0) * (1.0 / this.a);
if (this.no_rot) {
v = p.y;
u = p.x;
} else {
v = p.x * this.cosrot - p.y * this.sinrot;
u = p.y * this.cosrot + p.x * this.sinrot + this.u_0;
}
Qp = Math.exp(-this.BrA * v);
Sp = 0.5 * (Qp - 1 / Qp);
Tp = 0.5 * (Qp + 1 / Qp);
Vp = Math.sin(this.BrA * u);
Up = (Vp * this.cosgam + Sp * this.singam) / Tp;
if (Math.abs(Math.abs(Up) - 1) < EPSLN) {
coords.x = 0;
coords.y = Up < 0 ? -HALF_PI : HALF_PI;
} else {
coords.y = this.E / Math.sqrt((1 + Up) / (1 - Up));
coords.y = phi2z(this.e, Math.pow(coords.y, 1 / this.B));
if (coords.y === Infinity) {
throw new Error();
}
coords.x = -this.rB * Math.atan2((Sp * this.cosgam - Vp * this.singam), Math.cos(this.BrA * u));
}
coords.x += this.lam0;
return coords;
}
export var names = ["Hotine_Oblique_Mercator", "Hotine Oblique Mercator", "Hotine_Oblique_Mercator_Azimuth_Natural_Origin", "Hotine_Oblique_Mercator_Two_Point_Natural_Origin", "Hotine_Oblique_Mercator_Azimuth_Center", "Oblique_Mercator", "omerc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

91
node_modules/proj4/lib/projections/ortho.js generated vendored Normal file
View file

@ -0,0 +1,91 @@
import adjust_lon from '../common/adjust_lon';
import asinz from '../common/asinz';
import {EPSLN, HALF_PI} from '../constants/values';
export function init() {
//double temp; /* temporary variable */
/* Place parameters in static storage for common use
-------------------------------------------------*/
this.sin_p14 = Math.sin(this.lat0);
this.cos_p14 = Math.cos(this.lat0);
}
/* Orthographic forward equations--mapping lat,long to x,y
---------------------------------------------------*/
export function forward(p) {
var sinphi, cosphi; /* sin and cos value */
var dlon; /* delta longitude value */
var coslon; /* cos of longitude */
var ksp; /* scale factor */
var g, x, y;
var lon = p.x;
var lat = p.y;
/* Forward equations
-----------------*/
dlon = adjust_lon(lon - this.long0);
sinphi = Math.sin(lat);
cosphi = Math.cos(lat);
coslon = Math.cos(dlon);
g = this.sin_p14 * sinphi + this.cos_p14 * cosphi * coslon;
ksp = 1;
if ((g > 0) || (Math.abs(g) <= EPSLN)) {
x = this.a * ksp * cosphi * Math.sin(dlon);
y = this.y0 + this.a * ksp * (this.cos_p14 * sinphi - this.sin_p14 * cosphi * coslon);
}
p.x = x;
p.y = y;
return p;
}
export function inverse(p) {
var rh; /* height above ellipsoid */
var z; /* angle */
var sinz, cosz; /* sin of z and cos of z */
var con;
var lon, lat;
/* Inverse equations
-----------------*/
p.x -= this.x0;
p.y -= this.y0;
rh = Math.sqrt(p.x * p.x + p.y * p.y);
z = asinz(rh / this.a);
sinz = Math.sin(z);
cosz = Math.cos(z);
lon = this.long0;
if (Math.abs(rh) <= EPSLN) {
lat = this.lat0;
p.x = lon;
p.y = lat;
return p;
}
lat = asinz(cosz * this.sin_p14 + (p.y * sinz * this.cos_p14) / rh);
con = Math.abs(this.lat0) - HALF_PI;
if (Math.abs(con) <= EPSLN) {
if (this.lat0 >= 0) {
lon = adjust_lon(this.long0 + Math.atan2(p.x, - p.y));
}
else {
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
}
p.x = lon;
p.y = lat;
return p;
}
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz), rh * this.cos_p14 * cosz - p.y * this.sin_p14 * sinz));
p.x = lon;
p.y = lat;
return p;
}
export var names = ["ortho"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

135
node_modules/proj4/lib/projections/poly.js generated vendored Normal file
View file

@ -0,0 +1,135 @@
import e0fn from '../common/e0fn';
import e1fn from '../common/e1fn';
import e2fn from '../common/e2fn';
import e3fn from '../common/e3fn';
import adjust_lon from '../common/adjust_lon';
import adjust_lat from '../common/adjust_lat';
import mlfn from '../common/mlfn';
import {EPSLN} from '../constants/values';
import gN from '../common/gN';
var MAX_ITER = 20;
export function init() {
/* Place parameters in static storage for common use
-------------------------------------------------*/
this.temp = this.b / this.a;
this.es = 1 - Math.pow(this.temp, 2); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles
this.e = Math.sqrt(this.es);
this.e0 = e0fn(this.es);
this.e1 = e1fn(this.es);
this.e2 = e2fn(this.es);
this.e3 = e3fn(this.es);
this.ml0 = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, this.lat0); //si que des zeros le calcul ne se fait pas
}
/* Polyconic forward equations--mapping lat,long to x,y
---------------------------------------------------*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
var x, y, el;
var dlon = adjust_lon(lon - this.long0);
el = dlon * Math.sin(lat);
if (this.sphere) {
if (Math.abs(lat) <= EPSLN) {
x = this.a * dlon;
y = -1 * this.a * this.lat0;
}
else {
x = this.a * Math.sin(el) / Math.tan(lat);
y = this.a * (adjust_lat(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat));
}
}
else {
if (Math.abs(lat) <= EPSLN) {
x = this.a * dlon;
y = -1 * this.ml0;
}
else {
var nl = gN(this.a, this.e, Math.sin(lat)) / Math.tan(lat);
x = nl * Math.sin(el);
y = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el));
}
}
p.x = x + this.x0;
p.y = y + this.y0;
return p;
}
/* Inverse equations
-----------------*/
export function inverse(p) {
var lon, lat, x, y, i;
var al, bl;
var phi, dphi;
x = p.x - this.x0;
y = p.y - this.y0;
if (this.sphere) {
if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
lon = adjust_lon(x / this.a + this.long0);
lat = 0;
}
else {
al = this.lat0 + y / this.a;
bl = x * x / this.a / this.a + al * al;
phi = al;
var tanphi;
for (i = MAX_ITER; i; --i) {
tanphi = Math.tan(phi);
dphi = -1 * (al * (phi * tanphi + 1) - phi - 0.5 * (phi * phi + bl) * tanphi) / ((phi - al) / tanphi - 1);
phi += dphi;
if (Math.abs(dphi) <= EPSLN) {
lat = phi;
break;
}
}
lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));
}
}
else {
if (Math.abs(y + this.ml0) <= EPSLN) {
lat = 0;
lon = adjust_lon(this.long0 + x / this.a);
}
else {
al = (this.ml0 + y) / this.a;
bl = x * x / this.a / this.a + al * al;
phi = al;
var cl, mln, mlnp, ma;
var con;
for (i = MAX_ITER; i; --i) {
con = this.e * Math.sin(phi);
cl = Math.sqrt(1 - con * con) * Math.tan(phi);
mln = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, phi);
mlnp = this.e0 - 2 * this.e1 * Math.cos(2 * phi) + 4 * this.e2 * Math.cos(4 * phi) - 6 * this.e3 * Math.cos(6 * phi);
ma = mln / this.a;
dphi = (al * (cl * ma + 1) - ma - 0.5 * cl * (ma * ma + bl)) / (this.es * Math.sin(2 * phi) * (ma * ma + bl - 2 * al * ma) / (4 * cl) + (al - ma) * (cl * mlnp - 2 / Math.sin(2 * phi)) - mlnp);
phi -= dphi;
if (Math.abs(dphi) <= EPSLN) {
lat = phi;
break;
}
}
//lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
}
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Polyconic", "poly"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

368
node_modules/proj4/lib/projections/qsc.js generated vendored Normal file
View file

@ -0,0 +1,368 @@
// QSC projection rewritten from the original PROJ4
// https://github.com/OSGeo/proj.4/blob/master/src/PJ_qsc.c
import {EPSLN, TWO_PI, SPI, HALF_PI, FORTPI} from '../constants/values';
/* constants */
var FACE_ENUM = {
FRONT: 1,
RIGHT: 2,
BACK: 3,
LEFT: 4,
TOP: 5,
BOTTOM: 6
};
var AREA_ENUM = {
AREA_0: 1,
AREA_1: 2,
AREA_2: 3,
AREA_3: 4
};
export function init() {
this.x0 = this.x0 || 0;
this.y0 = this.y0 || 0;
this.lat0 = this.lat0 || 0;
this.long0 = this.long0 || 0;
this.lat_ts = this.lat_ts || 0;
this.title = this.title || "Quadrilateralized Spherical Cube";
/* Determine the cube face from the center of projection. */
if (this.lat0 >= HALF_PI - FORTPI / 2.0) {
this.face = FACE_ENUM.TOP;
} else if (this.lat0 <= -(HALF_PI - FORTPI / 2.0)) {
this.face = FACE_ENUM.BOTTOM;
} else if (Math.abs(this.long0) <= FORTPI) {
this.face = FACE_ENUM.FRONT;
} else if (Math.abs(this.long0) <= HALF_PI + FORTPI) {
this.face = this.long0 > 0.0 ? FACE_ENUM.RIGHT : FACE_ENUM.LEFT;
} else {
this.face = FACE_ENUM.BACK;
}
/* Fill in useful values for the ellipsoid <-> sphere shift
* described in [LK12]. */
if (this.es !== 0) {
this.one_minus_f = 1 - (this.a - this.b) / this.a;
this.one_minus_f_squared = this.one_minus_f * this.one_minus_f;
}
}
// QSC forward equations--mapping lat,long to x,y
// -----------------------------------------------------------------
export function forward(p) {
var xy = {x: 0, y: 0};
var lat, lon;
var theta, phi;
var t, mu;
/* nu; */
var area = {value: 0};
// move lon according to projection's lon
p.x -= this.long0;
/* Convert the geodetic latitude to a geocentric latitude.
* This corresponds to the shift from the ellipsoid to the sphere
* described in [LK12]. */
if (this.es !== 0) {//if (P->es != 0) {
lat = Math.atan(this.one_minus_f_squared * Math.tan(p.y));
} else {
lat = p.y;
}
/* Convert the input lat, lon into theta, phi as used by QSC.
* This depends on the cube face and the area on it.
* For the top and bottom face, we can compute theta and phi
* directly from phi, lam. For the other faces, we must use
* unit sphere cartesian coordinates as an intermediate step. */
lon = p.x; //lon = lp.lam;
if (this.face === FACE_ENUM.TOP) {
phi = HALF_PI - lat;
if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {
area.value = AREA_ENUM.AREA_0;
theta = lon - HALF_PI;
} else if (lon > HALF_PI + FORTPI || lon <= -(HALF_PI + FORTPI)) {
area.value = AREA_ENUM.AREA_1;
theta = (lon > 0.0 ? lon - SPI : lon + SPI);
} else if (lon > -(HALF_PI + FORTPI) && lon <= -FORTPI) {
area.value = AREA_ENUM.AREA_2;
theta = lon + HALF_PI;
} else {
area.value = AREA_ENUM.AREA_3;
theta = lon;
}
} else if (this.face === FACE_ENUM.BOTTOM) {
phi = HALF_PI + lat;
if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {
area.value = AREA_ENUM.AREA_0;
theta = -lon + HALF_PI;
} else if (lon < FORTPI && lon >= -FORTPI) {
area.value = AREA_ENUM.AREA_1;
theta = -lon;
} else if (lon < -FORTPI && lon >= -(HALF_PI + FORTPI)) {
area.value = AREA_ENUM.AREA_2;
theta = -lon - HALF_PI;
} else {
area.value = AREA_ENUM.AREA_3;
theta = (lon > 0.0 ? -lon + SPI : -lon - SPI);
}
} else {
var q, r, s;
var sinlat, coslat;
var sinlon, coslon;
if (this.face === FACE_ENUM.RIGHT) {
lon = qsc_shift_lon_origin(lon, +HALF_PI);
} else if (this.face === FACE_ENUM.BACK) {
lon = qsc_shift_lon_origin(lon, +SPI);
} else if (this.face === FACE_ENUM.LEFT) {
lon = qsc_shift_lon_origin(lon, -HALF_PI);
}
sinlat = Math.sin(lat);
coslat = Math.cos(lat);
sinlon = Math.sin(lon);
coslon = Math.cos(lon);
q = coslat * coslon;
r = coslat * sinlon;
s = sinlat;
if (this.face === FACE_ENUM.FRONT) {
phi = Math.acos(q);
theta = qsc_fwd_equat_face_theta(phi, s, r, area);
} else if (this.face === FACE_ENUM.RIGHT) {
phi = Math.acos(r);
theta = qsc_fwd_equat_face_theta(phi, s, -q, area);
} else if (this.face === FACE_ENUM.BACK) {
phi = Math.acos(-q);
theta = qsc_fwd_equat_face_theta(phi, s, -r, area);
} else if (this.face === FACE_ENUM.LEFT) {
phi = Math.acos(-r);
theta = qsc_fwd_equat_face_theta(phi, s, q, area);
} else {
/* Impossible */
phi = theta = 0;
area.value = AREA_ENUM.AREA_0;
}
}
/* Compute mu and nu for the area of definition.
* For mu, see Eq. (3-21) in [OL76], but note the typos:
* compare with Eq. (3-14). For nu, see Eq. (3-38). */
mu = Math.atan((12 / SPI) * (theta + Math.acos(Math.sin(theta) * Math.cos(FORTPI)) - HALF_PI));
t = Math.sqrt((1 - Math.cos(phi)) / (Math.cos(mu) * Math.cos(mu)) / (1 - Math.cos(Math.atan(1 / Math.cos(theta)))));
/* Apply the result to the real area. */
if (area.value === AREA_ENUM.AREA_1) {
mu += HALF_PI;
} else if (area.value === AREA_ENUM.AREA_2) {
mu += SPI;
} else if (area.value === AREA_ENUM.AREA_3) {
mu += 1.5 * SPI;
}
/* Now compute x, y from mu and nu */
xy.x = t * Math.cos(mu);
xy.y = t * Math.sin(mu);
xy.x = xy.x * this.a + this.x0;
xy.y = xy.y * this.a + this.y0;
p.x = xy.x;
p.y = xy.y;
return p;
}
// QSC inverse equations--mapping x,y to lat/long
// -----------------------------------------------------------------
export function inverse(p) {
var lp = {lam: 0, phi: 0};
var mu, nu, cosmu, tannu;
var tantheta, theta, cosphi, phi;
var t;
var area = {value: 0};
/* de-offset */
p.x = (p.x - this.x0) / this.a;
p.y = (p.y - this.y0) / this.a;
/* Convert the input x, y to the mu and nu angles as used by QSC.
* This depends on the area of the cube face. */
nu = Math.atan(Math.sqrt(p.x * p.x + p.y * p.y));
mu = Math.atan2(p.y, p.x);
if (p.x >= 0.0 && p.x >= Math.abs(p.y)) {
area.value = AREA_ENUM.AREA_0;
} else if (p.y >= 0.0 && p.y >= Math.abs(p.x)) {
area.value = AREA_ENUM.AREA_1;
mu -= HALF_PI;
} else if (p.x < 0.0 && -p.x >= Math.abs(p.y)) {
area.value = AREA_ENUM.AREA_2;
mu = (mu < 0.0 ? mu + SPI : mu - SPI);
} else {
area.value = AREA_ENUM.AREA_3;
mu += HALF_PI;
}
/* Compute phi and theta for the area of definition.
* The inverse projection is not described in the original paper, but some
* good hints can be found here (as of 2011-12-14):
* http://fits.gsfc.nasa.gov/fitsbits/saf.93/saf.9302
* (search for "Message-Id: <9302181759.AA25477 at fits.cv.nrao.edu>") */
t = (SPI / 12) * Math.tan(mu);
tantheta = Math.sin(t) / (Math.cos(t) - (1 / Math.sqrt(2)));
theta = Math.atan(tantheta);
cosmu = Math.cos(mu);
tannu = Math.tan(nu);
cosphi = 1 - cosmu * cosmu * tannu * tannu * (1 - Math.cos(Math.atan(1 / Math.cos(theta))));
if (cosphi < -1) {
cosphi = -1;
} else if (cosphi > +1) {
cosphi = +1;
}
/* Apply the result to the real area on the cube face.
* For the top and bottom face, we can compute phi and lam directly.
* For the other faces, we must use unit sphere cartesian coordinates
* as an intermediate step. */
if (this.face === FACE_ENUM.TOP) {
phi = Math.acos(cosphi);
lp.phi = HALF_PI - phi;
if (area.value === AREA_ENUM.AREA_0) {
lp.lam = theta + HALF_PI;
} else if (area.value === AREA_ENUM.AREA_1) {
lp.lam = (theta < 0.0 ? theta + SPI : theta - SPI);
} else if (area.value === AREA_ENUM.AREA_2) {
lp.lam = theta - HALF_PI;
} else /* area.value == AREA_ENUM.AREA_3 */ {
lp.lam = theta;
}
} else if (this.face === FACE_ENUM.BOTTOM) {
phi = Math.acos(cosphi);
lp.phi = phi - HALF_PI;
if (area.value === AREA_ENUM.AREA_0) {
lp.lam = -theta + HALF_PI;
} else if (area.value === AREA_ENUM.AREA_1) {
lp.lam = -theta;
} else if (area.value === AREA_ENUM.AREA_2) {
lp.lam = -theta - HALF_PI;
} else /* area.value == AREA_ENUM.AREA_3 */ {
lp.lam = (theta < 0.0 ? -theta - SPI : -theta + SPI);
}
} else {
/* Compute phi and lam via cartesian unit sphere coordinates. */
var q, r, s;
q = cosphi;
t = q * q;
if (t >= 1) {
s = 0;
} else {
s = Math.sqrt(1 - t) * Math.sin(theta);
}
t += s * s;
if (t >= 1) {
r = 0;
} else {
r = Math.sqrt(1 - t);
}
/* Rotate q,r,s into the correct area. */
if (area.value === AREA_ENUM.AREA_1) {
t = r;
r = -s;
s = t;
} else if (area.value === AREA_ENUM.AREA_2) {
r = -r;
s = -s;
} else if (area.value === AREA_ENUM.AREA_3) {
t = r;
r = s;
s = -t;
}
/* Rotate q,r,s into the correct cube face. */
if (this.face === FACE_ENUM.RIGHT) {
t = q;
q = -r;
r = t;
} else if (this.face === FACE_ENUM.BACK) {
q = -q;
r = -r;
} else if (this.face === FACE_ENUM.LEFT) {
t = q;
q = r;
r = -t;
}
/* Now compute phi and lam from the unit sphere coordinates. */
lp.phi = Math.acos(-s) - HALF_PI;
lp.lam = Math.atan2(r, q);
if (this.face === FACE_ENUM.RIGHT) {
lp.lam = qsc_shift_lon_origin(lp.lam, -HALF_PI);
} else if (this.face === FACE_ENUM.BACK) {
lp.lam = qsc_shift_lon_origin(lp.lam, -SPI);
} else if (this.face === FACE_ENUM.LEFT) {
lp.lam = qsc_shift_lon_origin(lp.lam, +HALF_PI);
}
}
/* Apply the shift from the sphere to the ellipsoid as described
* in [LK12]. */
if (this.es !== 0) {
var invert_sign;
var tanphi, xa;
invert_sign = (lp.phi < 0 ? 1 : 0);
tanphi = Math.tan(lp.phi);
xa = this.b / Math.sqrt(tanphi * tanphi + this.one_minus_f_squared);
lp.phi = Math.atan(Math.sqrt(this.a * this.a - xa * xa) / (this.one_minus_f * xa));
if (invert_sign) {
lp.phi = -lp.phi;
}
}
lp.lam += this.long0;
p.x = lp.lam;
p.y = lp.phi;
return p;
}
/* Helper function for forward projection: compute the theta angle
* and determine the area number. */
function qsc_fwd_equat_face_theta(phi, y, x, area) {
var theta;
if (phi < EPSLN) {
area.value = AREA_ENUM.AREA_0;
theta = 0.0;
} else {
theta = Math.atan2(y, x);
if (Math.abs(theta) <= FORTPI) {
area.value = AREA_ENUM.AREA_0;
} else if (theta > FORTPI && theta <= HALF_PI + FORTPI) {
area.value = AREA_ENUM.AREA_1;
theta -= HALF_PI;
} else if (theta > HALF_PI + FORTPI || theta <= -(HALF_PI + FORTPI)) {
area.value = AREA_ENUM.AREA_2;
theta = (theta >= 0.0 ? theta - SPI : theta + SPI);
} else {
area.value = AREA_ENUM.AREA_3;
theta += HALF_PI;
}
}
return theta;
}
/* Helper function: shift the longitude. */
function qsc_shift_lon_origin(lon, offset) {
var slon = lon + offset;
if (slon < -SPI) {
slon += TWO_PI;
} else if (slon > +SPI) {
slon -= TWO_PI;
}
return slon;
}
export var names = ["Quadrilateralized Spherical Cube", "Quadrilateralized_Spherical_Cube", "qsc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

161
node_modules/proj4/lib/projections/robin.js generated vendored Normal file
View file

@ -0,0 +1,161 @@
// Robinson projection
// Based on https://github.com/OSGeo/proj.4/blob/master/src/PJ_robin.c
// Polynomial coeficients from http://article.gmane.org/gmane.comp.gis.proj-4.devel/6039
import {HALF_PI, D2R, R2D, EPSLN} from '../constants/values';
import adjust_lon from '../common/adjust_lon';
var COEFS_X = [
[1.0000, 2.2199e-17, -7.15515e-05, 3.1103e-06],
[0.9986, -0.000482243, -2.4897e-05, -1.3309e-06],
[0.9954, -0.00083103, -4.48605e-05, -9.86701e-07],
[0.9900, -0.00135364, -5.9661e-05, 3.6777e-06],
[0.9822, -0.00167442, -4.49547e-06, -5.72411e-06],
[0.9730, -0.00214868, -9.03571e-05, 1.8736e-08],
[0.9600, -0.00305085, -9.00761e-05, 1.64917e-06],
[0.9427, -0.00382792, -6.53386e-05, -2.6154e-06],
[0.9216, -0.00467746, -0.00010457, 4.81243e-06],
[0.8962, -0.00536223, -3.23831e-05, -5.43432e-06],
[0.8679, -0.00609363, -0.000113898, 3.32484e-06],
[0.8350, -0.00698325, -6.40253e-05, 9.34959e-07],
[0.7986, -0.00755338, -5.00009e-05, 9.35324e-07],
[0.7597, -0.00798324, -3.5971e-05, -2.27626e-06],
[0.7186, -0.00851367, -7.01149e-05, -8.6303e-06],
[0.6732, -0.00986209, -0.000199569, 1.91974e-05],
[0.6213, -0.010418, 8.83923e-05, 6.24051e-06],
[0.5722, -0.00906601, 0.000182, 6.24051e-06],
[0.5322, -0.00677797, 0.000275608, 6.24051e-06]
];
var COEFS_Y = [
[-5.20417e-18, 0.0124, 1.21431e-18, -8.45284e-11],
[0.0620, 0.0124, -1.26793e-09, 4.22642e-10],
[0.1240, 0.0124, 5.07171e-09, -1.60604e-09],
[0.1860, 0.0123999, -1.90189e-08, 6.00152e-09],
[0.2480, 0.0124002, 7.10039e-08, -2.24e-08],
[0.3100, 0.0123992, -2.64997e-07, 8.35986e-08],
[0.3720, 0.0124029, 9.88983e-07, -3.11994e-07],
[0.4340, 0.0123893, -3.69093e-06, -4.35621e-07],
[0.4958, 0.0123198, -1.02252e-05, -3.45523e-07],
[0.5571, 0.0121916, -1.54081e-05, -5.82288e-07],
[0.6176, 0.0119938, -2.41424e-05, -5.25327e-07],
[0.6769, 0.011713, -3.20223e-05, -5.16405e-07],
[0.7346, 0.0113541, -3.97684e-05, -6.09052e-07],
[0.7903, 0.0109107, -4.89042e-05, -1.04739e-06],
[0.8435, 0.0103431, -6.4615e-05, -1.40374e-09],
[0.8936, 0.00969686, -6.4636e-05, -8.547e-06],
[0.9394, 0.00840947, -0.000192841, -4.2106e-06],
[0.9761, 0.00616527, -0.000256, -4.2106e-06],
[1.0000, 0.00328947, -0.000319159, -4.2106e-06]
];
var FXC = 0.8487;
var FYC = 1.3523;
var C1 = R2D/5; // rad to 5-degree interval
var RC1 = 1/C1;
var NODES = 18;
var poly3_val = function(coefs, x) {
return coefs[0] + x * (coefs[1] + x * (coefs[2] + x * coefs[3]));
};
var poly3_der = function(coefs, x) {
return coefs[1] + x * (2 * coefs[2] + x * 3 * coefs[3]);
};
function newton_rapshon(f_df, start, max_err, iters) {
var x = start;
for (; iters; --iters) {
var upd = f_df(x);
x -= upd;
if (Math.abs(upd) < max_err) {
break;
}
}
return x;
}
export function init() {
this.x0 = this.x0 || 0;
this.y0 = this.y0 || 0;
this.long0 = this.long0 || 0;
this.es = 0;
this.title = this.title || "Robinson";
}
export function forward(ll) {
var lon = adjust_lon(ll.x - this.long0);
var dphi = Math.abs(ll.y);
var i = Math.floor(dphi * C1);
if (i < 0) {
i = 0;
} else if (i >= NODES) {
i = NODES - 1;
}
dphi = R2D * (dphi - RC1 * i);
var xy = {
x: poly3_val(COEFS_X[i], dphi) * lon,
y: poly3_val(COEFS_Y[i], dphi)
};
if (ll.y < 0) {
xy.y = -xy.y;
}
xy.x = xy.x * this.a * FXC + this.x0;
xy.y = xy.y * this.a * FYC + this.y0;
return xy;
}
export function inverse(xy) {
var ll = {
x: (xy.x - this.x0) / (this.a * FXC),
y: Math.abs(xy.y - this.y0) / (this.a * FYC)
};
if (ll.y >= 1) { // pathologic case
ll.x /= COEFS_X[NODES][0];
ll.y = xy.y < 0 ? -HALF_PI : HALF_PI;
} else {
// find table interval
var i = Math.floor(ll.y * NODES);
if (i < 0) {
i = 0;
} else if (i >= NODES) {
i = NODES - 1;
}
for (;;) {
if (COEFS_Y[i][0] > ll.y) {
--i;
} else if (COEFS_Y[i+1][0] <= ll.y) {
++i;
} else {
break;
}
}
// linear interpolation in 5 degree interval
var coefs = COEFS_Y[i];
var t = 5 * (ll.y - coefs[0]) / (COEFS_Y[i+1][0] - coefs[0]);
// find t so that poly3_val(coefs, t) = ll.y
t = newton_rapshon(function(x) {
return (poly3_val(coefs, x) - ll.y) / poly3_der(coefs, x);
}, t, EPSLN, 100);
ll.x /= poly3_val(COEFS_X[i], t);
ll.y = (5 * i + t) * D2R;
if (xy.y < 0) {
ll.y = -ll.y;
}
}
ll.x = adjust_lon(ll.x + this.long0);
return ll;
}
export var names = ["Robinson", "robin"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

115
node_modules/proj4/lib/projections/sinu.js generated vendored Normal file
View file

@ -0,0 +1,115 @@
import adjust_lon from '../common/adjust_lon';
import adjust_lat from '../common/adjust_lat';
import pj_enfn from '../common/pj_enfn';
var MAX_ITER = 20;
import pj_mlfn from '../common/pj_mlfn';
import pj_inv_mlfn from '../common/pj_inv_mlfn';
import {EPSLN, HALF_PI} from '../constants/values';
import asinz from '../common/asinz';
export function init() {
/* Place parameters in static storage for common use
-------------------------------------------------*/
if (!this.sphere) {
this.en = pj_enfn(this.es);
}
else {
this.n = 1;
this.m = 0;
this.es = 0;
this.C_y = Math.sqrt((this.m + 1) / this.n);
this.C_x = this.C_y / (this.m + 1);
}
}
/* Sinusoidal forward equations--mapping lat,long to x,y
-----------------------------------------------------*/
export function forward(p) {
var x, y;
var lon = p.x;
var lat = p.y;
/* Forward equations
-----------------*/
lon = adjust_lon(lon - this.long0);
if (this.sphere) {
if (!this.m) {
lat = this.n !== 1 ? Math.asin(this.n * Math.sin(lat)) : lat;
}
else {
var k = this.n * Math.sin(lat);
for (var i = MAX_ITER; i; --i) {
var V = (this.m * lat + Math.sin(lat) - k) / (this.m + Math.cos(lat));
lat -= V;
if (Math.abs(V) < EPSLN) {
break;
}
}
}
x = this.a * this.C_x * lon * (this.m + Math.cos(lat));
y = this.a * this.C_y * lat;
}
else {
var s = Math.sin(lat);
var c = Math.cos(lat);
y = this.a * pj_mlfn(lat, s, c, this.en);
x = this.a * lon * c / Math.sqrt(1 - this.es * s * s);
}
p.x = x;
p.y = y;
return p;
}
export function inverse(p) {
var lat, temp, lon, s;
p.x -= this.x0;
lon = p.x / this.a;
p.y -= this.y0;
lat = p.y / this.a;
if (this.sphere) {
lat /= this.C_y;
lon = lon / (this.C_x * (this.m + Math.cos(lat)));
if (this.m) {
lat = asinz((this.m * lat + Math.sin(lat)) / this.n);
}
else if (this.n !== 1) {
lat = asinz(Math.sin(lat) / this.n);
}
lon = adjust_lon(lon + this.long0);
lat = adjust_lat(lat);
}
else {
lat = pj_inv_mlfn(p.y / this.a, this.es, this.en);
s = Math.abs(lat);
if (s < HALF_PI) {
s = Math.sin(lat);
temp = this.long0 + p.x * Math.sqrt(1 - this.es * s * s) / (this.a * Math.cos(lat));
//temp = this.long0 + p.x / (this.a * Math.cos(lat));
lon = adjust_lon(temp);
}
else if ((s - EPSLN) < HALF_PI) {
lon = this.long0;
}
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Sinusoidal", "sinu"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

86
node_modules/proj4/lib/projections/somerc.js generated vendored Normal file
View file

@ -0,0 +1,86 @@
/*
references:
Formules et constantes pour le Calcul pour la
projection cylindrique conforme à axe oblique et pour la transformation entre
des systèmes de référence.
http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
*/
export function init() {
var phy0 = this.lat0;
this.lambda0 = this.long0;
var sinPhy0 = Math.sin(phy0);
var semiMajorAxis = this.a;
var invF = this.rf;
var flattening = 1 / invF;
var e2 = 2 * flattening - Math.pow(flattening, 2);
var e = this.e = Math.sqrt(e2);
this.R = this.k0 * semiMajorAxis * Math.sqrt(1 - e2) / (1 - e2 * Math.pow(sinPhy0, 2));
this.alpha = Math.sqrt(1 + e2 / (1 - e2) * Math.pow(Math.cos(phy0), 4));
this.b0 = Math.asin(sinPhy0 / this.alpha);
var k1 = Math.log(Math.tan(Math.PI / 4 + this.b0 / 2));
var k2 = Math.log(Math.tan(Math.PI / 4 + phy0 / 2));
var k3 = Math.log((1 + e * sinPhy0) / (1 - e * sinPhy0));
this.K = k1 - this.alpha * k2 + this.alpha * e / 2 * k3;
}
export function forward(p) {
var Sa1 = Math.log(Math.tan(Math.PI / 4 - p.y / 2));
var Sa2 = this.e / 2 * Math.log((1 + this.e * Math.sin(p.y)) / (1 - this.e * Math.sin(p.y)));
var S = -this.alpha * (Sa1 + Sa2) + this.K;
// spheric latitude
var b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4);
// spheric longitude
var I = this.alpha * (p.x - this.lambda0);
// psoeudo equatorial rotation
var rotI = Math.atan(Math.sin(I) / (Math.sin(this.b0) * Math.tan(b) + Math.cos(this.b0) * Math.cos(I)));
var rotB = Math.asin(Math.cos(this.b0) * Math.sin(b) - Math.sin(this.b0) * Math.cos(b) * Math.cos(I));
p.y = this.R / 2 * Math.log((1 + Math.sin(rotB)) / (1 - Math.sin(rotB))) + this.y0;
p.x = this.R * rotI + this.x0;
return p;
}
export function inverse(p) {
var Y = p.x - this.x0;
var X = p.y - this.y0;
var rotI = Y / this.R;
var rotB = 2 * (Math.atan(Math.exp(X / this.R)) - Math.PI / 4);
var b = Math.asin(Math.cos(this.b0) * Math.sin(rotB) + Math.sin(this.b0) * Math.cos(rotB) * Math.cos(rotI));
var I = Math.atan(Math.sin(rotI) / (Math.cos(this.b0) * Math.cos(rotI) - Math.sin(this.b0) * Math.tan(rotB)));
var lambda = this.lambda0 + I / this.alpha;
var S = 0;
var phy = b;
var prevPhy = -1000;
var iteration = 0;
while (Math.abs(phy - prevPhy) > 0.0000001) {
if (++iteration > 20) {
//...reportError("omercFwdInfinity");
return;
}
//S = Math.log(Math.tan(Math.PI / 4 + phy / 2));
S = 1 / this.alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - this.K) + this.e * Math.log(Math.tan(Math.PI / 4 + Math.asin(this.e * Math.sin(phy)) / 2));
prevPhy = phy;
phy = 2 * Math.atan(Math.exp(S)) - Math.PI / 2;
}
p.x = lambda;
p.y = phy;
return p;
}
export var names = ["somerc"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

174
node_modules/proj4/lib/projections/stere.js generated vendored Normal file
View file

@ -0,0 +1,174 @@
import {EPSLN, HALF_PI} from '../constants/values';
import sign from '../common/sign';
import msfnz from '../common/msfnz';
import tsfnz from '../common/tsfnz';
import phi2z from '../common/phi2z';
import adjust_lon from '../common/adjust_lon';
export function ssfn_(phit, sinphi, eccen) {
sinphi *= eccen;
return (Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen));
}
export function init() {
this.coslat0 = Math.cos(this.lat0);
this.sinlat0 = Math.sin(this.lat0);
if (this.sphere) {
if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
this.k0 = 0.5 * (1 + sign(this.lat0) * Math.sin(this.lat_ts));
}
}
else {
if (Math.abs(this.coslat0) <= EPSLN) {
if (this.lat0 > 0) {
//North pole
//trace('stere:north pole');
this.con = 1;
}
else {
//South pole
//trace('stere:south pole');
this.con = -1;
}
}
this.cons = Math.sqrt(Math.pow(1 + this.e, 1 + this.e) * Math.pow(1 - this.e, 1 - this.e));
if (this.k0 === 1 && !isNaN(this.lat_ts) && Math.abs(this.coslat0) <= EPSLN) {
this.k0 = 0.5 * this.cons * msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts)) / tsfnz(this.e, this.con * this.lat_ts, this.con * Math.sin(this.lat_ts));
}
this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
this.cosX0 = Math.cos(this.X0);
this.sinX0 = Math.sin(this.X0);
}
}
// Stereographic forward equations--mapping lat,long to x,y
export function forward(p) {
var lon = p.x;
var lat = p.y;
var sinlat = Math.sin(lat);
var coslat = Math.cos(lat);
var A, X, sinX, cosX, ts, rh;
var dlon = adjust_lon(lon - this.long0);
if (Math.abs(Math.abs(lon - this.long0) - Math.PI) <= EPSLN && Math.abs(lat + this.lat0) <= EPSLN) {
//case of the origine point
//trace('stere:this is the origin point');
p.x = NaN;
p.y = NaN;
return p;
}
if (this.sphere) {
//trace('stere:sphere case');
A = 2 * this.k0 / (1 + this.sinlat0 * sinlat + this.coslat0 * coslat * Math.cos(dlon));
p.x = this.a * A * coslat * Math.sin(dlon) + this.x0;
p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;
return p;
}
else {
X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI;
cosX = Math.cos(X);
sinX = Math.sin(X);
if (Math.abs(this.coslat0) <= EPSLN) {
ts = tsfnz(this.e, lat * this.con, this.con * sinlat);
rh = 2 * this.a * this.k0 * ts / this.cons;
p.x = this.x0 + rh * Math.sin(lon - this.long0);
p.y = this.y0 - this.con * rh * Math.cos(lon - this.long0);
//trace(p.toString());
return p;
}
else if (Math.abs(this.sinlat0) < EPSLN) {
//Eq
//trace('stere:equateur');
A = 2 * this.a * this.k0 / (1 + cosX * Math.cos(dlon));
p.y = A * sinX;
}
else {
//other case
//trace('stere:normal case');
A = 2 * this.a * this.k0 * this.ms1 / (this.cosX0 * (1 + this.sinX0 * sinX + this.cosX0 * cosX * Math.cos(dlon)));
p.y = A * (this.cosX0 * sinX - this.sinX0 * cosX * Math.cos(dlon)) + this.y0;
}
p.x = A * cosX * Math.sin(dlon) + this.x0;
}
//trace(p.toString());
return p;
}
//* Stereographic inverse equations--mapping x,y to lat/long
export function inverse(p) {
p.x -= this.x0;
p.y -= this.y0;
var lon, lat, ts, ce, Chi;
var rh = Math.sqrt(p.x * p.x + p.y * p.y);
if (this.sphere) {
var c = 2 * Math.atan(rh / (2 * this.a * this.k0));
lon = this.long0;
lat = this.lat0;
if (rh <= EPSLN) {
p.x = lon;
p.y = lat;
return p;
}
lat = Math.asin(Math.cos(c) * this.sinlat0 + p.y * Math.sin(c) * this.coslat0 / rh);
if (Math.abs(this.coslat0) < EPSLN) {
if (this.lat0 > 0) {
lon = adjust_lon(this.long0 + Math.atan2(p.x, - 1 * p.y));
}
else {
lon = adjust_lon(this.long0 + Math.atan2(p.x, p.y));
}
}
else {
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(c), rh * this.coslat0 * Math.cos(c) - p.y * this.sinlat0 * Math.sin(c)));
}
p.x = lon;
p.y = lat;
return p;
}
else {
if (Math.abs(this.coslat0) <= EPSLN) {
if (rh <= EPSLN) {
lat = this.lat0;
lon = this.long0;
p.x = lon;
p.y = lat;
//trace(p.toString());
return p;
}
p.x *= this.con;
p.y *= this.con;
ts = rh * this.cons / (2 * this.a * this.k0);
lat = this.con * phi2z(this.e, ts);
lon = this.con * adjust_lon(this.con * this.long0 + Math.atan2(p.x, - 1 * p.y));
}
else {
ce = 2 * Math.atan(rh * this.cosX0 / (2 * this.a * this.k0 * this.ms1));
lon = this.long0;
if (rh <= EPSLN) {
Chi = this.X0;
}
else {
Chi = Math.asin(Math.cos(ce) * this.sinX0 + p.y * Math.sin(ce) * this.cosX0 / rh);
lon = adjust_lon(this.long0 + Math.atan2(p.x * Math.sin(ce), rh * this.cosX0 * Math.cos(ce) - p.y * this.sinX0 * Math.sin(ce)));
}
lat = -1 * phi2z(this.e, Math.tan(0.5 * (HALF_PI + Chi)));
}
}
p.x = lon;
p.y = lat;
//trace(p.toString());
return p;
}
export var names = ["stere", "Stereographic_South_Pole", "Polar Stereographic (variant B)"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names,
ssfn_: ssfn_
};

64
node_modules/proj4/lib/projections/sterea.js generated vendored Normal file
View file

@ -0,0 +1,64 @@
import gauss from './gauss';
import adjust_lon from '../common/adjust_lon';
export function init() {
gauss.init.apply(this);
if (!this.rc) {
return;
}
this.sinc0 = Math.sin(this.phic0);
this.cosc0 = Math.cos(this.phic0);
this.R2 = 2 * this.rc;
if (!this.title) {
this.title = "Oblique Stereographic Alternative";
}
}
export function forward(p) {
var sinc, cosc, cosl, k;
p.x = adjust_lon(p.x - this.long0);
gauss.forward.apply(this, [p]);
sinc = Math.sin(p.y);
cosc = Math.cos(p.y);
cosl = Math.cos(p.x);
k = this.k0 * this.R2 / (1 + this.sinc0 * sinc + this.cosc0 * cosc * cosl);
p.x = k * cosc * Math.sin(p.x);
p.y = k * (this.cosc0 * sinc - this.sinc0 * cosc * cosl);
p.x = this.a * p.x + this.x0;
p.y = this.a * p.y + this.y0;
return p;
}
export function inverse(p) {
var sinc, cosc, lon, lat, rho;
p.x = (p.x - this.x0) / this.a;
p.y = (p.y - this.y0) / this.a;
p.x /= this.k0;
p.y /= this.k0;
if ((rho = Math.sqrt(p.x * p.x + p.y * p.y))) {
var c = 2 * Math.atan2(rho, this.R2);
sinc = Math.sin(c);
cosc = Math.cos(c);
lat = Math.asin(cosc * this.sinc0 + p.y * sinc * this.cosc0 / rho);
lon = Math.atan2(p.x * sinc, rho * this.cosc0 * cosc - p.y * this.sinc0 * sinc);
}
else {
lat = this.phic0;
lon = 0;
}
p.x = lon;
p.y = lat;
gauss.inverse.apply(this, [p]);
p.x = adjust_lon(p.x + this.long0);
return p;
}
export var names = ["Stereographic_North_Pole", "Oblique_Stereographic", "Polar_Stereographic", "sterea","Oblique Stereographic Alternative","Double_Stereographic"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

173
node_modules/proj4/lib/projections/tmerc.js generated vendored Normal file
View file

@ -0,0 +1,173 @@
// Heavily based on this tmerc projection implementation
// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/tmerc.js
import pj_enfn from '../common/pj_enfn';
import pj_mlfn from '../common/pj_mlfn';
import pj_inv_mlfn from '../common/pj_inv_mlfn';
import adjust_lon from '../common/adjust_lon';
import {EPSLN, HALF_PI} from '../constants/values';
import sign from '../common/sign';
export function init() {
this.x0 = this.x0 !== undefined ? this.x0 : 0;
this.y0 = this.y0 !== undefined ? this.y0 : 0;
this.long0 = this.long0 !== undefined ? this.long0 : 0;
this.lat0 = this.lat0 !== undefined ? this.lat0 : 0;
if (this.es) {
this.en = pj_enfn(this.es);
this.ml0 = pj_mlfn(this.lat0, Math.sin(this.lat0), Math.cos(this.lat0), this.en);
}
}
/**
Transverse Mercator Forward - long/lat to x/y
long/lat in radians
*/
export function forward(p) {
var lon = p.x;
var lat = p.y;
var delta_lon = adjust_lon(lon - this.long0);
var con;
var x, y;
var sin_phi = Math.sin(lat);
var cos_phi = Math.cos(lat);
if (!this.es) {
var b = cos_phi * Math.sin(delta_lon);
if ((Math.abs(Math.abs(b) - 1)) < EPSLN) {
return (93);
}
else {
x = 0.5 * this.a * this.k0 * Math.log((1 + b) / (1 - b)) + this.x0;
y = cos_phi * Math.cos(delta_lon) / Math.sqrt(1 - Math.pow(b, 2));
b = Math.abs(y);
if (b >= 1) {
if ((b - 1) > EPSLN) {
return (93);
}
else {
y = 0;
}
}
else {
y = Math.acos(y);
}
if (lat < 0) {
y = -y;
}
y = this.a * this.k0 * (y - this.lat0) + this.y0;
}
}
else {
var al = cos_phi * delta_lon;
var als = Math.pow(al, 2);
var c = this.ep2 * Math.pow(cos_phi, 2);
var cs = Math.pow(c, 2);
var tq = Math.abs(cos_phi) > EPSLN ? Math.tan(lat) : 0;
var t = Math.pow(tq, 2);
var ts = Math.pow(t, 2);
con = 1 - this.es * Math.pow(sin_phi, 2);
al = al / Math.sqrt(con);
var ml = pj_mlfn(lat, sin_phi, cos_phi, this.en);
x = this.a * (this.k0 * al * (1 +
als / 6 * (1 - t + c +
als / 20 * (5 - 18 * t + ts + 14 * c - 58 * t * c +
als / 42 * (61 + 179 * ts - ts * t - 479 * t))))) +
this.x0;
y = this.a * (this.k0 * (ml - this.ml0 +
sin_phi * delta_lon * al / 2 * (1 +
als / 12 * (5 - t + 9 * c + 4 * cs +
als / 30 * (61 + ts - 58 * t + 270 * c - 330 * t * c +
als / 56 * (1385 + 543 * ts - ts * t - 3111 * t)))))) +
this.y0;
}
p.x = x;
p.y = y;
return p;
}
/**
Transverse Mercator Inverse - x/y to long/lat
*/
export function inverse(p) {
var con, phi;
var lat, lon;
var x = (p.x - this.x0) * (1 / this.a);
var y = (p.y - this.y0) * (1 / this.a);
if (!this.es) {
var f = Math.exp(x / this.k0);
var g = 0.5 * (f - 1 / f);
var temp = this.lat0 + y / this.k0;
var h = Math.cos(temp);
con = Math.sqrt((1 - Math.pow(h, 2)) / (1 + Math.pow(g, 2)));
lat = Math.asin(con);
if (y < 0) {
lat = -lat;
}
if ((g === 0) && (h === 0)) {
lon = 0;
}
else {
lon = adjust_lon(Math.atan2(g, h) + this.long0);
}
}
else { // ellipsoidal form
con = this.ml0 + y / this.k0;
phi = pj_inv_mlfn(con, this.es, this.en);
if (Math.abs(phi) < HALF_PI) {
var sin_phi = Math.sin(phi);
var cos_phi = Math.cos(phi);
var tan_phi = Math.abs(cos_phi) > EPSLN ? Math.tan(phi) : 0;
var c = this.ep2 * Math.pow(cos_phi, 2);
var cs = Math.pow(c, 2);
var t = Math.pow(tan_phi, 2);
var ts = Math.pow(t, 2);
con = 1 - this.es * Math.pow(sin_phi, 2);
var d = x * Math.sqrt(con) / this.k0;
var ds = Math.pow(d, 2);
con = con * tan_phi;
lat = phi - (con * ds / (1 - this.es)) * 0.5 * (1 -
ds / 12 * (5 + 3 * t - 9 * c * t + c - 4 * cs -
ds / 30 * (61 + 90 * t - 252 * c * t + 45 * ts + 46 * c -
ds / 56 * (1385 + 3633 * t + 4095 * ts + 1574 * ts * t))));
lon = adjust_lon(this.long0 + (d * (1 -
ds / 6 * (1 + 2 * t + c -
ds / 20 * (5 + 28 * t + 24 * ts + 8 * c * t + 6 * c -
ds / 42 * (61 + 662 * t + 1320 * ts + 720 * ts * t)))) / cos_phi));
}
else {
lat = HALF_PI * sign(y);
lon = 0;
}
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Fast_Transverse_Mercator", "Fast Transverse Mercator"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

169
node_modules/proj4/lib/projections/tpers.js generated vendored Normal file
View file

@ -0,0 +1,169 @@
var mode = {
N_POLE: 0,
S_POLE: 1,
EQUIT: 2,
OBLIQ: 3
};
import { D2R, HALF_PI, EPSLN } from "../constants/values";
import hypot from "../common/hypot";
var params = {
h: { def: 100000, num: true }, // default is Karman line, no default in PROJ.7
azi: { def: 0, num: true, degrees: true }, // default is North
tilt: { def: 0, num: true, degrees: true }, // default is Nadir
long0: { def: 0, num: true }, // default is Greenwich, conversion to rad is automatic
lat0: { def: 0, num: true } // default is Equator, conversion to rad is automatic
};
export function init() {
Object.keys(params).forEach(function (p) {
if (typeof this[p] === "undefined") {
this[p] = params[p].def;
} else if (params[p].num && isNaN(this[p])) {
throw new Error("Invalid parameter value, must be numeric " + p + " = " + this[p]);
} else if (params[p].num) {
this[p] = parseFloat(this[p]);
}
if (params[p].degrees) {
this[p] = this[p] * D2R;
}
}.bind(this));
if (Math.abs((Math.abs(this.lat0) - HALF_PI)) < EPSLN) {
this.mode = this.lat0 < 0 ? mode.S_POLE : mode.N_POLE;
} else if (Math.abs(this.lat0) < EPSLN) {
this.mode = mode.EQUIT;
} else {
this.mode = mode.OBLIQ;
this.sinph0 = Math.sin(this.lat0);
this.cosph0 = Math.cos(this.lat0);
}
this.pn1 = this.h / this.a; // Normalize relative to the Earth's radius
if (this.pn1 <= 0 || this.pn1 > 1e10) {
throw new Error("Invalid height");
}
this.p = 1 + this.pn1;
this.rp = 1 / this.p;
this.h1 = 1 / this.pn1;
this.pfact = (this.p + 1) * this.h1;
this.es = 0;
var omega = this.tilt;
var gamma = this.azi;
this.cg = Math.cos(gamma);
this.sg = Math.sin(gamma);
this.cw = Math.cos(omega);
this.sw = Math.sin(omega);
}
export function forward(p) {
p.x -= this.long0;
var sinphi = Math.sin(p.y);
var cosphi = Math.cos(p.y);
var coslam = Math.cos(p.x);
var x, y;
switch (this.mode) {
case mode.OBLIQ:
y = this.sinph0 * sinphi + this.cosph0 * cosphi * coslam;
break;
case mode.EQUIT:
y = cosphi * coslam;
break;
case mode.S_POLE:
y = -sinphi;
break;
case mode.N_POLE:
y = sinphi;
break;
}
y = this.pn1 / (this.p - y);
x = y * cosphi * Math.sin(p.x);
switch (this.mode) {
case mode.OBLIQ:
y *= this.cosph0 * sinphi - this.sinph0 * cosphi * coslam;
break;
case mode.EQUIT:
y *= sinphi;
break;
case mode.N_POLE:
y *= -(cosphi * coslam);
break;
case mode.S_POLE:
y *= cosphi * coslam;
break;
}
// Tilt
var yt, ba;
yt = y * this.cg + x * this.sg;
ba = 1 / (yt * this.sw * this.h1 + this.cw);
x = (x * this.cg - y * this.sg) * this.cw * ba;
y = yt * ba;
p.x = x * this.a;
p.y = y * this.a;
return p;
}
export function inverse(p) {
p.x /= this.a;
p.y /= this.a;
var r = { x: p.x, y: p.y };
// Un-Tilt
var bm, bq, yt;
yt = 1 / (this.pn1 - p.y * this.sw);
bm = this.pn1 * p.x * yt;
bq = this.pn1 * p.y * this.cw * yt;
p.x = bm * this.cg + bq * this.sg;
p.y = bq * this.cg - bm * this.sg;
var rh = hypot(p.x, p.y);
if (Math.abs(rh) < EPSLN) {
r.x = 0;
r.y = p.y;
} else {
var cosz, sinz;
sinz = 1 - rh * rh * this.pfact;
sinz = (this.p - Math.sqrt(sinz)) / (this.pn1 / rh + rh / this.pn1);
cosz = Math.sqrt(1 - sinz * sinz);
switch (this.mode) {
case mode.OBLIQ:
r.y = Math.asin(cosz * this.sinph0 + p.y * sinz * this.cosph0 / rh);
p.y = (cosz - this.sinph0 * Math.sin(r.y)) * rh;
p.x *= sinz * this.cosph0;
break;
case mode.EQUIT:
r.y = Math.asin(p.y * sinz / rh);
p.y = cosz * rh;
p.x *= sinz;
break;
case mode.N_POLE:
r.y = Math.asin(cosz);
p.y = -p.y;
break;
case mode.S_POLE:
r.y = -Math.asin(cosz);
break;
}
r.x = Math.atan2(p.x, p.y);
}
p.x = r.x + this.long0;
p.y = r.y;
return p;
}
export var names = ["Tilted_Perspective", "tpers"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};

28
node_modules/proj4/lib/projections/utm.js generated vendored Normal file
View file

@ -0,0 +1,28 @@
import adjust_zone from '../common/adjust_zone';
import etmerc from './etmerc';
export var dependsOn = 'etmerc';
import {D2R} from '../constants/values';
export function init() {
var zone = adjust_zone(this.zone, this.long0);
if (zone === undefined) {
throw new Error('unknown utm zone');
}
this.lat0 = 0;
this.long0 = ((6 * Math.abs(zone)) - 183) * D2R;
this.x0 = 500000;
this.y0 = this.utmSouth ? 10000000 : 0;
this.k0 = 0.9996;
etmerc.init.apply(this);
this.forward = etmerc.forward;
this.inverse = etmerc.inverse;
}
export var names = ["Universal Transverse Mercator System", "utm"];
export default {
init: init,
names: names,
dependsOn: dependsOn
};

129
node_modules/proj4/lib/projections/vandg.js generated vendored Normal file
View file

@ -0,0 +1,129 @@
import adjust_lon from '../common/adjust_lon';
import {HALF_PI, EPSLN} from '../constants/values';
import asinz from '../common/asinz';
/* Initialize the Van Der Grinten projection
----------------------------------------*/
export function init() {
//this.R = 6370997; //Radius of earth
this.R = this.a;
}
export function forward(p) {
var lon = p.x;
var lat = p.y;
/* Forward equations
-----------------*/
var dlon = adjust_lon(lon - this.long0);
var x, y;
if (Math.abs(lat) <= EPSLN) {
x = this.x0 + this.R * dlon;
y = this.y0;
}
var theta = asinz(2 * Math.abs(lat / Math.PI));
if ((Math.abs(dlon) <= EPSLN) || (Math.abs(Math.abs(lat) - HALF_PI) <= EPSLN)) {
x = this.x0;
if (lat >= 0) {
y = this.y0 + Math.PI * this.R * Math.tan(0.5 * theta);
}
else {
y = this.y0 + Math.PI * this.R * -Math.tan(0.5 * theta);
}
// return(OK);
}
var al = 0.5 * Math.abs((Math.PI / dlon) - (dlon / Math.PI));
var asq = al * al;
var sinth = Math.sin(theta);
var costh = Math.cos(theta);
var g = costh / (sinth + costh - 1);
var gsq = g * g;
var m = g * (2 / sinth - 1);
var msq = m * m;
var con = Math.PI * this.R * (al * (g - msq) + Math.sqrt(asq * (g - msq) * (g - msq) - (msq + asq) * (gsq - msq))) / (msq + asq);
if (dlon < 0) {
con = -con;
}
x = this.x0 + con;
//con = Math.abs(con / (Math.PI * this.R));
var q = asq + g;
con = Math.PI * this.R * (m * q - al * Math.sqrt((msq + asq) * (asq + 1) - q * q)) / (msq + asq);
if (lat >= 0) {
//y = this.y0 + Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);
y = this.y0 + con;
}
else {
//y = this.y0 - Math.PI * this.R * Math.sqrt(1 - con * con - 2 * al * con);
y = this.y0 - con;
}
p.x = x;
p.y = y;
return p;
}
/* Van Der Grinten inverse equations--mapping x,y to lat/long
---------------------------------------------------------*/
export function inverse(p) {
var lon, lat;
var xx, yy, xys, c1, c2, c3;
var a1;
var m1;
var con;
var th1;
var d;
/* inverse equations
-----------------*/
p.x -= this.x0;
p.y -= this.y0;
con = Math.PI * this.R;
xx = p.x / con;
yy = p.y / con;
xys = xx * xx + yy * yy;
c1 = -Math.abs(yy) * (1 + xys);
c2 = c1 - 2 * yy * yy + xx * xx;
c3 = -2 * c1 + 1 + 2 * yy * yy + xys * xys;
d = yy * yy / c3 + (2 * c2 * c2 * c2 / c3 / c3 / c3 - 9 * c1 * c2 / c3 / c3) / 27;
a1 = (c1 - c2 * c2 / 3 / c3) / c3;
m1 = 2 * Math.sqrt(-a1 / 3);
con = ((3 * d) / a1) / m1;
if (Math.abs(con) > 1) {
if (con >= 0) {
con = 1;
}
else {
con = -1;
}
}
th1 = Math.acos(con) / 3;
if (p.y >= 0) {
lat = (-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
}
else {
lat = -(-m1 * Math.cos(th1 + Math.PI / 3) - c2 / 3 / c3) * Math.PI;
}
if (Math.abs(xx) < EPSLN) {
lon = this.long0;
}
else {
lon = adjust_lon(this.long0 + Math.PI * (xys - 1 + Math.sqrt(1 + 2 * (xx * xx - yy * yy) + xys * xys)) / 2 / xx);
}
p.x = lon;
p.y = lat;
return p;
}
export var names = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
export default {
init: init,
forward: forward,
inverse: inverse,
names: names
};