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/projString.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {D2R} from './constants/values';
|
|
1
|
+
import { D2R } from './constants/values';
|
|
2
2
|
import PrimeMeridian from './constants/PrimeMeridian';
|
|
3
3
|
import units from './constants/units';
|
|
4
4
|
import match from './match';
|
|
5
5
|
|
|
6
|
-
export default function(defData) {
|
|
6
|
+
export default function (defData) {
|
|
7
7
|
var self = {};
|
|
8
|
-
var paramObj = defData.split('+').map(function(v) {
|
|
8
|
+
var paramObj = defData.split('+').map(function (v) {
|
|
9
9
|
return v.trim();
|
|
10
|
-
}).filter(function(a) {
|
|
10
|
+
}).filter(function (a) {
|
|
11
11
|
return a;
|
|
12
|
-
}).reduce(function(p, a) {
|
|
12
|
+
}).reduce(function (p, a) {
|
|
13
13
|
var split = a.split('=');
|
|
14
14
|
split.push(true);
|
|
15
15
|
p[split[0].toLowerCase()] = split[1];
|
|
@@ -19,106 +19,105 @@ export default function(defData) {
|
|
|
19
19
|
var params = {
|
|
20
20
|
proj: 'projName',
|
|
21
21
|
datum: 'datumCode',
|
|
22
|
-
rf: function(v) {
|
|
22
|
+
rf: function (v) {
|
|
23
23
|
self.rf = parseFloat(v);
|
|
24
24
|
},
|
|
25
|
-
lat_0: function(v) {
|
|
25
|
+
lat_0: function (v) {
|
|
26
26
|
self.lat0 = v * D2R;
|
|
27
27
|
},
|
|
28
|
-
lat_1: function(v) {
|
|
28
|
+
lat_1: function (v) {
|
|
29
29
|
self.lat1 = v * D2R;
|
|
30
30
|
},
|
|
31
|
-
lat_2: function(v) {
|
|
31
|
+
lat_2: function (v) {
|
|
32
32
|
self.lat2 = v * D2R;
|
|
33
33
|
},
|
|
34
|
-
lat_ts: function(v) {
|
|
34
|
+
lat_ts: function (v) {
|
|
35
35
|
self.lat_ts = v * D2R;
|
|
36
36
|
},
|
|
37
|
-
lon_0: function(v) {
|
|
37
|
+
lon_0: function (v) {
|
|
38
38
|
self.long0 = v * D2R;
|
|
39
39
|
},
|
|
40
|
-
lon_1: function(v) {
|
|
40
|
+
lon_1: function (v) {
|
|
41
41
|
self.long1 = v * D2R;
|
|
42
42
|
},
|
|
43
|
-
lon_2: function(v) {
|
|
43
|
+
lon_2: function (v) {
|
|
44
44
|
self.long2 = v * D2R;
|
|
45
45
|
},
|
|
46
|
-
alpha: function(v) {
|
|
46
|
+
alpha: function (v) {
|
|
47
47
|
self.alpha = parseFloat(v) * D2R;
|
|
48
48
|
},
|
|
49
|
-
gamma: function(v) {
|
|
50
|
-
self.rectified_grid_angle = parseFloat(v);
|
|
49
|
+
gamma: function (v) {
|
|
50
|
+
self.rectified_grid_angle = parseFloat(v) * D2R;
|
|
51
51
|
},
|
|
52
|
-
lonc: function(v) {
|
|
52
|
+
lonc: function (v) {
|
|
53
53
|
self.longc = v * D2R;
|
|
54
54
|
},
|
|
55
|
-
x_0: function(v) {
|
|
55
|
+
x_0: function (v) {
|
|
56
56
|
self.x0 = parseFloat(v);
|
|
57
57
|
},
|
|
58
|
-
y_0: function(v) {
|
|
58
|
+
y_0: function (v) {
|
|
59
59
|
self.y0 = parseFloat(v);
|
|
60
60
|
},
|
|
61
|
-
k_0: function(v) {
|
|
61
|
+
k_0: function (v) {
|
|
62
62
|
self.k0 = parseFloat(v);
|
|
63
63
|
},
|
|
64
|
-
k: function(v) {
|
|
64
|
+
k: function (v) {
|
|
65
65
|
self.k0 = parseFloat(v);
|
|
66
66
|
},
|
|
67
|
-
a: function(v) {
|
|
67
|
+
a: function (v) {
|
|
68
68
|
self.a = parseFloat(v);
|
|
69
69
|
},
|
|
70
|
-
b: function(v) {
|
|
70
|
+
b: function (v) {
|
|
71
71
|
self.b = parseFloat(v);
|
|
72
72
|
},
|
|
73
|
-
r: function(v) {
|
|
73
|
+
r: function (v) {
|
|
74
74
|
self.a = self.b = parseFloat(v);
|
|
75
75
|
},
|
|
76
|
-
r_a: function() {
|
|
76
|
+
r_a: function () {
|
|
77
77
|
self.R_A = true;
|
|
78
78
|
},
|
|
79
|
-
zone: function(v) {
|
|
79
|
+
zone: function (v) {
|
|
80
80
|
self.zone = parseInt(v, 10);
|
|
81
81
|
},
|
|
82
|
-
south: function() {
|
|
82
|
+
south: function () {
|
|
83
83
|
self.utmSouth = true;
|
|
84
84
|
},
|
|
85
|
-
towgs84: function(v) {
|
|
86
|
-
self.datum_params = v.split(
|
|
85
|
+
towgs84: function (v) {
|
|
86
|
+
self.datum_params = v.split(',').map(function (a) {
|
|
87
87
|
return parseFloat(a);
|
|
88
88
|
});
|
|
89
89
|
},
|
|
90
|
-
to_meter: function(v) {
|
|
90
|
+
to_meter: function (v) {
|
|
91
91
|
self.to_meter = parseFloat(v);
|
|
92
92
|
},
|
|
93
|
-
units: function(v) {
|
|
93
|
+
units: function (v) {
|
|
94
94
|
self.units = v;
|
|
95
95
|
var unit = match(units, v);
|
|
96
96
|
if (unit) {
|
|
97
97
|
self.to_meter = unit.to_meter;
|
|
98
98
|
}
|
|
99
99
|
},
|
|
100
|
-
from_greenwich: function(v) {
|
|
100
|
+
from_greenwich: function (v) {
|
|
101
101
|
self.from_greenwich = v * D2R;
|
|
102
102
|
},
|
|
103
|
-
pm: function(v) {
|
|
103
|
+
pm: function (v) {
|
|
104
104
|
var pm = match(PrimeMeridian, v);
|
|
105
105
|
self.from_greenwich = (pm ? pm : parseFloat(v)) * D2R;
|
|
106
106
|
},
|
|
107
|
-
nadgrids: function(v) {
|
|
107
|
+
nadgrids: function (v) {
|
|
108
108
|
if (v === '@null') {
|
|
109
109
|
self.datumCode = 'none';
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
110
|
+
} else {
|
|
112
111
|
self.nadgrids = v;
|
|
113
112
|
}
|
|
114
113
|
},
|
|
115
|
-
axis: function(v) {
|
|
116
|
-
var legalAxis =
|
|
114
|
+
axis: function (v) {
|
|
115
|
+
var legalAxis = 'ewnsud';
|
|
117
116
|
if (v.length === 3 && legalAxis.indexOf(v.substr(0, 1)) !== -1 && legalAxis.indexOf(v.substr(1, 1)) !== -1 && legalAxis.indexOf(v.substr(2, 1)) !== -1) {
|
|
118
117
|
self.axis = v;
|
|
119
118
|
}
|
|
120
119
|
},
|
|
121
|
-
approx: function() {
|
|
120
|
+
approx: function () {
|
|
122
121
|
self.approx = true;
|
|
123
122
|
}
|
|
124
123
|
};
|
|
@@ -128,16 +127,14 @@ export default function(defData) {
|
|
|
128
127
|
paramOutname = params[paramName];
|
|
129
128
|
if (typeof paramOutname === 'function') {
|
|
130
129
|
paramOutname(paramVal);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
130
|
+
} else {
|
|
133
131
|
self[paramOutname] = paramVal;
|
|
134
132
|
}
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
133
|
+
} else {
|
|
137
134
|
self[paramName] = paramVal;
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
|
-
if(typeof self.datumCode === 'string' && self.datumCode !==
|
|
137
|
+
if (typeof self.datumCode === 'string' && self.datumCode !== 'WGS84') {
|
|
141
138
|
self.datumCode = self.datumCode.toLowerCase();
|
|
142
139
|
}
|
|
143
140
|
return self;
|
package/lib/projections/aea.js
CHANGED
|
@@ -2,10 +2,9 @@ import msfnz from '../common/msfnz';
|
|
|
2
2
|
import qsfnz from '../common/qsfnz';
|
|
3
3
|
import adjust_lon from '../common/adjust_lon';
|
|
4
4
|
import asinz from '../common/asinz';
|
|
5
|
-
import {EPSLN} from '../constants/values';
|
|
5
|
+
import { EPSLN } from '../constants/values';
|
|
6
6
|
|
|
7
7
|
export function init() {
|
|
8
|
-
|
|
9
8
|
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
@@ -33,8 +32,7 @@ export function init() {
|
|
|
33
32
|
|
|
34
33
|
if (Math.abs(this.lat1 - this.lat2) > EPSLN) {
|
|
35
34
|
this.ns0 = (this.ms1 * this.ms1 - this.ms2 * this.ms2) / (this.qs2 - this.qs1);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
35
|
+
} else {
|
|
38
36
|
this.ns0 = this.con;
|
|
39
37
|
}
|
|
40
38
|
this.c = this.ms1 * this.ms1 + this.ns0 * this.qs1;
|
|
@@ -42,9 +40,8 @@ export function init() {
|
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
/* Albers Conical Equal Area forward equations--mapping lat,long to x,y
|
|
45
|
-
|
|
43
|
+
------------------------------------------------------------------- */
|
|
46
44
|
export function forward(p) {
|
|
47
|
-
|
|
48
45
|
var lon = p.x;
|
|
49
46
|
var lat = p.y;
|
|
50
47
|
|
|
@@ -70,8 +67,7 @@ export function inverse(p) {
|
|
|
70
67
|
if (this.ns0 >= 0) {
|
|
71
68
|
rh1 = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
72
69
|
con = 1;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
70
|
+
} else {
|
|
75
71
|
rh1 = -Math.sqrt(p.x * p.x + p.y * p.y);
|
|
76
72
|
con = -1;
|
|
77
73
|
}
|
|
@@ -82,8 +78,7 @@ export function inverse(p) {
|
|
|
82
78
|
con = rh1 * this.ns0 / this.a;
|
|
83
79
|
if (this.sphere) {
|
|
84
80
|
lat = Math.asin((this.c - con * con) / (2 * this.ns0));
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
81
|
+
} else {
|
|
87
82
|
qs = (this.c - con * con) / this.ns0;
|
|
88
83
|
lat = this.phi1z(this.e3, qs);
|
|
89
84
|
}
|
|
@@ -96,7 +91,7 @@ export function inverse(p) {
|
|
|
96
91
|
|
|
97
92
|
/* Function to compute phi1, the latitude for the inverse of the
|
|
98
93
|
Albers Conical Equal-Area projection.
|
|
99
|
-
|
|
94
|
+
------------------------------------------- */
|
|
100
95
|
export function phi1z(eccent, qs) {
|
|
101
96
|
var sinphi, cosphi, con, com, dphi;
|
|
102
97
|
var phi = asinz(0.5 * qs);
|
|
@@ -119,7 +114,7 @@ export function phi1z(eccent, qs) {
|
|
|
119
114
|
return null;
|
|
120
115
|
}
|
|
121
116
|
|
|
122
|
-
export var names = [
|
|
117
|
+
export var names = ['Albers_Conic_Equal_Area', 'Albers_Equal_Area', 'Albers', 'aea'];
|
|
123
118
|
export default {
|
|
124
119
|
init: init,
|
|
125
120
|
forward: forward,
|
package/lib/projections/aeqd.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import adjust_lon from '../common/adjust_lon';
|
|
2
|
-
import {HALF_PI, EPSLN} from '../constants/values';
|
|
3
|
-
|
|
2
|
+
import { HALF_PI, EPSLN, D2R } from '../constants/values';
|
|
4
3
|
import mlfn from '../common/mlfn';
|
|
5
4
|
import e0fn from '../common/e0fn';
|
|
6
5
|
import e1fn from '../common/e1fn';
|
|
7
6
|
import e2fn from '../common/e2fn';
|
|
8
7
|
import e3fn from '../common/e3fn';
|
|
9
|
-
import gN from '../common/gN';
|
|
10
8
|
import asinz from '../common/asinz';
|
|
11
9
|
import imlfn from '../common/imlfn';
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import { Geodesic } from 'geographiclib-geodesic';
|
|
14
11
|
|
|
15
12
|
export function init() {
|
|
16
13
|
this.sin_p12 = Math.sin(this.lat0);
|
|
17
14
|
this.cos_p12 = Math.cos(this.lat0);
|
|
15
|
+
this.g = new Geodesic.Geodesic(this.a, this.es / (1 + Math.sqrt(1 - this.es)));
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
export function forward(p) {
|
|
@@ -23,22 +21,20 @@ export function forward(p) {
|
|
|
23
21
|
var sinphi = Math.sin(p.y);
|
|
24
22
|
var cosphi = Math.cos(p.y);
|
|
25
23
|
var dlon = adjust_lon(lon - this.long0);
|
|
26
|
-
var e0, e1, e2, e3, Mlp, Ml,
|
|
24
|
+
var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c, lat1, lon1, lat2, lon2, vars, azi1;
|
|
27
25
|
if (this.sphere) {
|
|
28
26
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
|
29
|
-
//North Pole case
|
|
27
|
+
// North Pole case
|
|
30
28
|
p.x = this.x0 + this.a * (HALF_PI - lat) * Math.sin(dlon);
|
|
31
29
|
p.y = this.y0 - this.a * (HALF_PI - lat) * Math.cos(dlon);
|
|
32
30
|
return p;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//South Pole case
|
|
31
|
+
} else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
|
|
32
|
+
// South Pole case
|
|
36
33
|
p.x = this.x0 + this.a * (HALF_PI + lat) * Math.sin(dlon);
|
|
37
34
|
p.y = this.y0 + this.a * (HALF_PI + lat) * Math.cos(dlon);
|
|
38
35
|
return p;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//default case
|
|
36
|
+
} else {
|
|
37
|
+
// default case
|
|
42
38
|
cos_c = this.sin_p12 * sinphi + this.cos_p12 * cosphi * Math.cos(dlon);
|
|
43
39
|
c = Math.acos(cos_c);
|
|
44
40
|
kp = c ? c / Math.sin(c) : 1;
|
|
@@ -46,66 +42,50 @@ export function forward(p) {
|
|
|
46
42
|
p.y = this.y0 + this.a * kp * (this.cos_p12 * sinphi - this.sin_p12 * cosphi * Math.cos(dlon));
|
|
47
43
|
return p;
|
|
48
44
|
}
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
45
|
+
} else {
|
|
51
46
|
e0 = e0fn(this.es);
|
|
52
47
|
e1 = e1fn(this.es);
|
|
53
48
|
e2 = e2fn(this.es);
|
|
54
49
|
e3 = e3fn(this.es);
|
|
55
50
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
|
56
|
-
//North Pole case
|
|
51
|
+
// North Pole case
|
|
57
52
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
|
58
53
|
Ml = this.a * mlfn(e0, e1, e2, e3, lat);
|
|
59
54
|
p.x = this.x0 + (Mlp - Ml) * Math.sin(dlon);
|
|
60
55
|
p.y = this.y0 - (Mlp - Ml) * Math.cos(dlon);
|
|
61
56
|
return p;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
//South Pole case
|
|
57
|
+
} else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
|
|
58
|
+
// South Pole case
|
|
65
59
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
|
66
60
|
Ml = this.a * mlfn(e0, e1, e2, e3, lat);
|
|
67
61
|
p.x = this.x0 + (Mlp + Ml) * Math.sin(dlon);
|
|
68
62
|
p.y = this.y0 + (Mlp + Ml) * Math.cos(dlon);
|
|
69
63
|
return p;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Nl = gN(this.a, this.e, sinphi);
|
|
76
|
-
psi = Math.atan((1 - this.es) * tanphi + this.es * Nl1 * this.sin_p12 / (Nl * cosphi));
|
|
77
|
-
Az = Math.atan2(Math.sin(dlon), this.cos_p12 * Math.tan(psi) - this.sin_p12 * Math.cos(dlon));
|
|
78
|
-
if (Az === 0) {
|
|
79
|
-
s = Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
|
|
80
|
-
}
|
|
81
|
-
else if (Math.abs(Math.abs(Az) - Math.PI) <= EPSLN) {
|
|
82
|
-
s = -Math.asin(this.cos_p12 * Math.sin(psi) - this.sin_p12 * Math.cos(psi));
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
s = Math.asin(Math.sin(dlon) * Math.cos(psi) / Math.sin(Az));
|
|
64
|
+
} else {
|
|
65
|
+
// Default case
|
|
66
|
+
if (Math.abs(lon) < EPSLN && Math.abs(lat - this.lat0) < EPSLN) {
|
|
67
|
+
p.x = p.y = 0;
|
|
68
|
+
return p;
|
|
86
69
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
p.
|
|
97
|
-
p.y = this.y0 + c * Math.cos(Az);
|
|
70
|
+
lat1 = this.lat0 / D2R;
|
|
71
|
+
lon1 = this.long0 / D2R;
|
|
72
|
+
lat2 = lat / D2R;
|
|
73
|
+
lon2 = lon / D2R;
|
|
74
|
+
|
|
75
|
+
vars = this.g.Inverse(lat1, lon1, lat2, lon2, this.g.AZIMUTH);
|
|
76
|
+
azi1 = vars.azi1 * D2R;
|
|
77
|
+
|
|
78
|
+
p.x = vars.s12 * Math.sin(azi1);
|
|
79
|
+
p.y = vars.s12 * Math.cos(azi1);
|
|
98
80
|
return p;
|
|
99
81
|
}
|
|
100
82
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
83
|
}
|
|
104
84
|
|
|
105
85
|
export function inverse(p) {
|
|
106
86
|
p.x -= this.x0;
|
|
107
87
|
p.y -= this.y0;
|
|
108
|
-
var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M,
|
|
88
|
+
var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, lat1, lon1, azi1, s12, vars;
|
|
109
89
|
if (this.sphere) {
|
|
110
90
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
111
91
|
if (rh > (2 * HALF_PI * this.a)) {
|
|
@@ -119,26 +99,23 @@ export function inverse(p) {
|
|
|
119
99
|
lon = this.long0;
|
|
120
100
|
if (Math.abs(rh) <= EPSLN) {
|
|
121
101
|
lat = this.lat0;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
102
|
+
} else {
|
|
124
103
|
lat = asinz(cosz * this.sin_p12 + (p.y * sinz * this.cos_p12) / rh);
|
|
125
104
|
con = Math.abs(this.lat0) - HALF_PI;
|
|
126
105
|
if (Math.abs(con) <= EPSLN) {
|
|
127
106
|
if (this.lat0 >= 0) {
|
|
128
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x, -
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
107
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x, -p.y));
|
|
108
|
+
} else {
|
|
131
109
|
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
|
|
132
110
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/*con = cosz - this.sin_p12 * Math.sin(lat);
|
|
111
|
+
} else {
|
|
112
|
+
/* con = cosz - this.sin_p12 * Math.sin(lat);
|
|
136
113
|
if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
|
|
137
114
|
//no-op, just keep the lon value as is
|
|
138
115
|
} else {
|
|
139
116
|
var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
|
|
140
117
|
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
|
|
141
|
-
}*/
|
|
118
|
+
} */
|
|
142
119
|
lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
|
|
143
120
|
}
|
|
144
121
|
}
|
|
@@ -146,25 +123,23 @@ export function inverse(p) {
|
|
|
146
123
|
p.x = lon;
|
|
147
124
|
p.y = lat;
|
|
148
125
|
return p;
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
126
|
+
} else {
|
|
151
127
|
e0 = e0fn(this.es);
|
|
152
128
|
e1 = e1fn(this.es);
|
|
153
129
|
e2 = e2fn(this.es);
|
|
154
130
|
e3 = e3fn(this.es);
|
|
155
131
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
|
156
|
-
//North pole case
|
|
132
|
+
// North pole case
|
|
157
133
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
|
158
134
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
159
135
|
M = Mlp - rh;
|
|
160
136
|
lat = imlfn(M / this.a, e0, e1, e2, e3);
|
|
161
|
-
lon = adjust_lon(this.long0 + Math.atan2(p.x, -
|
|
137
|
+
lon = adjust_lon(this.long0 + Math.atan2(p.x, -1 * p.y));
|
|
162
138
|
p.x = lon;
|
|
163
139
|
p.y = lat;
|
|
164
140
|
return p;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
//South pole case
|
|
141
|
+
} else if (Math.abs(this.sin_p12 + 1) <= EPSLN) {
|
|
142
|
+
// South pole case
|
|
168
143
|
Mlp = this.a * mlfn(e0, e1, e2, e3, HALF_PI);
|
|
169
144
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
170
145
|
M = rh - Mlp;
|
|
@@ -174,32 +149,22 @@ export function inverse(p) {
|
|
|
174
149
|
p.x = lon;
|
|
175
150
|
p.y = lat;
|
|
176
151
|
return p;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
D = rh / N1;
|
|
188
|
-
Ee = D - A * (1 + A) * Math.pow(D, 3) / 6 - B * (1 + 3 * A) * Math.pow(D, 4) / 24;
|
|
189
|
-
F = 1 - A * Ee * Ee / 2 - D * Ee * Ee * Ee / 6;
|
|
190
|
-
psi = Math.asin(this.sin_p12 * Math.cos(Ee) + this.cos_p12 * Math.sin(Ee) * cosAz);
|
|
191
|
-
lon = adjust_lon(this.long0 + Math.asin(Math.sin(Az) * Math.sin(Ee) / Math.cos(psi)));
|
|
192
|
-
sinpsi = Math.sin(psi);
|
|
193
|
-
lat = Math.atan2((sinpsi - this.es * F * this.sin_p12) * Math.tan(psi), sinpsi * (1 - this.es));
|
|
194
|
-
p.x = lon;
|
|
195
|
-
p.y = lat;
|
|
152
|
+
} else {
|
|
153
|
+
// default case
|
|
154
|
+
lat1 = this.lat0 / D2R;
|
|
155
|
+
lon1 = this.long0 / D2R;
|
|
156
|
+
azi1 = Math.atan2(p.x, p.y) / D2R;
|
|
157
|
+
s12 = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
158
|
+
vars = this.g.Direct(lat1, lon1, azi1, s12, this.g.STANDARD);
|
|
159
|
+
|
|
160
|
+
p.x = vars.lon2 * D2R;
|
|
161
|
+
p.y = vars.lat2 * D2R;
|
|
196
162
|
return p;
|
|
197
163
|
}
|
|
198
164
|
}
|
|
199
|
-
|
|
200
165
|
}
|
|
201
166
|
|
|
202
|
-
export var names = [
|
|
167
|
+
export var names = ['Azimuthal_Equidistant', 'aeqd'];
|
|
203
168
|
export default {
|
|
204
169
|
init: init,
|
|
205
170
|
forward: forward,
|
package/lib/projections/bonne.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import adjust_lat from
|
|
2
|
-
import adjust_lon from
|
|
3
|
-
import hypot from
|
|
4
|
-
import pj_enfn from
|
|
5
|
-
import pj_inv_mlfn from
|
|
6
|
-
import pj_mlfn from
|
|
7
|
-
import { HALF_PI } from
|
|
1
|
+
import adjust_lat from '../common/adjust_lat';
|
|
2
|
+
import adjust_lon from '../common/adjust_lon';
|
|
3
|
+
import hypot from '../common/hypot';
|
|
4
|
+
import pj_enfn from '../common/pj_enfn';
|
|
5
|
+
import pj_inv_mlfn from '../common/pj_inv_mlfn';
|
|
6
|
+
import pj_mlfn from '../common/pj_mlfn';
|
|
7
|
+
import { HALF_PI } from '../constants/values';
|
|
8
8
|
|
|
9
9
|
var EPS10 = 1e-10;
|
|
10
10
|
|
|
@@ -25,8 +25,7 @@ export function init() {
|
|
|
25
25
|
} else {
|
|
26
26
|
if (Math.abs(this.phi1) + EPS10 >= HALF_PI) {
|
|
27
27
|
this.cphi1 = 0;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
28
|
+
} else {
|
|
30
29
|
this.cphi1 = 1 / Math.tan(this.phi1);
|
|
31
30
|
}
|
|
32
31
|
this.inverse = s_inv;
|
|
@@ -60,8 +59,7 @@ function e_inv(p) {
|
|
|
60
59
|
lam = rh * Math.atan2(p.x, p.y) * Math.sqrt(1 - this.es * s * s) / Math.cos(phi);
|
|
61
60
|
} else if (Math.abs(s - HALF_PI) <= EPS10) {
|
|
62
61
|
lam = 0;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
62
|
+
} else {
|
|
65
63
|
throw new Error();
|
|
66
64
|
}
|
|
67
65
|
p.x = adjust_lon(lam + (this.long0 || 0));
|
|
@@ -106,8 +104,8 @@ function s_inv(p) {
|
|
|
106
104
|
return p;
|
|
107
105
|
}
|
|
108
106
|
|
|
109
|
-
export var names = [
|
|
107
|
+
export var names = ['bonne', 'Bonne (Werner lat_1=90)'];
|
|
110
108
|
export default {
|
|
111
109
|
init: init,
|
|
112
110
|
names: names
|
|
113
|
-
};
|
|
111
|
+
};
|
package/lib/projections/cass.js
CHANGED
|
@@ -7,7 +7,7 @@ import gN from '../common/gN';
|
|
|
7
7
|
import adjust_lon from '../common/adjust_lon';
|
|
8
8
|
import adjust_lat from '../common/adjust_lat';
|
|
9
9
|
import imlfn from '../common/imlfn';
|
|
10
|
-
import {HALF_PI, EPSLN} from '../constants/values';
|
|
10
|
+
import { HALF_PI, EPSLN } from '../constants/values';
|
|
11
11
|
|
|
12
12
|
export function init() {
|
|
13
13
|
if (!this.sphere) {
|
|
@@ -20,11 +20,10 @@ export function init() {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/* Cassini forward equations--mapping lat,long to x,y
|
|
23
|
-
|
|
23
|
+
----------------------------------------------------------------------- */
|
|
24
24
|
export function forward(p) {
|
|
25
|
-
|
|
26
25
|
/* Forward equations
|
|
27
|
-
|
|
26
|
+
----------------- */
|
|
28
27
|
var x, y;
|
|
29
28
|
var lam = p.x;
|
|
30
29
|
var phi = p.y;
|
|
@@ -33,9 +32,8 @@ export function forward(p) {
|
|
|
33
32
|
if (this.sphere) {
|
|
34
33
|
x = this.a * Math.asin(Math.cos(phi) * Math.sin(lam));
|
|
35
34
|
y = this.a * (Math.atan2(Math.tan(phi), Math.cos(lam)) - this.lat0);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//ellipsoid
|
|
35
|
+
} else {
|
|
36
|
+
// ellipsoid
|
|
39
37
|
var sinphi = Math.sin(phi);
|
|
40
38
|
var cosphi = Math.cos(phi);
|
|
41
39
|
var nl = gN(this.a, this.e, sinphi);
|
|
@@ -47,8 +45,6 @@ export function forward(p) {
|
|
|
47
45
|
|
|
48
46
|
x = nl * al * (1 - asq * tl * (1 / 6 - (8 - tl + 8 * cl) * asq / 120));
|
|
49
47
|
y = ml - this.ml0 + nl * sinphi / cosphi * asq * (0.5 + (5 - tl + 6 * cl) * asq / 24);
|
|
50
|
-
|
|
51
|
-
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
p.x = x + this.x0;
|
|
@@ -57,7 +53,7 @@ export function forward(p) {
|
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
/* Inverse equations
|
|
60
|
-
|
|
56
|
+
----------------- */
|
|
61
57
|
export function inverse(p) {
|
|
62
58
|
p.x -= this.x0;
|
|
63
59
|
p.y -= this.y0;
|
|
@@ -69,8 +65,7 @@ export function inverse(p) {
|
|
|
69
65
|
var dd = y + this.lat0;
|
|
70
66
|
phi = Math.asin(Math.sin(dd) * Math.cos(x));
|
|
71
67
|
lam = Math.atan2(Math.tan(x), Math.cos(dd));
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
68
|
+
} else {
|
|
74
69
|
/* ellipsoid */
|
|
75
70
|
var ml1 = this.ml0 / this.a + y;
|
|
76
71
|
var phi1 = imlfn(ml1, this.e0, this.e1, this.e2, this.e3);
|
|
@@ -90,16 +85,14 @@ export function inverse(p) {
|
|
|
90
85
|
var dsq = dl * dl;
|
|
91
86
|
phi = phi1 - nl1 * Math.tan(phi1) / rl1 * dl * dl * (0.5 - (1 + 3 * tl1) * dl * dl / 24);
|
|
92
87
|
lam = dl * (1 - dsq * (tl1 / 3 + (1 + 3 * tl1) * tl1 * dsq / 15)) / Math.cos(phi1);
|
|
93
|
-
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
p.x = adjust_lon(lam + this.long0);
|
|
97
91
|
p.y = adjust_lat(phi);
|
|
98
92
|
return p;
|
|
99
|
-
|
|
100
93
|
}
|
|
101
94
|
|
|
102
|
-
export var names = [
|
|
95
|
+
export var names = ['Cassini', 'Cassini_Soldner', 'cass'];
|
|
103
96
|
export default {
|
|
104
97
|
init: init,
|
|
105
98
|
forward: forward,
|
package/lib/projections/cea.js
CHANGED
|
@@ -10,26 +10,25 @@ import iqsfnz from '../common/iqsfnz';
|
|
|
10
10
|
USGS Open File Report 90-284and Release 4 Interim Reports (2003)
|
|
11
11
|
*/
|
|
12
12
|
export function init() {
|
|
13
|
-
//no-op
|
|
13
|
+
// no-op
|
|
14
14
|
if (!this.sphere) {
|
|
15
15
|
this.k0 = msfnz(this.e, Math.sin(this.lat_ts), Math.cos(this.lat_ts));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/* Cylindrical Equal Area forward equations--mapping lat,long to x,y
|
|
20
|
-
|
|
20
|
+
------------------------------------------------------------ */
|
|
21
21
|
export function forward(p) {
|
|
22
22
|
var lon = p.x;
|
|
23
23
|
var lat = p.y;
|
|
24
24
|
var x, y;
|
|
25
25
|
/* Forward equations
|
|
26
|
-
|
|
26
|
+
----------------- */
|
|
27
27
|
var dlon = adjust_lon(lon - this.long0);
|
|
28
28
|
if (this.sphere) {
|
|
29
29
|
x = this.x0 + this.a * dlon * Math.cos(this.lat_ts);
|
|
30
30
|
y = this.y0 + this.a * Math.sin(lat) / Math.cos(this.lat_ts);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
31
|
+
} else {
|
|
33
32
|
var qs = qsfnz(this.e, Math.sin(lat));
|
|
34
33
|
x = this.x0 + this.a * this.k0 * dlon;
|
|
35
34
|
y = this.y0 + this.a * qs * 0.5 / this.k0;
|
|
@@ -41,7 +40,7 @@ export function forward(p) {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
/* Cylindrical Equal Area inverse equations--mapping x,y to lat/long
|
|
44
|
-
|
|
43
|
+
------------------------------------------------------------ */
|
|
45
44
|
export function inverse(p) {
|
|
46
45
|
p.x -= this.x0;
|
|
47
46
|
p.y -= this.y0;
|
|
@@ -50,8 +49,7 @@ export function inverse(p) {
|
|
|
50
49
|
if (this.sphere) {
|
|
51
50
|
lon = adjust_lon(this.long0 + (p.x / this.a) / Math.cos(this.lat_ts));
|
|
52
51
|
lat = Math.asin((p.y / this.a) * Math.cos(this.lat_ts));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
52
|
+
} else {
|
|
55
53
|
lat = iqsfnz(this.e, 2 * p.y * this.k0 / this.a);
|
|
56
54
|
lon = adjust_lon(this.long0 + p.x / (this.a * this.k0));
|
|
57
55
|
}
|
|
@@ -61,7 +59,7 @@ export function inverse(p) {
|
|
|
61
59
|
return p;
|
|
62
60
|
}
|
|
63
61
|
|
|
64
|
-
export var names = [
|
|
62
|
+
export var names = ['cea'];
|
|
65
63
|
export default {
|
|
66
64
|
init: init,
|
|
67
65
|
forward: forward,
|