proj4 2.16.2 → 2.19.0

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