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/lib/nadgrid.js CHANGED
@@ -4,13 +4,79 @@
4
4
  * - http://mimaka.com/help/gs/html/004_NTV2%20Data%20Format.htm
5
5
  */
6
6
 
7
+ /**
8
+ * @typedef {Object} NadgridInfo
9
+ * @property {string} name The name of the NAD grid or 'null' if not specified.
10
+ * @property {boolean} mandatory Indicates if the grid is mandatory (true) or optional (false).
11
+ * @property {*} grid The loaded NAD grid object, or null if not loaded or not applicable.
12
+ * @property {boolean} isNull True if the grid is explicitly 'null', otherwise false.
13
+ */
14
+
15
+ /**
16
+ * @typedef {Object} NTV2GridOptions
17
+ * @property {boolean} [includeErrorFields=true] Whether to include error fields in the subgrids.
18
+ */
19
+
20
+ /**
21
+ * @typedef {Object} NadgridHeader
22
+ * @property {number} [nFields] Number of fields in the header.
23
+ * @property {number} [nSubgridFields] Number of fields in each subgrid header.
24
+ * @property {number} nSubgrids Number of subgrids in the file.
25
+ * @property {string} [shiftType] Type of shift (e.g., "SECONDS").
26
+ * @property {number} [fromSemiMajorAxis] Source ellipsoid semi-major axis.
27
+ * @property {number} [fromSemiMinorAxis] Source ellipsoid semi-minor axis.
28
+ * @property {number} [toSemiMajorAxis] Target ellipsoid semi-major axis.
29
+ * @property {number} [toSemiMinorAxis] Target ellipsoid semi-minor axis.
30
+ */
31
+
32
+ /**
33
+ * @typedef {Object} Subgrid
34
+ * @property {Array<number>} ll Lower left corner of the grid in radians [longitude, latitude].
35
+ * @property {Array<number>} del Grid spacing in radians [longitude interval, latitude interval].
36
+ * @property {Array<number>} lim Number of columns in the grid [longitude columns, latitude columns].
37
+ * @property {number} [count] Total number of grid nodes.
38
+ * @property {Array} cvs Mapped node values for the grid.
39
+ */
40
+
41
+ /** @typedef {{header: NadgridHeader, subgrids: Array<Subgrid>}} NADGrid */
42
+
7
43
  var loadedNadgrids = {};
8
44
 
9
45
  /**
10
- * Load a binary NTv2 file (.gsb) to a key that can be used in a proj string like +nadgrids=<key>. Pass the NTv2 file
11
- * as an ArrayBuffer.
46
+ * @overload
47
+ * @param {string} key - The key to associate with the loaded grid.
48
+ * @param {ArrayBuffer} data - The NTv2 grid data as an ArrayBuffer.
49
+ * @param {NTV2GridOptions} [options] - Optional parameters for loading the grid.
50
+ * @returns {NADGrid} - The loaded NAD grid information.
51
+ */
52
+ /**
53
+ * @overload
54
+ * @param {string} key - The key to associate with the loaded grid.
55
+ * @param {import('geotiff').GeoTIFF} data - The GeoTIFF instance to read the grid from.
56
+ * @returns {{ready: Promise<NADGrid>}} - A promise that resolves to the loaded grid information.
57
+ */
58
+ /**
59
+ * 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
60
+ * as an ArrayBuffer. Pass Geotiff as a GeoTIFF instance from the geotiff.js library.
61
+ * @param {string} key - The key to associate with the loaded grid.
62
+ * @param {ArrayBuffer|import('geotiff').GeoTIFF} data The data to load, either an ArrayBuffer for NTv2 or a GeoTIFF instance.
63
+ * @param {NTV2GridOptions} [options] Optional parameters.
64
+ * @returns {{ready: Promise<NADGrid>}|NADGrid} - A promise that resolves to the loaded grid information.
12
65
  */
13
66
  export default function nadgrid(key, data, options) {
67
+ if (data instanceof ArrayBuffer) {
68
+ return readNTV2Grid(key, data, options);
69
+ }
70
+ return { ready: readGeotiffGrid(key, data) };
71
+ }
72
+
73
+ /**
74
+ * @param {string} key The key to associate with the loaded grid.
75
+ * @param {ArrayBuffer} data The NTv2 grid data as an ArrayBuffer.
76
+ * @param {NTV2GridOptions} [options] Optional parameters for loading the grid.
77
+ * @returns {NADGrid} The loaded NAD grid information.
78
+ */
79
+ function readNTV2Grid(key, data, options) {
14
80
  var includeErrorFields = true;
15
81
  if (options !== undefined && options.includeErrorFields === false) {
16
82
  includeErrorFields = false;
@@ -24,8 +90,60 @@ export default function nadgrid(key, data, options) {
24
90
  return nadgrid;
25
91
  }
26
92
 
93
+ /**
94
+ * @param {string} key The key to associate with the loaded grid.
95
+ * @param {import('geotiff').GeoTIFF} tiff The GeoTIFF instance to read the grid from.
96
+ * @returns {Promise<NADGrid>} A promise that resolves to the loaded NAD grid information.
97
+ */
98
+ async function readGeotiffGrid(key, tiff) {
99
+ var subgrids = [];
100
+ var subGridCount = await tiff.getImageCount();
101
+ // proj produced tiff grid shift files appear to organize lower res subgrids first, higher res/ child subgrids last.
102
+ for (var subgridIndex = subGridCount - 1; subgridIndex >= 0; subgridIndex--) {
103
+ var image = await tiff.getImage(subgridIndex);
104
+
105
+ var rasters = await image.readRasters();
106
+ var data = rasters;
107
+ var lim = [image.getWidth(), image.getHeight()];
108
+ var imageBBoxRadians = image.getBoundingBox().map(degreesToRadians);
109
+ var del = [image.fileDirectory.ModelPixelScale[0], image.fileDirectory.ModelPixelScale[1]].map(degreesToRadians);
110
+
111
+ var maxX = imageBBoxRadians[0] + (lim[0] - 1) * del[0];
112
+ var minY = imageBBoxRadians[3] - (lim[1] - 1) * del[1];
113
+
114
+ var latitudeOffsetBand = data[0];
115
+ var longitudeOffsetBand = data[1];
116
+ var nodes = [];
117
+
118
+ for (let i = lim[1] - 1; i >= 0; i--) {
119
+ for (let j = lim[0] - 1; j >= 0; j--) {
120
+ var index = i * lim[0] + j;
121
+ nodes.push([-secondsToRadians(longitudeOffsetBand[index]), secondsToRadians(latitudeOffsetBand[index])]);
122
+ }
123
+ }
124
+
125
+ subgrids.push({
126
+ del: del,
127
+ lim: lim,
128
+ ll: [-maxX, minY],
129
+ cvs: nodes
130
+ });
131
+ }
132
+
133
+ var tifGrid = {
134
+ header: {
135
+ nSubgrids: subGridCount
136
+ },
137
+ subgrids: subgrids
138
+ };
139
+ loadedNadgrids[key] = tifGrid;
140
+ return tifGrid;
141
+ };
142
+
27
143
  /**
28
144
  * Given a proj4 value for nadgrids, return an array of loaded grids
145
+ * @param {string} nadgrids A comma-separated list of grid names, optionally prefixed with '@' to indicate optional grids.
146
+ * @returns
29
147
  */
30
148
  export function getNadgrids(nadgrids) {
31
149
  // Format details: http://proj.maptools.org/gen_parms.html
@@ -36,6 +154,10 @@ export function getNadgrids(nadgrids) {
36
154
  return grids.map(parseNadgridString);
37
155
  }
38
156
 
157
+ /**
158
+ * @param {string} value The nadgrid string to get information for.
159
+ * @returns {NadgridInfo|null} An object with grid information, or null if the input is empty.
160
+ */
39
161
  function parseNadgridString(value) {
40
162
  if (value.length === 0) {
41
163
  return null;
@@ -55,6 +177,10 @@ function parseNadgridString(value) {
55
177
  };
56
178
  }
57
179
 
180
+ function degreesToRadians(degrees) {
181
+ return (degrees) * Math.PI / 180;
182
+ }
183
+
58
184
  function secondsToRadians(seconds) {
59
185
  return (seconds / 3600) * Math.PI / 180;
60
186
  }
@@ -115,6 +241,10 @@ function readSubgrids(view, header, isLittleEndian, includeErrorFields) {
115
241
  return grids;
116
242
  }
117
243
 
244
+ /**
245
+ * @param {*} nodes
246
+ * @returns Array<Array<number>>
247
+ */
118
248
  function mapNodes(nodes) {
119
249
  return nodes.map(function (r) {
120
250
  return [secondsToRadians(r.longitudeShift), secondsToRadians(r.latitudeShift)];
package/lib/parseCode.js CHANGED
@@ -30,6 +30,10 @@ function checkProjStr(item) {
30
30
  function testProj(code) {
31
31
  return code[0] === '+';
32
32
  }
33
+ /**
34
+ * @param {string | import('./core').PROJJSONDefinition | import('./defs').ProjectionDefinition} code
35
+ * @returns {import('./defs').ProjectionDefinition}
36
+ */
33
37
  function parse(code) {
34
38
  if (testObj(code)) {
35
39
  // check to see if this is a WKT string
@@ -51,7 +55,7 @@ function parse(code) {
51
55
  if (testProj(code)) {
52
56
  return projStr(code);
53
57
  }
54
- } else if (!code.projName) {
58
+ } else if (!('projName' in code)) {
55
59
  return wkt(code);
56
60
  } else {
57
61
  return code;
package/lib/projString.js CHANGED
@@ -3,13 +3,19 @@ import PrimeMeridian from './constants/PrimeMeridian';
3
3
  import units from './constants/units';
4
4
  import match from './match';
5
5
 
6
+ /**
7
+ * @param {string} defData
8
+ * @returns {import('./defs').ProjectionDefinition}
9
+ */
6
10
  export default function (defData) {
11
+ /** @type {import('./defs').ProjectionDefinition} */
7
12
  var self = {};
8
13
  var paramObj = defData.split('+').map(function (v) {
9
14
  return v.trim();
10
15
  }).filter(function (a) {
11
16
  return a;
12
17
  }).reduce(function (p, a) {
18
+ /** @type {Array<?>} */
13
19
  var split = a.split('=');
14
20
  split.push(true);
15
21
  p[split[0].toLowerCase()] = split[1];
@@ -4,6 +4,30 @@ import adjust_lon from '../common/adjust_lon';
4
4
  import asinz from '../common/asinz';
5
5
  import { EPSLN } from '../constants/values';
6
6
 
7
+ /**
8
+ * @typedef {Object} LocalThis
9
+ * @property {number} temp
10
+ * @property {number} es
11
+ * @property {number} e3
12
+ * @property {number} sin_po
13
+ * @property {number} cos_po
14
+ * @property {number} t1
15
+ * @property {number} con
16
+ * @property {number} ms1
17
+ * @property {number} qs1
18
+ * @property {number} t2
19
+ * @property {number} ms2
20
+ * @property {number} qs2
21
+ * @property {number} t3
22
+ * @property {number} qs0
23
+ * @property {number} ns0
24
+ * @property {number} c
25
+ * @property {number} rh
26
+ * @property {number} sin_phi
27
+ * @property {number} cos_phi
28
+ */
29
+
30
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
7
31
  export function init() {
8
32
  if (Math.abs(this.lat1 + this.lat2) < EPSLN) {
9
33
  return;
@@ -41,6 +65,7 @@ export function init() {
41
65
 
42
66
  /* Albers Conical Equal Area forward equations--mapping lat,long to x,y
43
67
  ------------------------------------------------------------------- */
68
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
44
69
  export function forward(p) {
45
70
  var lon = p.x;
46
71
  var lat = p.y;
@@ -1,5 +1,5 @@
1
1
  import adjust_lon from '../common/adjust_lon';
2
- import { HALF_PI, EPSLN, D2R } from '../constants/values';
2
+ import { HALF_PI, EPSLN } from '../constants/values';
3
3
  import mlfn from '../common/mlfn';
4
4
  import e0fn from '../common/e0fn';
5
5
  import e1fn from '../common/e1fn';
@@ -7,12 +7,23 @@ import e2fn from '../common/e2fn';
7
7
  import e3fn from '../common/e3fn';
8
8
  import asinz from '../common/asinz';
9
9
  import imlfn from '../common/imlfn';
10
- import { Geodesic } from 'geographiclib-geodesic';
10
+ import { vincentyDirect, vincentyInverse } from '../common/vincenty';
11
11
 
12
+ /**
13
+ * @typedef {Object} LocalThis
14
+ * @property {number} es
15
+ * @property {number} sin_p12
16
+ * @property {number} cos_p12
17
+ * @property {number} a
18
+ * @property {number} f
19
+ */
20
+
21
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
12
22
  export function init() {
13
23
  this.sin_p12 = Math.sin(this.lat0);
14
24
  this.cos_p12 = Math.cos(this.lat0);
15
- this.g = new Geodesic.Geodesic(this.a, this.es / (1 + Math.sqrt(1 - this.es)));
25
+ // flattening for ellipsoid
26
+ this.f = this.es / (1 + Math.sqrt(1 - this.es));
16
27
  }
17
28
 
18
29
  export function forward(p) {
@@ -21,7 +32,7 @@ export function forward(p) {
21
32
  var sinphi = Math.sin(p.y);
22
33
  var cosphi = Math.cos(p.y);
23
34
  var dlon = adjust_lon(lon - this.long0);
24
- var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c, lat1, lon1, lat2, lon2, vars, azi1;
35
+ var e0, e1, e2, e3, Mlp, Ml, c, kp, cos_c, vars, azi1;
25
36
  if (this.sphere) {
26
37
  if (Math.abs(this.sin_p12 - 1) <= EPSLN) {
27
38
  // North Pole case
@@ -67,14 +78,8 @@ export function forward(p) {
67
78
  p.x = p.y = 0;
68
79
  return p;
69
80
  }
70
- lat1 = this.lat0 / D2R;
71
- lon1 = this.long0 / D2R;
72
- lat2 = lat / D2R;
73
- lon2 = lon / D2R;
74
-
75
- vars = this.g.Inverse(lat1, lon1, lat2, lon2, this.g.AZIMUTH);
76
- azi1 = vars.azi1 * D2R;
77
-
81
+ vars = vincentyInverse(this.lat0, this.long0, lat, lon, this.a, this.f);
82
+ azi1 = vars.azi1;
78
83
  p.x = vars.s12 * Math.sin(azi1);
79
84
  p.y = vars.s12 * Math.cos(azi1);
80
85
  return p;
@@ -85,7 +90,7 @@ export function forward(p) {
85
90
  export function inverse(p) {
86
91
  p.x -= this.x0;
87
92
  p.y -= this.y0;
88
- var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, lat1, lon1, azi1, s12, vars;
93
+ var rh, z, sinz, cosz, lon, lat, con, e0, e1, e2, e3, Mlp, M, azi1, s12, vars;
89
94
  if (this.sphere) {
90
95
  rh = Math.sqrt(p.x * p.x + p.y * p.y);
91
96
  if (rh > (2 * HALF_PI * this.a)) {
@@ -109,13 +114,6 @@ export function inverse(p) {
109
114
  lon = adjust_lon(this.long0 - Math.atan2(-p.x, p.y));
110
115
  }
111
116
  } else {
112
- /* con = cosz - this.sin_p12 * Math.sin(lat);
113
- if ((Math.abs(con) < EPSLN) && (Math.abs(p.x) < EPSLN)) {
114
- //no-op, just keep the lon value as is
115
- } else {
116
- var temp = Math.atan2((p.x * sinz * this.cos_p12), (con * rh));
117
- lon = adjust_lon(this.long0 + Math.atan2((p.x * sinz * this.cos_p12), (con * rh)));
118
- } */
119
117
  lon = adjust_lon(this.long0 + Math.atan2(p.x * sinz, rh * this.cos_p12 * cosz - p.y * this.sin_p12 * sinz));
120
118
  }
121
119
  }
@@ -151,14 +149,12 @@ export function inverse(p) {
151
149
  return p;
152
150
  } else {
153
151
  // default case
154
- lat1 = this.lat0 / D2R;
155
- lon1 = this.long0 / D2R;
156
- azi1 = Math.atan2(p.x, p.y) / D2R;
152
+ azi1 = Math.atan2(p.x, p.y);
157
153
  s12 = Math.sqrt(p.x * p.x + p.y * p.y);
158
- vars = this.g.Direct(lat1, lon1, azi1, s12, this.g.STANDARD);
154
+ vars = vincentyDirect(this.lat0, this.long0, azi1, s12, this.a, this.f);
159
155
 
160
- p.x = vars.lon2 * D2R;
161
- p.y = vars.lat2 * D2R;
156
+ p.x = vars.lon2;
157
+ p.y = vars.lat2;
162
158
  return p;
163
159
  }
164
160
  }
@@ -6,8 +6,19 @@ import pj_inv_mlfn from '../common/pj_inv_mlfn';
6
6
  import pj_mlfn from '../common/pj_mlfn';
7
7
  import { HALF_PI } from '../constants/values';
8
8
 
9
+ /**
10
+ * @typedef {Object} LocalThis
11
+ * @property {number} phi1
12
+ * @property {number} cphi1
13
+ * @property {number} es
14
+ * @property {Array<number>} en
15
+ * @property {number} m1
16
+ * @property {number} am1
17
+ */
18
+
9
19
  var EPS10 = 1e-10;
10
20
 
21
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
11
22
  export function init() {
12
23
  var c;
13
24
 
@@ -9,6 +9,17 @@ import adjust_lat from '../common/adjust_lat';
9
9
  import imlfn from '../common/imlfn';
10
10
  import { HALF_PI, EPSLN } from '../constants/values';
11
11
 
12
+ /**
13
+ * @typedef {Object} LocalThis
14
+ * @property {number} es
15
+ * @property {number} e0
16
+ * @property {number} e1
17
+ * @property {number} e2
18
+ * @property {number} e3
19
+ * @property {number} ml0
20
+ */
21
+
22
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
12
23
  export function init() {
13
24
  if (!this.sphere) {
14
25
  this.e0 = e0fn(this.es);
@@ -3,11 +3,17 @@ import qsfnz from '../common/qsfnz';
3
3
  import msfnz from '../common/msfnz';
4
4
  import iqsfnz from '../common/iqsfnz';
5
5
 
6
- /*
6
+ /**
7
+ * @typedef {Object} LocalThis
8
+ * @property {number} e
9
+ */
10
+
11
+ /**
7
12
  reference:
8
13
  "Cartographic Projection Procedures for the UNIX Environment-
9
14
  A User's Manual" by Gerald I. Evenden,
10
15
  USGS Open File Report 90-284and Release 4 Interim Reports (2003)
16
+ @this {import('../defs.js').ProjectionDefinition & LocalThis}
11
17
  */
12
18
  export function init() {
13
19
  // no-op
@@ -9,6 +9,28 @@ import adjust_lat from '../common/adjust_lat';
9
9
  import imlfn from '../common/imlfn';
10
10
  import { EPSLN } from '../constants/values';
11
11
 
12
+ /**
13
+ * @typedef {Object} LocalThis
14
+ * @property {number} temp
15
+ * @property {number} es
16
+ * @property {number} e
17
+ * @property {number} e0
18
+ * @property {number} e1
19
+ * @property {number} e2
20
+ * @property {number} e3
21
+ * @property {number} sin_phi
22
+ * @property {number} cos_phi
23
+ * @property {number} ms1
24
+ * @property {number} ml1
25
+ * @property {number} ms2
26
+ * @property {number} ml2
27
+ * @property {number} ns
28
+ * @property {number} g
29
+ * @property {number} ml0
30
+ * @property {number} rh
31
+ */
32
+
33
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
12
34
  export function init() {
13
35
  /* Place parameters in static storage for common use
14
36
  ------------------------------------------------- */
@@ -25,18 +47,18 @@ export function init() {
25
47
  this.e2 = e2fn(this.es);
26
48
  this.e3 = e3fn(this.es);
27
49
 
28
- this.sinphi = Math.sin(this.lat1);
29
- this.cosphi = Math.cos(this.lat1);
50
+ this.sin_phi = Math.sin(this.lat1);
51
+ this.cos_phi = Math.cos(this.lat1);
30
52
 
31
- this.ms1 = msfnz(this.e, this.sinphi, this.cosphi);
53
+ this.ms1 = msfnz(this.e, this.sin_phi, this.cos_phi);
32
54
  this.ml1 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat1);
33
55
 
34
56
  if (Math.abs(this.lat1 - this.lat2) < EPSLN) {
35
- this.ns = this.sinphi;
57
+ this.ns = this.sin_phi;
36
58
  } else {
37
- this.sinphi = Math.sin(this.lat2);
38
- this.cosphi = Math.cos(this.lat2);
39
- this.ms2 = msfnz(this.e, this.sinphi, this.cosphi);
59
+ this.sin_phi = Math.sin(this.lat2);
60
+ this.cos_phi = Math.cos(this.lat2);
61
+ this.ms2 = msfnz(this.e, this.sin_phi, this.cos_phi);
40
62
  this.ml2 = mlfn(this.e0, this.e1, this.e2, this.e3, this.lat2);
41
63
  this.ns = (this.ms1 - this.ms2) / (this.ml2 - this.ml1);
42
64
  }
@@ -1,5 +1,12 @@
1
1
  import adjust_lon from '../common/adjust_lon';
2
2
 
3
+ /**
4
+ * @typedef {Object} LocalThis
5
+ * @property {number} t1
6
+ * @property {number} t2
7
+ */
8
+
9
+ /** @this {import('../defs.js').ProjectionDefinition} */
3
10
  export function init() {
4
11
  this.x0 = this.x0 || 0;
5
12
  this.y0 = this.y0 || 0;
@@ -8,8 +15,10 @@ export function init() {
8
15
  /// this.t2;
9
16
  }
10
17
 
11
- /* Equirectangular forward equations--mapping lat,long to x,y
12
- --------------------------------------------------------- */
18
+ /**
19
+ * Equirectangular forward equations--mapping lat,long to x,y
20
+ * @this {import('../defs.js').ProjectionDefinition & LocalThis}
21
+ */
13
22
  export function forward(p) {
14
23
  var lon = p.x;
15
24
  var lat = p.y;
@@ -10,6 +10,18 @@ import clens from '../common/clens';
10
10
  import clens_cmplx from '../common/clens_cmplx';
11
11
  import adjust_lon from '../common/adjust_lon';
12
12
 
13
+ /**
14
+ * @typedef {Object} LocalThis
15
+ * @property {number} es
16
+ * @property {Array<number>} cbg
17
+ * @property {Array<number>} cgb
18
+ * @property {Array<number>} utg
19
+ * @property {Array<number>} gtu
20
+ * @property {number} Qn
21
+ * @property {number} Zb
22
+ */
23
+
24
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
13
25
  export function init() {
14
26
  if (!this.approx && (isNaN(this.es) || this.es <= 0)) {
15
27
  throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');
@@ -2,6 +2,18 @@ import srat from '../common/srat';
2
2
  var MAX_ITER = 20;
3
3
  import { HALF_PI, FORTPI } from '../constants/values';
4
4
 
5
+ /**
6
+ * @typedef {Object} LocalThis
7
+ * @property {number} rc
8
+ * @property {number} C
9
+ * @property {number} phic0
10
+ * @property {number} ratexp
11
+ * @property {number} K
12
+ * @property {number} e
13
+ * @property {number} es
14
+ */
15
+
16
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
5
17
  export function init() {
6
18
  var sphi = Math.sin(this.lat0);
7
19
  var cphi = Math.cos(this.lat0);
@@ -1,5 +1,21 @@
1
1
  import hypot from '../common/hypot';
2
2
 
3
+ /**
4
+ * @typedef {Object} LocalThis
5
+ * @property {1 | 0} flip_axis
6
+ * @property {number} h
7
+ * @property {number} radius_g_1
8
+ * @property {number} radius_g
9
+ * @property {number} radius_p
10
+ * @property {number} radius_p2
11
+ * @property {number} radius_p_inv2
12
+ * @property {'ellipse'|'sphere'} shape
13
+ * @property {number} C
14
+ * @property {string} sweep
15
+ * @property {number} es
16
+ */
17
+
18
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
3
19
  export function init() {
4
20
  this.flip_axis = (this.sweep === 'x' ? 1 : 0);
5
21
  this.h = Number(this.h);
@@ -2,12 +2,21 @@ import adjust_lon from '../common/adjust_lon';
2
2
  import asinz from '../common/asinz';
3
3
  import { EPSLN } from '../constants/values';
4
4
 
5
- /*
5
+ /**
6
+ * @typedef {Object} LocalThis
7
+ * @property {number} sin_p14
8
+ * @property {number} cos_p14
9
+ * @property {number} infinity_dist
10
+ * @property {number} rc
11
+ */
12
+
13
+ /**
6
14
  reference:
7
15
  Wolfram Mathworld "Gnomonic Projection"
8
16
  http://mathworld.wolfram.com/GnomonicProjection.html
9
17
  Accessed: 12th November 2009
10
- */
18
+ @this {import('../defs.js').ProjectionDefinition & LocalThis}
19
+ */
11
20
  export function init() {
12
21
  /* Place parameters in static storage for common use
13
22
  ------------------------------------------------- */
@@ -3,6 +3,18 @@ import sinh from '../common/sinh';
3
3
  import cosh from '../common/cosh';
4
4
  import invlatiso from '../common/invlatiso';
5
5
 
6
+ /**
7
+ * @typedef {Object} LocalThis
8
+ * @property {number} e
9
+ * @property {number} lc
10
+ * @property {number} rs
11
+ * @property {number} cp
12
+ * @property {number} n2
13
+ * @property {number} xs
14
+ * @property {number} ys
15
+ */
16
+
17
+ /** @this {import('../defs.js').ProjectionDefinition & LocalThis} */
6
18
  export function init() {
7
19
  // array of: a, b, lon0, lat0, k0, x0, y0
8
20
  var temp = this.b / this.a;