proj4 2.16.2 → 2.19.0
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/README.md +12 -0
- package/bower.json +1 -1
- package/component.json +1 -1
- package/dist/lib/Point.d.ts +24 -0
- package/dist/lib/Proj.d.ts +71 -0
- package/dist/lib/adjust_axis.d.ts +1 -0
- package/dist/lib/checkSanity.d.ts +1 -0
- package/dist/lib/common/acosh.d.ts +1 -0
- package/dist/lib/common/adjust_lat.d.ts +1 -0
- package/dist/lib/common/adjust_lon.d.ts +1 -0
- package/dist/lib/common/adjust_zone.d.ts +1 -0
- package/dist/lib/common/asinh.d.ts +1 -0
- package/dist/lib/common/asinhy.d.ts +1 -0
- package/dist/lib/common/asinz.d.ts +1 -0
- package/dist/lib/common/atanh.d.ts +1 -0
- package/dist/lib/common/clens.d.ts +1 -0
- package/dist/lib/common/clens_cmplx.d.ts +1 -0
- package/dist/lib/common/cosh.d.ts +1 -0
- package/dist/lib/common/e0fn.d.ts +1 -0
- package/dist/lib/common/e1fn.d.ts +1 -0
- package/dist/lib/common/e2fn.d.ts +1 -0
- package/dist/lib/common/e3fn.d.ts +1 -0
- package/dist/lib/common/fL.d.ts +1 -0
- package/dist/lib/common/gN.d.ts +1 -0
- package/dist/lib/common/gatg.d.ts +1 -0
- package/dist/lib/common/hypot.d.ts +1 -0
- package/dist/lib/common/imlfn.d.ts +1 -0
- package/dist/lib/common/invlatiso.d.ts +1 -0
- package/dist/lib/common/iqsfnz.d.ts +1 -0
- package/dist/lib/common/latiso.d.ts +1 -0
- package/dist/lib/common/log1py.d.ts +1 -0
- package/dist/lib/common/mlfn.d.ts +1 -0
- package/dist/lib/common/msfnz.d.ts +1 -0
- package/dist/lib/common/phi2z.d.ts +1 -0
- package/dist/lib/common/pj_enfn.d.ts +1 -0
- package/dist/lib/common/pj_inv_mlfn.d.ts +1 -0
- package/dist/lib/common/pj_mlfn.d.ts +1 -0
- package/dist/lib/common/qsfnz.d.ts +1 -0
- package/dist/lib/common/sign.d.ts +1 -0
- package/dist/lib/common/sinh.d.ts +1 -0
- package/dist/lib/common/srat.d.ts +1 -0
- package/dist/lib/common/tanh.d.ts +1 -0
- package/dist/lib/common/toPoint.d.ts +5 -0
- package/dist/lib/common/tsfnz.d.ts +1 -0
- package/dist/lib/common/vincenty.d.ts +35 -0
- package/dist/lib/constants/Datum.d.ts +1715 -0
- package/dist/lib/constants/Ellipsoid.d.ts +353 -0
- package/dist/lib/constants/PrimeMeridian.d.ts +16 -0
- package/dist/lib/constants/units.d.ts +63 -0
- package/dist/lib/constants/values.d.ts +19 -0
- package/dist/lib/core.d.ts +117 -0
- package/dist/lib/datum.d.ts +10 -0
- package/dist/lib/datumUtils.d.ts +28 -0
- package/dist/lib/datum_transform.d.ts +2 -0
- package/dist/lib/defs.d.ts +57 -0
- package/dist/lib/deriveConstants.d.ts +11 -0
- package/dist/lib/extend.d.ts +1 -0
- package/dist/lib/global.d.ts +1 -0
- package/dist/lib/includedProjections.d.ts +1 -0
- package/dist/lib/index.d.ts +24 -0
- package/dist/lib/match.d.ts +1 -0
- package/dist/lib/nadgrid.d.ts +107 -0
- package/dist/lib/parseCode.d.ts +6 -0
- package/dist/lib/projString.d.ts +5 -0
- package/dist/lib/projections/aea.d.ts +83 -0
- package/dist/lib/projections/aeqd.d.ts +32 -0
- package/dist/lib/projections/bonne.d.ts +27 -0
- package/dist/lib/projections/cass.d.ts +36 -0
- package/dist/lib/projections/cea.d.ts +28 -0
- package/dist/lib/projections/eqc.d.ts +20 -0
- package/dist/lib/projections/eqdc.d.ts +71 -0
- package/dist/lib/projections/eqearth.d.ts +15 -0
- package/dist/lib/projections/equi.d.ts +40 -0
- package/dist/lib/projections/etmerc.d.ts +45 -0
- package/dist/lib/projections/gauss.d.ts +38 -0
- package/dist/lib/projections/geocent.d.ts +22 -0
- package/dist/lib/projections/geos.d.ts +51 -0
- package/dist/lib/projections/gnom.d.ts +37 -0
- package/dist/lib/projections/gstmerc.d.ts +41 -0
- package/dist/lib/projections/krovak.d.ts +34 -0
- package/dist/lib/projections/laea.d.ts +70 -0
- package/dist/lib/projections/lcc.d.ts +36 -0
- package/dist/lib/projections/longlat.d.ts +11 -0
- package/dist/lib/projections/merc.d.ts +30 -0
- package/dist/lib/projections/mill.d.ts +11 -0
- package/dist/lib/projections/moll.d.ts +11 -0
- package/dist/lib/projections/nzmg.d.ts +33 -0
- package/dist/lib/projections/omerc.d.ts +60 -0
- package/dist/lib/projections/ortho.d.ts +25 -0
- package/dist/lib/projections/poly.d.ts +32 -0
- package/dist/lib/projections/qsc.d.ts +31 -0
- package/dist/lib/projections/robin.d.ts +24 -0
- package/dist/lib/projections/sinu.d.ts +37 -0
- package/dist/lib/projections/somerc.d.ts +35 -0
- package/dist/lib/projections/stere.d.ts +52 -0
- package/dist/lib/projections/sterea.d.ts +33 -0
- package/dist/lib/projections/tmerc.d.ts +38 -0
- package/dist/lib/projections/tpers.d.ts +45 -0
- package/dist/lib/projections/utm.d.ts +19 -0
- package/dist/lib/projections/vandg.d.ts +28 -0
- package/dist/lib/projections.d.ts +10 -0
- package/dist/lib/transform.d.ts +8 -0
- package/dist/proj4-src.js +908 -249
- package/dist/proj4.js +1 -1
- package/dist/projs.d.ts +1 -0
- package/lib/Point.js +9 -3
- package/lib/Proj.js +25 -1
- package/lib/adjust_axis.js +1 -0
- package/lib/common/toPoint.js +4 -0
- package/lib/common/vincenty.js +123 -0
- package/lib/constants/PrimeMeridian.js +16 -15
- package/lib/core.js +152 -16
- package/lib/defs.js +65 -5
- package/lib/index.js +17 -11
- package/lib/nadgrid.js +132 -2
- package/lib/parseCode.js +5 -1
- package/lib/projString.js +6 -0
- package/lib/projections/aea.js +25 -0
- package/lib/projections/aeqd.js +22 -26
- package/lib/projections/bonne.js +11 -0
- package/lib/projections/cass.js +11 -0
- package/lib/projections/cea.js +7 -1
- package/lib/projections/eqdc.js +29 -7
- package/lib/projections/equi.js +11 -2
- package/lib/projections/etmerc.js +12 -0
- package/lib/projections/gauss.js +12 -0
- package/lib/projections/geos.js +16 -0
- package/lib/projections/gnom.js +11 -2
- package/lib/projections/gstmerc.js +12 -0
- package/lib/projections/laea.js +30 -11
- package/lib/projections/lcc.js +10 -0
- package/lib/projections/merc.js +9 -0
- package/lib/projections/omerc.js +29 -4
- package/lib/projections/ortho.js +7 -0
- package/lib/projections/poly.js +14 -0
- package/lib/projections/qsc.js +11 -0
- package/lib/projections/sinu.js +11 -0
- package/lib/projections/somerc.js +10 -0
- package/lib/projections/stere.js +16 -2
- package/lib/projections/sterea.js +10 -0
- package/lib/projections/tmerc.js +8 -0
- package/lib/projections/tpers.js +24 -3
- package/lib/projections/utm.js +1 -0
- package/lib/projections/vandg.js +9 -2
- package/lib/transform.js +9 -0
- package/package.json +9 -10
- package/tsconfig.json +14 -0
- package/.github/workflows/build-and-test.yml +0 -69
- package/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +0 -1
- package/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +0 -1
- package/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +0 -1
- package/.nyc_output/processinfo/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +0 -1
- package/.nyc_output/processinfo/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +0 -1
- package/.nyc_output/processinfo/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/scripts/readme.md +0 -10
- package/scripts/updateDatums.mjs +0 -119
- package/scripts/updateEllipsoids.mjs +0 -70
- package/test/BETA2007.gsb +0 -0
- package/test/ntv2_0_downsampled.gsb +0 -0
- package/test/ntv2_0_downsampled_no_error_columns.gsb +0 -0
- package/test/opt.html +0 -28
- package/test/puppeteer-tests.mjs +0 -110
- package/test/test-ci.mjs +0 -10
- package/test/test.js +0 -639
- package/test/testData.js +0 -2386
package/dist/proj4-src.js
CHANGED
|
@@ -51,21 +51,21 @@
|
|
|
51
51
|
// floating point error) from changing their sign.
|
|
52
52
|
var SPI = 3.14159265359;
|
|
53
53
|
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
var primeMeridian = {};
|
|
55
|
+
|
|
56
|
+
primeMeridian.greenwich = 0.0; // "0dE",
|
|
57
|
+
primeMeridian.lisbon = -9.131906111111; // "9d07'54.862\"W",
|
|
58
|
+
primeMeridian.paris = 2.337229166667; // "2d20'14.025\"E",
|
|
59
|
+
primeMeridian.bogota = -74.080916666667; // "74d04'51.3\"W",
|
|
60
|
+
primeMeridian.madrid = -3.687938888889; // "3d41'16.58\"W",
|
|
61
|
+
primeMeridian.rome = 12.452333333333; // "12d27'8.4\"E",
|
|
62
|
+
primeMeridian.bern = 7.439583333333; // "7d26'22.5\"E",
|
|
63
|
+
primeMeridian.jakarta = 106.807719444444; // "106d48'27.79\"E",
|
|
64
|
+
primeMeridian.ferro = -17.666666666667; // "17d40'W",
|
|
65
|
+
primeMeridian.brussels = 4.367975; // "4d22'4.71\"E",
|
|
66
|
+
primeMeridian.stockholm = 18.058277777778; // "18d3'29.8\"E",
|
|
67
|
+
primeMeridian.athens = 23.7163375; // "23d42'58.815\"E",
|
|
68
|
+
primeMeridian.oslo = 10.722916666667; // "10d43'22.5\"E"
|
|
69
69
|
|
|
70
70
|
var units = {
|
|
71
71
|
mm: { to_meter: 0.001 },
|
|
@@ -108,13 +108,19 @@
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @param {string} defData
|
|
113
|
+
* @returns {import('./defs').ProjectionDefinition}
|
|
114
|
+
*/
|
|
111
115
|
function projStr (defData) {
|
|
116
|
+
/** @type {import('./defs').ProjectionDefinition} */
|
|
112
117
|
var self = {};
|
|
113
118
|
var paramObj = defData.split('+').map(function (v) {
|
|
114
119
|
return v.trim();
|
|
115
120
|
}).filter(function (a) {
|
|
116
121
|
return a;
|
|
117
122
|
}).reduce(function (p, a) {
|
|
123
|
+
/** @type {Array<?>} */
|
|
118
124
|
var split = a.split('=');
|
|
119
125
|
split.push(true);
|
|
120
126
|
p[split[0].toLowerCase()] = split[1];
|
|
@@ -206,7 +212,7 @@
|
|
|
206
212
|
self.from_greenwich = v * D2R$1;
|
|
207
213
|
},
|
|
208
214
|
pm: function (v) {
|
|
209
|
-
var pm = match(
|
|
215
|
+
var pm = match(primeMeridian, v);
|
|
210
216
|
self.from_greenwich = (pm ? pm : parseFloat(v)) * D2R$1;
|
|
211
217
|
},
|
|
212
218
|
nadgrids: function (v) {
|
|
@@ -1458,6 +1464,66 @@
|
|
|
1458
1464
|
return obj[type];
|
|
1459
1465
|
}
|
|
1460
1466
|
|
|
1467
|
+
/**
|
|
1468
|
+
* @typedef {Object} ProjectionDefinition
|
|
1469
|
+
* @property {string} title
|
|
1470
|
+
* @property {string} [projName]
|
|
1471
|
+
* @property {string} [ellps]
|
|
1472
|
+
* @property {import('./Proj.js').DatumDefinition} [datum]
|
|
1473
|
+
* @property {string} [datumName]
|
|
1474
|
+
* @property {number} [rf]
|
|
1475
|
+
* @property {number} [lat0]
|
|
1476
|
+
* @property {number} [lat1]
|
|
1477
|
+
* @property {number} [lat2]
|
|
1478
|
+
* @property {number} [lat_ts]
|
|
1479
|
+
* @property {number} [long0]
|
|
1480
|
+
* @property {number} [long1]
|
|
1481
|
+
* @property {number} [long2]
|
|
1482
|
+
* @property {number} [alpha]
|
|
1483
|
+
* @property {number} [longc]
|
|
1484
|
+
* @property {number} [x0]
|
|
1485
|
+
* @property {number} [y0]
|
|
1486
|
+
* @property {number} [k0]
|
|
1487
|
+
* @property {number} [a]
|
|
1488
|
+
* @property {number} [b]
|
|
1489
|
+
* @property {true} [R_A]
|
|
1490
|
+
* @property {number} [zone]
|
|
1491
|
+
* @property {true} [utmSouth]
|
|
1492
|
+
* @property {string|Array<number>} [datum_params]
|
|
1493
|
+
* @property {number} [to_meter]
|
|
1494
|
+
* @property {string} [units]
|
|
1495
|
+
* @property {number} [from_greenwich]
|
|
1496
|
+
* @property {string} [datumCode]
|
|
1497
|
+
* @property {string} [nadgrids]
|
|
1498
|
+
* @property {string} [axis]
|
|
1499
|
+
* @property {boolean} [sphere]
|
|
1500
|
+
* @property {number} [rectified_grid_angle]
|
|
1501
|
+
* @property {boolean} [approx]
|
|
1502
|
+
* @property {<T extends import('./core').TemplateCoordinates>(coordinates: T, enforceAxis?: boolean) => T} inverse
|
|
1503
|
+
* @property {<T extends import('./core').TemplateCoordinates>(coordinates: T, enforceAxis?: boolean) => T} forward
|
|
1504
|
+
*/
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* @overload
|
|
1508
|
+
* @param {string} name
|
|
1509
|
+
* @param {string|ProjectionDefinition|import('./core.js').PROJJSONDefinition} projection
|
|
1510
|
+
* @returns {void}
|
|
1511
|
+
*/
|
|
1512
|
+
/**
|
|
1513
|
+
* @overload
|
|
1514
|
+
* @param {Array<string, string>} name
|
|
1515
|
+
* @returns {Array<ProjectionDefinition|undefined>}
|
|
1516
|
+
*/
|
|
1517
|
+
/**
|
|
1518
|
+
* @overload
|
|
1519
|
+
* @param {string} name
|
|
1520
|
+
* @returns {ProjectionDefinition}
|
|
1521
|
+
*/
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* @param {string | Array<Array<string>> | Partial<Record<'EPSG'|'ESRI'|'IAU2000', ProjectionDefinition>>} name
|
|
1525
|
+
* @returns {ProjectionDefinition | Array<ProjectionDefinition|undefined> | void}
|
|
1526
|
+
*/
|
|
1461
1527
|
function defs(name) {
|
|
1462
1528
|
/* global console */
|
|
1463
1529
|
var that = this;
|
|
@@ -1465,20 +1531,20 @@
|
|
|
1465
1531
|
var def = arguments[1];
|
|
1466
1532
|
if (typeof def === 'string') {
|
|
1467
1533
|
if (def.charAt(0) === '+') {
|
|
1468
|
-
defs[name] = projStr(arguments[1]);
|
|
1534
|
+
defs[/** @type {string} */ (name)] = projStr(arguments[1]);
|
|
1469
1535
|
} else {
|
|
1470
|
-
defs[name] = wkt(arguments[1]);
|
|
1536
|
+
defs[/** @type {string} */ (name)] = wkt(arguments[1]);
|
|
1471
1537
|
}
|
|
1472
1538
|
} else {
|
|
1473
|
-
defs[name] = def;
|
|
1539
|
+
defs[/** @type {string} */ (name)] = def;
|
|
1474
1540
|
}
|
|
1475
1541
|
} else if (arguments.length === 1) {
|
|
1476
1542
|
if (Array.isArray(name)) {
|
|
1477
1543
|
return name.map(function (v) {
|
|
1478
1544
|
if (Array.isArray(v)) {
|
|
1479
|
-
defs.apply(that, v);
|
|
1545
|
+
return defs.apply(that, v);
|
|
1480
1546
|
} else {
|
|
1481
|
-
defs(v);
|
|
1547
|
+
return defs(v);
|
|
1482
1548
|
}
|
|
1483
1549
|
});
|
|
1484
1550
|
} else if (typeof name === 'string') {
|
|
@@ -1527,6 +1593,10 @@
|
|
|
1527
1593
|
function testProj(code) {
|
|
1528
1594
|
return code[0] === '+';
|
|
1529
1595
|
}
|
|
1596
|
+
/**
|
|
1597
|
+
* @param {string | import('./core').PROJJSONDefinition | import('./defs').ProjectionDefinition} code
|
|
1598
|
+
* @returns {import('./defs').ProjectionDefinition}
|
|
1599
|
+
*/
|
|
1530
1600
|
function parse(code) {
|
|
1531
1601
|
if (testObj(code)) {
|
|
1532
1602
|
// check to see if this is a WKT string
|
|
@@ -1548,7 +1618,7 @@
|
|
|
1548
1618
|
if (testProj(code)) {
|
|
1549
1619
|
return projStr(code);
|
|
1550
1620
|
}
|
|
1551
|
-
} else if (!code
|
|
1621
|
+
} else if (!('projName' in code)) {
|
|
1552
1622
|
return wkt(code);
|
|
1553
1623
|
} else {
|
|
1554
1624
|
return code;
|
|
@@ -1606,6 +1676,14 @@
|
|
|
1606
1676
|
return -9999;
|
|
1607
1677
|
}
|
|
1608
1678
|
|
|
1679
|
+
/**
|
|
1680
|
+
* @typedef {Object} LocalThis
|
|
1681
|
+
* @property {number} es
|
|
1682
|
+
* @property {number} e
|
|
1683
|
+
* @property {number} k
|
|
1684
|
+
*/
|
|
1685
|
+
|
|
1686
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
1609
1687
|
function init$x() {
|
|
1610
1688
|
var con = this.b / this.a;
|
|
1611
1689
|
this.es = 1 - con * con;
|
|
@@ -3346,13 +3424,79 @@
|
|
|
3346
3424
|
* - http://mimaka.com/help/gs/html/004_NTV2%20Data%20Format.htm
|
|
3347
3425
|
*/
|
|
3348
3426
|
|
|
3427
|
+
/**
|
|
3428
|
+
* @typedef {Object} NadgridInfo
|
|
3429
|
+
* @property {string} name The name of the NAD grid or 'null' if not specified.
|
|
3430
|
+
* @property {boolean} mandatory Indicates if the grid is mandatory (true) or optional (false).
|
|
3431
|
+
* @property {*} grid The loaded NAD grid object, or null if not loaded or not applicable.
|
|
3432
|
+
* @property {boolean} isNull True if the grid is explicitly 'null', otherwise false.
|
|
3433
|
+
*/
|
|
3434
|
+
|
|
3435
|
+
/**
|
|
3436
|
+
* @typedef {Object} NTV2GridOptions
|
|
3437
|
+
* @property {boolean} [includeErrorFields=true] Whether to include error fields in the subgrids.
|
|
3438
|
+
*/
|
|
3439
|
+
|
|
3440
|
+
/**
|
|
3441
|
+
* @typedef {Object} NadgridHeader
|
|
3442
|
+
* @property {number} [nFields] Number of fields in the header.
|
|
3443
|
+
* @property {number} [nSubgridFields] Number of fields in each subgrid header.
|
|
3444
|
+
* @property {number} nSubgrids Number of subgrids in the file.
|
|
3445
|
+
* @property {string} [shiftType] Type of shift (e.g., "SECONDS").
|
|
3446
|
+
* @property {number} [fromSemiMajorAxis] Source ellipsoid semi-major axis.
|
|
3447
|
+
* @property {number} [fromSemiMinorAxis] Source ellipsoid semi-minor axis.
|
|
3448
|
+
* @property {number} [toSemiMajorAxis] Target ellipsoid semi-major axis.
|
|
3449
|
+
* @property {number} [toSemiMinorAxis] Target ellipsoid semi-minor axis.
|
|
3450
|
+
*/
|
|
3451
|
+
|
|
3452
|
+
/**
|
|
3453
|
+
* @typedef {Object} Subgrid
|
|
3454
|
+
* @property {Array<number>} ll Lower left corner of the grid in radians [longitude, latitude].
|
|
3455
|
+
* @property {Array<number>} del Grid spacing in radians [longitude interval, latitude interval].
|
|
3456
|
+
* @property {Array<number>} lim Number of columns in the grid [longitude columns, latitude columns].
|
|
3457
|
+
* @property {number} [count] Total number of grid nodes.
|
|
3458
|
+
* @property {Array} cvs Mapped node values for the grid.
|
|
3459
|
+
*/
|
|
3460
|
+
|
|
3461
|
+
/** @typedef {{header: NadgridHeader, subgrids: Array<Subgrid>}} NADGrid */
|
|
3462
|
+
|
|
3349
3463
|
var loadedNadgrids = {};
|
|
3350
3464
|
|
|
3351
3465
|
/**
|
|
3352
|
-
*
|
|
3353
|
-
*
|
|
3466
|
+
* @overload
|
|
3467
|
+
* @param {string} key - The key to associate with the loaded grid.
|
|
3468
|
+
* @param {ArrayBuffer} data - The NTv2 grid data as an ArrayBuffer.
|
|
3469
|
+
* @param {NTV2GridOptions} [options] - Optional parameters for loading the grid.
|
|
3470
|
+
* @returns {NADGrid} - The loaded NAD grid information.
|
|
3471
|
+
*/
|
|
3472
|
+
/**
|
|
3473
|
+
* @overload
|
|
3474
|
+
* @param {string} key - The key to associate with the loaded grid.
|
|
3475
|
+
* @param {import('geotiff').GeoTIFF} data - The GeoTIFF instance to read the grid from.
|
|
3476
|
+
* @returns {{ready: Promise<NADGrid>}} - A promise that resolves to the loaded grid information.
|
|
3477
|
+
*/
|
|
3478
|
+
/**
|
|
3479
|
+
* Load either a NTv2 file (.gsb) or a Geotiff (.tif) to a key that can be used in a proj string like +nadgrids=<key>. Pass the NTv2 file
|
|
3480
|
+
* as an ArrayBuffer. Pass Geotiff as a GeoTIFF instance from the geotiff.js library.
|
|
3481
|
+
* @param {string} key - The key to associate with the loaded grid.
|
|
3482
|
+
* @param {ArrayBuffer|import('geotiff').GeoTIFF} data The data to load, either an ArrayBuffer for NTv2 or a GeoTIFF instance.
|
|
3483
|
+
* @param {NTV2GridOptions} [options] Optional parameters.
|
|
3484
|
+
* @returns {{ready: Promise<NADGrid>}|NADGrid} - A promise that resolves to the loaded grid information.
|
|
3354
3485
|
*/
|
|
3355
3486
|
function nadgrid(key, data, options) {
|
|
3487
|
+
if (data instanceof ArrayBuffer) {
|
|
3488
|
+
return readNTV2Grid(key, data, options);
|
|
3489
|
+
}
|
|
3490
|
+
return { ready: readGeotiffGrid(key, data) };
|
|
3491
|
+
}
|
|
3492
|
+
|
|
3493
|
+
/**
|
|
3494
|
+
* @param {string} key The key to associate with the loaded grid.
|
|
3495
|
+
* @param {ArrayBuffer} data The NTv2 grid data as an ArrayBuffer.
|
|
3496
|
+
* @param {NTV2GridOptions} [options] Optional parameters for loading the grid.
|
|
3497
|
+
* @returns {NADGrid} The loaded NAD grid information.
|
|
3498
|
+
*/
|
|
3499
|
+
function readNTV2Grid(key, data, options) {
|
|
3356
3500
|
var includeErrorFields = true;
|
|
3357
3501
|
if (options !== undefined && options.includeErrorFields === false) {
|
|
3358
3502
|
includeErrorFields = false;
|
|
@@ -3366,8 +3510,59 @@
|
|
|
3366
3510
|
return nadgrid;
|
|
3367
3511
|
}
|
|
3368
3512
|
|
|
3513
|
+
/**
|
|
3514
|
+
* @param {string} key The key to associate with the loaded grid.
|
|
3515
|
+
* @param {import('geotiff').GeoTIFF} tiff The GeoTIFF instance to read the grid from.
|
|
3516
|
+
* @returns {Promise<NADGrid>} A promise that resolves to the loaded NAD grid information.
|
|
3517
|
+
*/
|
|
3518
|
+
async function readGeotiffGrid(key, tiff) {
|
|
3519
|
+
var subgrids = [];
|
|
3520
|
+
var subGridCount = await tiff.getImageCount();
|
|
3521
|
+
// proj produced tiff grid shift files appear to organize lower res subgrids first, higher res/ child subgrids last.
|
|
3522
|
+
for (var subgridIndex = subGridCount - 1; subgridIndex >= 0; subgridIndex--) {
|
|
3523
|
+
var image = await tiff.getImage(subgridIndex);
|
|
3524
|
+
|
|
3525
|
+
var rasters = await image.readRasters();
|
|
3526
|
+
var data = rasters;
|
|
3527
|
+
var lim = [image.getWidth(), image.getHeight()];
|
|
3528
|
+
var imageBBoxRadians = image.getBoundingBox().map(degreesToRadians);
|
|
3529
|
+
var del = [image.fileDirectory.ModelPixelScale[0], image.fileDirectory.ModelPixelScale[1]].map(degreesToRadians);
|
|
3530
|
+
|
|
3531
|
+
var maxX = imageBBoxRadians[0] + (lim[0] - 1) * del[0];
|
|
3532
|
+
var minY = imageBBoxRadians[3] - (lim[1] - 1) * del[1];
|
|
3533
|
+
|
|
3534
|
+
var latitudeOffsetBand = data[0];
|
|
3535
|
+
var longitudeOffsetBand = data[1];
|
|
3536
|
+
var nodes = [];
|
|
3537
|
+
|
|
3538
|
+
for (let i = lim[1] - 1; i >= 0; i--) {
|
|
3539
|
+
for (let j = lim[0] - 1; j >= 0; j--) {
|
|
3540
|
+
var index = i * lim[0] + j;
|
|
3541
|
+
nodes.push([-secondsToRadians(longitudeOffsetBand[index]), secondsToRadians(latitudeOffsetBand[index])]);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
|
|
3545
|
+
subgrids.push({
|
|
3546
|
+
del: del,
|
|
3547
|
+
lim: lim,
|
|
3548
|
+
ll: [-maxX, minY],
|
|
3549
|
+
cvs: nodes
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
var tifGrid = {
|
|
3554
|
+
header: {
|
|
3555
|
+
nSubgrids: subGridCount
|
|
3556
|
+
},
|
|
3557
|
+
subgrids: subgrids
|
|
3558
|
+
};
|
|
3559
|
+
loadedNadgrids[key] = tifGrid;
|
|
3560
|
+
return tifGrid;
|
|
3561
|
+
}
|
|
3369
3562
|
/**
|
|
3370
3563
|
* Given a proj4 value for nadgrids, return an array of loaded grids
|
|
3564
|
+
* @param {string} nadgrids A comma-separated list of grid names, optionally prefixed with '@' to indicate optional grids.
|
|
3565
|
+
* @returns
|
|
3371
3566
|
*/
|
|
3372
3567
|
function getNadgrids(nadgrids) {
|
|
3373
3568
|
// Format details: http://proj.maptools.org/gen_parms.html
|
|
@@ -3378,6 +3573,10 @@
|
|
|
3378
3573
|
return grids.map(parseNadgridString);
|
|
3379
3574
|
}
|
|
3380
3575
|
|
|
3576
|
+
/**
|
|
3577
|
+
* @param {string} value The nadgrid string to get information for.
|
|
3578
|
+
* @returns {NadgridInfo|null} An object with grid information, or null if the input is empty.
|
|
3579
|
+
*/
|
|
3381
3580
|
function parseNadgridString(value) {
|
|
3382
3581
|
if (value.length === 0) {
|
|
3383
3582
|
return null;
|
|
@@ -3397,6 +3596,10 @@
|
|
|
3397
3596
|
};
|
|
3398
3597
|
}
|
|
3399
3598
|
|
|
3599
|
+
function degreesToRadians(degrees) {
|
|
3600
|
+
return (degrees) * Math.PI / 180;
|
|
3601
|
+
}
|
|
3602
|
+
|
|
3400
3603
|
function secondsToRadians(seconds) {
|
|
3401
3604
|
return (seconds / 3600) * Math.PI / 180;
|
|
3402
3605
|
}
|
|
@@ -3457,6 +3660,10 @@
|
|
|
3457
3660
|
return grids;
|
|
3458
3661
|
}
|
|
3459
3662
|
|
|
3663
|
+
/**
|
|
3664
|
+
* @param {*} nodes
|
|
3665
|
+
* @returns Array<Array<number>>
|
|
3666
|
+
*/
|
|
3460
3667
|
function mapNodes(nodes) {
|
|
3461
3668
|
return nodes.map(function (r) {
|
|
3462
3669
|
return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)];
|
|
@@ -3503,10 +3710,31 @@
|
|
|
3503
3710
|
return gridShiftRecords;
|
|
3504
3711
|
}
|
|
3505
3712
|
|
|
3713
|
+
/**
|
|
3714
|
+
* @typedef {Object} DatumDefinition
|
|
3715
|
+
* @property {number} datum_type - The type of datum.
|
|
3716
|
+
* @property {number} a - Semi-major axis of the ellipsoid.
|
|
3717
|
+
* @property {number} b - Semi-minor axis of the ellipsoid.
|
|
3718
|
+
* @property {number} es - Eccentricity squared of the ellipsoid.
|
|
3719
|
+
* @property {number} ep2 - Second eccentricity squared of the ellipsoid.
|
|
3720
|
+
*/
|
|
3721
|
+
|
|
3722
|
+
/**
|
|
3723
|
+
* @param {string | import('./core').PROJJSONDefinition | import('./defs').ProjectionDefinition} srsCode
|
|
3724
|
+
* @param {(errorMessage?: string, instance?: Projection) => void} [callback]
|
|
3725
|
+
*/
|
|
3506
3726
|
function Projection(srsCode, callback) {
|
|
3507
3727
|
if (!(this instanceof Projection)) {
|
|
3508
3728
|
return new Projection(srsCode);
|
|
3509
3729
|
}
|
|
3730
|
+
/** @type {<T extends import('./core').TemplateCoordinates>(coordinates: T, enforceAxis?: boolean) => T} */
|
|
3731
|
+
this.forward = null;
|
|
3732
|
+
/** @type {<T extends import('./core').TemplateCoordinates>(coordinates: T, enforceAxis?: boolean) => T} */
|
|
3733
|
+
this.inverse = null;
|
|
3734
|
+
/** @type {string} */
|
|
3735
|
+
this.name;
|
|
3736
|
+
/** @type {string} */
|
|
3737
|
+
this.title;
|
|
3510
3738
|
callback = callback || function (error) {
|
|
3511
3739
|
if (error) {
|
|
3512
3740
|
throw error;
|
|
@@ -3538,6 +3766,7 @@
|
|
|
3538
3766
|
var sphere_ = sphere(json.a, json.b, json.rf, json.ellps, json.sphere);
|
|
3539
3767
|
var ecc = eccentricity(sphere_.a, sphere_.b, sphere_.rf, json.R_A);
|
|
3540
3768
|
var nadgrids = getNadgrids(json.nadgrids);
|
|
3769
|
+
/** @type {DatumDefinition} */
|
|
3541
3770
|
var datumObj = json.datum || datum(json.datumCode, json.datum_params, sphere_.a, sphere_.b, ecc.es, ecc.ep2,
|
|
3542
3771
|
nadgrids);
|
|
3543
3772
|
|
|
@@ -3559,7 +3788,9 @@
|
|
|
3559
3788
|
this.datum = datumObj;
|
|
3560
3789
|
|
|
3561
3790
|
// init the projection
|
|
3562
|
-
this.init
|
|
3791
|
+
if ('init' in this && typeof this.init === 'function') {
|
|
3792
|
+
this.init();
|
|
3793
|
+
}
|
|
3563
3794
|
|
|
3564
3795
|
// legecy callback from back in the day when it went to spatialreference.org
|
|
3565
3796
|
callback(null, this);
|
|
@@ -3996,6 +4227,7 @@
|
|
|
3996
4227
|
yin = point.y,
|
|
3997
4228
|
zin = point.z || 0.0;
|
|
3998
4229
|
var v, t, i;
|
|
4230
|
+
/** @type {import("./core").InterfaceCoordinates} */
|
|
3999
4231
|
var out = {};
|
|
4000
4232
|
for (i = 0; i < 3; i++) {
|
|
4001
4233
|
if (denorm && i === 2 && point.z === undefined) {
|
|
@@ -4050,6 +4282,10 @@
|
|
|
4050
4282
|
return out;
|
|
4051
4283
|
}
|
|
4052
4284
|
|
|
4285
|
+
/**
|
|
4286
|
+
* @param {Array<number>} array
|
|
4287
|
+
* @returns {import("../core").InterfaceCoordinates}
|
|
4288
|
+
*/
|
|
4053
4289
|
function common (array) {
|
|
4054
4290
|
var out = {
|
|
4055
4291
|
x: array[0],
|
|
@@ -4086,6 +4322,13 @@
|
|
|
4086
4322
|
|| ((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM || dest.datum.datum_type === PJD_GRIDSHIFT) && source.datumCode !== 'WGS84');
|
|
4087
4323
|
}
|
|
4088
4324
|
|
|
4325
|
+
/**
|
|
4326
|
+
* @param {import('./defs').ProjectionDefinition} source
|
|
4327
|
+
* @param {import('./defs').ProjectionDefinition} dest
|
|
4328
|
+
* @param {import('./core').TemplateCoordinates} point
|
|
4329
|
+
* @param {boolean} enforceAxis
|
|
4330
|
+
* @returns {import('./core').InterfaceCoordinates | undefined}
|
|
4331
|
+
*/
|
|
4089
4332
|
function transform(source, dest, point, enforceAxis) {
|
|
4090
4333
|
var wgs84;
|
|
4091
4334
|
if (Array.isArray(point)) {
|
|
@@ -4142,6 +4385,8 @@
|
|
|
4142
4385
|
return;
|
|
4143
4386
|
}
|
|
4144
4387
|
|
|
4388
|
+
point = /** @type {import('./core').InterfaceCoordinates} */ (point);
|
|
4389
|
+
|
|
4145
4390
|
// Adjust for the prime meridian if necessary
|
|
4146
4391
|
if (dest.from_greenwich) {
|
|
4147
4392
|
point = {
|
|
@@ -4182,6 +4427,85 @@
|
|
|
4182
4427
|
|
|
4183
4428
|
var wgs84 = Projection('WGS84');
|
|
4184
4429
|
|
|
4430
|
+
/**
|
|
4431
|
+
* @typedef {{x: number, y: number, z?: number, m?: number}} InterfaceCoordinates
|
|
4432
|
+
*/
|
|
4433
|
+
|
|
4434
|
+
/**
|
|
4435
|
+
* @typedef {Array<number> | InterfaceCoordinates} TemplateCoordinates
|
|
4436
|
+
*/
|
|
4437
|
+
|
|
4438
|
+
/**
|
|
4439
|
+
* @typedef {Object} Converter
|
|
4440
|
+
* @property {<T extends TemplateCoordinates>(coordinates: T, enforceAxis?: boolean) => T} forward
|
|
4441
|
+
* @property {<T extends TemplateCoordinates>(coordinates: T, enforceAxis?: boolean) => T} inverse
|
|
4442
|
+
* @property {proj} [oProj]
|
|
4443
|
+
*/
|
|
4444
|
+
|
|
4445
|
+
/**
|
|
4446
|
+
* @typedef {Object} PROJJSONDefinition
|
|
4447
|
+
* @property {string} [$schema]
|
|
4448
|
+
* @property {string} type
|
|
4449
|
+
* @property {string} [name]
|
|
4450
|
+
* @property {{authority: string, code: number}} [id]
|
|
4451
|
+
* @property {string} [scope]
|
|
4452
|
+
* @property {string} [area]
|
|
4453
|
+
* @property {{south_latitude: number, west_longitude: number, north_latitude: number, east_longitude: number}} [bbox]
|
|
4454
|
+
* @property {PROJJSONDefinition[]} [components]
|
|
4455
|
+
* @property {{type: string, name: string}} [datum]
|
|
4456
|
+
* @property {{
|
|
4457
|
+
* name: string,
|
|
4458
|
+
* members: Array<{
|
|
4459
|
+
* name: string,
|
|
4460
|
+
* id?: {authority: string, code: number}
|
|
4461
|
+
* }>,
|
|
4462
|
+
* ellipsoid?: {
|
|
4463
|
+
* name: string,
|
|
4464
|
+
* semi_major_axis: number,
|
|
4465
|
+
* inverse_flattening?: number
|
|
4466
|
+
* },
|
|
4467
|
+
* accuracy?: string,
|
|
4468
|
+
* id?: {authority: string, code: number}
|
|
4469
|
+
* }} [datum_ensemble]
|
|
4470
|
+
* @property {{
|
|
4471
|
+
* subtype: string,
|
|
4472
|
+
* axis: Array<{
|
|
4473
|
+
* name: string,
|
|
4474
|
+
* abbreviation?: string,
|
|
4475
|
+
* direction: string,
|
|
4476
|
+
* unit: string
|
|
4477
|
+
* }>
|
|
4478
|
+
* }} [coordinate_system]
|
|
4479
|
+
* @property {{
|
|
4480
|
+
* name: string,
|
|
4481
|
+
* method: {name: string},
|
|
4482
|
+
* parameters: Array<{
|
|
4483
|
+
* name: string,
|
|
4484
|
+
* value: number,
|
|
4485
|
+
* unit?: string
|
|
4486
|
+
* }>
|
|
4487
|
+
* }} [conversion]
|
|
4488
|
+
* @property {{
|
|
4489
|
+
* name: string,
|
|
4490
|
+
* method: {name: string},
|
|
4491
|
+
* parameters: Array<{
|
|
4492
|
+
* name: string,
|
|
4493
|
+
* value: number,
|
|
4494
|
+
* unit?: string,
|
|
4495
|
+
* type?: string,
|
|
4496
|
+
* file_name?: string
|
|
4497
|
+
* }>
|
|
4498
|
+
* }} [transformation]
|
|
4499
|
+
*/
|
|
4500
|
+
|
|
4501
|
+
/**
|
|
4502
|
+
* @template {TemplateCoordinates} T
|
|
4503
|
+
* @param {proj} from
|
|
4504
|
+
* @param {proj} to
|
|
4505
|
+
* @param {T} coords
|
|
4506
|
+
* @param {boolean} [enforceAxis]
|
|
4507
|
+
* @returns {T}
|
|
4508
|
+
*/
|
|
4185
4509
|
function transformer(from, to, coords, enforceAxis) {
|
|
4186
4510
|
var transformedArray, out, keys;
|
|
4187
4511
|
if (Array.isArray(coords)) {
|
|
@@ -4189,21 +4513,21 @@
|
|
|
4189
4513
|
if (coords.length > 2) {
|
|
4190
4514
|
if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {
|
|
4191
4515
|
if (typeof transformedArray.z === 'number') {
|
|
4192
|
-
return [transformedArray.x, transformedArray.y, transformedArray.z].concat(coords.slice(3));
|
|
4516
|
+
return /** @type {T} */ ([transformedArray.x, transformedArray.y, transformedArray.z].concat(coords.slice(3)));
|
|
4193
4517
|
} else {
|
|
4194
|
-
return [transformedArray.x, transformedArray.y, coords[2]].concat(coords.slice(3));
|
|
4518
|
+
return /** @type {T} */ ([transformedArray.x, transformedArray.y, coords[2]].concat(coords.slice(3)));
|
|
4195
4519
|
}
|
|
4196
4520
|
} else {
|
|
4197
|
-
return [transformedArray.x, transformedArray.y].concat(coords.slice(2));
|
|
4521
|
+
return /** @type {T} */ ([transformedArray.x, transformedArray.y].concat(coords.slice(2)));
|
|
4198
4522
|
}
|
|
4199
4523
|
} else {
|
|
4200
|
-
return [transformedArray.x, transformedArray.y];
|
|
4524
|
+
return /** @type {T} */ ([transformedArray.x, transformedArray.y]);
|
|
4201
4525
|
}
|
|
4202
4526
|
} else {
|
|
4203
4527
|
out = transform(from, to, coords, enforceAxis);
|
|
4204
4528
|
keys = Object.keys(coords);
|
|
4205
4529
|
if (keys.length === 2) {
|
|
4206
|
-
return out;
|
|
4530
|
+
return /** @type {T} */ (out);
|
|
4207
4531
|
}
|
|
4208
4532
|
keys.forEach(function (key) {
|
|
4209
4533
|
if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {
|
|
@@ -4217,42 +4541,98 @@
|
|
|
4217
4541
|
}
|
|
4218
4542
|
out[key] = coords[key];
|
|
4219
4543
|
});
|
|
4220
|
-
return out;
|
|
4544
|
+
return /** @type {T} */ (out);
|
|
4221
4545
|
}
|
|
4222
4546
|
}
|
|
4223
4547
|
|
|
4548
|
+
/**
|
|
4549
|
+
* @param {proj | string | PROJJSONDefinition | Converter} item
|
|
4550
|
+
* @returns {import('./Proj').default}
|
|
4551
|
+
*/
|
|
4224
4552
|
function checkProj(item) {
|
|
4225
4553
|
if (item instanceof Projection) {
|
|
4226
4554
|
return item;
|
|
4227
4555
|
}
|
|
4228
|
-
if (item
|
|
4556
|
+
if (typeof item === 'object' && 'oProj' in item) {
|
|
4229
4557
|
return item.oProj;
|
|
4230
4558
|
}
|
|
4231
|
-
return Projection(item);
|
|
4559
|
+
return Projection(/** @type {string | PROJJSONDefinition} */ (item));
|
|
4232
4560
|
}
|
|
4233
4561
|
|
|
4234
|
-
|
|
4235
|
-
|
|
4562
|
+
/**
|
|
4563
|
+
* @overload
|
|
4564
|
+
* @param {string | PROJJSONDefinition | proj} toProj
|
|
4565
|
+
* @returns {Converter}
|
|
4566
|
+
*/
|
|
4567
|
+
/**
|
|
4568
|
+
* @overload
|
|
4569
|
+
* @param {string | PROJJSONDefinition | proj} fromProj
|
|
4570
|
+
* @param {string | PROJJSONDefinition | proj} toProj
|
|
4571
|
+
* @returns {Converter}
|
|
4572
|
+
*/
|
|
4573
|
+
/**
|
|
4574
|
+
* @overload
|
|
4575
|
+
* @param {string | PROJJSONDefinition | proj} toProj
|
|
4576
|
+
* @param {T} coord
|
|
4577
|
+
* @returns {T}
|
|
4578
|
+
*/
|
|
4579
|
+
/**
|
|
4580
|
+
* @overload
|
|
4581
|
+
* @param {string | PROJJSONDefinition | proj} fromProj
|
|
4582
|
+
* @param {string | PROJJSONDefinition | proj} toProj
|
|
4583
|
+
* @param {T} coord
|
|
4584
|
+
* @returns {T}
|
|
4585
|
+
*/
|
|
4586
|
+
/**
|
|
4587
|
+
* @template {TemplateCoordinates} T
|
|
4588
|
+
* @param {string | PROJJSONDefinition | proj} fromProjOrToProj
|
|
4589
|
+
* @param {string | PROJJSONDefinition | proj | TemplateCoordinates} [toProjOrCoord]
|
|
4590
|
+
* @param {T} [coord]
|
|
4591
|
+
* @returns {T|Converter}
|
|
4592
|
+
*/
|
|
4593
|
+
function proj4$1(fromProjOrToProj, toProjOrCoord, coord) {
|
|
4594
|
+
/** @type {proj} */
|
|
4595
|
+
var fromProj;
|
|
4596
|
+
/** @type {proj} */
|
|
4597
|
+
var toProj;
|
|
4236
4598
|
var single = false;
|
|
4599
|
+
/** @type {Converter} */
|
|
4237
4600
|
var obj;
|
|
4238
|
-
if (typeof
|
|
4239
|
-
toProj =
|
|
4601
|
+
if (typeof toProjOrCoord === 'undefined') {
|
|
4602
|
+
toProj = checkProj(fromProjOrToProj);
|
|
4240
4603
|
fromProj = wgs84;
|
|
4241
4604
|
single = true;
|
|
4242
|
-
} else if (typeof
|
|
4243
|
-
coord =
|
|
4244
|
-
toProj =
|
|
4605
|
+
} else if (typeof /** @type {?} */ (toProjOrCoord).x !== 'undefined' || Array.isArray(toProjOrCoord)) {
|
|
4606
|
+
coord = /** @type {T} */ (/** @type {?} */ (toProjOrCoord));
|
|
4607
|
+
toProj = checkProj(fromProjOrToProj);
|
|
4245
4608
|
fromProj = wgs84;
|
|
4246
4609
|
single = true;
|
|
4247
4610
|
}
|
|
4248
|
-
|
|
4611
|
+
if (!fromProj) {
|
|
4612
|
+
fromProj = checkProj(fromProjOrToProj);
|
|
4613
|
+
}
|
|
4614
|
+
if (!toProj) {
|
|
4615
|
+
toProj = checkProj(/** @type {string | PROJJSONDefinition | proj } */ (toProjOrCoord));
|
|
4616
|
+
}
|
|
4249
4617
|
if (coord) {
|
|
4250
4618
|
return transformer(fromProj, toProj, coord);
|
|
4251
4619
|
} else {
|
|
4252
4620
|
obj = {
|
|
4621
|
+
/**
|
|
4622
|
+
* @template {TemplateCoordinates} T
|
|
4623
|
+
* @param {T} coords
|
|
4624
|
+
* @param {boolean=} enforceAxis
|
|
4625
|
+
* @returns {T}
|
|
4626
|
+
*/
|
|
4253
4627
|
forward: function (coords, enforceAxis) {
|
|
4254
4628
|
return transformer(fromProj, toProj, coords, enforceAxis);
|
|
4255
4629
|
},
|
|
4630
|
+
/**
|
|
4631
|
+
* @template {TemplateCoordinates} T
|
|
4632
|
+
* @param {T} coords
|
|
4633
|
+
* @param {boolean=} enforceAxis
|
|
4634
|
+
* @returns {T}
|
|
4635
|
+
*/
|
|
4256
4636
|
inverse: function (coords, enforceAxis) {
|
|
4257
4637
|
return transformer(toProj, fromProj, coords, enforceAxis);
|
|
4258
4638
|
}
|
|
@@ -5005,6 +5385,12 @@
|
|
|
5005
5385
|
|
|
5006
5386
|
}
|
|
5007
5387
|
|
|
5388
|
+
/**
|
|
5389
|
+
* @deprecated v3.0.0 - use proj4.toPoint instead
|
|
5390
|
+
* @param {number | import('./core').TemplateCoordinates | string} x
|
|
5391
|
+
* @param {number} [y]
|
|
5392
|
+
* @param {number} [z]
|
|
5393
|
+
*/
|
|
5008
5394
|
function Point(x, y, z) {
|
|
5009
5395
|
if (!(this instanceof Point)) {
|
|
5010
5396
|
return new Point(x, y, z);
|
|
@@ -5019,9 +5405,9 @@
|
|
|
5019
5405
|
this.z = x.z || 0.0;
|
|
5020
5406
|
} else if (typeof x === 'string' && typeof y === 'undefined') {
|
|
5021
5407
|
var coords = x.split(',');
|
|
5022
|
-
this.x = parseFloat(coords[0]
|
|
5023
|
-
this.y = parseFloat(coords[1]
|
|
5024
|
-
this.z = parseFloat(coords[2]
|
|
5408
|
+
this.x = parseFloat(coords[0]);
|
|
5409
|
+
this.y = parseFloat(coords[1]);
|
|
5410
|
+
this.z = parseFloat(coords[2]) || 0.0;
|
|
5025
5411
|
} else {
|
|
5026
5412
|
this.x = x;
|
|
5027
5413
|
this.y = y;
|
|
@@ -5092,6 +5478,14 @@
|
|
|
5092
5478
|
// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/tmerc.js
|
|
5093
5479
|
|
|
5094
5480
|
|
|
5481
|
+
/**
|
|
5482
|
+
* @typedef {Object} LocalThis
|
|
5483
|
+
* @property {number} es
|
|
5484
|
+
* @property {Array<number>} en
|
|
5485
|
+
* @property {number} ml0
|
|
5486
|
+
*/
|
|
5487
|
+
|
|
5488
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
5095
5489
|
function init$v() {
|
|
5096
5490
|
this.x0 = this.x0 !== undefined ? this.x0 : 0;
|
|
5097
5491
|
this.y0 = this.y0 !== undefined ? this.y0 : 0;
|
|
@@ -5349,6 +5743,18 @@
|
|
|
5349
5743
|
// https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/etmerc.js
|
|
5350
5744
|
|
|
5351
5745
|
|
|
5746
|
+
/**
|
|
5747
|
+
* @typedef {Object} LocalThis
|
|
5748
|
+
* @property {number} es
|
|
5749
|
+
* @property {Array<number>} cbg
|
|
5750
|
+
* @property {Array<number>} cgb
|
|
5751
|
+
* @property {Array<number>} utg
|
|
5752
|
+
* @property {Array<number>} gtu
|
|
5753
|
+
* @property {number} Qn
|
|
5754
|
+
* @property {number} Zb
|
|
5755
|
+
*/
|
|
5756
|
+
|
|
5757
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
5352
5758
|
function init$u() {
|
|
5353
5759
|
if (!this.approx && (isNaN(this.es) || this.es <= 0)) {
|
|
5354
5760
|
throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');
|
|
@@ -5523,6 +5929,7 @@
|
|
|
5523
5929
|
|
|
5524
5930
|
var dependsOn = 'etmerc';
|
|
5525
5931
|
|
|
5932
|
+
/** @this {import('../defs.js').ProjectionDefinition} */
|
|
5526
5933
|
function init$t() {
|
|
5527
5934
|
var zone = adjust_zone(this.zone, this.long0);
|
|
5528
5935
|
if (zone === undefined) {
|
|
@@ -5552,6 +5959,18 @@
|
|
|
5552
5959
|
|
|
5553
5960
|
var MAX_ITER$2 = 20;
|
|
5554
5961
|
|
|
5962
|
+
/**
|
|
5963
|
+
* @typedef {Object} LocalThis
|
|
5964
|
+
* @property {number} rc
|
|
5965
|
+
* @property {number} C
|
|
5966
|
+
* @property {number} phic0
|
|
5967
|
+
* @property {number} ratexp
|
|
5968
|
+
* @property {number} K
|
|
5969
|
+
* @property {number} e
|
|
5970
|
+
* @property {number} es
|
|
5971
|
+
*/
|
|
5972
|
+
|
|
5973
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
5555
5974
|
function init$s() {
|
|
5556
5975
|
var sphi = Math.sin(this.lat0);
|
|
5557
5976
|
var cphi = Math.cos(this.lat0);
|
|
@@ -5597,6 +6016,16 @@
|
|
|
5597
6016
|
forward: forward$r,
|
|
5598
6017
|
inverse: inverse$r};
|
|
5599
6018
|
|
|
6019
|
+
/**
|
|
6020
|
+
* @typedef {Object} LocalThis
|
|
6021
|
+
* @property {number} sinc0
|
|
6022
|
+
* @property {number} cosc0
|
|
6023
|
+
* @property {number} R2
|
|
6024
|
+
* @property {number} rc
|
|
6025
|
+
* @property {number} phic0
|
|
6026
|
+
*/
|
|
6027
|
+
|
|
6028
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
5600
6029
|
function init$r() {
|
|
5601
6030
|
gauss.init.apply(this);
|
|
5602
6031
|
if (!this.rc) {
|
|
@@ -5658,11 +6087,25 @@
|
|
|
5658
6087
|
names: names$r
|
|
5659
6088
|
};
|
|
5660
6089
|
|
|
6090
|
+
/**
|
|
6091
|
+
* @typedef {Object} LocalThis
|
|
6092
|
+
* @property {number} coslat0
|
|
6093
|
+
* @property {number} sinlat0
|
|
6094
|
+
* @property {number} ms1
|
|
6095
|
+
* @property {number} X0
|
|
6096
|
+
* @property {number} cosX0
|
|
6097
|
+
* @property {number} sinX0
|
|
6098
|
+
* @property {number} con
|
|
6099
|
+
* @property {number} cons
|
|
6100
|
+
* @property {number} e
|
|
6101
|
+
*/
|
|
6102
|
+
|
|
5661
6103
|
function ssfn_(phit, sinphi, eccen) {
|
|
5662
6104
|
sinphi *= eccen;
|
|
5663
6105
|
return (Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen));
|
|
5664
6106
|
}
|
|
5665
6107
|
|
|
6108
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
5666
6109
|
function init$q() {
|
|
5667
6110
|
// setting default parameters
|
|
5668
6111
|
this.x0 = this.x0 || 0;
|
|
@@ -5695,7 +6138,7 @@
|
|
|
5695
6138
|
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));
|
|
5696
6139
|
}
|
|
5697
6140
|
this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
|
|
5698
|
-
this.X0 = 2 * Math.atan(
|
|
6141
|
+
this.X0 = 2 * Math.atan(ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
|
|
5699
6142
|
this.cosX0 = Math.cos(this.X0);
|
|
5700
6143
|
this.sinX0 = Math.sin(this.X0);
|
|
5701
6144
|
}
|
|
@@ -5724,7 +6167,7 @@
|
|
|
5724
6167
|
p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;
|
|
5725
6168
|
return p;
|
|
5726
6169
|
} else {
|
|
5727
|
-
X = 2 * Math.atan(
|
|
6170
|
+
X = 2 * Math.atan(ssfn_(lat, sinlat, this.e)) - HALF_PI;
|
|
5728
6171
|
cosX = Math.cos(X);
|
|
5729
6172
|
sinX = Math.sin(X);
|
|
5730
6173
|
if (Math.abs(this.coslat0) <= EPSLN) {
|
|
@@ -5830,6 +6273,16 @@
|
|
|
5830
6273
|
http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
|
|
5831
6274
|
*/
|
|
5832
6275
|
|
|
6276
|
+
/**
|
|
6277
|
+
* @typedef {Object} LocalThis
|
|
6278
|
+
* @property {number} lambda0
|
|
6279
|
+
* @property {number} e
|
|
6280
|
+
* @property {number} R
|
|
6281
|
+
* @property {number} b0
|
|
6282
|
+
* @property {number} K
|
|
6283
|
+
*/
|
|
6284
|
+
|
|
6285
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
5833
6286
|
function init$p() {
|
|
5834
6287
|
var phy0 = this.lat0;
|
|
5835
6288
|
this.lambda0 = this.long0;
|
|
@@ -5909,6 +6362,29 @@
|
|
|
5909
6362
|
names: names$p
|
|
5910
6363
|
};
|
|
5911
6364
|
|
|
6365
|
+
/**
|
|
6366
|
+
* @typedef {Object} LocalThis
|
|
6367
|
+
* @property {boolean} no_off
|
|
6368
|
+
* @property {boolean} no_rot
|
|
6369
|
+
* @property {number} rectified_grid_angle
|
|
6370
|
+
* @property {number} es
|
|
6371
|
+
* @property {number} A
|
|
6372
|
+
* @property {number} B
|
|
6373
|
+
* @property {number} E
|
|
6374
|
+
* @property {number} e
|
|
6375
|
+
* @property {number} lam0
|
|
6376
|
+
* @property {number} singam
|
|
6377
|
+
* @property {number} cosgam
|
|
6378
|
+
* @property {number} sinrot
|
|
6379
|
+
* @property {number} cosrot
|
|
6380
|
+
* @property {number} rB
|
|
6381
|
+
* @property {number} ArB
|
|
6382
|
+
* @property {number} BrA
|
|
6383
|
+
* @property {number} u_0
|
|
6384
|
+
* @property {number} v_pole_n
|
|
6385
|
+
* @property {number} v_pole_s
|
|
6386
|
+
*/
|
|
6387
|
+
|
|
5912
6388
|
var TOL = 1e-7;
|
|
5913
6389
|
|
|
5914
6390
|
function isTypeA(P) {
|
|
@@ -5918,8 +6394,10 @@
|
|
|
5918
6394
|
return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1 || typeAProjections.indexOf(getNormalizedProjName(projectionName)) !== -1;
|
|
5919
6395
|
}
|
|
5920
6396
|
|
|
5921
|
-
|
|
5922
|
-
|
|
6397
|
+
/**
|
|
6398
|
+
* Initialize the Oblique Mercator projection
|
|
6399
|
+
* @this {import('../defs.js').ProjectionDefinition & LocalThis}
|
|
6400
|
+
*/
|
|
5923
6401
|
function init$o() {
|
|
5924
6402
|
var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0,
|
|
5925
6403
|
gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0;
|
|
@@ -6012,9 +6490,9 @@
|
|
|
6012
6490
|
J = (J - L * H) / (J + L * H);
|
|
6013
6491
|
con = lam1 - lam2;
|
|
6014
6492
|
|
|
6015
|
-
if (con < -Math.
|
|
6493
|
+
if (con < -Math.PI) {
|
|
6016
6494
|
lam2 -= TWO_PI;
|
|
6017
|
-
} else if (con > Math.
|
|
6495
|
+
} else if (con > Math.PI) {
|
|
6018
6496
|
lam2 += TWO_PI;
|
|
6019
6497
|
}
|
|
6020
6498
|
|
|
@@ -6143,6 +6621,15 @@
|
|
|
6143
6621
|
names: names$o
|
|
6144
6622
|
};
|
|
6145
6623
|
|
|
6624
|
+
/**
|
|
6625
|
+
* @typedef {Object} LocalThis
|
|
6626
|
+
* @property {number} e
|
|
6627
|
+
* @property {number} ns
|
|
6628
|
+
* @property {number} f0
|
|
6629
|
+
* @property {number} rh
|
|
6630
|
+
*/
|
|
6631
|
+
|
|
6632
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
6146
6633
|
function init$n() {
|
|
6147
6634
|
// double lat0; /* the reference latitude */
|
|
6148
6635
|
// double long0; /* the reference longitude */
|
|
@@ -6434,6 +6921,17 @@
|
|
|
6434
6921
|
return NaN;
|
|
6435
6922
|
}
|
|
6436
6923
|
|
|
6924
|
+
/**
|
|
6925
|
+
* @typedef {Object} LocalThis
|
|
6926
|
+
* @property {number} es
|
|
6927
|
+
* @property {number} e0
|
|
6928
|
+
* @property {number} e1
|
|
6929
|
+
* @property {number} e2
|
|
6930
|
+
* @property {number} e3
|
|
6931
|
+
* @property {number} ml0
|
|
6932
|
+
*/
|
|
6933
|
+
|
|
6934
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
6437
6935
|
function init$l() {
|
|
6438
6936
|
if (!this.sphere) {
|
|
6439
6937
|
this.e0 = e0fn(this.es);
|
|
@@ -6535,6 +7033,24 @@
|
|
|
6535
7033
|
}
|
|
6536
7034
|
}
|
|
6537
7035
|
|
|
7036
|
+
/**
|
|
7037
|
+
* @typedef {Object} LocalThis
|
|
7038
|
+
* @property {number} mode
|
|
7039
|
+
* @property {Array<number>} apa
|
|
7040
|
+
* @property {number} dd
|
|
7041
|
+
* @property {number} e
|
|
7042
|
+
* @property {number} es
|
|
7043
|
+
* @property {number} mmf
|
|
7044
|
+
* @property {number} rq
|
|
7045
|
+
* @property {number} qp
|
|
7046
|
+
* @property {number} sinb1
|
|
7047
|
+
* @property {number} cosb1
|
|
7048
|
+
* @property {number} ymf
|
|
7049
|
+
* @property {number} xmf
|
|
7050
|
+
* @property {number} sinph0
|
|
7051
|
+
* @property {number} cosph0
|
|
7052
|
+
*/
|
|
7053
|
+
|
|
6538
7054
|
/*
|
|
6539
7055
|
reference
|
|
6540
7056
|
"New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
|
|
@@ -6542,21 +7058,22 @@
|
|
|
6542
7058
|
*/
|
|
6543
7059
|
|
|
6544
7060
|
var S_POLE = 1;
|
|
6545
|
-
|
|
6546
7061
|
var N_POLE = 2;
|
|
6547
7062
|
var EQUIT = 3;
|
|
6548
7063
|
var OBLIQ = 4;
|
|
6549
7064
|
|
|
6550
|
-
|
|
6551
|
-
|
|
7065
|
+
/**
|
|
7066
|
+
* Initialize the Lambert Azimuthal Equal Area projection
|
|
7067
|
+
* @this {import('../defs.js').ProjectionDefinition & LocalThis}
|
|
7068
|
+
*/
|
|
6552
7069
|
function init$k() {
|
|
6553
7070
|
var t = Math.abs(this.lat0);
|
|
6554
7071
|
if (Math.abs(t - HALF_PI) < EPSLN) {
|
|
6555
|
-
this.mode = this.lat0 < 0 ?
|
|
7072
|
+
this.mode = this.lat0 < 0 ? S_POLE : N_POLE;
|
|
6556
7073
|
} else if (Math.abs(t) < EPSLN) {
|
|
6557
|
-
this.mode =
|
|
7074
|
+
this.mode = EQUIT;
|
|
6558
7075
|
} else {
|
|
6559
|
-
this.mode =
|
|
7076
|
+
this.mode = OBLIQ;
|
|
6560
7077
|
}
|
|
6561
7078
|
if (this.es > 0) {
|
|
6562
7079
|
var sinphi;
|
|
@@ -6565,19 +7082,19 @@
|
|
|
6565
7082
|
this.mmf = 0.5 / (1 - this.es);
|
|
6566
7083
|
this.apa = authset(this.es);
|
|
6567
7084
|
switch (this.mode) {
|
|
6568
|
-
case
|
|
7085
|
+
case N_POLE:
|
|
6569
7086
|
this.dd = 1;
|
|
6570
7087
|
break;
|
|
6571
|
-
case
|
|
7088
|
+
case S_POLE:
|
|
6572
7089
|
this.dd = 1;
|
|
6573
7090
|
break;
|
|
6574
|
-
case
|
|
7091
|
+
case EQUIT:
|
|
6575
7092
|
this.rq = Math.sqrt(0.5 * this.qp);
|
|
6576
7093
|
this.dd = 1 / this.rq;
|
|
6577
7094
|
this.xmf = 1;
|
|
6578
7095
|
this.ymf = 0.5 * this.qp;
|
|
6579
7096
|
break;
|
|
6580
|
-
case
|
|
7097
|
+
case OBLIQ:
|
|
6581
7098
|
this.rq = Math.sqrt(0.5 * this.qp);
|
|
6582
7099
|
sinphi = Math.sin(this.lat0);
|
|
6583
7100
|
this.sinb1 = qsfnz(this.e, sinphi) / this.qp;
|
|
@@ -6588,7 +7105,7 @@
|
|
|
6588
7105
|
break;
|
|
6589
7106
|
}
|
|
6590
7107
|
} else {
|
|
6591
|
-
if (this.mode ===
|
|
7108
|
+
if (this.mode === OBLIQ) {
|
|
6592
7109
|
this.sinph0 = Math.sin(this.lat0);
|
|
6593
7110
|
this.cosph0 = Math.cos(this.lat0);
|
|
6594
7111
|
}
|
|
@@ -6824,6 +7341,30 @@
|
|
|
6824
7341
|
return Math.asin(x);
|
|
6825
7342
|
}
|
|
6826
7343
|
|
|
7344
|
+
/**
|
|
7345
|
+
* @typedef {Object} LocalThis
|
|
7346
|
+
* @property {number} temp
|
|
7347
|
+
* @property {number} es
|
|
7348
|
+
* @property {number} e3
|
|
7349
|
+
* @property {number} sin_po
|
|
7350
|
+
* @property {number} cos_po
|
|
7351
|
+
* @property {number} t1
|
|
7352
|
+
* @property {number} con
|
|
7353
|
+
* @property {number} ms1
|
|
7354
|
+
* @property {number} qs1
|
|
7355
|
+
* @property {number} t2
|
|
7356
|
+
* @property {number} ms2
|
|
7357
|
+
* @property {number} qs2
|
|
7358
|
+
* @property {number} t3
|
|
7359
|
+
* @property {number} qs0
|
|
7360
|
+
* @property {number} ns0
|
|
7361
|
+
* @property {number} c
|
|
7362
|
+
* @property {number} rh
|
|
7363
|
+
* @property {number} sin_phi
|
|
7364
|
+
* @property {number} cos_phi
|
|
7365
|
+
*/
|
|
7366
|
+
|
|
7367
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
6827
7368
|
function init$j() {
|
|
6828
7369
|
if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
|
|
6829
7370
|
return;
|
|
@@ -6861,6 +7402,7 @@
|
|
|
6861
7402
|
|
|
6862
7403
|
/* Albers Conical Equal Area forward equations--mapping lat,long to x,y
|
|
6863
7404
|
------------------------------------------------------------------- */
|
|
7405
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
6864
7406
|
function forward$i(p) {
|
|
6865
7407
|
var lon = p.x;
|
|
6866
7408
|
var lat = p.y;
|
|
@@ -6943,12 +7485,21 @@
|
|
|
6943
7485
|
phi1z: phi1z
|
|
6944
7486
|
};
|
|
6945
7487
|
|
|
6946
|
-
|
|
7488
|
+
/**
|
|
7489
|
+
* @typedef {Object} LocalThis
|
|
7490
|
+
* @property {number} sin_p14
|
|
7491
|
+
* @property {number} cos_p14
|
|
7492
|
+
* @property {number} infinity_dist
|
|
7493
|
+
* @property {number} rc
|
|
7494
|
+
*/
|
|
7495
|
+
|
|
7496
|
+
/**
|
|
6947
7497
|
reference:
|
|
6948
7498
|
Wolfram Mathworld "Gnomonic Projection"
|
|
6949
7499
|
http://mathworld.wolfram.com/GnomonicProjection.html
|
|
6950
7500
|
Accessed: 12th November 2009
|
|
6951
|
-
|
|
7501
|
+
@this {import('../defs.js').ProjectionDefinition & LocalThis}
|
|
7502
|
+
*/
|
|
6952
7503
|
function init$i() {
|
|
6953
7504
|
/* Place parameters in static storage for common use
|
|
6954
7505
|
------------------------------------------------- */
|
|
@@ -7069,11 +7620,17 @@
|
|
|
7069
7620
|
return NaN;
|
|
7070
7621
|
}
|
|
7071
7622
|
|
|
7072
|
-
|
|
7623
|
+
/**
|
|
7624
|
+
* @typedef {Object} LocalThis
|
|
7625
|
+
* @property {number} e
|
|
7626
|
+
*/
|
|
7627
|
+
|
|
7628
|
+
/**
|
|
7073
7629
|
reference:
|
|
7074
7630
|
"Cartographic Projection Procedures for the UNIX Environment-
|
|
7075
7631
|
A User's Manual" by Gerald I. Evenden,
|
|
7076
7632
|
USGS Open File Report 90-284and Release 4 Interim Reports (2003)
|
|
7633
|
+
@this {import('../defs.js').ProjectionDefinition & LocalThis}
|
|
7077
7634
|
*/
|
|
7078
7635
|
function init$h() {
|
|
7079
7636
|
// no-op
|
|
@@ -7176,8 +7733,21 @@
|
|
|
7176
7733
|
names: names$g
|
|
7177
7734
|
};
|
|
7178
7735
|
|
|
7736
|
+
/**
|
|
7737
|
+
* @typedef {Object} LocalThis
|
|
7738
|
+
* @property {number} temp
|
|
7739
|
+
* @property {number} es
|
|
7740
|
+
* @property {number} e
|
|
7741
|
+
* @property {number} e0
|
|
7742
|
+
* @property {number} e1
|
|
7743
|
+
* @property {number} e2
|
|
7744
|
+
* @property {number} e3
|
|
7745
|
+
* @property {number} ml0
|
|
7746
|
+
*/
|
|
7747
|
+
|
|
7179
7748
|
var MAX_ITER$1 = 20;
|
|
7180
7749
|
|
|
7750
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
7181
7751
|
function init$f() {
|
|
7182
7752
|
/* Place parameters in static storage for common use
|
|
7183
7753
|
------------------------------------------------- */
|
|
@@ -7555,6 +8125,17 @@
|
|
|
7555
8125
|
|
|
7556
8126
|
var MAX_ITER = 20;
|
|
7557
8127
|
|
|
8128
|
+
/**
|
|
8129
|
+
* @typedef {Object} LocalThis
|
|
8130
|
+
* @property {Array<number>} en
|
|
8131
|
+
* @property {number} n
|
|
8132
|
+
* @property {number} m
|
|
8133
|
+
* @property {number} C_y
|
|
8134
|
+
* @property {number} C_x
|
|
8135
|
+
* @property {number} es
|
|
8136
|
+
*/
|
|
8137
|
+
|
|
8138
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
7558
8139
|
function init$c() {
|
|
7559
8140
|
/* Place parameters in static storage for common use
|
|
7560
8141
|
------------------------------------------------- */
|
|
@@ -7731,6 +8312,28 @@
|
|
|
7731
8312
|
names: names$b
|
|
7732
8313
|
};
|
|
7733
8314
|
|
|
8315
|
+
/**
|
|
8316
|
+
* @typedef {Object} LocalThis
|
|
8317
|
+
* @property {number} temp
|
|
8318
|
+
* @property {number} es
|
|
8319
|
+
* @property {number} e
|
|
8320
|
+
* @property {number} e0
|
|
8321
|
+
* @property {number} e1
|
|
8322
|
+
* @property {number} e2
|
|
8323
|
+
* @property {number} e3
|
|
8324
|
+
* @property {number} sin_phi
|
|
8325
|
+
* @property {number} cos_phi
|
|
8326
|
+
* @property {number} ms1
|
|
8327
|
+
* @property {number} ml1
|
|
8328
|
+
* @property {number} ms2
|
|
8329
|
+
* @property {number} ml2
|
|
8330
|
+
* @property {number} ns
|
|
8331
|
+
* @property {number} g
|
|
8332
|
+
* @property {number} ml0
|
|
8333
|
+
* @property {number} rh
|
|
8334
|
+
*/
|
|
8335
|
+
|
|
8336
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
7734
8337
|
function init$a() {
|
|
7735
8338
|
/* Place parameters in static storage for common use
|
|
7736
8339
|
------------------------------------------------- */
|
|
@@ -7747,18 +8350,18 @@
|
|
|
7747
8350
|
this.e2 = e2fn(this.es);
|
|
7748
8351
|
this.e3 = e3fn(this.es);
|
|
7749
8352
|
|
|
7750
|
-
this.
|
|
7751
|
-
this.
|
|
8353
|
+
this.sin_phi = Math.sin(this.lat1);
|
|
8354
|
+
this.cos_phi = Math.cos(this.lat1);
|
|
7752
8355
|
|
|
7753
|
-
this.ms1 = msfnz(this.e, this.
|
|
8356
|
+
this.ms1 = msfnz(this.e, this.sin_phi, this.cos_phi);
|
|
7754
8357
|
this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
|
|
7755
8358
|
|
|
7756
8359
|
if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
|
|
7757
|
-
this.ns = this.
|
|
8360
|
+
this.ns = this.sin_phi;
|
|
7758
8361
|
} else {
|
|
7759
|
-
this.
|
|
7760
|
-
this.
|
|
7761
|
-
this.ms2 = msfnz(this.e, this.
|
|
8362
|
+
this.sin_phi = Math.sin(this.lat2);
|
|
8363
|
+
this.cos_phi = Math.cos(this.lat2);
|
|
8364
|
+
this.ms2 = msfnz(this.e, this.sin_phi, this.cos_phi);
|
|
7762
8365
|
this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
|
|
7763
8366
|
this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
|
|
7764
8367
|
}
|
|
@@ -7832,8 +8435,15 @@
|
|
|
7832
8435
|
names: names$a
|
|
7833
8436
|
};
|
|
7834
8437
|
|
|
7835
|
-
|
|
7836
|
-
|
|
8438
|
+
/**
|
|
8439
|
+
* @typedef {Object} LocalThis
|
|
8440
|
+
* @property {number} R - Radius of the Earth
|
|
8441
|
+
*/
|
|
8442
|
+
|
|
8443
|
+
/**
|
|
8444
|
+
* Initialize the Van Der Grinten projection
|
|
8445
|
+
* @this {import('../defs.js').ProjectionDefinition & LocalThis}
|
|
8446
|
+
*/
|
|
7837
8447
|
function init$9() {
|
|
7838
8448
|
// this.R = 6370997; //Radius of earth
|
|
7839
8449
|
this.R = this.a;
|
|
@@ -7950,153 +8560,145 @@
|
|
|
7950
8560
|
names: names$9
|
|
7951
8561
|
};
|
|
7952
8562
|
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
if(outmask&g.LATITUDE)
|
|
8046
|
-
vals.lat2=m.atan2d(sbet2,this._f1*cbet2);if(outmask&g.AZIMUTH)
|
|
8047
|
-
vals.azi2=m.atan2d(salp2,calp2);if(outmask&(g.REDUCEDLENGTH|g.GEODESICSCALE)){B22=g.SinCosSeries(true,ssig2,csig2,this._C2a);AB2=(1+this._A2m1)*(B22-this._B21);J12=(this._A1m1-this._A2m1)*sig12+(AB1-AB2);if(outmask&g.REDUCEDLENGTH)
|
|
8048
|
-
vals.m12=this._b*((dn2*(this._csig1*ssig2)-
|
|
8049
|
-
this._dn1*(this._ssig1*csig2))-
|
|
8050
|
-
this._csig1*csig2*J12);if(outmask&g.GEODESICSCALE){t=this._k2*(ssig2-this._ssig1)*(ssig2+this._ssig1)/(this._dn1+dn2);vals.M12=csig12+
|
|
8051
|
-
(t*ssig2-csig2*J12)*this._ssig1/this._dn1;vals.M21=csig12-
|
|
8052
|
-
(t*this._ssig1-this._csig1*J12)*ssig2/dn2;}}
|
|
8053
|
-
if(outmask&g.AREA){B42=g.SinCosSeries(false,ssig2,csig2,this._C4a);if(this._calp0===0||this._salp0===0){salp12=salp2*this.calp1-calp2*this.salp1;calp12=calp2*this.calp1+salp2*this.salp1;}else {salp12=this._calp0*this._salp0*(csig12<=0?this._csig1*(1-csig12)+ssig12*this._ssig1:ssig12*(this._csig1*ssig12/(1+csig12)+this._ssig1));calp12=m.sq(this._salp0)+m.sq(this._calp0)*this._csig1*csig2;}
|
|
8054
|
-
vals.S12=this._c2*Math.atan2(salp12,calp12)+
|
|
8055
|
-
this._A4*(B42-this._B41);}
|
|
8056
|
-
if(!arcmode)
|
|
8057
|
-
vals.a12=sig12/m.degree;return vals;};l.GeodesicLine.prototype.Position=function(s12,outmask){return this.GenPosition(false,s12,outmask);};l.GeodesicLine.prototype.ArcPosition=function(a12,outmask){return this.GenPosition(true,a12,outmask);};l.GeodesicLine.prototype.GenSetDistance=function(arcmode,s13_a13){if(arcmode)
|
|
8058
|
-
this.SetArc(s13_a13);else
|
|
8059
|
-
this.SetDistance(s13_a13);};l.GeodesicLine.prototype.SetDistance=function(s13){var r;this.s13=s13;r=this.GenPosition(false,this.s13,g.ARC);this.a13=0+r.a12;};l.GeodesicLine.prototype.SetArc=function(a13){var r;this.a13=a13;r=this.GenPosition(true,this.a13,g.DISTANCE);this.s13=0+r.s12;};})(geodesic.Geodesic,geodesic.GeodesicLine,geodesic.Math);(function(p,g,m,a){var transit,transitdirect,AreaReduceA,AreaReduceB;transit=function(lon1,lon2){var lon12=m.AngDiff(lon1,lon2).d;lon1=m.AngNormalize(lon1);lon2=m.AngNormalize(lon2);return lon12>0&&((lon1<0&&lon2>=0)||(lon1>0&&lon2===0))?1:(lon12<0&&lon1>=0&&lon2<0?-1:0);};transitdirect=function(lon1,lon2){lon1=lon1%720;lon2=lon2%720;return ((0<=lon2&&lon2<360)||lon2<-360?0:1)-
|
|
8060
|
-
((0<=lon1&&lon1<360)||lon1<-360?0:1);};AreaReduceA=function(area,area0,crossings,reverse,sign){area.Remainder(area0);if(crossings&1)
|
|
8061
|
-
area.Add((area.Sum()<0?1:-1)*area0/2);if(!reverse)
|
|
8062
|
-
area.Negate();if(sign){if(area.Sum()>area0/2)
|
|
8063
|
-
area.Add(-area0);else if(area.Sum()<=-area0/2)
|
|
8064
|
-
area.Add(+area0);}else {if(area.Sum()>=area0)
|
|
8065
|
-
area.Add(-area0);else if(area.Sum()<0)
|
|
8066
|
-
area.Add(+area0);}
|
|
8067
|
-
return 0+area.Sum();};AreaReduceB=function(area,area0,crossings,reverse,sign){area=m.remainder(area,area0);if(crossings&1)
|
|
8068
|
-
area+=(area<0?1:-1)*area0/2;if(!reverse)
|
|
8069
|
-
area*=-1;if(sign){if(area>area0/2)
|
|
8070
|
-
area-=area0;else if(area<=-area0/2)
|
|
8071
|
-
area+=area0;}else {if(area>=area0)
|
|
8072
|
-
area-=area0;else if(area<0)
|
|
8073
|
-
area+=area0;}
|
|
8074
|
-
return 0+area;};p.PolygonArea=function(geod,polyline){this._geod=geod;this.a=this._geod.a;this.f=this._geod.f;this._area0=4*Math.PI*geod._c2;this.polyline=!polyline?false:polyline;this._mask=g.LATITUDE|g.LONGITUDE|g.DISTANCE|(this.polyline?g.NONE:g.AREA|g.LONG_UNROLL);if(!this.polyline)
|
|
8075
|
-
this._areasum=new a.Accumulator(0);this._perimetersum=new a.Accumulator(0);this.Clear();};p.PolygonArea.prototype.Clear=function(){this.num=0;this._crossings=0;if(!this.polyline)
|
|
8076
|
-
this._areasum.Set(0);this._perimetersum.Set(0);this._lat0=this._lon0=this.lat=this.lon=NaN;};p.PolygonArea.prototype.AddPoint=function(lat,lon){var t;if(this.num===0){this._lat0=this.lat=lat;this._lon0=this.lon=lon;}else {t=this._geod.Inverse(this.lat,this.lon,lat,lon,this._mask);this._perimetersum.Add(t.s12);if(!this.polyline){this._areasum.Add(t.S12);this._crossings+=transit(this.lon,lon);}
|
|
8077
|
-
this.lat=lat;this.lon=lon;}
|
|
8078
|
-
++this.num;};p.PolygonArea.prototype.AddEdge=function(azi,s){var t;if(this.num){t=this._geod.Direct(this.lat,this.lon,azi,s,this._mask);this._perimetersum.Add(s);if(!this.polyline){this._areasum.Add(t.S12);this._crossings+=transitdirect(this.lon,t.lon2);}
|
|
8079
|
-
this.lat=t.lat2;this.lon=t.lon2;}
|
|
8080
|
-
++this.num;};p.PolygonArea.prototype.Compute=function(reverse,sign){var vals={number:this.num},t,tempsum;if(this.num<2){vals.perimeter=0;if(!this.polyline)
|
|
8081
|
-
vals.area=0;return vals;}
|
|
8082
|
-
if(this.polyline){vals.perimeter=this._perimetersum.Sum();return vals;}
|
|
8083
|
-
t=this._geod.Inverse(this.lat,this.lon,this._lat0,this._lon0,this._mask);vals.perimeter=this._perimetersum.Sum(t.s12);tempsum=new a.Accumulator(this._areasum);tempsum.Add(t.S12);vals.area=AreaReduceA(tempsum,this._area0,this._crossings+transit(this.lon,this._lon0),reverse,sign);return vals;};p.PolygonArea.prototype.TestPoint=function(lat,lon,reverse,sign){var vals={number:this.num+1},t,tempsum,crossings,i;if(this.num===0){vals.perimeter=0;if(!this.polyline)
|
|
8084
|
-
vals.area=0;return vals;}
|
|
8085
|
-
vals.perimeter=this._perimetersum.Sum();tempsum=this.polyline?0:this._areasum.Sum();crossings=this._crossings;for(i=0;i<(this.polyline?1:2);++i){t=this._geod.Inverse(i===0?this.lat:lat,i===0?this.lon:lon,i!==0?this._lat0:lat,i!==0?this._lon0:lon,this._mask);vals.perimeter+=t.s12;if(!this.polyline){tempsum+=t.S12;crossings+=transit(i===0?this.lon:lon,i!==0?this._lon0:lon);}}
|
|
8086
|
-
if(this.polyline)
|
|
8087
|
-
return vals;vals.area=AreaReduceB(tempsum,this._area0,crossings,reverse,sign);return vals;};p.PolygonArea.prototype.TestEdge=function(azi,s,reverse,sign){var vals={number:this.num?this.num+1:0},t,tempsum,crossings;if(this.num===0)
|
|
8088
|
-
return vals;vals.perimeter=this._perimetersum.Sum()+s;if(this.polyline)
|
|
8089
|
-
return vals;tempsum=this._areasum.Sum();crossings=this._crossings;t=this._geod.Direct(this.lat,this.lon,azi,s,this._mask);tempsum+=t.S12;crossings+=transitdirect(this.lon,t.lon2);crossings+=transit(t.lon2,this._lon0);t=this._geod.Inverse(t.lat2,t.lon2,this._lat0,this._lon0,this._mask);vals.perimeter+=t.s12;tempsum+=t.S12;vals.area=AreaReduceB(tempsum,this._area0,crossings,reverse,sign);return vals;};})(geodesic.PolygonArea,geodesic.Geodesic,geodesic.Math,geodesic.Accumulator);cb(geodesic);})(function(geo){if(module.exports){module.exports=geo;}else {window.geodesic=geo;}});
|
|
8090
|
-
} (geographiclibGeodesic_min));
|
|
8091
|
-
return geographiclibGeodesic_min.exports;
|
|
8092
|
-
}
|
|
8093
|
-
|
|
8094
|
-
var geographiclibGeodesic_minExports = requireGeographiclibGeodesic_min();
|
|
8563
|
+
/**
|
|
8564
|
+
* Calculates the inverse geodesic problem using Vincenty's formulae.
|
|
8565
|
+
* Computes the forward azimuth and ellipsoidal distance between two points
|
|
8566
|
+
* specified by latitude and longitude on the surface of an ellipsoid.
|
|
8567
|
+
*
|
|
8568
|
+
* @param {number} lat1 Latitude of the first point in radians.
|
|
8569
|
+
* @param {number} lon1 Longitude of the first point in radians.
|
|
8570
|
+
* @param {number} lat2 Latitude of the second point in radians.
|
|
8571
|
+
* @param {number} lon2 Longitude of the second point in radians.
|
|
8572
|
+
* @param {number} a Semi-major axis of the ellipsoid (meters).
|
|
8573
|
+
* @param {number} f Flattening of the ellipsoid.
|
|
8574
|
+
* @returns {{ azi1: number, s12: number }} An object containing:
|
|
8575
|
+
* - azi1: Forward azimuth from the first point to the second point (radians).
|
|
8576
|
+
* - s12: Ellipsoidal distance between the two points (meters).
|
|
8577
|
+
*/
|
|
8578
|
+
function vincentyInverse(lat1, lon1, lat2, lon2, a, f) {
|
|
8579
|
+
const L = lon2 - lon1;
|
|
8580
|
+
const U1 = Math.atan((1 - f) * Math.tan(lat1));
|
|
8581
|
+
const U2 = Math.atan((1 - f) * Math.tan(lat2));
|
|
8582
|
+
const sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
|
|
8583
|
+
const sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
|
|
8584
|
+
|
|
8585
|
+
let lambda = L, lambdaP, iterLimit = 100;
|
|
8586
|
+
let sinLambda, cosLambda, sinSigma, cosSigma, sigma, sinAlpha, cos2Alpha, cos2SigmaM, C;
|
|
8587
|
+
let uSq, A, B, deltaSigma, s;
|
|
8588
|
+
|
|
8589
|
+
do {
|
|
8590
|
+
sinLambda = Math.sin(lambda);
|
|
8591
|
+
cosLambda = Math.cos(lambda);
|
|
8592
|
+
sinSigma = Math.sqrt(
|
|
8593
|
+
(cosU2 * sinLambda) * (cosU2 * sinLambda)
|
|
8594
|
+
+ (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
|
|
8595
|
+
* (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
|
|
8596
|
+
);
|
|
8597
|
+
if (sinSigma === 0) {
|
|
8598
|
+
return { azi1: 0, s12: 0 }; // coincident points
|
|
8599
|
+
}
|
|
8600
|
+
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
|
|
8601
|
+
sigma = Math.atan2(sinSigma, cosSigma);
|
|
8602
|
+
sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
|
|
8603
|
+
cos2Alpha = 1 - sinAlpha * sinAlpha;
|
|
8604
|
+
cos2SigmaM = (cos2Alpha !== 0) ? (cosSigma - 2 * sinU1 * sinU2 / cos2Alpha) : 0;
|
|
8605
|
+
C = f / 16 * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha));
|
|
8606
|
+
lambdaP = lambda;
|
|
8607
|
+
lambda = L + (1 - C) * f * sinAlpha
|
|
8608
|
+
* (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
|
8609
|
+
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
|
|
8610
|
+
|
|
8611
|
+
if (iterLimit === 0) {
|
|
8612
|
+
return { azi1: NaN, s12: NaN }; // formula failed to converge
|
|
8613
|
+
}
|
|
8614
|
+
|
|
8615
|
+
uSq = cos2Alpha * (a * a - (a * (1 - f)) * (a * (1 - f))) / ((a * (1 - f)) * (a * (1 - f)));
|
|
8616
|
+
A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
|
8617
|
+
B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
|
8618
|
+
deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
|
|
8619
|
+
- B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
|
8620
|
+
|
|
8621
|
+
s = (a * (1 - f)) * A * (sigma - deltaSigma);
|
|
8622
|
+
|
|
8623
|
+
// Forward azimuth
|
|
8624
|
+
const azi1 = Math.atan2(cosU2 * sinLambda, cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
|
|
8625
|
+
|
|
8626
|
+
return { azi1, s12: s };
|
|
8627
|
+
}
|
|
8628
|
+
|
|
8629
|
+
/**
|
|
8630
|
+
* Solves the direct geodetic problem using Vincenty's formulae.
|
|
8631
|
+
* Given a starting point, initial azimuth, and distance, computes the destination point on the ellipsoid.
|
|
8632
|
+
*
|
|
8633
|
+
* @param {number} lat1 Latitude of the starting point in radians.
|
|
8634
|
+
* @param {number} lon1 Longitude of the starting point in radians.
|
|
8635
|
+
* @param {number} azi1 Initial azimuth (forward azimuth) in radians.
|
|
8636
|
+
* @param {number} s12 Distance to travel from the starting point in meters.
|
|
8637
|
+
* @param {number} a Semi-major axis of the ellipsoid in meters.
|
|
8638
|
+
* @param {number} f Flattening of the ellipsoid.
|
|
8639
|
+
* @returns {{lat2: number, lon2: number}} The latitude and longitude (in radians) of the destination point.
|
|
8640
|
+
*/
|
|
8641
|
+
function vincentyDirect(lat1, lon1, azi1, s12, a, f) {
|
|
8642
|
+
const U1 = Math.atan((1 - f) * Math.tan(lat1));
|
|
8643
|
+
const sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
|
|
8644
|
+
const sinAlpha1 = Math.sin(azi1), cosAlpha1 = Math.cos(azi1);
|
|
8645
|
+
|
|
8646
|
+
const sigma1 = Math.atan2(sinU1, cosU1 * cosAlpha1);
|
|
8647
|
+
const sinAlpha = cosU1 * sinAlpha1;
|
|
8648
|
+
const cos2Alpha = 1 - sinAlpha * sinAlpha;
|
|
8649
|
+
const uSq = cos2Alpha * (a * a - (a * (1 - f)) * (a * (1 - f))) / ((a * (1 - f)) * (a * (1 - f)));
|
|
8650
|
+
const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
|
8651
|
+
const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
|
8652
|
+
|
|
8653
|
+
let sigma = s12 / ((a * (1 - f)) * A), sigmaP, iterLimit = 100;
|
|
8654
|
+
let cos2SigmaM, sinSigma, cosSigma, deltaSigma;
|
|
8095
8655
|
|
|
8656
|
+
do {
|
|
8657
|
+
cos2SigmaM = Math.cos(2 * sigma1 + sigma);
|
|
8658
|
+
sinSigma = Math.sin(sigma);
|
|
8659
|
+
cosSigma = Math.cos(sigma);
|
|
8660
|
+
deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
|
|
8661
|
+
- B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
|
8662
|
+
sigmaP = sigma;
|
|
8663
|
+
sigma = s12 / ((a * (1 - f)) * A) + deltaSigma;
|
|
8664
|
+
} while (Math.abs(sigma - sigmaP) > 1e-12 && --iterLimit > 0);
|
|
8665
|
+
|
|
8666
|
+
if (iterLimit === 0) {
|
|
8667
|
+
return { lat2: NaN, lon2: NaN };
|
|
8668
|
+
}
|
|
8669
|
+
|
|
8670
|
+
const tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
|
|
8671
|
+
const lat2 = Math.atan2(
|
|
8672
|
+
sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
|
|
8673
|
+
(1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)
|
|
8674
|
+
);
|
|
8675
|
+
const lambda = Math.atan2(
|
|
8676
|
+
sinSigma * sinAlpha1,
|
|
8677
|
+
cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1
|
|
8678
|
+
);
|
|
8679
|
+
const C = f / 16 * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha));
|
|
8680
|
+
const L = lambda - (1 - C) * f * sinAlpha
|
|
8681
|
+
* (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
|
8682
|
+
const lon2 = lon1 + L;
|
|
8683
|
+
|
|
8684
|
+
return { lat2, lon2 };
|
|
8685
|
+
}
|
|
8686
|
+
|
|
8687
|
+
/**
|
|
8688
|
+
* @typedef {Object} LocalThis
|
|
8689
|
+
* @property {number} es
|
|
8690
|
+
* @property {number} sin_p12
|
|
8691
|
+
* @property {number} cos_p12
|
|
8692
|
+
* @property {number} a
|
|
8693
|
+
* @property {number} f
|
|
8694
|
+
*/
|
|
8695
|
+
|
|
8696
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
8096
8697
|
function init$8() {
|
|
8097
8698
|
this.sin_p12 = Math.sin(this.lat0);
|
|
8098
8699
|
this.cos_p12 = Math.cos(this.lat0);
|
|
8099
|
-
|
|
8700
|
+
// flattening for ellipsoid
|
|
8701
|
+
this.f = this.es / (1 + Math.sqrt(1 - this.es));
|
|
8100
8702
|
}
|
|
8101
8703
|
|
|
8102
8704
|
function forward$7(p) {
|
|
@@ -8105,7 +8707,7 @@
|
|
|
8105
8707
|
var sinphi = Math.sin(p.y);
|
|
8106
8708
|
var cosphi = Math.cos(p.y);
|
|
8107
8709
|
var dlon = adjust_lon(lon - this.long0);
|
|
8108
|
-
var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c,
|
|
8710
|
+
var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c, vars, azi1;
|
|
8109
8711
|
if (this.sphere) {
|
|
8110
8712
|
if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
|
|
8111
8713
|
// North Pole case
|
|
@@ -8151,14 +8753,8 @@
|
|
|
8151
8753
|
p.x = p.y = 0;
|
|
8152
8754
|
return p;
|
|
8153
8755
|
}
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
lat2 = lat / D2R$1;
|
|
8157
|
-
lon2 = lon / D2R$1;
|
|
8158
|
-
|
|
8159
|
-
vars = this.g.Inverse(lat1, lon1, lat2, lon2, this.g.AZIMUTH);
|
|
8160
|
-
azi1 = vars.azi1 * D2R$1;
|
|
8161
|
-
|
|
8756
|
+
vars = vincentyInverse(this.lat0, this.long0, lat, lon, this.a, this.f);
|
|
8757
|
+
azi1 = vars.azi1;
|
|
8162
8758
|
p.x = vars.s12 * Math.sin(azi1);
|
|
8163
8759
|
p.y = vars.s12 * Math.cos(azi1);
|
|
8164
8760
|
return p;
|
|
@@ -8169,7 +8765,7 @@
|
|
|
8169
8765
|
function inverse$7(p) {
|
|
8170
8766
|
p.x -= this.x0;
|
|
8171
8767
|
p.y -= this.y0;
|
|
8172
|
-
var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M,
|
|
8768
|
+
var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, azi1, s12, vars;
|
|
8173
8769
|
if (this.sphere) {
|
|
8174
8770
|
rh = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
8175
8771
|
if (rh > (2 * HALF_PI * this.a)) {
|
|
@@ -8193,13 +8789,6 @@
|
|
|
8193
8789
|
lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
|
|
8194
8790
|
}
|
|
8195
8791
|
} else {
|
|
8196
|
-
/* con = cosz - this.sin_p12 * Math.sin(lat);
|
|
8197
|
-
if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
|
|
8198
|
-
//no-op, just keep the lon value as is
|
|
8199
|
-
} else {
|
|
8200
|
-
var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
|
|
8201
|
-
lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
|
|
8202
|
-
} */
|
|
8203
8792
|
lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
|
|
8204
8793
|
}
|
|
8205
8794
|
}
|
|
@@ -8235,14 +8824,12 @@
|
|
|
8235
8824
|
return p;
|
|
8236
8825
|
} else {
|
|
8237
8826
|
// default case
|
|
8238
|
-
|
|
8239
|
-
lon1 = this.long0 / D2R$1;
|
|
8240
|
-
azi1 = Math.atan2(p.x, p.y) / D2R$1;
|
|
8827
|
+
azi1 = Math.atan2(p.x, p.y);
|
|
8241
8828
|
s12 = Math.sqrt(p.x * p.x + p.y * p.y);
|
|
8242
|
-
vars = this.
|
|
8829
|
+
vars = vincentyDirect(this.lat0, this.long0, azi1, s12, this.a, this.f);
|
|
8243
8830
|
|
|
8244
|
-
p.x = vars.lon2
|
|
8245
|
-
p.y = vars.lat2
|
|
8831
|
+
p.x = vars.lon2;
|
|
8832
|
+
p.y = vars.lat2;
|
|
8246
8833
|
return p;
|
|
8247
8834
|
}
|
|
8248
8835
|
}
|
|
@@ -8256,6 +8843,13 @@
|
|
|
8256
8843
|
names: names$8
|
|
8257
8844
|
};
|
|
8258
8845
|
|
|
8846
|
+
/**
|
|
8847
|
+
* @typedef {Object} LocalThis
|
|
8848
|
+
* @property {number} sin_p14
|
|
8849
|
+
* @property {number} cos_p14
|
|
8850
|
+
*/
|
|
8851
|
+
|
|
8852
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
8259
8853
|
function init$7() {
|
|
8260
8854
|
// double temp; /* temporary variable */
|
|
8261
8855
|
|
|
@@ -8347,6 +8941,16 @@
|
|
|
8347
8941
|
// https://github.com/OSGeo/proj.4/blob/master/src/PJ_qsc.c
|
|
8348
8942
|
|
|
8349
8943
|
|
|
8944
|
+
/**
|
|
8945
|
+
* @typedef {Object} LocalThis
|
|
8946
|
+
* @property {number} face
|
|
8947
|
+
* @property {number} x0
|
|
8948
|
+
* @property {number} y0
|
|
8949
|
+
* @property {number} es
|
|
8950
|
+
* @property {number} one_minus_f
|
|
8951
|
+
* @property {number} one_minus_f_squared
|
|
8952
|
+
*/
|
|
8953
|
+
|
|
8350
8954
|
/* constants */
|
|
8351
8955
|
var FACE_ENUM = {
|
|
8352
8956
|
FRONT: 1,
|
|
@@ -8364,6 +8968,7 @@
|
|
|
8364
8968
|
AREA_3: 4
|
|
8365
8969
|
};
|
|
8366
8970
|
|
|
8971
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
8367
8972
|
function init$6() {
|
|
8368
8973
|
this.x0 = this.x0 || 0;
|
|
8369
8974
|
this.y0 = this.y0 || 0;
|
|
@@ -8891,6 +9496,26 @@
|
|
|
8891
9496
|
names: names$4
|
|
8892
9497
|
};
|
|
8893
9498
|
|
|
9499
|
+
/**
|
|
9500
|
+
* @typedef {Object} LocalThis
|
|
9501
|
+
* @property {number} mode
|
|
9502
|
+
* @property {number} sinph0
|
|
9503
|
+
* @property {number} cosph0
|
|
9504
|
+
* @property {number} pn1
|
|
9505
|
+
* @property {number} h
|
|
9506
|
+
* @property {number} rp
|
|
9507
|
+
* @property {number} p
|
|
9508
|
+
* @property {number} h1
|
|
9509
|
+
* @property {number} pfact
|
|
9510
|
+
* @property {number} es
|
|
9511
|
+
* @property {number} tilt
|
|
9512
|
+
* @property {number} azi
|
|
9513
|
+
* @property {number} cg
|
|
9514
|
+
* @property {number} sg
|
|
9515
|
+
* @property {number} cw
|
|
9516
|
+
* @property {number} sw
|
|
9517
|
+
*/
|
|
9518
|
+
|
|
8894
9519
|
var mode = {
|
|
8895
9520
|
N_POLE: 0,
|
|
8896
9521
|
S_POLE: 1,
|
|
@@ -8906,6 +9531,7 @@
|
|
|
8906
9531
|
lat0: { def: 0, num: true } // default is Equator, conversion to rad is automatic
|
|
8907
9532
|
};
|
|
8908
9533
|
|
|
9534
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
8909
9535
|
function init$3() {
|
|
8910
9536
|
Object.keys(params).forEach(function (p) {
|
|
8911
9537
|
if (typeof this[p] === 'undefined') {
|
|
@@ -9057,6 +9683,22 @@
|
|
|
9057
9683
|
names: names$3
|
|
9058
9684
|
};
|
|
9059
9685
|
|
|
9686
|
+
/**
|
|
9687
|
+
* @typedef {Object} LocalThis
|
|
9688
|
+
* @property {1 | 0} flip_axis
|
|
9689
|
+
* @property {number} h
|
|
9690
|
+
* @property {number} radius_g_1
|
|
9691
|
+
* @property {number} radius_g
|
|
9692
|
+
* @property {number} radius_p
|
|
9693
|
+
* @property {number} radius_p2
|
|
9694
|
+
* @property {number} radius_p_inv2
|
|
9695
|
+
* @property {'ellipse'|'sphere'} shape
|
|
9696
|
+
* @property {number} C
|
|
9697
|
+
* @property {string} sweep
|
|
9698
|
+
* @property {number} es
|
|
9699
|
+
*/
|
|
9700
|
+
|
|
9701
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
9060
9702
|
function init$2() {
|
|
9061
9703
|
this.flip_axis = (this.sweep === 'x' ? 1 : 0);
|
|
9062
9704
|
this.h = Number(this.h);
|
|
@@ -9307,8 +9949,19 @@
|
|
|
9307
9949
|
names: names$1
|
|
9308
9950
|
};
|
|
9309
9951
|
|
|
9952
|
+
/**
|
|
9953
|
+
* @typedef {Object} LocalThis
|
|
9954
|
+
* @property {number} phi1
|
|
9955
|
+
* @property {number} cphi1
|
|
9956
|
+
* @property {number} es
|
|
9957
|
+
* @property {Array<number>} en
|
|
9958
|
+
* @property {number} m1
|
|
9959
|
+
* @property {number} am1
|
|
9960
|
+
*/
|
|
9961
|
+
|
|
9310
9962
|
var EPS10 = 1e-10;
|
|
9311
9963
|
|
|
9964
|
+
/** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
|
|
9312
9965
|
function init() {
|
|
9313
9966
|
var c;
|
|
9314
9967
|
|
|
@@ -9445,16 +10098,22 @@
|
|
|
9445
10098
|
proj4.Proj.projections.add(bonne);
|
|
9446
10099
|
}
|
|
9447
10100
|
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
proj4
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
10101
|
+
/**
|
|
10102
|
+
* @template {import('./core').TemplateCoordinates} T
|
|
10103
|
+
* @type {core<T> & {defaultDatum: string, Proj: typeof Proj, WGS84: Proj, Point: typeof Point, toPoint: typeof common, defs: typeof defs, nadgrid: typeof nadgrid, transform: typeof transform, mgrs: typeof mgrs, version: string}}
|
|
10104
|
+
*/
|
|
10105
|
+
const proj4 = Object.assign(proj4$1, {
|
|
10106
|
+
defaultDatum: 'WGS84',
|
|
10107
|
+
Proj: Projection,
|
|
10108
|
+
WGS84: new Projection('WGS84'),
|
|
10109
|
+
Point,
|
|
10110
|
+
toPoint: common,
|
|
10111
|
+
defs,
|
|
10112
|
+
nadgrid,
|
|
10113
|
+
transform,
|
|
10114
|
+
mgrs,
|
|
10115
|
+
version: '2.19.0'
|
|
10116
|
+
});
|
|
9458
10117
|
includedProjections(proj4);
|
|
9459
10118
|
|
|
9460
10119
|
return proj4;
|