proj4 2.17.0 → 2.19.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.
Files changed (154) hide show
  1. package/bower.json +1 -1
  2. package/component.json +1 -1
  3. package/dist/lib/Point.d.ts +24 -0
  4. package/dist/lib/Proj.d.ts +71 -0
  5. package/dist/lib/adjust_axis.d.ts +1 -0
  6. package/dist/lib/checkSanity.d.ts +1 -0
  7. package/dist/lib/common/acosh.d.ts +1 -0
  8. package/dist/lib/common/adjust_lat.d.ts +1 -0
  9. package/dist/lib/common/adjust_lon.d.ts +1 -0
  10. package/dist/lib/common/adjust_zone.d.ts +1 -0
  11. package/dist/lib/common/asinh.d.ts +1 -0
  12. package/dist/lib/common/asinhy.d.ts +1 -0
  13. package/dist/lib/common/asinz.d.ts +1 -0
  14. package/dist/lib/common/atanh.d.ts +1 -0
  15. package/dist/lib/common/clens.d.ts +1 -0
  16. package/dist/lib/common/clens_cmplx.d.ts +1 -0
  17. package/dist/lib/common/cosh.d.ts +1 -0
  18. package/dist/lib/common/e0fn.d.ts +1 -0
  19. package/dist/lib/common/e1fn.d.ts +1 -0
  20. package/dist/lib/common/e2fn.d.ts +1 -0
  21. package/dist/lib/common/e3fn.d.ts +1 -0
  22. package/dist/lib/common/fL.d.ts +1 -0
  23. package/dist/lib/common/gN.d.ts +1 -0
  24. package/dist/lib/common/gatg.d.ts +1 -0
  25. package/dist/lib/common/hypot.d.ts +1 -0
  26. package/dist/lib/common/imlfn.d.ts +1 -0
  27. package/dist/lib/common/invlatiso.d.ts +1 -0
  28. package/dist/lib/common/iqsfnz.d.ts +1 -0
  29. package/dist/lib/common/latiso.d.ts +1 -0
  30. package/dist/lib/common/log1py.d.ts +1 -0
  31. package/dist/lib/common/mlfn.d.ts +1 -0
  32. package/dist/lib/common/msfnz.d.ts +1 -0
  33. package/dist/lib/common/phi2z.d.ts +1 -0
  34. package/dist/lib/common/pj_enfn.d.ts +1 -0
  35. package/dist/lib/common/pj_inv_mlfn.d.ts +1 -0
  36. package/dist/lib/common/pj_mlfn.d.ts +1 -0
  37. package/dist/lib/common/qsfnz.d.ts +1 -0
  38. package/dist/lib/common/sign.d.ts +1 -0
  39. package/dist/lib/common/sinh.d.ts +1 -0
  40. package/dist/lib/common/srat.d.ts +1 -0
  41. package/dist/lib/common/tanh.d.ts +1 -0
  42. package/dist/lib/common/toPoint.d.ts +5 -0
  43. package/dist/lib/common/tsfnz.d.ts +1 -0
  44. package/dist/lib/common/vincenty.d.ts +35 -0
  45. package/dist/lib/constants/Datum.d.ts +1715 -0
  46. package/dist/lib/constants/Ellipsoid.d.ts +353 -0
  47. package/dist/lib/constants/PrimeMeridian.d.ts +16 -0
  48. package/dist/lib/constants/units.d.ts +63 -0
  49. package/dist/lib/constants/values.d.ts +19 -0
  50. package/dist/lib/core.d.ts +119 -0
  51. package/dist/lib/datum.d.ts +10 -0
  52. package/dist/lib/datumUtils.d.ts +28 -0
  53. package/dist/lib/datum_transform.d.ts +2 -0
  54. package/dist/lib/defs.d.ts +57 -0
  55. package/dist/lib/deriveConstants.d.ts +11 -0
  56. package/dist/lib/extend.d.ts +1 -0
  57. package/dist/lib/global.d.ts +1 -0
  58. package/dist/lib/includedProjections.d.ts +1 -0
  59. package/dist/lib/index.d.ts +24 -0
  60. package/dist/lib/match.d.ts +1 -0
  61. package/dist/lib/nadgrid.d.ts +107 -0
  62. package/dist/lib/parseCode.d.ts +6 -0
  63. package/dist/lib/projString.d.ts +5 -0
  64. package/dist/lib/projections/aea.d.ts +83 -0
  65. package/dist/lib/projections/aeqd.d.ts +32 -0
  66. package/dist/lib/projections/bonne.d.ts +27 -0
  67. package/dist/lib/projections/cass.d.ts +36 -0
  68. package/dist/lib/projections/cea.d.ts +28 -0
  69. package/dist/lib/projections/eqc.d.ts +20 -0
  70. package/dist/lib/projections/eqdc.d.ts +71 -0
  71. package/dist/lib/projections/eqearth.d.ts +15 -0
  72. package/dist/lib/projections/equi.d.ts +40 -0
  73. package/dist/lib/projections/etmerc.d.ts +45 -0
  74. package/dist/lib/projections/gauss.d.ts +38 -0
  75. package/dist/lib/projections/geocent.d.ts +22 -0
  76. package/dist/lib/projections/geos.d.ts +51 -0
  77. package/dist/lib/projections/gnom.d.ts +37 -0
  78. package/dist/lib/projections/gstmerc.d.ts +41 -0
  79. package/dist/lib/projections/krovak.d.ts +34 -0
  80. package/dist/lib/projections/laea.d.ts +70 -0
  81. package/dist/lib/projections/lcc.d.ts +36 -0
  82. package/dist/lib/projections/longlat.d.ts +11 -0
  83. package/dist/lib/projections/merc.d.ts +30 -0
  84. package/dist/lib/projections/mill.d.ts +11 -0
  85. package/dist/lib/projections/moll.d.ts +11 -0
  86. package/dist/lib/projections/nzmg.d.ts +33 -0
  87. package/dist/lib/projections/omerc.d.ts +60 -0
  88. package/dist/lib/projections/ortho.d.ts +25 -0
  89. package/dist/lib/projections/poly.d.ts +32 -0
  90. package/dist/lib/projections/qsc.d.ts +31 -0
  91. package/dist/lib/projections/robin.d.ts +24 -0
  92. package/dist/lib/projections/sinu.d.ts +37 -0
  93. package/dist/lib/projections/somerc.d.ts +35 -0
  94. package/dist/lib/projections/stere.d.ts +52 -0
  95. package/dist/lib/projections/sterea.d.ts +33 -0
  96. package/dist/lib/projections/tmerc.d.ts +38 -0
  97. package/dist/lib/projections/tpers.d.ts +45 -0
  98. package/dist/lib/projections/utm.d.ts +19 -0
  99. package/dist/lib/projections/vandg.d.ts +28 -0
  100. package/dist/lib/projections.d.ts +10 -0
  101. package/dist/lib/transform.d.ts +8 -0
  102. package/dist/proj4-src.js +849 -247
  103. package/dist/proj4.js +1 -1
  104. package/dist/projs.d.ts +1 -0
  105. package/lib/Point.js +9 -3
  106. package/lib/Proj.js +25 -1
  107. package/lib/adjust_axis.js +1 -0
  108. package/lib/common/toPoint.js +4 -0
  109. package/lib/common/vincenty.js +123 -0
  110. package/lib/constants/PrimeMeridian.js +16 -15
  111. package/lib/core.js +154 -16
  112. package/lib/defs.js +65 -5
  113. package/lib/index.js +17 -11
  114. package/lib/nadgrid.js +70 -0
  115. package/lib/parseCode.js +5 -1
  116. package/lib/projString.js +6 -0
  117. package/lib/projections/aea.js +25 -0
  118. package/lib/projections/aeqd.js +22 -26
  119. package/lib/projections/bonne.js +11 -0
  120. package/lib/projections/cass.js +11 -0
  121. package/lib/projections/cea.js +7 -1
  122. package/lib/projections/eqdc.js +29 -7
  123. package/lib/projections/equi.js +11 -2
  124. package/lib/projections/etmerc.js +12 -0
  125. package/lib/projections/gauss.js +12 -0
  126. package/lib/projections/geos.js +16 -0
  127. package/lib/projections/gnom.js +11 -2
  128. package/lib/projections/gstmerc.js +12 -0
  129. package/lib/projections/laea.js +30 -11
  130. package/lib/projections/lcc.js +10 -0
  131. package/lib/projections/merc.js +9 -0
  132. package/lib/projections/omerc.js +29 -4
  133. package/lib/projections/ortho.js +7 -0
  134. package/lib/projections/poly.js +14 -0
  135. package/lib/projections/qsc.js +11 -0
  136. package/lib/projections/sinu.js +11 -0
  137. package/lib/projections/somerc.js +10 -0
  138. package/lib/projections/stere.js +16 -2
  139. package/lib/projections/sterea.js +10 -0
  140. package/lib/projections/tmerc.js +8 -0
  141. package/lib/projections/tpers.js +24 -3
  142. package/lib/projections/utm.js +1 -0
  143. package/lib/projections/vandg.js +9 -2
  144. package/lib/transform.js +9 -0
  145. package/package.json +8 -6
  146. package/tsconfig.json +14 -0
  147. package/.github/workflows/build-and-test.yml +0 -69
  148. package/.nyc_output/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +0 -1
  149. package/.nyc_output/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +0 -1
  150. package/.nyc_output/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +0 -1
  151. package/.nyc_output/processinfo/6b047fc9-1bf2-4565-9e8a-9c0defc09dd7.json +0 -1
  152. package/.nyc_output/processinfo/e2c5d0cc-9478-4f26-ad2f-de246d4c35de.json +0 -1
  153. package/.nyc_output/processinfo/f4b0e40f-04ca-4b6d-bfeb-51d617db9841.json +0 -1
  154. package/.nyc_output/processinfo/index.json +0 -1
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 exports$1 = {};
55
-
56
- exports$1.greenwich = 0.0; // "0dE",
57
- exports$1.lisbon = -9.131906111111; // "9d07'54.862\"W",
58
- exports$1.paris = 2.337229166667; // "2d20'14.025\"E",
59
- exports$1.bogota = -74.080916666667; // "74d04'51.3\"W",
60
- exports$1.madrid = -3.687938888889; // "3d41'16.58\"W",
61
- exports$1.rome = 12.452333333333; // "12d27'8.4\"E",
62
- exports$1.bern = 7.439583333333; // "7d26'22.5\"E",
63
- exports$1.jakarta = 106.807719444444; // "106d48'27.79\"E",
64
- exports$1.ferro = -17.666666666667; // "17d40'W",
65
- exports$1.brussels = 4.367975; // "4d22'4.71\"E",
66
- exports$1.stockholm = 18.058277777778; // "18d3'29.8\"E",
67
- exports$1.athens = 23.7163375; // "23d42'58.815\"E",
68
- exports$1.oslo = 10.722916666667; // "10d43'22.5\"E"
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(exports$1, v);
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.projName) {
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,11 +3424,64 @@
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
 
3465
+ /**
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
+ */
3351
3478
  /**
3352
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
3353
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) {
3356
3487
  if (data instanceof ArrayBuffer) {
@@ -3359,6 +3490,12 @@
3359
3490
  return { ready: readGeotiffGrid(key, data) };
3360
3491
  }
3361
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
+ */
3362
3499
  function readNTV2Grid(key, data, options) {
3363
3500
  var includeErrorFields = true;
3364
3501
  if (options !== undefined && options.includeErrorFields === false) {
@@ -3373,6 +3510,11 @@
3373
3510
  return nadgrid;
3374
3511
  }
3375
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
+ */
3376
3518
  async function readGeotiffGrid(key, tiff) {
3377
3519
  var subgrids = [];
3378
3520
  var subGridCount = await tiff.getImageCount();
@@ -3419,6 +3561,8 @@
3419
3561
  }
3420
3562
  /**
3421
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
3422
3566
  */
3423
3567
  function getNadgrids(nadgrids) {
3424
3568
  // Format details: http://proj.maptools.org/gen_parms.html
@@ -3429,6 +3573,10 @@
3429
3573
  return grids.map(parseNadgridString);
3430
3574
  }
3431
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
+ */
3432
3580
  function parseNadgridString(value) {
3433
3581
  if (value.length === 0) {
3434
3582
  return null;
@@ -3562,10 +3710,31 @@
3562
3710
  return gridShiftRecords;
3563
3711
  }
3564
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
+ */
3565
3726
  function Projection(srsCode, callback) {
3566
3727
  if (!(this instanceof Projection)) {
3567
3728
  return new Projection(srsCode);
3568
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;
3569
3738
  callback = callback || function (error) {
3570
3739
  if (error) {
3571
3740
  throw error;
@@ -3597,6 +3766,7 @@
3597
3766
  var sphere_ = sphere(json.a, json.b, json.rf, json.ellps, json.sphere);
3598
3767
  var ecc = eccentricity(sphere_.a, sphere_.b, sphere_.rf, json.R_A);
3599
3768
  var nadgrids = getNadgrids(json.nadgrids);
3769
+ /** @type {DatumDefinition} */
3600
3770
  var datumObj = json.datum || datum(json.datumCode, json.datum_params, sphere_.a, sphere_.b, ecc.es, ecc.ep2,
3601
3771
  nadgrids);
3602
3772
 
@@ -3618,7 +3788,9 @@
3618
3788
  this.datum = datumObj;
3619
3789
 
3620
3790
  // init the projection
3621
- this.init();
3791
+ if ('init' in this && typeof this.init === 'function') {
3792
+ this.init();
3793
+ }
3622
3794
 
3623
3795
  // legecy callback from back in the day when it went to spatialreference.org
3624
3796
  callback(null, this);
@@ -4055,6 +4227,7 @@
4055
4227
  yin = point.y,
4056
4228
  zin = point.z || 0.0;
4057
4229
  var v, t, i;
4230
+ /** @type {import("./core").InterfaceCoordinates} */
4058
4231
  var out = {};
4059
4232
  for (i = 0; i < 3; i++) {
4060
4233
  if (denorm && i === 2 && point.z === undefined) {
@@ -4109,6 +4282,10 @@
4109
4282
  return out;
4110
4283
  }
4111
4284
 
4285
+ /**
4286
+ * @param {Array<number>} array
4287
+ * @returns {import("../core").InterfaceCoordinates}
4288
+ */
4112
4289
  function common (array) {
4113
4290
  var out = {
4114
4291
  x: array[0],
@@ -4145,6 +4322,13 @@
4145
4322
  || ((dest.datum.datum_type === PJD_3PARAM || dest.datum.datum_type === PJD_7PARAM || dest.datum.datum_type === PJD_GRIDSHIFT) && source.datumCode !== 'WGS84');
4146
4323
  }
4147
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
+ */
4148
4332
  function transform(source, dest, point, enforceAxis) {
4149
4333
  var wgs84;
4150
4334
  if (Array.isArray(point)) {
@@ -4201,6 +4385,8 @@
4201
4385
  return;
4202
4386
  }
4203
4387
 
4388
+ point = /** @type {import('./core').InterfaceCoordinates} */ (point);
4389
+
4204
4390
  // Adjust for the prime meridian if necessary
4205
4391
  if (dest.from_greenwich) {
4206
4392
  point = {
@@ -4241,6 +4427,85 @@
4241
4427
 
4242
4428
  var wgs84 = Projection('WGS84');
4243
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
+ */
4244
4509
  function transformer(from, to, coords, enforceAxis) {
4245
4510
  var transformedArray, out, keys;
4246
4511
  if (Array.isArray(coords)) {
@@ -4248,21 +4513,21 @@
4248
4513
  if (coords.length > 2) {
4249
4514
  if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {
4250
4515
  if (typeof transformedArray.z === 'number') {
4251
- 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)));
4252
4517
  } else {
4253
- 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)));
4254
4519
  }
4255
4520
  } else {
4256
- return [transformedArray.x, transformedArray.y].concat(coords.slice(2));
4521
+ return /** @type {T} */ ([transformedArray.x, transformedArray.y].concat(coords.slice(2)));
4257
4522
  }
4258
4523
  } else {
4259
- return [transformedArray.x, transformedArray.y];
4524
+ return /** @type {T} */ ([transformedArray.x, transformedArray.y]);
4260
4525
  }
4261
4526
  } else {
4262
4527
  out = transform(from, to, coords, enforceAxis);
4263
4528
  keys = Object.keys(coords);
4264
4529
  if (keys.length === 2) {
4265
- return out;
4530
+ return /** @type {T} */ (out);
4266
4531
  }
4267
4532
  keys.forEach(function (key) {
4268
4533
  if ((typeof from.name !== 'undefined' && from.name === 'geocent') || (typeof to.name !== 'undefined' && to.name === 'geocent')) {
@@ -4276,42 +4541,100 @@
4276
4541
  }
4277
4542
  out[key] = coords[key];
4278
4543
  });
4279
- return out;
4544
+ return /** @type {T} */ (out);
4280
4545
  }
4281
4546
  }
4282
4547
 
4548
+ /**
4549
+ * @param {proj | string | PROJJSONDefinition | Converter} item
4550
+ * @returns {import('./Proj').default}
4551
+ */
4283
4552
  function checkProj(item) {
4284
4553
  if (item instanceof Projection) {
4285
4554
  return item;
4286
4555
  }
4287
- if (item.oProj) {
4556
+ if (typeof item === 'object' && 'oProj' in item) {
4288
4557
  return item.oProj;
4289
4558
  }
4290
- return Projection(item);
4559
+ return Projection(/** @type {string | PROJJSONDefinition} */ (item));
4291
4560
  }
4292
4561
 
4293
- function proj4(fromProj, toProj, coord) {
4294
- fromProj = checkProj(fromProj);
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
+ * @template {TemplateCoordinates} T
4575
+ * @overload
4576
+ * @param {string | PROJJSONDefinition | proj} toProj
4577
+ * @param {T} coord
4578
+ * @returns {T}
4579
+ */
4580
+ /**
4581
+ * @template {TemplateCoordinates} T
4582
+ * @overload
4583
+ * @param {string | PROJJSONDefinition | proj} fromProj
4584
+ * @param {string | PROJJSONDefinition | proj} toProj
4585
+ * @param {T} coord
4586
+ * @returns {T}
4587
+ */
4588
+ /**
4589
+ * @template {TemplateCoordinates} T
4590
+ * @param {string | PROJJSONDefinition | proj} fromProjOrToProj
4591
+ * @param {string | PROJJSONDefinition | proj | TemplateCoordinates} [toProjOrCoord]
4592
+ * @param {T} [coord]
4593
+ * @returns {T|Converter}
4594
+ */
4595
+ function proj4$1(fromProjOrToProj, toProjOrCoord, coord) {
4596
+ /** @type {proj} */
4597
+ var fromProj;
4598
+ /** @type {proj} */
4599
+ var toProj;
4295
4600
  var single = false;
4601
+ /** @type {Converter} */
4296
4602
  var obj;
4297
- if (typeof toProj === 'undefined') {
4298
- toProj = fromProj;
4603
+ if (typeof toProjOrCoord === 'undefined') {
4604
+ toProj = checkProj(fromProjOrToProj);
4299
4605
  fromProj = wgs84;
4300
4606
  single = true;
4301
- } else if (typeof toProj.x !== 'undefined' || Array.isArray(toProj)) {
4302
- coord = toProj;
4303
- toProj = fromProj;
4607
+ } else if (typeof /** @type {?} */ (toProjOrCoord).x !== 'undefined' || Array.isArray(toProjOrCoord)) {
4608
+ coord = /** @type {T} */ (/** @type {?} */ (toProjOrCoord));
4609
+ toProj = checkProj(fromProjOrToProj);
4304
4610
  fromProj = wgs84;
4305
4611
  single = true;
4306
4612
  }
4307
- toProj = checkProj(toProj);
4613
+ if (!fromProj) {
4614
+ fromProj = checkProj(fromProjOrToProj);
4615
+ }
4616
+ if (!toProj) {
4617
+ toProj = checkProj(/** @type {string | PROJJSONDefinition | proj } */ (toProjOrCoord));
4618
+ }
4308
4619
  if (coord) {
4309
4620
  return transformer(fromProj, toProj, coord);
4310
4621
  } else {
4311
4622
  obj = {
4623
+ /**
4624
+ * @template {TemplateCoordinates} T
4625
+ * @param {T} coords
4626
+ * @param {boolean=} enforceAxis
4627
+ * @returns {T}
4628
+ */
4312
4629
  forward: function (coords, enforceAxis) {
4313
4630
  return transformer(fromProj, toProj, coords, enforceAxis);
4314
4631
  },
4632
+ /**
4633
+ * @template {TemplateCoordinates} T
4634
+ * @param {T} coords
4635
+ * @param {boolean=} enforceAxis
4636
+ * @returns {T}
4637
+ */
4315
4638
  inverse: function (coords, enforceAxis) {
4316
4639
  return transformer(toProj, fromProj, coords, enforceAxis);
4317
4640
  }
@@ -5064,6 +5387,12 @@
5064
5387
 
5065
5388
  }
5066
5389
 
5390
+ /**
5391
+ * @deprecated v3.0.0 - use proj4.toPoint instead
5392
+ * @param {number | import('./core').TemplateCoordinates | string} x
5393
+ * @param {number} [y]
5394
+ * @param {number} [z]
5395
+ */
5067
5396
  function Point(x, y, z) {
5068
5397
  if (!(this instanceof Point)) {
5069
5398
  return new Point(x, y, z);
@@ -5078,9 +5407,9 @@
5078
5407
  this.z = x.z || 0.0;
5079
5408
  } else if (typeof x === 'string' && typeof y === 'undefined') {
5080
5409
  var coords = x.split(',');
5081
- this.x = parseFloat(coords[0], 10);
5082
- this.y = parseFloat(coords[1], 10);
5083
- this.z = parseFloat(coords[2], 10) || 0.0;
5410
+ this.x = parseFloat(coords[0]);
5411
+ this.y = parseFloat(coords[1]);
5412
+ this.z = parseFloat(coords[2]) || 0.0;
5084
5413
  } else {
5085
5414
  this.x = x;
5086
5415
  this.y = y;
@@ -5151,6 +5480,14 @@
5151
5480
  // https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/tmerc.js
5152
5481
 
5153
5482
 
5483
+ /**
5484
+ * @typedef {Object} LocalThis
5485
+ * @property {number} es
5486
+ * @property {Array<number>} en
5487
+ * @property {number} ml0
5488
+ */
5489
+
5490
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5154
5491
  function init$v() {
5155
5492
  this.x0 = this.x0 !== undefined ? this.x0 : 0;
5156
5493
  this.y0 = this.y0 !== undefined ? this.y0 : 0;
@@ -5408,6 +5745,18 @@
5408
5745
  // https://github.com/mbloch/mapshaper-proj/blob/master/src/projections/etmerc.js
5409
5746
 
5410
5747
 
5748
+ /**
5749
+ * @typedef {Object} LocalThis
5750
+ * @property {number} es
5751
+ * @property {Array<number>} cbg
5752
+ * @property {Array<number>} cgb
5753
+ * @property {Array<number>} utg
5754
+ * @property {Array<number>} gtu
5755
+ * @property {number} Qn
5756
+ * @property {number} Zb
5757
+ */
5758
+
5759
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5411
5760
  function init$u() {
5412
5761
  if (!this.approx && (isNaN(this.es) || this.es <= 0)) {
5413
5762
  throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');
@@ -5582,6 +5931,7 @@
5582
5931
 
5583
5932
  var dependsOn = 'etmerc';
5584
5933
 
5934
+ /** @this {import('../defs.js').ProjectionDefinition} */
5585
5935
  function init$t() {
5586
5936
  var zone = adjust_zone(this.zone, this.long0);
5587
5937
  if (zone === undefined) {
@@ -5611,6 +5961,18 @@
5611
5961
 
5612
5962
  var MAX_ITER$2 = 20;
5613
5963
 
5964
+ /**
5965
+ * @typedef {Object} LocalThis
5966
+ * @property {number} rc
5967
+ * @property {number} C
5968
+ * @property {number} phic0
5969
+ * @property {number} ratexp
5970
+ * @property {number} K
5971
+ * @property {number} e
5972
+ * @property {number} es
5973
+ */
5974
+
5975
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5614
5976
  function init$s() {
5615
5977
  var sphi = Math.sin(this.lat0);
5616
5978
  var cphi = Math.cos(this.lat0);
@@ -5656,6 +6018,16 @@
5656
6018
  forward: forward$r,
5657
6019
  inverse: inverse$r};
5658
6020
 
6021
+ /**
6022
+ * @typedef {Object} LocalThis
6023
+ * @property {number} sinc0
6024
+ * @property {number} cosc0
6025
+ * @property {number} R2
6026
+ * @property {number} rc
6027
+ * @property {number} phic0
6028
+ */
6029
+
6030
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5659
6031
  function init$r() {
5660
6032
  gauss.init.apply(this);
5661
6033
  if (!this.rc) {
@@ -5717,11 +6089,25 @@
5717
6089
  names: names$r
5718
6090
  };
5719
6091
 
6092
+ /**
6093
+ * @typedef {Object} LocalThis
6094
+ * @property {number} coslat0
6095
+ * @property {number} sinlat0
6096
+ * @property {number} ms1
6097
+ * @property {number} X0
6098
+ * @property {number} cosX0
6099
+ * @property {number} sinX0
6100
+ * @property {number} con
6101
+ * @property {number} cons
6102
+ * @property {number} e
6103
+ */
6104
+
5720
6105
  function ssfn_(phit, sinphi, eccen) {
5721
6106
  sinphi *= eccen;
5722
6107
  return (Math.tan(0.5 * (HALF_PI + phit)) * Math.pow((1 - sinphi) / (1 + sinphi), 0.5 * eccen));
5723
6108
  }
5724
6109
 
6110
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5725
6111
  function init$q() {
5726
6112
  // setting default parameters
5727
6113
  this.x0 = this.x0 || 0;
@@ -5754,7 +6140,7 @@
5754
6140
  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));
5755
6141
  }
5756
6142
  this.ms1 = msfnz(this.e, this.sinlat0, this.coslat0);
5757
- this.X0 = 2 * Math.atan(this.ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
6143
+ this.X0 = 2 * Math.atan(ssfn_(this.lat0, this.sinlat0, this.e)) - HALF_PI;
5758
6144
  this.cosX0 = Math.cos(this.X0);
5759
6145
  this.sinX0 = Math.sin(this.X0);
5760
6146
  }
@@ -5783,7 +6169,7 @@
5783
6169
  p.y = this.a * A * (this.coslat0 * sinlat - this.sinlat0 * coslat * Math.cos(dlon)) + this.y0;
5784
6170
  return p;
5785
6171
  } else {
5786
- X = 2 * Math.atan(this.ssfn_(lat, sinlat, this.e)) - HALF_PI;
6172
+ X = 2 * Math.atan(ssfn_(lat, sinlat, this.e)) - HALF_PI;
5787
6173
  cosX = Math.cos(X);
5788
6174
  sinX = Math.sin(X);
5789
6175
  if (Math.abs(this.coslat0) <= EPSLN) {
@@ -5889,6 +6275,16 @@
5889
6275
  http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
5890
6276
  */
5891
6277
 
6278
+ /**
6279
+ * @typedef {Object} LocalThis
6280
+ * @property {number} lambda0
6281
+ * @property {number} e
6282
+ * @property {number} R
6283
+ * @property {number} b0
6284
+ * @property {number} K
6285
+ */
6286
+
6287
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5892
6288
  function init$p() {
5893
6289
  var phy0 = this.lat0;
5894
6290
  this.lambda0 = this.long0;
@@ -5968,6 +6364,29 @@
5968
6364
  names: names$p
5969
6365
  };
5970
6366
 
6367
+ /**
6368
+ * @typedef {Object} LocalThis
6369
+ * @property {boolean} no_off
6370
+ * @property {boolean} no_rot
6371
+ * @property {number} rectified_grid_angle
6372
+ * @property {number} es
6373
+ * @property {number} A
6374
+ * @property {number} B
6375
+ * @property {number} E
6376
+ * @property {number} e
6377
+ * @property {number} lam0
6378
+ * @property {number} singam
6379
+ * @property {number} cosgam
6380
+ * @property {number} sinrot
6381
+ * @property {number} cosrot
6382
+ * @property {number} rB
6383
+ * @property {number} ArB
6384
+ * @property {number} BrA
6385
+ * @property {number} u_0
6386
+ * @property {number} v_pole_n
6387
+ * @property {number} v_pole_s
6388
+ */
6389
+
5971
6390
  var TOL = 1e-7;
5972
6391
 
5973
6392
  function isTypeA(P) {
@@ -5977,8 +6396,10 @@
5977
6396
  return 'no_uoff' in P || 'no_off' in P || typeAProjections.indexOf(projectionName) !== -1 || typeAProjections.indexOf(getNormalizedProjName(projectionName)) !== -1;
5978
6397
  }
5979
6398
 
5980
- /* Initialize the Oblique Mercator projection
5981
- ------------------------------------------ */
6399
+ /**
6400
+ * Initialize the Oblique Mercator projection
6401
+ * @this {import('../defs.js').ProjectionDefinition & LocalThis}
6402
+ */
5982
6403
  function init$o() {
5983
6404
  var con, com, cosph0, D, F, H, L, sinph0, p, J, gamma = 0,
5984
6405
  gamma0, lamc = 0, lam1 = 0, lam2 = 0, phi1 = 0, phi2 = 0, alpha_c = 0;
@@ -6071,9 +6492,9 @@
6071
6492
  J = (J - L * H) / (J + L * H);
6072
6493
  con = lam1 - lam2;
6073
6494
 
6074
- if (con < -Math.pi) {
6495
+ if (con < -Math.PI) {
6075
6496
  lam2 -= TWO_PI;
6076
- } else if (con > Math.pi) {
6497
+ } else if (con > Math.PI) {
6077
6498
  lam2 += TWO_PI;
6078
6499
  }
6079
6500
 
@@ -6202,6 +6623,15 @@
6202
6623
  names: names$o
6203
6624
  };
6204
6625
 
6626
+ /**
6627
+ * @typedef {Object} LocalThis
6628
+ * @property {number} e
6629
+ * @property {number} ns
6630
+ * @property {number} f0
6631
+ * @property {number} rh
6632
+ */
6633
+
6634
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
6205
6635
  function init$n() {
6206
6636
  // double lat0; /* the reference latitude */
6207
6637
  // double long0; /* the reference longitude */
@@ -6493,6 +6923,17 @@
6493
6923
  return NaN;
6494
6924
  }
6495
6925
 
6926
+ /**
6927
+ * @typedef {Object} LocalThis
6928
+ * @property {number} es
6929
+ * @property {number} e0
6930
+ * @property {number} e1
6931
+ * @property {number} e2
6932
+ * @property {number} e3
6933
+ * @property {number} ml0
6934
+ */
6935
+
6936
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
6496
6937
  function init$l() {
6497
6938
  if (!this.sphere) {
6498
6939
  this.e0 = e0fn(this.es);
@@ -6594,6 +7035,24 @@
6594
7035
  }
6595
7036
  }
6596
7037
 
7038
+ /**
7039
+ * @typedef {Object} LocalThis
7040
+ * @property {number} mode
7041
+ * @property {Array<number>} apa
7042
+ * @property {number} dd
7043
+ * @property {number} e
7044
+ * @property {number} es
7045
+ * @property {number} mmf
7046
+ * @property {number} rq
7047
+ * @property {number} qp
7048
+ * @property {number} sinb1
7049
+ * @property {number} cosb1
7050
+ * @property {number} ymf
7051
+ * @property {number} xmf
7052
+ * @property {number} sinph0
7053
+ * @property {number} cosph0
7054
+ */
7055
+
6597
7056
  /*
6598
7057
  reference
6599
7058
  "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
@@ -6601,21 +7060,22 @@
6601
7060
  */
6602
7061
 
6603
7062
  var S_POLE = 1;
6604
-
6605
7063
  var N_POLE = 2;
6606
7064
  var EQUIT = 3;
6607
7065
  var OBLIQ = 4;
6608
7066
 
6609
- /* Initialize the Lambert Azimuthal Equal Area projection
6610
- ------------------------------------------------------ */
7067
+ /**
7068
+ * Initialize the Lambert Azimuthal Equal Area projection
7069
+ * @this {import('../defs.js').ProjectionDefinition & LocalThis}
7070
+ */
6611
7071
  function init$k() {
6612
7072
  var t = Math.abs(this.lat0);
6613
7073
  if (Math.abs(t - HALF_PI) < EPSLN) {
6614
- this.mode = this.lat0 < 0 ? this.S_POLE : this.N_POLE;
7074
+ this.mode = this.lat0 < 0 ? S_POLE : N_POLE;
6615
7075
  } else if (Math.abs(t) < EPSLN) {
6616
- this.mode = this.EQUIT;
7076
+ this.mode = EQUIT;
6617
7077
  } else {
6618
- this.mode = this.OBLIQ;
7078
+ this.mode = OBLIQ;
6619
7079
  }
6620
7080
  if (this.es > 0) {
6621
7081
  var sinphi;
@@ -6624,19 +7084,19 @@
6624
7084
  this.mmf = 0.5 / (1 - this.es);
6625
7085
  this.apa = authset(this.es);
6626
7086
  switch (this.mode) {
6627
- case this.N_POLE:
7087
+ case N_POLE:
6628
7088
  this.dd = 1;
6629
7089
  break;
6630
- case this.S_POLE:
7090
+ case S_POLE:
6631
7091
  this.dd = 1;
6632
7092
  break;
6633
- case this.EQUIT:
7093
+ case EQUIT:
6634
7094
  this.rq = Math.sqrt(0.5 * this.qp);
6635
7095
  this.dd = 1 / this.rq;
6636
7096
  this.xmf = 1;
6637
7097
  this.ymf = 0.5 * this.qp;
6638
7098
  break;
6639
- case this.OBLIQ:
7099
+ case OBLIQ:
6640
7100
  this.rq = Math.sqrt(0.5 * this.qp);
6641
7101
  sinphi = Math.sin(this.lat0);
6642
7102
  this.sinb1 = qsfnz(this.e, sinphi) / this.qp;
@@ -6647,7 +7107,7 @@
6647
7107
  break;
6648
7108
  }
6649
7109
  } else {
6650
- if (this.mode === this.OBLIQ) {
7110
+ if (this.mode === OBLIQ) {
6651
7111
  this.sinph0 = Math.sin(this.lat0);
6652
7112
  this.cosph0 = Math.cos(this.lat0);
6653
7113
  }
@@ -6883,6 +7343,30 @@
6883
7343
  return Math.asin(x);
6884
7344
  }
6885
7345
 
7346
+ /**
7347
+ * @typedef {Object} LocalThis
7348
+ * @property {number} temp
7349
+ * @property {number} es
7350
+ * @property {number} e3
7351
+ * @property {number} sin_po
7352
+ * @property {number} cos_po
7353
+ * @property {number} t1
7354
+ * @property {number} con
7355
+ * @property {number} ms1
7356
+ * @property {number} qs1
7357
+ * @property {number} t2
7358
+ * @property {number} ms2
7359
+ * @property {number} qs2
7360
+ * @property {number} t3
7361
+ * @property {number} qs0
7362
+ * @property {number} ns0
7363
+ * @property {number} c
7364
+ * @property {number} rh
7365
+ * @property {number} sin_phi
7366
+ * @property {number} cos_phi
7367
+ */
7368
+
7369
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
6886
7370
  function init$j() {
6887
7371
  if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
6888
7372
  return;
@@ -6920,6 +7404,7 @@
6920
7404
 
6921
7405
  /* Albers Conical Equal Area forward equations--mapping lat,long to x,y
6922
7406
  ------------------------------------------------------------------- */
7407
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
6923
7408
  function forward$i(p) {
6924
7409
  var lon = p.x;
6925
7410
  var lat = p.y;
@@ -7002,12 +7487,21 @@
7002
7487
  phi1z: phi1z
7003
7488
  };
7004
7489
 
7005
- /*
7490
+ /**
7491
+ * @typedef {Object} LocalThis
7492
+ * @property {number} sin_p14
7493
+ * @property {number} cos_p14
7494
+ * @property {number} infinity_dist
7495
+ * @property {number} rc
7496
+ */
7497
+
7498
+ /**
7006
7499
  reference:
7007
7500
  Wolfram Mathworld "Gnomonic Projection"
7008
7501
  http://mathworld.wolfram.com/GnomonicProjection.html
7009
7502
  Accessed: 12th November 2009
7010
- */
7503
+ @this {import('../defs.js').ProjectionDefinition & LocalThis}
7504
+ */
7011
7505
  function init$i() {
7012
7506
  /* Place parameters in static storage for common use
7013
7507
  ------------------------------------------------- */
@@ -7128,11 +7622,17 @@
7128
7622
  return NaN;
7129
7623
  }
7130
7624
 
7131
- /*
7625
+ /**
7626
+ * @typedef {Object} LocalThis
7627
+ * @property {number} e
7628
+ */
7629
+
7630
+ /**
7132
7631
  reference:
7133
7632
  "Cartographic Projection Procedures for the UNIX Environment-
7134
7633
  A User's Manual" by Gerald I. Evenden,
7135
7634
  USGS Open File Report 90-284and Release 4 Interim Reports (2003)
7635
+ @this {import('../defs.js').ProjectionDefinition & LocalThis}
7136
7636
  */
7137
7637
  function init$h() {
7138
7638
  // no-op
@@ -7235,8 +7735,21 @@
7235
7735
  names: names$g
7236
7736
  };
7237
7737
 
7738
+ /**
7739
+ * @typedef {Object} LocalThis
7740
+ * @property {number} temp
7741
+ * @property {number} es
7742
+ * @property {number} e
7743
+ * @property {number} e0
7744
+ * @property {number} e1
7745
+ * @property {number} e2
7746
+ * @property {number} e3
7747
+ * @property {number} ml0
7748
+ */
7749
+
7238
7750
  var MAX_ITER$1 = 20;
7239
7751
 
7752
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
7240
7753
  function init$f() {
7241
7754
  /* Place parameters in static storage for common use
7242
7755
  ------------------------------------------------- */
@@ -7614,6 +8127,17 @@
7614
8127
 
7615
8128
  var MAX_ITER = 20;
7616
8129
 
8130
+ /**
8131
+ * @typedef {Object} LocalThis
8132
+ * @property {Array<number>} en
8133
+ * @property {number} n
8134
+ * @property {number} m
8135
+ * @property {number} C_y
8136
+ * @property {number} C_x
8137
+ * @property {number} es
8138
+ */
8139
+
8140
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
7617
8141
  function init$c() {
7618
8142
  /* Place parameters in static storage for common use
7619
8143
  ------------------------------------------------- */
@@ -7790,6 +8314,28 @@
7790
8314
  names: names$b
7791
8315
  };
7792
8316
 
8317
+ /**
8318
+ * @typedef {Object} LocalThis
8319
+ * @property {number} temp
8320
+ * @property {number} es
8321
+ * @property {number} e
8322
+ * @property {number} e0
8323
+ * @property {number} e1
8324
+ * @property {number} e2
8325
+ * @property {number} e3
8326
+ * @property {number} sin_phi
8327
+ * @property {number} cos_phi
8328
+ * @property {number} ms1
8329
+ * @property {number} ml1
8330
+ * @property {number} ms2
8331
+ * @property {number} ml2
8332
+ * @property {number} ns
8333
+ * @property {number} g
8334
+ * @property {number} ml0
8335
+ * @property {number} rh
8336
+ */
8337
+
8338
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
7793
8339
  function init$a() {
7794
8340
  /* Place parameters in static storage for common use
7795
8341
  ------------------------------------------------- */
@@ -7806,18 +8352,18 @@
7806
8352
  this.e2 = e2fn(this.es);
7807
8353
  this.e3 = e3fn(this.es);
7808
8354
 
7809
- this.sinphi = Math.sin(this.lat1);
7810
- this.cosphi = Math.cos(this.lat1);
8355
+ this.sin_phi = Math.sin(this.lat1);
8356
+ this.cos_phi = Math.cos(this.lat1);
7811
8357
 
7812
- this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);
8358
+ this.ms1 = msfnz(this.e, this.sin_phi, this.cos_phi);
7813
8359
  this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
7814
8360
 
7815
8361
  if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
7816
- this.ns = this.sinphi;
8362
+ this.ns = this.sin_phi;
7817
8363
  } else {
7818
- this.sinphi = Math.sin(this.lat2);
7819
- this.cosphi = Math.cos(this.lat2);
7820
- this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);
8364
+ this.sin_phi = Math.sin(this.lat2);
8365
+ this.cos_phi = Math.cos(this.lat2);
8366
+ this.ms2 = msfnz(this.e, this.sin_phi, this.cos_phi);
7821
8367
  this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
7822
8368
  this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
7823
8369
  }
@@ -7891,8 +8437,15 @@
7891
8437
  names: names$a
7892
8438
  };
7893
8439
 
7894
- /* Initialize the Van Der Grinten projection
7895
- ---------------------------------------- */
8440
+ /**
8441
+ * @typedef {Object} LocalThis
8442
+ * @property {number} R - Radius of the Earth
8443
+ */
8444
+
8445
+ /**
8446
+ * Initialize the Van Der Grinten projection
8447
+ * @this {import('../defs.js').ProjectionDefinition & LocalThis}
8448
+ */
7896
8449
  function init$9() {
7897
8450
  // this.R = 6370997; //Radius of earth
7898
8451
  this.R = this.a;
@@ -8009,153 +8562,145 @@
8009
8562
  names: names$9
8010
8563
  };
8011
8564
 
8012
- var geographiclibGeodesic_min = {exports: {}};
8013
-
8014
- var hasRequiredGeographiclibGeodesic_min;
8015
-
8016
- function requireGeographiclibGeodesic_min () {
8017
- if (hasRequiredGeographiclibGeodesic_min) return geographiclibGeodesic_min.exports;
8018
- hasRequiredGeographiclibGeodesic_min = 1;
8019
- (function (module) {
8020
- (function(cb){var geodesic={};geodesic.Constants={};geodesic.Math={};geodesic.Accumulator={};(function(c){c.WGS84={a:6378137,f:1/298.257223563};c.version={major:2,minor:1,patch:1};c.version_string="2.1.1";})(geodesic.Constants);(function(m){m.digits=53;m.epsilon=Math.pow(0.5,m.digits-1);m.degree=Math.PI/180;m.sq=function(x){return x*x;};m.hypot=function(x,y){return Math.sqrt(x*x+y*y);};m.cbrt=Math.cbrt||function(x){var y=Math.pow(Math.abs(x),1/3);return x>0?y:(x<0?-y:x);};m.log1p=Math.log1p||function(x){var y=1+x,z=y-1;return z===0?x:x*Math.log(y)/z;};m.atanh=Math.atanh||function(x){var y=Math.abs(x);y=m.log1p(2*y/(1-y))/2;return x>0?y:(x<0?-y:x);};m.copysign=function(x,y){return Math.abs(x)*(y<0||(y===0&&1/y<0)?-1:1);};m.sum=function(u,v){var s=u+v,up=s-v,vpp=s-up,t;up-=u;vpp-=v;t=s?0-(up+vpp):s;return {s:s,t:t};};m.polyval=function(N,p,s,x){var y=N<0?0:p[s++];while(--N>=0)y=y*x+p[s++];return y;};m.AngRound=function(x){var z=1/16,y=Math.abs(x);y=y<z?z-(z-y):y;return m.copysign(y,x);};m.remainder=function(x,y){x%=y;return x<-y/2?x+y:(x<y/2?x:x-y);};m.AngNormalize=function(x){var y=m.remainder(x,360);return Math.abs(y)===180?m.copysign(180,x):y;};m.LatFix=function(x){return Math.abs(x)>90?NaN:x;};m.AngDiff=function(x,y){var r=m.sum(m.remainder(-x,360),m.remainder(y,360)),d,e;r=m.sum(m.remainder(r.s,360),r.t);d=r.s;e=r.t;if(d===0||Math.abs(d)===180)
8021
- d=m.copysign(d,e===0?y-x:-e);return {d:d,e:e};};m.sincosd=function(x){var d,r,q,s,c,sinx,cosx;d=x%360;q=Math.round(d/90);d-=90*q;r=d*this.degree;s=Math.sin(r);c=Math.cos(r);if(Math.abs(d)===45){c=Math.sqrt(0.5);s=m.copysign(c,r);}else if(Math.abs(d)===30){c=Math.sqrt(0.75);s=m.copysign(0.5,r);}
8022
- switch(q&3){case 0:sinx=s;cosx=c;break;case 1:sinx=c;cosx=-s;break;case 2:sinx=-s;cosx=-c;break;default:sinx=-c;cosx=s;break;}
8023
- cosx+=0;if(sinx===0)sinx=m.copysign(sinx,x);return {s:sinx,c:cosx};};m.sincosde=function(x,t){var d,r,q,s,c,sinx,cosx;d=x%360;q=Math.round(d/90);d=m.AngRound((d-90*q)+t);r=d*this.degree;s=Math.sin(r);c=Math.cos(r);if(Math.abs(d)===45){c=Math.sqrt(0.5);s=m.copysign(c,r);}else if(Math.abs(d)===30){c=Math.sqrt(0.75);s=m.copysign(0.5,r);}
8024
- switch(q&3){case 0:sinx=s;cosx=c;break;case 1:sinx=c;cosx=-s;break;case 2:sinx=-s;cosx=-c;break;default:sinx=-c;cosx=s;break;}
8025
- cosx+=0;if(sinx===0)sinx=m.copysign(sinx,x+t);return {s:sinx,c:cosx};};m.atan2d=function(y,x){var q=0,ang;if(Math.abs(y)>Math.abs(x)){[y,x]=[x,y];q=2;}
8026
- if(m.copysign(1,x)<0){x=-x;++q;}
8027
- ang=Math.atan2(y,x)/this.degree;switch(q){case 1:ang=m.copysign(180,y)-ang;break;case 2:ang=90-ang;break;case 3:ang=-90+ang;break;}
8028
- return ang;};})(geodesic.Math);(function(a,m){a.Accumulator=function(y){this.Set(y);};a.Accumulator.prototype.Set=function(y){if(!y)y=0;if(y.constructor===a.Accumulator){this._s=y._s;this._t=y._t;}else {this._s=y;this._t=0;}};a.Accumulator.prototype.Add=function(y){var u=m.sum(y,this._t),v=m.sum(u.s,this._s);u=u.t;this._s=v.s;this._t=v.t;if(this._s===0)
8029
- this._s=u;else
8030
- this._t+=u;};a.Accumulator.prototype.Sum=function(y){var b;if(!y)
8031
- return this._s;else {b=new a.Accumulator(this);b.Add(y);return b._s;}};a.Accumulator.prototype.Negate=function(){this._s*=-1;this._t*=-1;};a.Accumulator.prototype.Remainder=function(y){this._s=m.remainder(this._s,y);this.Add(0);};})(geodesic.Accumulator,geodesic.Math);geodesic.Geodesic={};geodesic.GeodesicLine={};geodesic.PolygonArea={};(function(g,l,p,m,c){var GEOGRAPHICLIB_GEODESIC_ORDER=6,nA1_=GEOGRAPHICLIB_GEODESIC_ORDER,nA2_=GEOGRAPHICLIB_GEODESIC_ORDER,nA3_=GEOGRAPHICLIB_GEODESIC_ORDER,nA3x_=nA3_,nC3x_,nC4x_,maxit1_=20,maxit2_=maxit1_+m.digits+10,tol0_=m.epsilon,tol1_=200*tol0_,tol2_=Math.sqrt(tol0_),tolb_=tol0_,xthresh_=1000*tol2_,CAP_NONE=0,CAP_ALL=0x1F,OUT_ALL=0x7F80,astroid,A1m1f_coeff,C1f_coeff,C1pf_coeff,A2m1f_coeff,C2f_coeff,A3_coeff,C3_coeff,C4_coeff;g.tiny_=Math.sqrt(Number.MIN_VALUE/Number.EPSILON);g.nC1_=GEOGRAPHICLIB_GEODESIC_ORDER;g.nC1p_=GEOGRAPHICLIB_GEODESIC_ORDER;g.nC2_=GEOGRAPHICLIB_GEODESIC_ORDER;g.nC3_=GEOGRAPHICLIB_GEODESIC_ORDER;g.nC4_=GEOGRAPHICLIB_GEODESIC_ORDER;nC3x_=(g.nC3_*(g.nC3_-1))/2;nC4x_=(g.nC4_*(g.nC4_+1))/2;g.CAP_C1=1<<0;g.CAP_C1p=1<<1;g.CAP_C2=1<<2;g.CAP_C3=1<<3;g.CAP_C4=1<<4;g.NONE=0;g.ARC=1<<6;g.LATITUDE=1<<7|CAP_NONE;g.LONGITUDE=1<<8|g.CAP_C3;g.AZIMUTH=1<<9|CAP_NONE;g.DISTANCE=1<<10|g.CAP_C1;g.STANDARD=g.LATITUDE|g.LONGITUDE|g.AZIMUTH|g.DISTANCE;g.DISTANCE_IN=1<<11|g.CAP_C1|g.CAP_C1p;g.REDUCEDLENGTH=1<<12|g.CAP_C1|g.CAP_C2;g.GEODESICSCALE=1<<13|g.CAP_C1|g.CAP_C2;g.AREA=1<<14|g.CAP_C4;g.ALL=OUT_ALL|CAP_ALL;g.LONG_UNROLL=1<<15;g.OUT_MASK=OUT_ALL|g.LONG_UNROLL;g.SinCosSeries=function(sinp,sinx,cosx,c){var k=c.length,n=k-(sinp?1:0),ar=2*(cosx-sinx)*(cosx+sinx),y0=n&1?c[--k]:0,y1=0;n=Math.floor(n/2);while(n--){y1=ar*y0-y1+c[--k];y0=ar*y1-y0+c[--k];}
8032
- return(sinp?2*sinx*cosx*y0:cosx*(y0-y1));};astroid=function(x,y){var k,p=m.sq(x),q=m.sq(y),r=(p+q-1)/6,S,r2,r3,disc,u,T3,T,ang,v,uv,w;if(!(q===0&&r<=0)){S=p*q/4;r2=m.sq(r);r3=r*r2;disc=S*(S+2*r3);u=r;if(disc>=0){T3=S+r3;T3+=T3<0?-Math.sqrt(disc):Math.sqrt(disc);T=m.cbrt(T3);u+=T+(T!==0?r2/T:0);}else {ang=Math.atan2(Math.sqrt(-disc),-(S+r3));u+=2*r*Math.cos(ang/3);}
8033
- v=Math.sqrt(m.sq(u)+q);uv=u<0?q/(v-u):u+v;w=(uv-q)/(2*v);k=uv/(Math.sqrt(uv+m.sq(w))+w);}else {k=0;}
8034
- return k;};A1m1f_coeff=[1,4,64,0,256];g.A1m1f=function(eps){var p=Math.floor(nA1_/2),t=m.polyval(p,A1m1f_coeff,0,m.sq(eps))/A1m1f_coeff[p+1];return (t+eps)/(1-eps);};C1f_coeff=[-1,6,-16,32,-9,64,-128,2048,9,-16,768,3,-5,512,-7,1280,-7,2048];g.C1f=function(eps,c){var eps2=m.sq(eps),d=eps,o=0,l,p;for(l=1;l<=g.nC1_;++l){p=Math.floor((g.nC1_-l)/2);c[l]=d*m.polyval(p,C1f_coeff,o,eps2)/C1f_coeff[o+p+1];o+=p+2;d*=eps;}};C1pf_coeff=[205,-432,768,1536,4005,-4736,3840,12288,-225,116,384,-7173,2695,7680,3467,7680,38081,61440];g.C1pf=function(eps,c){var eps2=m.sq(eps),d=eps,o=0,l,p;for(l=1;l<=g.nC1p_;++l){p=Math.floor((g.nC1p_-l)/2);c[l]=d*m.polyval(p,C1pf_coeff,o,eps2)/C1pf_coeff[o+p+1];o+=p+2;d*=eps;}};A2m1f_coeff=[-11,-28,-192,0,256];g.A2m1f=function(eps){var p=Math.floor(nA2_/2),t=m.polyval(p,A2m1f_coeff,0,m.sq(eps))/A2m1f_coeff[p+1];return (t-eps)/(1+eps);};C2f_coeff=[1,2,16,32,35,64,384,2048,15,80,768,7,35,512,63,1280,77,2048];g.C2f=function(eps,c){var eps2=m.sq(eps),d=eps,o=0,l,p;for(l=1;l<=g.nC2_;++l){p=Math.floor((g.nC2_-l)/2);c[l]=d*m.polyval(p,C2f_coeff,o,eps2)/C2f_coeff[o+p+1];o+=p+2;d*=eps;}};g.Geodesic=function(a,f){this.a=a;this.f=f;this._f1=1-this.f;this._e2=this.f*(2-this.f);this._ep2=this._e2/m.sq(this._f1);this._n=this.f/(2-this.f);this._b=this.a*this._f1;this._c2=(m.sq(this.a)+m.sq(this._b)*(this._e2===0?1:(this._e2>0?m.atanh(Math.sqrt(this._e2)):Math.atan(Math.sqrt(-this._e2)))/Math.sqrt(Math.abs(this._e2))))/2;this._etol2=0.1*tol2_/Math.sqrt(Math.max(0.001,Math.abs(this.f))*Math.min(1,1-this.f/2)/2);if(!(isFinite(this.a)&&this.a>0))
8035
- throw new Error("Equatorial radius is not positive");if(!(isFinite(this._b)&&this._b>0))
8036
- throw new Error("Polar semi-axis is not positive");this._A3x=new Array(nA3x_);this._C3x=new Array(nC3x_);this._C4x=new Array(nC4x_);this.A3coeff();this.C3coeff();this.C4coeff();};A3_coeff=[-3,128,-2,-3,64,-1,-3,-1,16,3,-1,-2,8,1,-1,2,1,1];g.Geodesic.prototype.A3coeff=function(){var o=0,k=0,j,p;for(j=nA3_-1;j>=0;--j){p=Math.min(nA3_-j-1,j);this._A3x[k++]=m.polyval(p,A3_coeff,o,this._n)/A3_coeff[o+p+1];o+=p+2;}};C3_coeff=[3,128,2,5,128,-1,3,3,64,-1,0,1,8,-1,1,4,5,256,1,3,128,-3,-2,3,64,1,-3,2,32,7,512,-10,9,384,5,-9,5,192,7,512,-14,7,512,21,2560];g.Geodesic.prototype.C3coeff=function(){var o=0,k=0,l,j,p;for(l=1;l<g.nC3_;++l){for(j=g.nC3_-1;j>=l;--j){p=Math.min(g.nC3_-j-1,j);this._C3x[k++]=m.polyval(p,C3_coeff,o,this._n)/C3_coeff[o+p+1];o+=p+2;}}};C4_coeff=[97,15015,1088,156,45045,-224,-4784,1573,45045,-10656,14144,-4576,-858,45045,64,624,-4576,6864,-3003,15015,100,208,572,3432,-12012,30030,45045,1,9009,-2944,468,135135,5792,1040,-1287,135135,5952,-11648,9152,-2574,135135,-64,-624,4576,-6864,3003,135135,8,10725,1856,-936,225225,-8448,4992,-1144,225225,-1440,4160,-4576,1716,225225,-136,63063,1024,-208,105105,3584,-3328,1144,315315,-128,135135,-2560,832,405405,128,99099];g.Geodesic.prototype.C4coeff=function(){var o=0,k=0,l,j,p;for(l=0;l<g.nC4_;++l){for(j=g.nC4_-1;j>=l;--j){p=g.nC4_-j-1;this._C4x[k++]=m.polyval(p,C4_coeff,o,this._n)/C4_coeff[o+p+1];o+=p+2;}}};g.Geodesic.prototype.A3f=function(eps){return m.polyval(nA3x_-1,this._A3x,0,eps);};g.Geodesic.prototype.C3f=function(eps,c){var mult=1,o=0,l,p;for(l=1;l<g.nC3_;++l){p=g.nC3_-l-1;mult*=eps;c[l]=mult*m.polyval(p,this._C3x,o,eps);o+=p+1;}};g.Geodesic.prototype.C4f=function(eps,c){var mult=1,o=0,l,p;for(l=0;l<g.nC4_;++l){p=g.nC4_-l-1;c[l]=mult*m.polyval(p,this._C4x,o,eps);o+=p+1;mult*=eps;}};g.Geodesic.prototype.Lengths=function(eps,sig12,ssig1,csig1,dn1,ssig2,csig2,dn2,cbet1,cbet2,outmask,C1a,C2a){outmask&=g.OUT_MASK;var vals={},m0x=0,J12=0,A1=0,A2=0,B1,B2,l,csig12,t;if(outmask&(g.DISTANCE|g.REDUCEDLENGTH|g.GEODESICSCALE)){A1=g.A1m1f(eps);g.C1f(eps,C1a);if(outmask&(g.REDUCEDLENGTH|g.GEODESICSCALE)){A2=g.A2m1f(eps);g.C2f(eps,C2a);m0x=A1-A2;A2=1+A2;}
8037
- A1=1+A1;}
8038
- if(outmask&g.DISTANCE){B1=g.SinCosSeries(true,ssig2,csig2,C1a)-
8039
- g.SinCosSeries(true,ssig1,csig1,C1a);vals.s12b=A1*(sig12+B1);if(outmask&(g.REDUCEDLENGTH|g.GEODESICSCALE)){B2=g.SinCosSeries(true,ssig2,csig2,C2a)-
8040
- g.SinCosSeries(true,ssig1,csig1,C2a);J12=m0x*sig12+(A1*B1-A2*B2);}}else if(outmask&(g.REDUCEDLENGTH|g.GEODESICSCALE)){for(l=1;l<=g.nC2_;++l)
8041
- C2a[l]=A1*C1a[l]-A2*C2a[l];J12=m0x*sig12+(g.SinCosSeries(true,ssig2,csig2,C2a)-
8042
- g.SinCosSeries(true,ssig1,csig1,C2a));}
8043
- if(outmask&g.REDUCEDLENGTH){vals.m0=m0x;vals.m12b=dn2*(csig1*ssig2)-dn1*(ssig1*csig2)-
8044
- csig1*csig2*J12;}
8045
- if(outmask&g.GEODESICSCALE){csig12=csig1*csig2+ssig1*ssig2;t=this._ep2*(cbet1-cbet2)*(cbet1+cbet2)/(dn1+dn2);vals.M12=csig12+(t*ssig2-csig2*J12)*ssig1/dn1;vals.M21=csig12-(t*ssig1-csig1*J12)*ssig2/dn2;}
8046
- return vals;};g.Geodesic.prototype.InverseStart=function(sbet1,cbet1,dn1,sbet2,cbet2,dn2,lam12,slam12,clam12,C1a,C2a){var vals={},sbet12=sbet2*cbet1-cbet2*sbet1,cbet12=cbet2*cbet1+sbet2*sbet1,sbet12a,shortline,omg12,sbetm2,somg12,comg12,t,ssig12,csig12,x,y,lamscale,betscale,k2,eps,cbet12a,bet12a,m12b,m0,nvals,k,omg12a,lam12x;vals.sig12=-1;sbet12a=sbet2*cbet1;sbet12a+=cbet2*sbet1;shortline=cbet12>=0&&sbet12<0.5&&cbet2*lam12<0.5;if(shortline){sbetm2=m.sq(sbet1+sbet2);sbetm2/=sbetm2+m.sq(cbet1+cbet2);vals.dnm=Math.sqrt(1+this._ep2*sbetm2);omg12=lam12/(this._f1*vals.dnm);somg12=Math.sin(omg12);comg12=Math.cos(omg12);}else {somg12=slam12;comg12=clam12;}
8047
- vals.salp1=cbet2*somg12;vals.calp1=comg12>=0?sbet12+cbet2*sbet1*m.sq(somg12)/(1+comg12):sbet12a-cbet2*sbet1*m.sq(somg12)/(1-comg12);ssig12=m.hypot(vals.salp1,vals.calp1);csig12=sbet1*sbet2+cbet1*cbet2*comg12;if(shortline&&ssig12<this._etol2){vals.salp2=cbet1*somg12;vals.calp2=sbet12-cbet1*sbet2*(comg12>=0?m.sq(somg12)/(1+comg12):1-comg12);t=m.hypot(vals.salp2,vals.calp2);vals.salp2/=t;vals.calp2/=t;vals.sig12=Math.atan2(ssig12,csig12);}else if(Math.abs(this._n)>0.1||csig12>=0||ssig12>=6*Math.abs(this._n)*Math.PI*m.sq(cbet1));else {lam12x=Math.atan2(-slam12,-clam12);if(this.f>=0){k2=m.sq(sbet1)*this._ep2;eps=k2/(2*(1+Math.sqrt(1+k2))+k2);lamscale=this.f*cbet1*this.A3f(eps)*Math.PI;betscale=lamscale*cbet1;x=lam12x/lamscale;y=sbet12a/betscale;}else {cbet12a=cbet2*cbet1-sbet2*sbet1;bet12a=Math.atan2(sbet12a,cbet12a);nvals=this.Lengths(this._n,Math.PI+bet12a,sbet1,-cbet1,dn1,sbet2,cbet2,dn2,cbet1,cbet2,g.REDUCEDLENGTH,C1a,C2a);m12b=nvals.m12b;m0=nvals.m0;x=-1+m12b/(cbet1*cbet2*m0*Math.PI);betscale=x<-0.01?sbet12a/x:-this.f*m.sq(cbet1)*Math.PI;lamscale=betscale/cbet1;y=lam12/lamscale;}
8048
- if(y>-tol1_&&x>-1-xthresh_){if(this.f>=0){vals.salp1=Math.min(1,-x);vals.calp1=-Math.sqrt(1-m.sq(vals.salp1));}else {vals.calp1=Math.max(x>-tol1_?0:-1,x);vals.salp1=Math.sqrt(1-m.sq(vals.calp1));}}else {k=astroid(x,y);omg12a=lamscale*(this.f>=0?-x*k/(1+k):-y*(1+k)/k);somg12=Math.sin(omg12a);comg12=-Math.cos(omg12a);vals.salp1=cbet2*somg12;vals.calp1=sbet12a-
8049
- cbet2*sbet1*m.sq(somg12)/(1-comg12);}}
8050
- if(!(vals.salp1<=0)){t=m.hypot(vals.salp1,vals.calp1);vals.salp1/=t;vals.calp1/=t;}else {vals.salp1=1;vals.calp1=0;}
8051
- return vals;};g.Geodesic.prototype.Lambda12=function(sbet1,cbet1,dn1,sbet2,cbet2,dn2,salp1,calp1,slam120,clam120,diffp,C1a,C2a,C3a){var vals={},t,salp0,calp0,somg1,comg1,somg2,comg2,somg12,comg12,B312,eta,k2,nvals;if(sbet1===0&&calp1===0)
8052
- calp1=-g.tiny_;salp0=salp1*cbet1;calp0=m.hypot(calp1,salp1*sbet1);vals.ssig1=sbet1;somg1=salp0*sbet1;vals.csig1=comg1=calp1*cbet1;t=m.hypot(vals.ssig1,vals.csig1);vals.ssig1/=t;vals.csig1/=t;vals.salp2=cbet2!==cbet1?salp0/cbet2:salp1;vals.calp2=cbet2!==cbet1||Math.abs(sbet2)!==-sbet1?Math.sqrt(m.sq(calp1*cbet1)+(cbet1<-sbet1?(cbet2-cbet1)*(cbet1+cbet2):(sbet1-sbet2)*(sbet1+sbet2)))/cbet2:Math.abs(calp1);vals.ssig2=sbet2;somg2=salp0*sbet2;vals.csig2=comg2=vals.calp2*cbet2;t=m.hypot(vals.ssig2,vals.csig2);vals.ssig2/=t;vals.csig2/=t;vals.sig12=Math.atan2(Math.max(0,vals.csig1*vals.ssig2-
8053
- vals.ssig1*vals.csig2),vals.csig1*vals.csig2+
8054
- vals.ssig1*vals.ssig2);somg12=Math.max(0,comg1*somg2-somg1*comg2);comg12=comg1*comg2+somg1*somg2;eta=Math.atan2(somg12*clam120-comg12*slam120,comg12*clam120+somg12*slam120);k2=m.sq(calp0)*this._ep2;vals.eps=k2/(2*(1+Math.sqrt(1+k2))+k2);this.C3f(vals.eps,C3a);B312=(g.SinCosSeries(true,vals.ssig2,vals.csig2,C3a)-
8055
- g.SinCosSeries(true,vals.ssig1,vals.csig1,C3a));vals.domg12=-this.f*this.A3f(vals.eps)*salp0*(vals.sig12+B312);vals.lam12=eta+vals.domg12;if(diffp){if(vals.calp2===0)
8056
- vals.dlam12=-2*this._f1*dn1/sbet1;else {nvals=this.Lengths(vals.eps,vals.sig12,vals.ssig1,vals.csig1,dn1,vals.ssig2,vals.csig2,dn2,cbet1,cbet2,g.REDUCEDLENGTH,C1a,C2a);vals.dlam12=nvals.m12b;vals.dlam12*=this._f1/(vals.calp2*cbet2);}}
8057
- return vals;};g.Geodesic.prototype.Inverse=function(lat1,lon1,lat2,lon2,outmask){var r,vals;if(!outmask)outmask=g.STANDARD;if(outmask===g.LONG_UNROLL)outmask|=g.STANDARD;outmask&=g.OUT_MASK;r=this.InverseInt(lat1,lon1,lat2,lon2,outmask);vals=r.vals;if(outmask&g.AZIMUTH){vals.azi1=m.atan2d(r.salp1,r.calp1);vals.azi2=m.atan2d(r.salp2,r.calp2);}
8058
- return vals;};g.Geodesic.prototype.InverseInt=function(lat1,lon1,lat2,lon2,outmask){var vals={},lon12,lon12s,lonsign,t,swapp,latsign,sbet1,cbet1,sbet2,cbet2,s12x,m12x,dn1,dn2,lam12,slam12,clam12,sig12,calp1,salp1,calp2,salp2,C1a,C2a,C3a,meridian,nvals,ssig1,csig1,ssig2,csig2,eps,omg12,dnm,numit,salp1a,calp1a,salp1b,calp1b,tripn,tripb,v,dv,dalp1,sdalp1,cdalp1,nsalp1,lengthmask,salp0,calp0,alp12,k2,A4,C4a,B41,B42,somg12,comg12,domg12,dbet1,dbet2,salp12,calp12,sdomg12,cdomg12;vals.lat1=lat1=m.LatFix(lat1);vals.lat2=lat2=m.LatFix(lat2);lat1=m.AngRound(lat1);lat2=m.AngRound(lat2);lon12=m.AngDiff(lon1,lon2);lon12s=lon12.e;lon12=lon12.d;if(outmask&g.LONG_UNROLL){vals.lon1=lon1;vals.lon2=(lon1+lon12)+lon12s;}else {vals.lon1=m.AngNormalize(lon1);vals.lon2=m.AngNormalize(lon2);}
8059
- lonsign=m.copysign(1,lon12);lon12*=lonsign;lon12s*=lonsign;lam12=lon12*m.degree;t=m.sincosde(lon12,lon12s);slam12=t.s;clam12=t.c;lon12s=(180-lon12)-lon12s;swapp=Math.abs(lat1)<Math.abs(lat2)||isNaN(lat2)?-1:1;if(swapp<0){lonsign*=-1;[lat2,lat1]=[lat1,lat2];}
8060
- latsign=m.copysign(1,-lat1);lat1*=latsign;lat2*=latsign;t=m.sincosd(lat1);sbet1=this._f1*t.s;cbet1=t.c;t=m.hypot(sbet1,cbet1);sbet1/=t;cbet1/=t;cbet1=Math.max(g.tiny_,cbet1);t=m.sincosd(lat2);sbet2=this._f1*t.s;cbet2=t.c;t=m.hypot(sbet2,cbet2);sbet2/=t;cbet2/=t;cbet2=Math.max(g.tiny_,cbet2);if(cbet1<-sbet1){if(cbet2===cbet1)
8061
- sbet2=m.copysign(sbet1,sbet2);}else {if(Math.abs(sbet2)===-sbet1)
8062
- cbet2=cbet1;}
8063
- dn1=Math.sqrt(1+this._ep2*m.sq(sbet1));dn2=Math.sqrt(1+this._ep2*m.sq(sbet2));C1a=new Array(g.nC1_+1);C2a=new Array(g.nC2_+1);C3a=new Array(g.nC3_);meridian=lat1===-90||slam12===0;if(meridian){calp1=clam12;salp1=slam12;calp2=1;salp2=0;ssig1=sbet1;csig1=calp1*cbet1;ssig2=sbet2;csig2=calp2*cbet2;sig12=Math.atan2(Math.max(0,csig1*ssig2-ssig1*csig2),csig1*csig2+ssig1*ssig2);nvals=this.Lengths(this._n,sig12,ssig1,csig1,dn1,ssig2,csig2,dn2,cbet1,cbet2,outmask|g.DISTANCE|g.REDUCEDLENGTH,C1a,C2a);s12x=nvals.s12b;m12x=nvals.m12b;if(outmask&g.GEODESICSCALE){vals.M12=nvals.M12;vals.M21=nvals.M21;}
8064
- if(sig12<1||m12x>=0){if(sig12<3*g.tiny_||(sig12<tol0_&&(s12x<0||m12x<0)))
8065
- sig12=m12x=s12x=0;m12x*=this._b;s12x*=this._b;vals.a12=sig12/m.degree;}else
8066
- meridian=false;}
8067
- somg12=2;if(!meridian&&sbet1===0&&(this.f<=0||lon12s>=this.f*180)){calp1=calp2=0;salp1=salp2=1;s12x=this.a*lam12;sig12=omg12=lam12/this._f1;m12x=this._b*Math.sin(sig12);if(outmask&g.GEODESICSCALE)
8068
- vals.M12=vals.M21=Math.cos(sig12);vals.a12=lon12/this._f1;}else if(!meridian){nvals=this.InverseStart(sbet1,cbet1,dn1,sbet2,cbet2,dn2,lam12,slam12,clam12,C1a,C2a);sig12=nvals.sig12;salp1=nvals.salp1;calp1=nvals.calp1;if(sig12>=0){salp2=nvals.salp2;calp2=nvals.calp2;dnm=nvals.dnm;s12x=sig12*this._b*dnm;m12x=m.sq(dnm)*this._b*Math.sin(sig12/dnm);if(outmask&g.GEODESICSCALE)
8069
- vals.M12=vals.M21=Math.cos(sig12/dnm);vals.a12=sig12/m.degree;omg12=lam12/(this._f1*dnm);}else {numit=0;salp1a=g.tiny_;calp1a=1;salp1b=g.tiny_;calp1b=-1;for(tripn=false,tripb=false;;++numit){nvals=this.Lambda12(sbet1,cbet1,dn1,sbet2,cbet2,dn2,salp1,calp1,slam12,clam12,numit<maxit1_,C1a,C2a,C3a);v=nvals.lam12;salp2=nvals.salp2;calp2=nvals.calp2;sig12=nvals.sig12;ssig1=nvals.ssig1;csig1=nvals.csig1;ssig2=nvals.ssig2;csig2=nvals.csig2;eps=nvals.eps;domg12=nvals.domg12;dv=nvals.dlam12;if(tripb||!(Math.abs(v)>=(tripn?8:1)*tol0_)||numit==maxit2_)
8070
- break;if(v>0&&(numit<maxit1_||calp1/salp1>calp1b/salp1b)){salp1b=salp1;calp1b=calp1;}else if(v<0&&(numit<maxit1_||calp1/salp1<calp1a/salp1a)){salp1a=salp1;calp1a=calp1;}
8071
- if(numit<maxit1_&&dv>0){dalp1=-v/dv;if(Math.abs(dalp1)<Math.PI){sdalp1=Math.sin(dalp1);cdalp1=Math.cos(dalp1);nsalp1=salp1*cdalp1+calp1*sdalp1;if(nsalp1>0){calp1=calp1*cdalp1-salp1*sdalp1;salp1=nsalp1;t=m.hypot(salp1,calp1);salp1/=t;calp1/=t;tripn=Math.abs(v)<=16*tol0_;continue;}}}
8072
- salp1=(salp1a+salp1b)/2;calp1=(calp1a+calp1b)/2;t=m.hypot(salp1,calp1);salp1/=t;calp1/=t;tripn=false;tripb=(Math.abs(salp1a-salp1)+(calp1a-calp1)<tolb_||Math.abs(salp1-salp1b)+(calp1-calp1b)<tolb_);}
8073
- lengthmask=outmask|(outmask&(g.REDUCEDLENGTH|g.GEODESICSCALE)?g.DISTANCE:g.NONE);nvals=this.Lengths(eps,sig12,ssig1,csig1,dn1,ssig2,csig2,dn2,cbet1,cbet2,lengthmask,C1a,C2a);s12x=nvals.s12b;m12x=nvals.m12b;if(outmask&g.GEODESICSCALE){vals.M12=nvals.M12;vals.M21=nvals.M21;}
8074
- m12x*=this._b;s12x*=this._b;vals.a12=sig12/m.degree;if(outmask&g.AREA){sdomg12=Math.sin(domg12);cdomg12=Math.cos(domg12);somg12=slam12*cdomg12-clam12*sdomg12;comg12=clam12*cdomg12+slam12*sdomg12;}}}
8075
- if(outmask&g.DISTANCE)
8076
- vals.s12=0+s12x;if(outmask&g.REDUCEDLENGTH)
8077
- vals.m12=0+m12x;if(outmask&g.AREA){salp0=salp1*cbet1;calp0=m.hypot(calp1,salp1*sbet1);if(calp0!==0&&salp0!==0){ssig1=sbet1;csig1=calp1*cbet1;ssig2=sbet2;csig2=calp2*cbet2;k2=m.sq(calp0)*this._ep2;eps=k2/(2*(1+Math.sqrt(1+k2))+k2);A4=m.sq(this.a)*calp0*salp0*this._e2;t=m.hypot(ssig1,csig1);ssig1/=t;csig1/=t;t=m.hypot(ssig2,csig2);ssig2/=t;csig2/=t;C4a=new Array(g.nC4_);this.C4f(eps,C4a);B41=g.SinCosSeries(false,ssig1,csig1,C4a);B42=g.SinCosSeries(false,ssig2,csig2,C4a);vals.S12=A4*(B42-B41);}else
8078
- vals.S12=0;if(!meridian&&somg12==2){somg12=Math.sin(omg12);comg12=Math.cos(omg12);}
8079
- if(!meridian&&comg12>-0.7071&&sbet2-sbet1<1.75){domg12=1+comg12;dbet1=1+cbet1;dbet2=1+cbet2;alp12=2*Math.atan2(somg12*(sbet1*dbet2+sbet2*dbet1),domg12*(sbet1*sbet2+dbet1*dbet2));}else {salp12=salp2*calp1-calp2*salp1;calp12=calp2*calp1+salp2*salp1;if(salp12===0&&calp12<0){salp12=g.tiny_*calp1;calp12=-1;}
8080
- alp12=Math.atan2(salp12,calp12);}
8081
- vals.S12+=this._c2*alp12;vals.S12*=swapp*lonsign*latsign;vals.S12+=0;}
8082
- if(swapp<0){[salp2,salp1]=[salp1,salp2];[calp2,calp1]=[calp1,calp2];if(outmask&g.GEODESICSCALE){[vals.M21,vals.M12]=[vals.M12,vals.M21];}}
8083
- salp1*=swapp*lonsign;calp1*=swapp*latsign;salp2*=swapp*lonsign;calp2*=swapp*latsign;return {vals:vals,salp1:salp1,calp1:calp1,salp2:salp2,calp2:calp2};};g.Geodesic.prototype.GenDirect=function(lat1,lon1,azi1,arcmode,s12_a12,outmask){var line;if(!outmask)outmask=g.STANDARD;else if(outmask===g.LONG_UNROLL)outmask|=g.STANDARD;if(!arcmode)outmask|=g.DISTANCE_IN;line=new l.GeodesicLine(this,lat1,lon1,azi1,outmask);return line.GenPosition(arcmode,s12_a12,outmask);};g.Geodesic.prototype.Direct=function(lat1,lon1,azi1,s12,outmask){return this.GenDirect(lat1,lon1,azi1,false,s12,outmask);};g.Geodesic.prototype.ArcDirect=function(lat1,lon1,azi1,a12,outmask){return this.GenDirect(lat1,lon1,azi1,true,a12,outmask);};g.Geodesic.prototype.Line=function(lat1,lon1,azi1,caps){return new l.GeodesicLine(this,lat1,lon1,azi1,caps);};g.Geodesic.prototype.DirectLine=function(lat1,lon1,azi1,s12,caps){return this.GenDirectLine(lat1,lon1,azi1,false,s12,caps);};g.Geodesic.prototype.ArcDirectLine=function(lat1,lon1,azi1,a12,caps){return this.GenDirectLine(lat1,lon1,azi1,true,a12,caps);};g.Geodesic.prototype.GenDirectLine=function(lat1,lon1,azi1,arcmode,s12_a12,caps){var t;if(!caps)caps=g.STANDARD|g.DISTANCE_IN;if(!arcmode)caps|=g.DISTANCE_IN;t=new l.GeodesicLine(this,lat1,lon1,azi1,caps);t.GenSetDistance(arcmode,s12_a12);return t;};g.Geodesic.prototype.InverseLine=function(lat1,lon1,lat2,lon2,caps){var r,t,azi1;if(!caps)caps=g.STANDARD|g.DISTANCE_IN;r=this.InverseInt(lat1,lon1,lat2,lon2,g.ARC);azi1=m.atan2d(r.salp1,r.calp1);if(caps&(g.OUT_MASK&g.DISTANCE_IN))caps|=g.DISTANCE;t=new l.GeodesicLine(this,lat1,lon1,azi1,caps,r.salp1,r.calp1);t.SetArc(r.vals.a12);return t;};g.Geodesic.prototype.Polygon=function(polyline){return new p.PolygonArea(this,polyline);};g.WGS84=new g.Geodesic(c.WGS84.a,c.WGS84.f);})(geodesic.Geodesic,geodesic.GeodesicLine,geodesic.PolygonArea,geodesic.Math,geodesic.Constants);(function(g,l,m){l.GeodesicLine=function(geod,lat1,lon1,azi1,caps,salp1,calp1){var t,cbet1,sbet1,eps,s,c;if(!caps)caps=g.STANDARD|g.DISTANCE_IN;this.a=geod.a;this.f=geod.f;this._b=geod._b;this._c2=geod._c2;this._f1=geod._f1;this.caps=caps|g.LATITUDE|g.AZIMUTH|g.LONG_UNROLL;this.lat1=m.LatFix(lat1);this.lon1=lon1;if(typeof salp1==='undefined'||typeof calp1==='undefined'){this.azi1=m.AngNormalize(azi1);t=m.sincosd(m.AngRound(this.azi1));this.salp1=t.s;this.calp1=t.c;}else {this.azi1=azi1;this.salp1=salp1;this.calp1=calp1;}
8084
- t=m.sincosd(m.AngRound(this.lat1));sbet1=this._f1*t.s;cbet1=t.c;t=m.hypot(sbet1,cbet1);sbet1/=t;cbet1/=t;cbet1=Math.max(g.tiny_,cbet1);this._dn1=Math.sqrt(1+geod._ep2*m.sq(sbet1));this._salp0=this.salp1*cbet1;this._calp0=m.hypot(this.calp1,this.salp1*sbet1);this._ssig1=sbet1;this._somg1=this._salp0*sbet1;this._csig1=this._comg1=sbet1!==0||this.calp1!==0?cbet1*this.calp1:1;t=m.hypot(this._ssig1,this._csig1);this._ssig1/=t;this._csig1/=t;this._k2=m.sq(this._calp0)*geod._ep2;eps=this._k2/(2*(1+Math.sqrt(1+this._k2))+this._k2);if(this.caps&g.CAP_C1){this._A1m1=g.A1m1f(eps);this._C1a=new Array(g.nC1_+1);g.C1f(eps,this._C1a);this._B11=g.SinCosSeries(true,this._ssig1,this._csig1,this._C1a);s=Math.sin(this._B11);c=Math.cos(this._B11);this._stau1=this._ssig1*c+this._csig1*s;this._ctau1=this._csig1*c-this._ssig1*s;}
8085
- if(this.caps&g.CAP_C1p){this._C1pa=new Array(g.nC1p_+1);g.C1pf(eps,this._C1pa);}
8086
- if(this.caps&g.CAP_C2){this._A2m1=g.A2m1f(eps);this._C2a=new Array(g.nC2_+1);g.C2f(eps,this._C2a);this._B21=g.SinCosSeries(true,this._ssig1,this._csig1,this._C2a);}
8087
- if(this.caps&g.CAP_C3){this._C3a=new Array(g.nC3_);geod.C3f(eps,this._C3a);this._A3c=-this.f*this._salp0*geod.A3f(eps);this._B31=g.SinCosSeries(true,this._ssig1,this._csig1,this._C3a);}
8088
- if(this.caps&g.CAP_C4){this._C4a=new Array(g.nC4_);geod.C4f(eps,this._C4a);this._A4=m.sq(this.a)*this._calp0*this._salp0*geod._e2;this._B41=g.SinCosSeries(false,this._ssig1,this._csig1,this._C4a);}
8089
- this.a13=this.s13=NaN;};l.GeodesicLine.prototype.GenPosition=function(arcmode,s12_a12,outmask){var vals={},sig12,ssig12,csig12,B12,AB1,ssig2,csig2,tau12,s,c,serr,omg12,lam12,lon12,E,sbet2,cbet2,somg2,comg2,salp2,calp2,dn2,B22,AB2,J12,t,B42,salp12,calp12;if(!outmask)outmask=g.STANDARD;else if(outmask===g.LONG_UNROLL)outmask|=g.STANDARD;outmask&=this.caps&g.OUT_MASK;vals.lat1=this.lat1;vals.azi1=this.azi1;vals.lon1=outmask&g.LONG_UNROLL?this.lon1:m.AngNormalize(this.lon1);if(arcmode)
8090
- vals.a12=s12_a12;else
8091
- vals.s12=s12_a12;if(!(arcmode||(this.caps&g.DISTANCE_IN&g.OUT_MASK))){vals.a12=NaN;return vals;}
8092
- B12=0;AB1=0;if(arcmode){sig12=s12_a12*m.degree;t=m.sincosd(s12_a12);ssig12=t.s;csig12=t.c;}else {tau12=s12_a12/(this._b*(1+this._A1m1));s=Math.sin(tau12);c=Math.cos(tau12);B12=-g.SinCosSeries(true,this._stau1*c+this._ctau1*s,this._ctau1*c-this._stau1*s,this._C1pa);sig12=tau12-(B12-this._B11);ssig12=Math.sin(sig12);csig12=Math.cos(sig12);if(Math.abs(this.f)>0.01){ssig2=this._ssig1*csig12+this._csig1*ssig12;csig2=this._csig1*csig12-this._ssig1*ssig12;B12=g.SinCosSeries(true,ssig2,csig2,this._C1a);serr=(1+this._A1m1)*(sig12+(B12-this._B11))-
8093
- s12_a12/this._b;sig12=sig12-serr/Math.sqrt(1+this._k2*m.sq(ssig2));ssig12=Math.sin(sig12);csig12=Math.cos(sig12);}}
8094
- ssig2=this._ssig1*csig12+this._csig1*ssig12;csig2=this._csig1*csig12-this._ssig1*ssig12;dn2=Math.sqrt(1+this._k2*m.sq(ssig2));if(outmask&(g.DISTANCE|g.REDUCEDLENGTH|g.GEODESICSCALE)){if(arcmode||Math.abs(this.f)>0.01)
8095
- B12=g.SinCosSeries(true,ssig2,csig2,this._C1a);AB1=(1+this._A1m1)*(B12-this._B11);}
8096
- sbet2=this._calp0*ssig2;cbet2=m.hypot(this._salp0,this._calp0*csig2);if(cbet2===0)
8097
- cbet2=csig2=g.tiny_;salp2=this._salp0;calp2=this._calp0*csig2;if(arcmode&&(outmask&g.DISTANCE))
8098
- vals.s12=this._b*((1+this._A1m1)*sig12+AB1);if(outmask&g.LONGITUDE){somg2=this._salp0*ssig2;comg2=csig2;E=m.copysign(1,this._salp0);omg12=outmask&g.LONG_UNROLL?E*(sig12-
8099
- (Math.atan2(ssig2,csig2)-
8100
- Math.atan2(this._ssig1,this._csig1))+
8101
- (Math.atan2(E*somg2,comg2)-
8102
- Math.atan2(E*this._somg1,this._comg1))):Math.atan2(somg2*this._comg1-comg2*this._somg1,comg2*this._comg1+somg2*this._somg1);lam12=omg12+this._A3c*(sig12+(g.SinCosSeries(true,ssig2,csig2,this._C3a)-
8103
- this._B31));lon12=lam12/m.degree;vals.lon2=outmask&g.LONG_UNROLL?this.lon1+lon12:m.AngNormalize(m.AngNormalize(this.lon1)+m.AngNormalize(lon12));}
8104
- if(outmask&g.LATITUDE)
8105
- vals.lat2=m.atan2d(sbet2,this._f1*cbet2);if(outmask&g.AZIMUTH)
8106
- 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)
8107
- vals.m12=this._b*((dn2*(this._csig1*ssig2)-
8108
- this._dn1*(this._ssig1*csig2))-
8109
- this._csig1*csig2*J12);if(outmask&g.GEODESICSCALE){t=this._k2*(ssig2-this._ssig1)*(ssig2+this._ssig1)/(this._dn1+dn2);vals.M12=csig12+
8110
- (t*ssig2-csig2*J12)*this._ssig1/this._dn1;vals.M21=csig12-
8111
- (t*this._ssig1-this._csig1*J12)*ssig2/dn2;}}
8112
- 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;}
8113
- vals.S12=this._c2*Math.atan2(salp12,calp12)+
8114
- this._A4*(B42-this._B41);}
8115
- if(!arcmode)
8116
- 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)
8117
- this.SetArc(s13_a13);else
8118
- 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)-
8119
- ((0<=lon1&&lon1<360)||lon1<-360?0:1);};AreaReduceA=function(area,area0,crossings,reverse,sign){area.Remainder(area0);if(crossings&1)
8120
- area.Add((area.Sum()<0?1:-1)*area0/2);if(!reverse)
8121
- area.Negate();if(sign){if(area.Sum()>area0/2)
8122
- area.Add(-area0);else if(area.Sum()<=-area0/2)
8123
- area.Add(+area0);}else {if(area.Sum()>=area0)
8124
- area.Add(-area0);else if(area.Sum()<0)
8125
- area.Add(+area0);}
8126
- return 0+area.Sum();};AreaReduceB=function(area,area0,crossings,reverse,sign){area=m.remainder(area,area0);if(crossings&1)
8127
- area+=(area<0?1:-1)*area0/2;if(!reverse)
8128
- area*=-1;if(sign){if(area>area0/2)
8129
- area-=area0;else if(area<=-area0/2)
8130
- area+=area0;}else {if(area>=area0)
8131
- area-=area0;else if(area<0)
8132
- area+=area0;}
8133
- 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)
8134
- 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)
8135
- 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);}
8136
- this.lat=lat;this.lon=lon;}
8137
- ++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);}
8138
- this.lat=t.lat2;this.lon=t.lon2;}
8139
- ++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)
8140
- vals.area=0;return vals;}
8141
- if(this.polyline){vals.perimeter=this._perimetersum.Sum();return vals;}
8142
- 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)
8143
- vals.area=0;return vals;}
8144
- 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);}}
8145
- if(this.polyline)
8146
- 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)
8147
- return vals;vals.perimeter=this._perimetersum.Sum()+s;if(this.polyline)
8148
- 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;}});
8149
- } (geographiclibGeodesic_min));
8150
- return geographiclibGeodesic_min.exports;
8151
- }
8152
-
8153
- var geographiclibGeodesic_minExports = requireGeographiclibGeodesic_min();
8565
+ /**
8566
+ * Calculates the inverse geodesic problem using Vincenty's formulae.
8567
+ * Computes the forward azimuth and ellipsoidal distance between two points
8568
+ * specified by latitude and longitude on the surface of an ellipsoid.
8569
+ *
8570
+ * @param {number} lat1 Latitude of the first point in radians.
8571
+ * @param {number} lon1 Longitude of the first point in radians.
8572
+ * @param {number} lat2 Latitude of the second point in radians.
8573
+ * @param {number} lon2 Longitude of the second point in radians.
8574
+ * @param {number} a Semi-major axis of the ellipsoid (meters).
8575
+ * @param {number} f Flattening of the ellipsoid.
8576
+ * @returns {{ azi1: number, s12: number }} An object containing:
8577
+ * - azi1: Forward azimuth from the first point to the second point (radians).
8578
+ * - s12: Ellipsoidal distance between the two points (meters).
8579
+ */
8580
+ function vincentyInverse(lat1, lon1, lat2, lon2, a, f) {
8581
+ const L = lon2 - lon1;
8582
+ const U1 = Math.atan((1 - f) * Math.tan(lat1));
8583
+ const U2 = Math.atan((1 - f) * Math.tan(lat2));
8584
+ const sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
8585
+ const sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
8586
+
8587
+ let lambda = L, lambdaP, iterLimit = 100;
8588
+ let sinLambda, cosLambda, sinSigma, cosSigma, sigma, sinAlpha, cos2Alpha, cos2SigmaM, C;
8589
+ let uSq, A, B, deltaSigma, s;
8590
+
8591
+ do {
8592
+ sinLambda = Math.sin(lambda);
8593
+ cosLambda = Math.cos(lambda);
8594
+ sinSigma = Math.sqrt(
8595
+ (cosU2 * sinLambda) * (cosU2 * sinLambda)
8596
+ + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
8597
+ * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda)
8598
+ );
8599
+ if (sinSigma === 0) {
8600
+ return { azi1: 0, s12: 0 }; // coincident points
8601
+ }
8602
+ cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
8603
+ sigma = Math.atan2(sinSigma, cosSigma);
8604
+ sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
8605
+ cos2Alpha = 1 - sinAlpha * sinAlpha;
8606
+ cos2SigmaM = (cos2Alpha !== 0) ? (cosSigma - 2 * sinU1 * sinU2 / cos2Alpha) : 0;
8607
+ C = f / 16 * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha));
8608
+ lambdaP = lambda;
8609
+ lambda = L + (1 - C) * f * sinAlpha
8610
+ * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
8611
+ } while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
8612
+
8613
+ if (iterLimit === 0) {
8614
+ return { azi1: NaN, s12: NaN }; // formula failed to converge
8615
+ }
8616
+
8617
+ uSq = cos2Alpha * (a * a - (a * (1 - f)) * (a * (1 - f))) / ((a * (1 - f)) * (a * (1 - f)));
8618
+ A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
8619
+ B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
8620
+ deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
8621
+ - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
8154
8622
 
8623
+ s = (a * (1 - f)) * A * (sigma - deltaSigma);
8624
+
8625
+ // Forward azimuth
8626
+ const azi1 = Math.atan2(cosU2 * sinLambda, cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
8627
+
8628
+ return { azi1, s12: s };
8629
+ }
8630
+
8631
+ /**
8632
+ * Solves the direct geodetic problem using Vincenty's formulae.
8633
+ * Given a starting point, initial azimuth, and distance, computes the destination point on the ellipsoid.
8634
+ *
8635
+ * @param {number} lat1 Latitude of the starting point in radians.
8636
+ * @param {number} lon1 Longitude of the starting point in radians.
8637
+ * @param {number} azi1 Initial azimuth (forward azimuth) in radians.
8638
+ * @param {number} s12 Distance to travel from the starting point in meters.
8639
+ * @param {number} a Semi-major axis of the ellipsoid in meters.
8640
+ * @param {number} f Flattening of the ellipsoid.
8641
+ * @returns {{lat2: number, lon2: number}} The latitude and longitude (in radians) of the destination point.
8642
+ */
8643
+ function vincentyDirect(lat1, lon1, azi1, s12, a, f) {
8644
+ const U1 = Math.atan((1 - f) * Math.tan(lat1));
8645
+ const sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
8646
+ const sinAlpha1 = Math.sin(azi1), cosAlpha1 = Math.cos(azi1);
8647
+
8648
+ const sigma1 = Math.atan2(sinU1, cosU1 * cosAlpha1);
8649
+ const sinAlpha = cosU1 * sinAlpha1;
8650
+ const cos2Alpha = 1 - sinAlpha * sinAlpha;
8651
+ const uSq = cos2Alpha * (a * a - (a * (1 - f)) * (a * (1 - f))) / ((a * (1 - f)) * (a * (1 - f)));
8652
+ const A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
8653
+ const B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
8654
+
8655
+ let sigma = s12 / ((a * (1 - f)) * A), sigmaP, iterLimit = 100;
8656
+ let cos2SigmaM, sinSigma, cosSigma, deltaSigma;
8657
+
8658
+ do {
8659
+ cos2SigmaM = Math.cos(2 * sigma1 + sigma);
8660
+ sinSigma = Math.sin(sigma);
8661
+ cosSigma = Math.cos(sigma);
8662
+ deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
8663
+ - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
8664
+ sigmaP = sigma;
8665
+ sigma = s12 / ((a * (1 - f)) * A) + deltaSigma;
8666
+ } while (Math.abs(sigma - sigmaP) > 1e-12 && --iterLimit > 0);
8667
+
8668
+ if (iterLimit === 0) {
8669
+ return { lat2: NaN, lon2: NaN };
8670
+ }
8671
+
8672
+ const tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
8673
+ const lat2 = Math.atan2(
8674
+ sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
8675
+ (1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp)
8676
+ );
8677
+ const lambda = Math.atan2(
8678
+ sinSigma * sinAlpha1,
8679
+ cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1
8680
+ );
8681
+ const C = f / 16 * cos2Alpha * (4 + f * (4 - 3 * cos2Alpha));
8682
+ const L = lambda - (1 - C) * f * sinAlpha
8683
+ * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
8684
+ const lon2 = lon1 + L;
8685
+
8686
+ return { lat2, lon2 };
8687
+ }
8688
+
8689
+ /**
8690
+ * @typedef {Object} LocalThis
8691
+ * @property {number} es
8692
+ * @property {number} sin_p12
8693
+ * @property {number} cos_p12
8694
+ * @property {number} a
8695
+ * @property {number} f
8696
+ */
8697
+
8698
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
8155
8699
  function init$8() {
8156
8700
  this.sin_p12 = Math.sin(this.lat0);
8157
8701
  this.cos_p12 = Math.cos(this.lat0);
8158
- this.g = new geographiclibGeodesic_minExports.Geodesic.Geodesic(this.a, this.es / (1 + Math.sqrt(1 - this.es)));
8702
+ // flattening for ellipsoid
8703
+ this.f = this.es / (1 + Math.sqrt(1 - this.es));
8159
8704
  }
8160
8705
 
8161
8706
  function forward$7(p) {
@@ -8164,7 +8709,7 @@
8164
8709
  var sinphi = Math.sin(p.y);
8165
8710
  var cosphi = Math.cos(p.y);
8166
8711
  var dlon = adjust_lon(lon - this.long0);
8167
- var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c, lat1, lon1, lat2, lon2, vars, azi1;
8712
+ var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c, vars, azi1;
8168
8713
  if (this.sphere) {
8169
8714
  if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
8170
8715
  // North Pole case
@@ -8210,14 +8755,8 @@
8210
8755
  p.x = p.y = 0;
8211
8756
  return p;
8212
8757
  }
8213
- lat1 = this.lat0 / D2R$1;
8214
- lon1 = this.long0 / D2R$1;
8215
- lat2 = lat / D2R$1;
8216
- lon2 = lon / D2R$1;
8217
-
8218
- vars = this.g.Inverse(lat1, lon1, lat2, lon2, this.g.AZIMUTH);
8219
- azi1 = vars.azi1 * D2R$1;
8220
-
8758
+ vars = vincentyInverse(this.lat0, this.long0, lat, lon, this.a, this.f);
8759
+ azi1 = vars.azi1;
8221
8760
  p.x = vars.s12 * Math.sin(azi1);
8222
8761
  p.y = vars.s12 * Math.cos(azi1);
8223
8762
  return p;
@@ -8228,7 +8767,7 @@
8228
8767
  function inverse$7(p) {
8229
8768
  p.x -= this.x0;
8230
8769
  p.y -= this.y0;
8231
- var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, lat1, lon1, azi1, s12, vars;
8770
+ var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, azi1, s12, vars;
8232
8771
  if (this.sphere) {
8233
8772
  rh = Math.sqrt(p.x * p.x + p.y * p.y);
8234
8773
  if (rh > (2 * HALF_PI * this.a)) {
@@ -8252,13 +8791,6 @@
8252
8791
  lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
8253
8792
  }
8254
8793
  } else {
8255
- /* con = cosz - this.sin_p12 * Math.sin(lat);
8256
- if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
8257
- //no-op, just keep the lon value as is
8258
- } else {
8259
- var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
8260
- lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
8261
- } */
8262
8794
  lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
8263
8795
  }
8264
8796
  }
@@ -8294,14 +8826,12 @@
8294
8826
  return p;
8295
8827
  } else {
8296
8828
  // default case
8297
- lat1 = this.lat0 / D2R$1;
8298
- lon1 = this.long0 / D2R$1;
8299
- azi1 = Math.atan2(p.x, p.y) / D2R$1;
8829
+ azi1 = Math.atan2(p.x, p.y);
8300
8830
  s12 = Math.sqrt(p.x * p.x + p.y * p.y);
8301
- vars = this.g.Direct(lat1, lon1, azi1, s12, this.g.STANDARD);
8831
+ vars = vincentyDirect(this.lat0, this.long0, azi1, s12, this.a, this.f);
8302
8832
 
8303
- p.x = vars.lon2 * D2R$1;
8304
- p.y = vars.lat2 * D2R$1;
8833
+ p.x = vars.lon2;
8834
+ p.y = vars.lat2;
8305
8835
  return p;
8306
8836
  }
8307
8837
  }
@@ -8315,6 +8845,13 @@
8315
8845
  names: names$8
8316
8846
  };
8317
8847
 
8848
+ /**
8849
+ * @typedef {Object} LocalThis
8850
+ * @property {number} sin_p14
8851
+ * @property {number} cos_p14
8852
+ */
8853
+
8854
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
8318
8855
  function init$7() {
8319
8856
  // double temp; /* temporary variable */
8320
8857
 
@@ -8406,6 +8943,16 @@
8406
8943
  // https://github.com/OSGeo/proj.4/blob/master/src/PJ_qsc.c
8407
8944
 
8408
8945
 
8946
+ /**
8947
+ * @typedef {Object} LocalThis
8948
+ * @property {number} face
8949
+ * @property {number} x0
8950
+ * @property {number} y0
8951
+ * @property {number} es
8952
+ * @property {number} one_minus_f
8953
+ * @property {number} one_minus_f_squared
8954
+ */
8955
+
8409
8956
  /* constants */
8410
8957
  var FACE_ENUM = {
8411
8958
  FRONT: 1,
@@ -8423,6 +8970,7 @@
8423
8970
  AREA_3: 4
8424
8971
  };
8425
8972
 
8973
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
8426
8974
  function init$6() {
8427
8975
  this.x0 = this.x0 || 0;
8428
8976
  this.y0 = this.y0 || 0;
@@ -8950,6 +9498,26 @@
8950
9498
  names: names$4
8951
9499
  };
8952
9500
 
9501
+ /**
9502
+ * @typedef {Object} LocalThis
9503
+ * @property {number} mode
9504
+ * @property {number} sinph0
9505
+ * @property {number} cosph0
9506
+ * @property {number} pn1
9507
+ * @property {number} h
9508
+ * @property {number} rp
9509
+ * @property {number} p
9510
+ * @property {number} h1
9511
+ * @property {number} pfact
9512
+ * @property {number} es
9513
+ * @property {number} tilt
9514
+ * @property {number} azi
9515
+ * @property {number} cg
9516
+ * @property {number} sg
9517
+ * @property {number} cw
9518
+ * @property {number} sw
9519
+ */
9520
+
8953
9521
  var mode = {
8954
9522
  N_POLE: 0,
8955
9523
  S_POLE: 1,
@@ -8965,6 +9533,7 @@
8965
9533
  lat0: { def: 0, num: true } // default is Equator, conversion to rad is automatic
8966
9534
  };
8967
9535
 
9536
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
8968
9537
  function init$3() {
8969
9538
  Object.keys(params).forEach(function (p) {
8970
9539
  if (typeof this[p] === 'undefined') {
@@ -9116,6 +9685,22 @@
9116
9685
  names: names$3
9117
9686
  };
9118
9687
 
9688
+ /**
9689
+ * @typedef {Object} LocalThis
9690
+ * @property {1 | 0} flip_axis
9691
+ * @property {number} h
9692
+ * @property {number} radius_g_1
9693
+ * @property {number} radius_g
9694
+ * @property {number} radius_p
9695
+ * @property {number} radius_p2
9696
+ * @property {number} radius_p_inv2
9697
+ * @property {'ellipse'|'sphere'} shape
9698
+ * @property {number} C
9699
+ * @property {string} sweep
9700
+ * @property {number} es
9701
+ */
9702
+
9703
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
9119
9704
  function init$2() {
9120
9705
  this.flip_axis = (this.sweep === 'x' ? 1 : 0);
9121
9706
  this.h = Number(this.h);
@@ -9366,8 +9951,19 @@
9366
9951
  names: names$1
9367
9952
  };
9368
9953
 
9954
+ /**
9955
+ * @typedef {Object} LocalThis
9956
+ * @property {number} phi1
9957
+ * @property {number} cphi1
9958
+ * @property {number} es
9959
+ * @property {Array<number>} en
9960
+ * @property {number} m1
9961
+ * @property {number} am1
9962
+ */
9963
+
9369
9964
  var EPS10 = 1e-10;
9370
9965
 
9966
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
9371
9967
  function init() {
9372
9968
  var c;
9373
9969
 
@@ -9504,16 +10100,22 @@
9504
10100
  proj4.Proj.projections.add(bonne);
9505
10101
  }
9506
10102
 
9507
- proj4.defaultDatum = 'WGS84'; // default datum
9508
- proj4.Proj = Projection;
9509
- proj4.WGS84 = new proj4.Proj('WGS84');
9510
- proj4.Point = Point;
9511
- proj4.toPoint = common;
9512
- proj4.defs = defs;
9513
- proj4.nadgrid = nadgrid;
9514
- proj4.transform = transform;
9515
- proj4.mgrs = mgrs;
9516
- proj4.version = '2.17.0';
10103
+ /**
10104
+ * @template {import('./core').TemplateCoordinates} T
10105
+ * @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}}
10106
+ */
10107
+ const proj4 = Object.assign(proj4$1, {
10108
+ defaultDatum: 'WGS84',
10109
+ Proj: Projection,
10110
+ WGS84: new Projection('WGS84'),
10111
+ Point,
10112
+ toPoint: common,
10113
+ defs,
10114
+ nadgrid,
10115
+ transform,
10116
+ mgrs,
10117
+ version: '2.19.1'
10118
+ });
9517
10119
  includedProjections(proj4);
9518
10120
 
9519
10121
  return proj4;