proj4 2.15.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build-and-test.yml +45 -7
- package/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
- package/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
- package/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
- package/.nyc_output/processinfo/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +1 -0
- package/.nyc_output/processinfo/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +1 -0
- package/.nyc_output/processinfo/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/Gruntfile.js +20 -84
- package/README.md +20 -6
- package/bower.json +1 -1
- package/component.json +1 -1
- package/dist/proj4-src.js +8934 -7083
- package/dist/proj4.js +1 -1
- package/eslint.config.mjs +41 -0
- package/lib/Point.js +4 -4
- package/lib/Proj.js +7 -8
- package/lib/adjust_axis.js +30 -33
- package/lib/common/acosh.js +2 -2
- package/lib/common/adjust_lat.js +2 -2
- package/lib/common/adjust_lon.js +2 -3
- package/lib/common/adjust_zone.js +1 -1
- package/lib/common/asinh.js +2 -2
- package/lib/common/asinhy.js +1 -1
- package/lib/common/asinz.js +2 -2
- package/lib/common/atanh.js +2 -2
- package/lib/common/clens.js +1 -1
- package/lib/common/clens_cmplx.js +1 -1
- package/lib/common/cosh.js +2 -2
- package/lib/common/e0fn.js +2 -2
- package/lib/common/e1fn.js +2 -2
- package/lib/common/e2fn.js +2 -2
- package/lib/common/e3fn.js +2 -2
- package/lib/common/fL.js +2 -2
- package/lib/common/gN.js +2 -2
- package/lib/common/gatg.js +1 -1
- package/lib/common/hypot.js +1 -1
- package/lib/common/imlfn.js +3 -3
- package/lib/common/invlatiso.js +2 -2
- package/lib/common/iqsfnz.js +5 -6
- package/lib/common/latiso.js +2 -2
- package/lib/common/log1py.js +1 -1
- package/lib/common/mlfn.js +2 -2
- package/lib/common/msfnz.js +2 -2
- package/lib/common/phi2z.js +3 -3
- package/lib/common/pj_enfn.js +2 -2
- package/lib/common/pj_inv_mlfn.js +6 -6
- package/lib/common/pj_mlfn.js +2 -2
- package/lib/common/qsfnz.js +3 -4
- package/lib/common/sign.js +3 -3
- package/lib/common/sinh.js +2 -2
- package/lib/common/srat.js +2 -2
- package/lib/common/tanh.js +2 -2
- package/lib/common/toPoint.js +4 -4
- package/lib/common/tsfnz.js +2 -2
- package/lib/constants/Datum.js +1228 -46
- package/lib/constants/Ellipsoid.js +225 -266
- package/lib/constants/PrimeMeridian.js +14 -14
- package/lib/constants/units.js +20 -20
- package/lib/constants/values.js +4 -4
- package/lib/core.js +2 -2
- package/lib/datum.js +2 -2
- package/lib/datumUtils.js +9 -14
- package/lib/datum_transform.js +26 -26
- package/lib/defs.js +10 -20
- package/lib/deriveConstants.js +4 -2
- package/lib/extend.js +1 -1
- package/lib/global.js +6 -6
- package/lib/includedProjections.js +25 -25
- package/lib/index.js +9 -9
- package/lib/nadgrid.js +36 -14
- package/lib/parseCode.js +10 -11
- package/lib/projString.js +41 -44
- package/lib/projections/aea.js +7 -12
- package/lib/projections/aeqd.js +51 -86
- package/lib/projections/bonne.js +11 -13
- package/lib/projections/cass.js +8 -15
- package/lib/projections/cea.js +7 -9
- package/lib/projections/eqc.js +2 -5
- package/lib/projections/eqdc.js +10 -16
- package/lib/projections/eqearth.js +17 -17
- package/lib/projections/equi.js +4 -6
- package/lib/projections/etmerc.js +9 -11
- package/lib/projections/gauss.js +3 -3
- package/lib/projections/geocent.js +13 -14
- package/lib/projections/geos.js +136 -137
- package/lib/projections/gnom.js +8 -13
- package/lib/projections/gstmerc.js +2 -5
- package/lib/projections/krovak.js +3 -3
- package/lib/projections/laea.js +85 -97
- package/lib/projections/lcc.js +28 -33
- package/lib/projections/longlat.js +4 -4
- package/lib/projections/merc.js +12 -19
- package/lib/projections/mill.js +6 -7
- package/lib/projections/moll.js +8 -9
- package/lib/projections/nzmg.js +2 -2
- package/lib/projections/omerc.js +55 -57
- package/lib/projections/ortho.js +9 -10
- package/lib/projections/poly.js +13 -21
- package/lib/projections/qsc.js +19 -21
- package/lib/projections/robin.js +118 -118
- package/lib/projections/sinu.js +12 -23
- package/lib/projections/somerc.js +3 -3
- package/lib/projections/stere.js +29 -41
- package/lib/projections/sterea.js +3 -4
- package/lib/projections/tmerc.js +29 -36
- package/lib/projections/tpers.js +14 -15
- package/lib/projections/utm.js +3 -4
- package/lib/projections/vandg.js +15 -21
- package/lib/projections.js +12 -4
- package/lib/transform.js +3 -3
- package/package.json +29 -22
- package/projs.js +2 -2
- package/publish.sh +2 -2
- package/rollup.config.mjs +29 -0
- package/scripts/readme.md +10 -0
- package/scripts/updateDatums.mjs +119 -0
- package/scripts/updateEllipsoids.mjs +70 -0
- package/test/ntv2_0_downsampled_no_error_columns.gsb +0 -0
- package/test/opt.html +27 -24
- package/test/puppeteer-tests.mjs +110 -0
- package/test/test-ci.mjs +10 -0
- package/test/test.js +197 -125
- package/test/testData.js +1802 -312
- package/.jshintrc +0 -12
- package/test/amd.html +0 -63
- package/test/package.json.js +0 -1
package/lib/projections/mill.js
CHANGED
|
@@ -6,20 +6,19 @@ import adjust_lon from '../common/adjust_lon';
|
|
|
6
6
|
The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
/* Initialize the Miller Cylindrical projection
|
|
11
|
-
|
|
10
|
+
------------------------------------------- */
|
|
12
11
|
export function init() {
|
|
13
|
-
//no-op
|
|
12
|
+
// no-op
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
/* Miller Cylindrical forward equations--mapping lat,long to x,y
|
|
17
|
-
|
|
16
|
+
------------------------------------------------------------ */
|
|
18
17
|
export function forward(p) {
|
|
19
18
|
var lon = p.x;
|
|
20
19
|
var lat = p.y;
|
|
21
20
|
/* Forward equations
|
|
22
|
-
|
|
21
|
+
----------------- */
|
|
23
22
|
var dlon = adjust_lon(lon - this.long0);
|
|
24
23
|
var x = this.x0 + this.a * dlon;
|
|
25
24
|
var y = this.y0 + this.a * Math.log(Math.tan((Math.PI / 4) + (lat / 2.5))) * 1.25;
|
|
@@ -30,7 +29,7 @@ export function forward(p) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
/* Miller Cylindrical inverse equations--mapping x,y to lat/long
|
|
33
|
-
|
|
32
|
+
------------------------------------------------------------ */
|
|
34
33
|
export function inverse(p) {
|
|
35
34
|
p.x -= this.x0;
|
|
36
35
|
p.y -= this.y0;
|
|
@@ -43,7 +42,7 @@ export function inverse(p) {
|
|
|
43
42
|
return p;
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
export var names = [
|
|
45
|
+
export var names = ['Miller_Cylindrical', 'mill'];
|
|
47
46
|
export default {
|
|
48
47
|
init: init,
|
|
49
48
|
forward: forward,
|
package/lib/projections/moll.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import adjust_lon from '../common/adjust_lon';
|
|
2
2
|
export function init() {}
|
|
3
|
-
import {EPSLN} from '../constants/values';
|
|
3
|
+
import { EPSLN } from '../constants/values';
|
|
4
4
|
/* Mollweide forward equations--mapping lat,long to x,y
|
|
5
|
-
|
|
5
|
+
---------------------------------------------------- */
|
|
6
6
|
export function forward(p) {
|
|
7
|
-
|
|
8
7
|
/* Forward equations
|
|
9
|
-
|
|
8
|
+
----------------- */
|
|
10
9
|
var lon = p.x;
|
|
11
10
|
var lat = p.y;
|
|
12
11
|
|
|
@@ -15,7 +14,7 @@ export function forward(p) {
|
|
|
15
14
|
var con = Math.PI * Math.sin(lat);
|
|
16
15
|
|
|
17
16
|
/* Iterate using the Newton-Raphson method to find theta
|
|
18
|
-
|
|
17
|
+
----------------------------------------------------- */
|
|
19
18
|
while (true) {
|
|
20
19
|
var delta_theta = -(theta + Math.sin(theta) - con) / (1 + Math.cos(theta));
|
|
21
20
|
theta += delta_theta;
|
|
@@ -27,7 +26,7 @@ export function forward(p) {
|
|
|
27
26
|
|
|
28
27
|
/* If the latitude is 90 deg, force the x coordinate to be "0 + false easting"
|
|
29
28
|
this is done here because of precision problems with "cos(theta)"
|
|
30
|
-
|
|
29
|
+
-------------------------------------------------------------------------- */
|
|
31
30
|
if (Math.PI / 2 - Math.abs(lat) < EPSLN) {
|
|
32
31
|
delta_lon = 0;
|
|
33
32
|
}
|
|
@@ -44,14 +43,14 @@ export function inverse(p) {
|
|
|
44
43
|
var arg;
|
|
45
44
|
|
|
46
45
|
/* Inverse equations
|
|
47
|
-
|
|
46
|
+
----------------- */
|
|
48
47
|
p.x -= this.x0;
|
|
49
48
|
p.y -= this.y0;
|
|
50
49
|
arg = p.y / (1.4142135623731 * this.a);
|
|
51
50
|
|
|
52
51
|
/* Because of division by zero problems, 'arg' can not be 1. Therefore
|
|
53
52
|
a number very close to one is used instead.
|
|
54
|
-
|
|
53
|
+
------------------------------------------------------------------- */
|
|
55
54
|
if (Math.abs(arg) > 0.999999999999) {
|
|
56
55
|
arg = 0.999999999999;
|
|
57
56
|
}
|
|
@@ -74,7 +73,7 @@ export function inverse(p) {
|
|
|
74
73
|
return p;
|
|
75
74
|
}
|
|
76
75
|
|
|
77
|
-
export var names = [
|
|
76
|
+
export var names = ['Mollweide', 'moll'];
|
|
78
77
|
export default {
|
|
79
78
|
init: init,
|
|
80
79
|
forward: forward,
|
package/lib/projections/nzmg.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SEC_TO_RAD} from '../constants/values';
|
|
1
|
+
import { SEC_TO_RAD } from '../constants/values';
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
reference
|
|
@@ -217,7 +217,7 @@ export function inverse(p) {
|
|
|
217
217
|
return p;
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
export var names = [
|
|
220
|
+
export var names = ['New_Zealand_Map_Grid', 'nzmg'];
|
|
221
221
|
export default {
|
|
222
222
|
init: init,
|
|
223
223
|
forward: forward,
|
package/lib/projections/omerc.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import tsfnz from '../common/tsfnz';
|
|
2
2
|
import adjust_lon from '../common/adjust_lon';
|
|
3
3
|
import phi2z from '../common/phi2z';
|
|
4
|
-
import {
|
|
4
|
+
import { EPSLN, HALF_PI, TWO_PI, FORTPI } from '../constants/values';
|
|
5
|
+
import { getNormalizedProjName } from '../projections';
|
|
5
6
|
|
|
6
7
|
var TOL = 1e-7;
|
|
7
8
|
|
|
8
9
|
function isTypeA(P) {
|
|
9
|
-
var typeAProjections = ['Hotine_Oblique_Mercator','Hotine_Oblique_Mercator_Azimuth_Natural_Origin'];
|
|
10
|
-
var projectionName = typeof P.
|
|
11
|
-
|
|
12
|
-
return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1;
|
|
13
|
-
}
|
|
10
|
+
var typeAProjections = ['Hotine_Oblique_Mercator', 'Hotine_Oblique_Mercator_variant_A', 'Hotine_Oblique_Mercator_Azimuth_Natural_Origin'];
|
|
11
|
+
var projectionName = typeof P.projName === 'object' ? Object.keys(P.projName)[0] : P.projName;
|
|
14
12
|
|
|
13
|
+
return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1 || typeAProjections.indexOf(getNormalizedProjName(projectionName)) !== -1;
|
|
14
|
+
}
|
|
15
15
|
|
|
16
16
|
/* Initialize the Oblique Mercator projection
|
|
17
|
-
|
|
18
|
-
export function init() {
|
|
17
|
+
------------------------------------------ */
|
|
18
|
+
export function init() {
|
|
19
19
|
var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0,
|
|
20
|
-
gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0
|
|
21
|
-
|
|
20
|
+
gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0;
|
|
21
|
+
|
|
22
22
|
// only Type A uses the no_off or no_uoff property
|
|
23
23
|
// https://github.com/OSGeo/proj.4/issues/104
|
|
24
24
|
this.no_off = isTypeA(this);
|
|
25
25
|
this.no_rot = 'no_rot' in this;
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
var alp = false;
|
|
28
|
-
if (
|
|
28
|
+
if ('alpha' in this) {
|
|
29
29
|
alp = true;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
var gam = false;
|
|
33
|
-
if (
|
|
33
|
+
if ('rectified_grid_angle' in this) {
|
|
34
34
|
gam = true;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
if (alp) {
|
|
38
38
|
alpha_c = this.alpha;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
|
|
41
41
|
if (gam) {
|
|
42
|
-
gamma =
|
|
42
|
+
gamma = this.rectified_grid_angle;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
if (alp || gam) {
|
|
46
46
|
lamc = this.longc;
|
|
47
47
|
} else {
|
|
@@ -49,17 +49,17 @@ export function init() {
|
|
|
49
49
|
phi1 = this.lat1;
|
|
50
50
|
lam2 = this.long2;
|
|
51
51
|
phi2 = this.lat2;
|
|
52
|
-
|
|
53
|
-
if (Math.abs(phi1 - phi2) <= TOL || (con = Math.abs(phi1)) <= TOL
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
|
|
53
|
+
if (Math.abs(phi1 - phi2) <= TOL || (con = Math.abs(phi1)) <= TOL
|
|
54
|
+
|| Math.abs(con - HALF_PI) <= TOL || Math.abs(Math.abs(this.lat0) - HALF_PI) <= TOL
|
|
55
|
+
|| Math.abs(Math.abs(phi2) - HALF_PI) <= TOL) {
|
|
56
56
|
throw new Error();
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
var one_es = 1.0 - this.es;
|
|
61
61
|
com = Math.sqrt(one_es);
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
if (Math.abs(this.lat0) > EPSLN) {
|
|
64
64
|
sinph0 = Math.sin(this.lat0);
|
|
65
65
|
cosph0 = Math.cos(this.lat0);
|
|
@@ -68,8 +68,8 @@ export function init() {
|
|
|
68
68
|
this.B = Math.sqrt(1 + this.es * this.B * this.B / one_es);
|
|
69
69
|
this.A = this.B * this.k0 * com / con;
|
|
70
70
|
D = this.B * com / (cosph0 * Math.sqrt(con));
|
|
71
|
-
F = D * D -1;
|
|
72
|
-
|
|
71
|
+
F = D * D - 1;
|
|
72
|
+
|
|
73
73
|
if (F <= 0) {
|
|
74
74
|
F = 0;
|
|
75
75
|
} else {
|
|
@@ -78,7 +78,7 @@ export function init() {
|
|
|
78
78
|
F = -F;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
this.E = F += D;
|
|
83
83
|
this.E *= Math.pow(tsfnz(this.e, this.lat0, sinph0), this.B);
|
|
84
84
|
} else {
|
|
@@ -86,7 +86,7 @@ export function init() {
|
|
|
86
86
|
this.A = this.k0;
|
|
87
87
|
this.E = D = F = 1;
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
if (alp || gam) {
|
|
91
91
|
if (alp) {
|
|
92
92
|
gamma0 = Math.asin(Math.sin(alpha_c) / D);
|
|
@@ -106,77 +106,75 @@ export function init() {
|
|
|
106
106
|
J = this.E * this.E;
|
|
107
107
|
J = (J - L * H) / (J + L * H);
|
|
108
108
|
con = lam1 - lam2;
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
if (con < -Math.pi) {
|
|
111
|
-
lam2 -=TWO_PI;
|
|
111
|
+
lam2 -= TWO_PI;
|
|
112
112
|
} else if (con > Math.pi) {
|
|
113
113
|
lam2 += TWO_PI;
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
this.lam0 = adjust_lon(0.5 * (lam1 + lam2) - Math.atan(J * Math.tan(0.5 * this.B * (lam1 - lam2)) / p) / this.B);
|
|
117
117
|
gamma0 = Math.atan(2 * Math.sin(this.B * adjust_lon(lam1 - this.lam0)) / (F - 1 / F));
|
|
118
118
|
gamma = alpha_c = Math.asin(D * Math.sin(gamma0));
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
this.singam = Math.sin(gamma0);
|
|
122
122
|
this.cosgam = Math.cos(gamma0);
|
|
123
123
|
this.sinrot = Math.sin(gamma);
|
|
124
124
|
this.cosrot = Math.cos(gamma);
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
this.rB = 1 / this.B;
|
|
127
127
|
this.ArB = this.A * this.rB;
|
|
128
128
|
this.BrA = 1 / this.ArB;
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
if (this.no_off) {
|
|
132
131
|
this.u_0 = 0;
|
|
133
132
|
} else {
|
|
134
133
|
this.u_0 = Math.abs(this.ArB * Math.atan(Math.sqrt(D * D - 1) / Math.cos(alpha_c)));
|
|
135
|
-
|
|
134
|
+
|
|
136
135
|
if (this.lat0 < 0) {
|
|
137
|
-
this.u_0 = -
|
|
138
|
-
}
|
|
136
|
+
this.u_0 = -this.u_0;
|
|
137
|
+
}
|
|
139
138
|
}
|
|
140
|
-
|
|
139
|
+
|
|
141
140
|
F = 0.5 * gamma0;
|
|
142
141
|
this.v_pole_n = this.ArB * Math.log(Math.tan(FORTPI - F));
|
|
143
142
|
this.v_pole_s = this.ArB * Math.log(Math.tan(FORTPI + F));
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
|
|
147
145
|
/* Oblique Mercator forward equations--mapping lat,long to x,y
|
|
148
|
-
|
|
146
|
+
---------------------------------------------------------- */
|
|
149
147
|
export function forward(p) {
|
|
150
148
|
var coords = {};
|
|
151
149
|
var S, T, U, V, W, temp, u, v;
|
|
152
150
|
p.x = p.x - this.lam0;
|
|
153
|
-
|
|
151
|
+
|
|
154
152
|
if (Math.abs(Math.abs(p.y) - HALF_PI) > EPSLN) {
|
|
155
153
|
W = this.E / Math.pow(tsfnz(this.e, p.y, Math.sin(p.y)), this.B);
|
|
156
|
-
|
|
154
|
+
|
|
157
155
|
temp = 1 / W;
|
|
158
156
|
S = 0.5 * (W - temp);
|
|
159
157
|
T = 0.5 * (W + temp);
|
|
160
158
|
V = Math.sin(this.B * p.x);
|
|
161
159
|
U = (S * this.singam - V * this.cosgam) / T;
|
|
162
|
-
|
|
160
|
+
|
|
163
161
|
if (Math.abs(Math.abs(U) - 1.0) < EPSLN) {
|
|
164
162
|
throw new Error();
|
|
165
163
|
}
|
|
166
|
-
|
|
167
|
-
v = 0.5 * this.ArB * Math.log((1 - U)/(1 + U));
|
|
164
|
+
|
|
165
|
+
v = 0.5 * this.ArB * Math.log((1 - U) / (1 + U));
|
|
168
166
|
temp = Math.cos(this.B * p.x);
|
|
169
|
-
|
|
167
|
+
|
|
170
168
|
if (Math.abs(temp) < TOL) {
|
|
171
169
|
u = this.A * p.x;
|
|
172
170
|
} else {
|
|
173
171
|
u = this.ArB * Math.atan2((S * this.cosgam + V * this.singam), temp);
|
|
174
|
-
}
|
|
172
|
+
}
|
|
175
173
|
} else {
|
|
176
174
|
v = p.y > 0 ? this.v_pole_n : this.v_pole_s;
|
|
177
175
|
u = this.ArB * p.y;
|
|
178
176
|
}
|
|
179
|
-
|
|
177
|
+
|
|
180
178
|
if (this.no_rot) {
|
|
181
179
|
coords.x = u;
|
|
182
180
|
coords.y = v;
|
|
@@ -185,17 +183,17 @@ export function forward(p) {
|
|
|
185
183
|
coords.x = v * this.cosrot + u * this.sinrot;
|
|
186
184
|
coords.y = u * this.cosrot - v * this.sinrot;
|
|
187
185
|
}
|
|
188
|
-
|
|
186
|
+
|
|
189
187
|
coords.x = (this.a * coords.x + this.x0);
|
|
190
188
|
coords.y = (this.a * coords.y + this.y0);
|
|
191
|
-
|
|
189
|
+
|
|
192
190
|
return coords;
|
|
193
191
|
}
|
|
194
192
|
|
|
195
193
|
export function inverse(p) {
|
|
196
194
|
var u, v, Qp, Sp, Tp, Vp, Up;
|
|
197
195
|
var coords = {};
|
|
198
|
-
|
|
196
|
+
|
|
199
197
|
p.x = (p.x - this.x0) * (1.0 / this.a);
|
|
200
198
|
p.y = (p.y - this.y0) * (1.0 / this.a);
|
|
201
199
|
|
|
@@ -206,33 +204,33 @@ export function inverse(p) {
|
|
|
206
204
|
v = p.x * this.cosrot - p.y * this.sinrot;
|
|
207
205
|
u = p.y * this.cosrot + p.x * this.sinrot + this.u_0;
|
|
208
206
|
}
|
|
209
|
-
|
|
207
|
+
|
|
210
208
|
Qp = Math.exp(-this.BrA * v);
|
|
211
209
|
Sp = 0.5 * (Qp - 1 / Qp);
|
|
212
210
|
Tp = 0.5 * (Qp + 1 / Qp);
|
|
213
211
|
Vp = Math.sin(this.BrA * u);
|
|
214
212
|
Up = (Vp * this.cosgam + Sp * this.singam) / Tp;
|
|
215
|
-
|
|
213
|
+
|
|
216
214
|
if (Math.abs(Math.abs(Up) - 1) < EPSLN) {
|
|
217
215
|
coords.x = 0;
|
|
218
216
|
coords.y = Up < 0 ? -HALF_PI : HALF_PI;
|
|
219
217
|
} else {
|
|
220
218
|
coords.y = this.E / Math.sqrt((1 + Up) / (1 - Up));
|
|
221
219
|
coords.y = phi2z(this.e, Math.pow(coords.y, 1 / this.B));
|
|
222
|
-
|
|
220
|
+
|
|
223
221
|
if (coords.y === Infinity) {
|
|
224
222
|
throw new Error();
|
|
225
223
|
}
|
|
226
|
-
|
|
224
|
+
|
|
227
225
|
coords.x = -this.rB * Math.atan2((Sp * this.cosgam - Vp * this.singam), Math.cos(this.BrA * u));
|
|
228
226
|
}
|
|
229
|
-
|
|
227
|
+
|
|
230
228
|
coords.x += this.lam0;
|
|
231
|
-
|
|
229
|
+
|
|
232
230
|
return coords;
|
|
233
231
|
}
|
|
234
232
|
|
|
235
|
-
export var names = [
|
|
233
|
+
export var names = ['Hotine_Oblique_Mercator', 'Hotine Oblique Mercator', 'Hotine_Oblique_Mercator_variant_A', 'Hotine_Oblique_Mercator_Variant_B', 'Hotine_Oblique_Mercator_Azimuth_Natural_Origin', 'Hotine_Oblique_Mercator_Two_Point_Natural_Origin', 'Hotine_Oblique_Mercator_Azimuth_Center', 'Oblique_Mercator', 'omerc'];
|
|
236
234
|
export default {
|
|
237
235
|
init: init,
|
|
238
236
|
forward: forward,
|
package/lib/projections/ortho.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import adjust_lon from '../common/adjust_lon';
|
|
2
2
|
import asinz from '../common/asinz';
|
|
3
|
-
import {EPSLN, HALF_PI} from '../constants/values';
|
|
3
|
+
import { EPSLN, HALF_PI } from '../constants/values';
|
|
4
4
|
|
|
5
5
|
export function init() {
|
|
6
|
-
//double temp; /* temporary variable */
|
|
6
|
+
// double temp; /* temporary variable */
|
|
7
7
|
|
|
8
8
|
/* Place parameters in static storage for common use
|
|
9
|
-
|
|
9
|
+
------------------------------------------------- */
|
|
10
10
|
this.sin_p14 = Math.sin(this.lat0);
|
|
11
11
|
this.cos_p14 = Math.cos(this.lat0);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/* Orthographic forward equations--mapping lat,long to x,y
|
|
15
|
-
|
|
15
|
+
--------------------------------------------------- */
|
|
16
16
|
export function forward(p) {
|
|
17
17
|
var sinphi, cosphi; /* sin and cos value */
|
|
18
18
|
var dlon; /* delta longitude value */
|
|
@@ -22,7 +22,7 @@ export function forward(p) {
|
|
|
22
22
|
var lon = p.x;
|
|
23
23
|
var lat = p.y;
|
|
24
24
|
/* Forward equations
|
|
25
|
-
|
|
25
|
+
----------------- */
|
|
26
26
|
dlon = adjust_lon(lon - this.long0);
|
|
27
27
|
|
|
28
28
|
sinphi = Math.sin(lat);
|
|
@@ -47,7 +47,7 @@ export function inverse(p) {
|
|
|
47
47
|
var con;
|
|
48
48
|
var lon, lat;
|
|
49
49
|
/* Inverse equations
|
|
50
|
-
|
|
50
|
+
----------------- */
|
|
51
51
|
p.x -= this.x0;
|
|
52
52
|
p.y -= this.y0;
|
|
53
53
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
@@ -67,9 +67,8 @@ export function inverse(p) {
|
|
|
67
67
|
con = Math.abs(this.lat0) - HALF_PI;
|
|
68
68
|
if (Math.abs(con) <= EPSLN) {
|
|
69
69
|
if (this.lat0 >= 0) {
|
|
70
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x, -
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
70
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x, -p.y));
|
|
71
|
+
} else {
|
|
73
72
|
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
|
|
74
73
|
}
|
|
75
74
|
p.x = lon;
|
|
@@ -82,7 +81,7 @@ export function inverse(p) {
|
|
|
82
81
|
return p;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
export var names = [
|
|
84
|
+
export var names = ['ortho'];
|
|
86
85
|
export default {
|
|
87
86
|
init: init,
|
|
88
87
|
forward: forward,
|
package/lib/projections/poly.js
CHANGED
|
@@ -5,14 +5,14 @@ import e3fn from '../common/e3fn';
|
|
|
5
5
|
import adjust_lon from '../common/adjust_lon';
|
|
6
6
|
import adjust_lat from '../common/adjust_lat';
|
|
7
7
|
import mlfn from '../common/mlfn';
|
|
8
|
-
import {EPSLN} from '../constants/values';
|
|
8
|
+
import { EPSLN } from '../constants/values';
|
|
9
9
|
|
|
10
10
|
import gN from '../common/gN';
|
|
11
11
|
var MAX_ITER = 20;
|
|
12
12
|
|
|
13
13
|
export function init() {
|
|
14
14
|
/* Place parameters in static storage for common use
|
|
15
|
-
|
|
15
|
+
------------------------------------------------- */
|
|
16
16
|
this.temp = this.b / this.a;
|
|
17
17
|
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
|
|
18
18
|
this.e = Math.sqrt(this.es);
|
|
@@ -20,11 +20,11 @@ export function init() {
|
|
|
20
20
|
this.e1 = e1fn(this.es);
|
|
21
21
|
this.e2 = e2fn(this.es);
|
|
22
22
|
this.e3 = e3fn(this.es);
|
|
23
|
-
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
|
|
23
|
+
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
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/* Polyconic forward equations--mapping lat,long to x,y
|
|
27
|
-
|
|
27
|
+
--------------------------------------------------- */
|
|
28
28
|
export function forward(p) {
|
|
29
29
|
var lon = p.x;
|
|
30
30
|
var lat = p.y;
|
|
@@ -35,23 +35,19 @@ export function forward(p) {
|
|
|
35
35
|
if (Math.abs(lat) <= EPSLN) {
|
|
36
36
|
x = this.a * dlon;
|
|
37
37
|
y = -1 * this.a * this.lat0;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
38
|
+
} else {
|
|
40
39
|
x = this.a * Math.sin(el) / Math.tan(lat);
|
|
41
40
|
y = this.a * (adjust_lat(lat - this.lat0) + (1 - Math.cos(el)) / Math.tan(lat));
|
|
42
41
|
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
42
|
+
} else {
|
|
45
43
|
if (Math.abs(lat) <= EPSLN) {
|
|
46
44
|
x = this.a * dlon;
|
|
47
45
|
y = -1 * this.ml0;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
46
|
+
} else {
|
|
50
47
|
var nl = gN(this.a, this.e, Math.sin(lat)) / Math.tan(lat);
|
|
51
48
|
x = nl * Math.sin(el);
|
|
52
49
|
y = this.a * mlfn(this.e0, this.e1, this.e2, this.e3, lat) - this.ml0 + nl * (1 - Math.cos(el));
|
|
53
50
|
}
|
|
54
|
-
|
|
55
51
|
}
|
|
56
52
|
p.x = x + this.x0;
|
|
57
53
|
p.y = y + this.y0;
|
|
@@ -59,7 +55,7 @@ export function forward(p) {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
/* Inverse equations
|
|
62
|
-
|
|
58
|
+
----------------- */
|
|
63
59
|
export function inverse(p) {
|
|
64
60
|
var lon, lat, x, y, i;
|
|
65
61
|
var al, bl;
|
|
@@ -71,8 +67,7 @@ export function inverse(p) {
|
|
|
71
67
|
if (Math.abs(y + this.a * this.lat0) <= EPSLN) {
|
|
72
68
|
lon = adjust_lon(x / this.a + this.long0);
|
|
73
69
|
lat = 0;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
70
|
+
} else {
|
|
76
71
|
al = this.lat0 + y / this.a;
|
|
77
72
|
bl = x * x / this.a / this.a + al * al;
|
|
78
73
|
phi = al;
|
|
@@ -88,14 +83,11 @@ export function inverse(p) {
|
|
|
88
83
|
}
|
|
89
84
|
lon = adjust_lon(this.long0 + (Math.asin(x * Math.tan(phi) / this.a)) / Math.sin(lat));
|
|
90
85
|
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
86
|
+
} else {
|
|
93
87
|
if (Math.abs(y + this.ml0) <= EPSLN) {
|
|
94
88
|
lat = 0;
|
|
95
89
|
lon = adjust_lon(this.long0 + x / this.a);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
|
|
90
|
+
} else {
|
|
99
91
|
al = (this.ml0 + y) / this.a;
|
|
100
92
|
bl = x * x / this.a / this.a + al * al;
|
|
101
93
|
phi = al;
|
|
@@ -115,7 +107,7 @@ export function inverse(p) {
|
|
|
115
107
|
}
|
|
116
108
|
}
|
|
117
109
|
|
|
118
|
-
//lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
|
|
110
|
+
// lat=phi4z(this.e,this.e0,this.e1,this.e2,this.e3,al,bl,0,0);
|
|
119
111
|
cl = Math.sqrt(1 - this.es * Math.pow(Math.sin(lat), 2)) * Math.tan(lat);
|
|
120
112
|
lon = adjust_lon(this.long0 + Math.asin(x * cl / this.a) / Math.sin(lat));
|
|
121
113
|
}
|
|
@@ -126,7 +118,7 @@ export function inverse(p) {
|
|
|
126
118
|
return p;
|
|
127
119
|
}
|
|
128
120
|
|
|
129
|
-
export var names = [
|
|
121
|
+
export var names = ['Polyconic', 'American_Polyconic', 'poly'];
|
|
130
122
|
export default {
|
|
131
123
|
init: init,
|
|
132
124
|
forward: forward,
|
package/lib/projections/qsc.js
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
// QSC projection rewritten from the original PROJ4
|
|
2
2
|
// https://github.com/OSGeo/proj.4/blob/master/src/PJ_qsc.c
|
|
3
3
|
|
|
4
|
-
import {EPSLN, TWO_PI, SPI, HALF_PI, FORTPI} from '../constants/values';
|
|
4
|
+
import { EPSLN, TWO_PI, SPI, HALF_PI, FORTPI } from '../constants/values';
|
|
5
5
|
|
|
6
6
|
/* constants */
|
|
7
7
|
var FACE_ENUM = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
FRONT: 1,
|
|
9
|
+
RIGHT: 2,
|
|
10
|
+
BACK: 3,
|
|
11
|
+
LEFT: 4,
|
|
12
|
+
TOP: 5,
|
|
13
|
+
BOTTOM: 6
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
var AREA_ENUM = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
AREA_0: 1,
|
|
18
|
+
AREA_1: 2,
|
|
19
|
+
AREA_2: 3,
|
|
20
|
+
AREA_3: 4
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export function init() {
|
|
24
|
-
|
|
25
24
|
this.x0 = this.x0 || 0;
|
|
26
25
|
this.y0 = this.y0 || 0;
|
|
27
26
|
this.lat0 = this.lat0 || 0;
|
|
28
27
|
this.long0 = this.long0 || 0;
|
|
29
28
|
this.lat_ts = this.lat_ts || 0;
|
|
30
|
-
this.title = this.title ||
|
|
29
|
+
this.title = this.title || 'Quadrilateralized Spherical Cube';
|
|
31
30
|
|
|
32
31
|
/* Determine the cube face from the center of projection. */
|
|
33
32
|
if (this.lat0 >= HALF_PI - FORTPI / 2.0) {
|
|
@@ -53,12 +52,12 @@ export function init() {
|
|
|
53
52
|
// QSC forward equations--mapping lat,long to x,y
|
|
54
53
|
// -----------------------------------------------------------------
|
|
55
54
|
export function forward(p) {
|
|
56
|
-
var xy = {x: 0, y: 0};
|
|
55
|
+
var xy = { x: 0, y: 0 };
|
|
57
56
|
var lat, lon;
|
|
58
57
|
var theta, phi;
|
|
59
58
|
var t, mu;
|
|
60
59
|
/* nu; */
|
|
61
|
-
var area = {value: 0};
|
|
60
|
+
var area = { value: 0 };
|
|
62
61
|
|
|
63
62
|
// move lon according to projection's lon
|
|
64
63
|
p.x -= this.long0;
|
|
@@ -66,7 +65,7 @@ export function forward(p) {
|
|
|
66
65
|
/* Convert the geodetic latitude to a geocentric latitude.
|
|
67
66
|
* This corresponds to the shift from the ellipsoid to the sphere
|
|
68
67
|
* described in [LK12]. */
|
|
69
|
-
if (this.es !== 0) {//if (P->es != 0) {
|
|
68
|
+
if (this.es !== 0) { // if (P->es != 0) {
|
|
70
69
|
lat = Math.atan(this.one_minus_f_squared * Math.tan(p.y));
|
|
71
70
|
} else {
|
|
72
71
|
lat = p.y;
|
|
@@ -77,7 +76,7 @@ export function forward(p) {
|
|
|
77
76
|
* For the top and bottom face, we can compute theta and phi
|
|
78
77
|
* directly from phi, lam. For the other faces, we must use
|
|
79
78
|
* unit sphere cartesian coordinates as an intermediate step. */
|
|
80
|
-
lon = p.x; //lon = lp.lam;
|
|
79
|
+
lon = p.x; // lon = lp.lam;
|
|
81
80
|
if (this.face === FACE_ENUM.TOP) {
|
|
82
81
|
phi = HALF_PI - lat;
|
|
83
82
|
if (lon >= FORTPI && lon <= HALF_PI + FORTPI) {
|
|
@@ -176,11 +175,11 @@ export function forward(p) {
|
|
|
176
175
|
// QSC inverse equations--mapping x,y to lat/long
|
|
177
176
|
// -----------------------------------------------------------------
|
|
178
177
|
export function inverse(p) {
|
|
179
|
-
var lp = {lam: 0, phi: 0};
|
|
178
|
+
var lp = { lam: 0, phi: 0 };
|
|
180
179
|
var mu, nu, cosmu, tannu;
|
|
181
180
|
var tantheta, theta, cosphi, phi;
|
|
182
181
|
var t;
|
|
183
|
-
var area = {value: 0};
|
|
182
|
+
var area = { value: 0 };
|
|
184
183
|
|
|
185
184
|
/* de-offset */
|
|
186
185
|
p.x = (p.x - this.x0) / this.a;
|
|
@@ -358,11 +357,10 @@ function qsc_shift_lon_origin(lon, offset) {
|
|
|
358
357
|
return slon;
|
|
359
358
|
}
|
|
360
359
|
|
|
361
|
-
export var names = [
|
|
360
|
+
export var names = ['Quadrilateralized Spherical Cube', 'Quadrilateralized_Spherical_Cube', 'qsc'];
|
|
362
361
|
export default {
|
|
363
362
|
init: init,
|
|
364
363
|
forward: forward,
|
|
365
364
|
inverse: inverse,
|
|
366
365
|
names: names
|
|
367
366
|
};
|
|
368
|
-
|