@ac-kit/math-geodesy 0.0.0-stage → 0.1.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 (56) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +57 -0
  3. package/README.md +89 -2
  4. package/dist/_brand.d.ts +14 -0
  5. package/dist/_brand.d.ts.map +1 -0
  6. package/dist/_brand.js +2 -0
  7. package/dist/_brand.js.map +1 -0
  8. package/dist/_ecef-forward-bound.d.ts +7 -0
  9. package/dist/_ecef-forward-bound.d.ts.map +1 -0
  10. package/dist/_ecef-forward-bound.js +7 -0
  11. package/dist/_ecef-forward-bound.js.map +1 -0
  12. package/dist/_ecef-height.d.ts +31 -0
  13. package/dist/_ecef-height.d.ts.map +1 -0
  14. package/dist/_ecef-height.js +99 -0
  15. package/dist/_ecef-height.js.map +1 -0
  16. package/dist/ellipsoid.d.ts +52 -0
  17. package/dist/ellipsoid.d.ts.map +1 -0
  18. package/dist/ellipsoid.js +75 -0
  19. package/dist/ellipsoid.js.map +1 -0
  20. package/dist/geodesic/_angle.d.ts +51 -0
  21. package/dist/geodesic/_angle.d.ts.map +1 -0
  22. package/dist/geodesic/_angle.js +129 -0
  23. package/dist/geodesic/_angle.js.map +1 -0
  24. package/dist/geodesic/_constants.d.ts +38 -0
  25. package/dist/geodesic/_constants.d.ts.map +1 -0
  26. package/dist/geodesic/_constants.js +141 -0
  27. package/dist/geodesic/_constants.js.map +1 -0
  28. package/dist/geodesic/_inverse.d.ts +22 -0
  29. package/dist/geodesic/_inverse.d.ts.map +1 -0
  30. package/dist/geodesic/_inverse.js +714 -0
  31. package/dist/geodesic/_inverse.js.map +1 -0
  32. package/dist/geodesic/_line.d.ts +38 -0
  33. package/dist/geodesic/_line.d.ts.map +1 -0
  34. package/dist/geodesic/_line.js +214 -0
  35. package/dist/geodesic/_line.js.map +1 -0
  36. package/dist/geodesic/_series.d.ts +69 -0
  37. package/dist/geodesic/_series.d.ts.map +1 -0
  38. package/dist/geodesic/_series.js +203 -0
  39. package/dist/geodesic/_series.js.map +1 -0
  40. package/dist/geodesic.d.ts +84 -0
  41. package/dist/geodesic.d.ts.map +1 -0
  42. package/dist/geodesic.js +197 -0
  43. package/dist/geodesic.js.map +1 -0
  44. package/dist/geodetic.d.ts +194 -0
  45. package/dist/geodetic.d.ts.map +1 -0
  46. package/dist/geodetic.js +430 -0
  47. package/dist/geodetic.js.map +1 -0
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +5 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/local-frame.d.ts +19 -0
  53. package/dist/local-frame.d.ts.map +1 -0
  54. package/dist/local-frame.js +35 -0
  55. package/dist/local-frame.js.map +1 -0
  56. package/package.json +72 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ # @ac-kit/math-geodesy
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 34e8cfa: First release: the Earth's reference ellipsoid. `ellipsoidCreate`,
8
+ `ELLIPSOID_WGS84` and `ELLIPSOID_GRS80` describe it; `ecefFromGeodetic` and
9
+ `geodeticFromEcef` (and their `Float64Array` bulk forms) convert between
10
+ `[longitudeDeg, latitudeDeg, heightM]` and Earth-centred coordinates;
11
+ `affine3FromLocalFrame` builds the transform to local east-north-up or
12
+ north-east-down metres at a geodetic origin; and `geodesicInverse`,
13
+ `geodesicDirect` and the line functions (`geodesicLine`, `geodesicLineBetween`,
14
+ `geodesicLinePosition`, `geodesicLinePositions`) solve geodesics on the
15
+ ellipsoid to 15 nanometres on WGS 84 with no per-call result object. Degrees and
16
+ metres, longitude first, and `NaN` rather than a throw for an undefined result.
17
+
18
+ The geodesic algorithms are a port of GeographicLib's JavaScript (Charles
19
+ Karney, MIT), so the package is licensed `BSD-3-Clause AND MIT` and its
20
+ `LICENSE` carries GeographicLib's notice; there is no runtime dependency.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [34e8cfa]
25
+ - Updated dependencies [34e8cfa]
26
+ - Updated dependencies [34e8cfa]
27
+ - Updated dependencies [34e8cfa]
28
+ - Updated dependencies [34e8cfa]
29
+ - Updated dependencies [34e8cfa]
30
+ - Updated dependencies [34e8cfa]
31
+ - Updated dependencies [34e8cfa]
32
+ - Updated dependencies [34e8cfa]
33
+ - Updated dependencies [34e8cfa]
34
+ - Updated dependencies [34e8cfa]
35
+ - Updated dependencies [34e8cfa]
36
+ - Updated dependencies [34e8cfa]
37
+ - Updated dependencies [34e8cfa]
38
+ - Updated dependencies [34e8cfa]
39
+ - Updated dependencies [34e8cfa]
40
+ - Updated dependencies [34e8cfa]
41
+ - Updated dependencies [34e8cfa]
42
+ - Updated dependencies [34e8cfa]
43
+ - Updated dependencies [34e8cfa]
44
+ - Updated dependencies [34e8cfa]
45
+ - Updated dependencies [34e8cfa]
46
+ - Updated dependencies [34e8cfa]
47
+ - Updated dependencies [34e8cfa]
48
+ - Updated dependencies [34e8cfa]
49
+ - Updated dependencies [34e8cfa]
50
+ - Updated dependencies [34e8cfa]
51
+ - Updated dependencies [34e8cfa]
52
+ - Updated dependencies [34e8cfa]
53
+ - Updated dependencies [34e8cfa]
54
+ - Updated dependencies [34e8cfa]
55
+ - Updated dependencies [34e8cfa]
56
+ - Updated dependencies [34e8cfa]
57
+ - Updated dependencies [34e8cfa]
58
+ - @ac-kit/core@0.12.0
59
+ - @ac-kit/math-scalar@0.3.0
60
+ - @ac-kit/math-linear@0.3.0
61
+ - @ac-kit/math-geometry@0.3.0
package/LICENSE ADDED
@@ -0,0 +1,57 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ ---
31
+
32
+ Portions of this package (`src/geodesic/`) are derived from GeographicLib
33
+ (geographiclib-geodesic 2.2.0) and are licensed under the MIT License:
34
+
35
+ The MIT License (MIT).
36
+
37
+ Copyright (c) 2011-2022, Charles Karney
38
+
39
+ Permission is hereby granted, free of charge, to any person
40
+ obtaining a copy of this software and associated documentation
41
+ files (the "Software"), to deal in the Software without
42
+ restriction, including without limitation the rights to use, copy,
43
+ modify, merge, publish, distribute, sublicense, and/or sell copies
44
+ of the Software, and to permit persons to whom the Software is
45
+ furnished to do so, subject to the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
53
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
54
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
55
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
57
+ DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,90 @@
1
- # Temporary Holding Version
1
+ # @ac-kit/math-geodesy
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Earth's reference ellipsoid: coordinates, local frames and geodesics.
4
+ Degrees and metres at the API, longitude first (like a GeoJSON position), `NaN`
5
+ rather than a throw for an undefined result.
6
+
7
+ ```ts
8
+ import {
9
+ ELLIPSOID_WGS84,
10
+ geodesicInverse,
11
+ geodesicInverseCreate,
12
+ geodeticOf,
13
+ } from "@ac-kit/math-geodesy";
14
+
15
+ const out = geodesicInverseCreate();
16
+ geodesicInverse(
17
+ out,
18
+ geodeticOf(-73.8, 40.6, 0), // New York
19
+ geodeticOf(2.55, 49.017, 0), // Paris
20
+ ELLIPSOID_WGS84,
21
+ );
22
+ // [distanceM ≈ 5 853 212.613, azimuth1Deg ≈ 53.47, azimuth2Deg ≈ 111.59]
23
+ ```
24
+
25
+ ## Contents
26
+
27
+ | Symbol | Description |
28
+ | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------- |
29
+ | `Ellipsoid`, `ellipsoidCreate(a, f)`, `ellipsoidSphere(radius)` | A frozen parameter record, made once; `0 ≤ f < 1`, throws `RangeError` |
30
+ | `ELLIPSOID_WGS84`, `ELLIPSOID_GRS80` | The two usual ones |
31
+ | `ellipsoidMeridionalRadius`, `ellipsoidPrimeVerticalRadius` | Radii of curvature `M` and `N` at a latitude |
32
+ | `Geodetic`, `geodeticOf`, `geodeticCreate`, … | `[longitudeDeg, latitudeDeg, heightM]`, a branded value with the usual family |
33
+ | `ecefFromGeodetic`, `geodeticFromEcef` | Geodetic ↔ Earth-centred metres, closed forms |
34
+ | `ecefArrayFromGeodetic`, `geodeticArrayFromEcef` | The same over a `Float64Array` of triples, in place allowed |
35
+ | `affine3FromLocalFrame(out, origin, ellipsoid, axes)` | Earth-centred metres → local east-north-up (or north-east-down) metres |
36
+ | `geodesicInverse(out, from, to, ellipsoid)` | Distance and both azimuths between two positions |
37
+ | `geodesicDirect(out, from, azimuthDeg, distanceM, ellipsoid)` | The end point of a geodesic |
38
+ | `geodesicLine`, `geodesicLineBetween`, `geodesicLinePosition`, `…Azimuth`, `…Distance`, `…Positions` | A line built once, queried many times (a horizon of 600 samples is one call) |
39
+
40
+ Heights are ignored by the geodesic functions (geodesics lie on the
41
+ ellipsoid). Azimuths are degrees clockwise from north in `(−180, 180]`;
42
+ coincident points give a distance of `0` and `NaN` azimuths; a non-finite
43
+ argument, or a latitude beyond ±90°, gives `NaN`.
44
+
45
+ ## Accuracy
46
+
47
+ - Geodesics: within 15 nanometres on WGS 84 (GeographicLib's published bound),
48
+ checked on the whole of Karney's GeodTest set (`yarn test:geodtest`: 500 000
49
+ lines, worst 11 nm, never worse than `geographiclib-geodesic`), including
50
+ nearly antipodal, pole and equatorial lines.
51
+ - `geodeticFromEcef`: latitude within 1e−13° (measured 2.1e−14°) and height
52
+ within 1 nm (measured 0.47 nm) of the exact geodetic position of the given
53
+ double point, against 80-digit mpmath references over 1 512 points, heights
54
+ from −6 000 km to 10 000 km (the height is evaluated in double-double
55
+ arithmetic; plain doubles give 3.7 nm); beyond, up to coordinates of 1e150 m,
56
+ the height stays within 1 nm plus half an ulp of itself.
57
+ - `ecefFromGeodetic`: each coordinate within `5·2⁻⁵³·(a + |h|)` of the exact
58
+ value, 3.5 nm at sea level and 59 nm at 100 000 km (measured worst
59
+ 3.95·2⁻⁵³·(a + |h|) over a seeded 500 000-point mpmath sweep, heights from
60
+ −6 000 km to 100 000 km: `scripts/ecef-sweep.ts`); poles and cardinal
61
+ meridians are exact. Each angle is reduced once, exactly in degrees, and
62
+ costs one `Math.sin`, the cosine coming from `√(1 − sin²)`: about 0.28 of
63
+ `proj4`'s time.
64
+ - `geodeticFromEcef` needs coordinates within `[1e−150, 1e150]` (it squares
65
+ them; far from the Earth its quartic is rescaled by a power of two), and
66
+ `ecefFromGeodetic` takes any finite height; both give `NaN` in all three
67
+ outputs for a component that is not finite.
68
+
69
+ The series are of order 6 in the third flattening: accurate to round-off for
70
+ `|f| ≤ 0.01`, with a Newton correction above it. Prolate ellipsoids (`f < 0`)
71
+ and `|f| > 0.02` precision are not offered yet.
72
+
73
+ ## Credits
74
+
75
+ The geodesic algorithms (`src/geodesic/`) are a port of
76
+ [GeographicLib](https://geographiclib.sourceforge.io/)'s JavaScript
77
+ (`geographiclib-geodesic` 2.2.0, Copyright © 2011–2022 Charles Karney, MIT
78
+ licence), after C. F. F. Karney, _Algorithms for geodesics_, J. Geodesy 87
79
+ (2013) 43–55,
80
+ [doi:10.1007/s00190-012-0578-z](https://doi.org/10.1007/s00190-012-0578-z). The
81
+ package is therefore licensed `BSD-3-Clause AND MIT`; `LICENSE` carries both
82
+ texts, and every ported file opens with GeographicLib's legal comment. The
83
+ geodetic ↔ ECEF conversion follows H. Vermeille, _Direct transformation from
84
+ geocentric coordinates to geodetic coordinates_, J. Geodesy 76 (2002) 451–454
85
+ (its 2011 revision, J. Geodesy 85, 105–117, adds the region near the Earth's
86
+ centre, which is not offered); nothing else here is ported.
87
+
88
+ See the
89
+ [generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/math-geodesy/)
90
+ for the full reference.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The brand of every value type of the math packages: a property with a string
3
+ * key that is stable across versions, so two installed copies of a package (two
4
+ * dependents pinning different minors) stay assignable to each other, which a
5
+ * per-package `unique symbol` would not allow.
6
+ *
7
+ * Declared identically and internally in each package, never imported across
8
+ * packages: the structure is the identity. The key is reserved, and the brand
9
+ * costs nothing at run time.
10
+ */
11
+ export type Brand_<Name extends string> = {
12
+ readonly "~acKitMathType": Name;
13
+ };
14
+ //# sourceMappingURL=_brand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_brand.d.ts","sourceRoot":"","sources":["../src/_brand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,MAAM,CAAC,IAAI,SAAS,MAAM,IAAI;IACzC,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC;CAChC,CAAC"}
package/dist/_brand.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=_brand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_brand.js","sourceRoot":"","sources":["../src/_brand.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The error bound of `ecefFromGeodetic` the README states, per coordinate, in
3
+ * units of `2⁻⁵³·(a + |h|)`. Measured worst 3.95 on the 500 000-point mpmath
4
+ * sweep of `scripts/ecef-sweep.ts` (heights from −6 000 km to 100 000 km).
5
+ */
6
+ export declare const ECEF_FORWARD_BOUND_EPSILONS_ = 5;
7
+ //# sourceMappingURL=_ecef-forward-bound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ecef-forward-bound.d.ts","sourceRoot":"","sources":["../src/_ecef-forward-bound.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,IAAI,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The error bound of `ecefFromGeodetic` the README states, per coordinate, in
3
+ * units of `2⁻⁵³·(a + |h|)`. Measured worst 3.95 on the 500 000-point mpmath
4
+ * sweep of `scripts/ecef-sweep.ts` (heights from −6 000 km to 100 000 km).
5
+ */
6
+ export const ECEF_FORWARD_BOUND_EPSILONS_ = 5;
7
+ //# sourceMappingURL=_ecef-forward-bound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ecef-forward-bound.js","sourceRoot":"","sources":["../src/_ecef-forward-bound.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The height above the ellipsoid of the point `(x, y, z)` whose foot on the
3
+ * ellipsoid has the sine of the geodetic latitude `s` (the latitude only to
4
+ * about 1e−15 rad: the height is stationary in it, so that costs a second-order
5
+ * 1e−29 m), evaluated in double-double arithmetic so the cancellation of terms
6
+ * of about 6 400 km costs nothing, then rounded once:
7
+ *
8
+ * h = (p − N·cosφ)·cosφ + (z − N·(1 − e²)·sinφ)·sinφ,
9
+ * p = √(x² + y²), N = a / w, w = √(cos²φ + (1 − f)²·sin²φ), cosφ = √(1 − sin²φ).
10
+ *
11
+ * The polar ratio `1 − f` is carried as a pair, as is every intermediate; the
12
+ * results of `Math.sqrt` are refined by one Newton step on the exact residual,
13
+ * and each product by Dekker's error term (Dekker, "A floating-point technique
14
+ * for extending the available precision", 1971; Ogita–Rump–Oishi 2005). Needs
15
+ * the coordinates within `[1e−150, 1e150]`: it squares them.
16
+ *
17
+ * The inputs are read from `heightRegisters_` (`HEIGHT_X_` …
18
+ * `HEIGHT_FLATTENING_`) and the height left in
19
+ * `heightRegisters_[HEIGHT_RESULT_]`: a double argument or result would be
20
+ * boxed, as this function is too large for V8 to inline.
21
+ */
22
+ export declare function heightAboveEllipsoid_(): void;
23
+ export declare const HEIGHT_X_ = 0;
24
+ export declare const HEIGHT_Y_ = 1;
25
+ export declare const HEIGHT_Z_ = 2;
26
+ export declare const HEIGHT_SINE_ = 3;
27
+ export declare const HEIGHT_SEMI_MAJOR_AXIS_ = 4;
28
+ export declare const HEIGHT_FLATTENING_ = 5;
29
+ export declare const HEIGHT_RESULT_ = 6;
30
+ export declare const heightRegisters_: Float64Array<ArrayBuffer>;
31
+ //# sourceMappingURL=_ecef-height.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ecef-height.d.ts","sourceRoot":"","sources":["../src/_ecef-height.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CA+E5C;AAED,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,gBAAgB,2BAAsB,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { twoProductError, twoSumError } from "@ac-kit/math-scalar";
2
+ /**
3
+ * The height above the ellipsoid of the point `(x, y, z)` whose foot on the
4
+ * ellipsoid has the sine of the geodetic latitude `s` (the latitude only to
5
+ * about 1e−15 rad: the height is stationary in it, so that costs a second-order
6
+ * 1e−29 m), evaluated in double-double arithmetic so the cancellation of terms
7
+ * of about 6 400 km costs nothing, then rounded once:
8
+ *
9
+ * h = (p − N·cosφ)·cosφ + (z − N·(1 − e²)·sinφ)·sinφ,
10
+ * p = √(x² + y²), N = a / w, w = √(cos²φ + (1 − f)²·sin²φ), cosφ = √(1 − sin²φ).
11
+ *
12
+ * The polar ratio `1 − f` is carried as a pair, as is every intermediate; the
13
+ * results of `Math.sqrt` are refined by one Newton step on the exact residual,
14
+ * and each product by Dekker's error term (Dekker, "A floating-point technique
15
+ * for extending the available precision", 1971; Ogita–Rump–Oishi 2005). Needs
16
+ * the coordinates within `[1e−150, 1e150]`: it squares them.
17
+ *
18
+ * The inputs are read from `heightRegisters_` (`HEIGHT_X_` …
19
+ * `HEIGHT_FLATTENING_`) and the height left in
20
+ * `heightRegisters_[HEIGHT_RESULT_]`: a double argument or result would be
21
+ * boxed, as this function is too large for V8 to inline.
22
+ */
23
+ export function heightAboveEllipsoid_() {
24
+ const x = heightRegisters_[HEIGHT_X_];
25
+ const y = heightRegisters_[HEIGHT_Y_];
26
+ const z = heightRegisters_[HEIGHT_Z_];
27
+ const s = heightRegisters_[HEIGHT_SINE_];
28
+ const semiMajorAxis = heightRegisters_[HEIGHT_SEMI_MAJOR_AXIS_];
29
+ const flattening = heightRegisters_[HEIGHT_FLATTENING_];
30
+ // p = √(x² + y²) as a pair
31
+ const x2 = x * x;
32
+ const y2 = y * y;
33
+ const q0 = x2 + y2;
34
+ const q1 = twoSumError(x2, y2, q0) +
35
+ twoProductError(x, x, x2) +
36
+ twoProductError(y, y, y2);
37
+ const ph = Math.sqrt(q0);
38
+ const pl = (q0 - ph * ph - twoProductError(ph, ph, ph * ph) + q1) / (2 * ph) || 0;
39
+ // the polar ratio r = 1 − f and r², as pairs
40
+ const rh = 1 - flattening;
41
+ const rl = twoSumError(1, -flattening, rh);
42
+ const r2h = rh * rh;
43
+ const r2l = twoProductError(rh, rh, r2h) + 2 * rh * rl;
44
+ // sin²φ and cos²φ = 1 − sin²φ, and cosφ
45
+ const s2h = s * s;
46
+ const s2l = twoProductError(s, s, s2h);
47
+ const c2h = 1 - s2h;
48
+ const c2l = twoSumError(1, -s2h, c2h) - s2l;
49
+ const ch = Math.sqrt(c2h);
50
+ const cl = ch === 0
51
+ ? 0
52
+ : (c2h - ch * ch - twoProductError(ch, ch, ch * ch) + c2l) / (2 * ch);
53
+ // w² = cos²φ + r²·sin²φ, and w = √w², then 1/w as a pair
54
+ const m0 = r2h * s2h;
55
+ const m1 = twoProductError(r2h, s2h, m0) + r2h * s2l + r2l * s2h;
56
+ const w2h = c2h + m0;
57
+ const w2l = twoSumError(c2h, m0, w2h) + c2l + m1;
58
+ const wh = Math.sqrt(w2h);
59
+ const wl = (w2h - wh * wh - twoProductError(wh, wh, wh * wh) + w2l) / (2 * wh);
60
+ const uh = 1 / wh;
61
+ const ul = uh * (1 - wh * uh - twoProductError(wh, uh, wh * uh) - wl * uh);
62
+ // F_p = a·cosφ / w
63
+ const aph = semiMajorAxis * ch;
64
+ const apl = twoProductError(semiMajorAxis, ch, aph) + semiMajorAxis * cl;
65
+ const fph = aph * uh;
66
+ const fpl = twoProductError(aph, uh, fph) + aph * ul + apl * uh;
67
+ // F_z = a·r²·sinφ / w
68
+ const azh = semiMajorAxis * s;
69
+ const azl = twoProductError(semiMajorAxis, s, azh);
70
+ const bzh = azh * r2h;
71
+ const bzl = twoProductError(azh, r2h, bzh) + azh * r2l + azl * r2h;
72
+ const fzh = bzh * uh;
73
+ const fzl = twoProductError(bzh, uh, fzh) + bzh * ul + bzl * uh;
74
+ // the offsets of the point from the foot point
75
+ const dph = ph - fph;
76
+ const dpl = twoSumError(ph, -fph, dph) + pl - fpl;
77
+ const dzh = z - fzh;
78
+ const dzl = twoSumError(z, -fzh, dzh) - fzl;
79
+ // h = dp·cosφ + dz·sinφ
80
+ const t0 = dph * ch;
81
+ const t1 = dzh * s;
82
+ const hh = t0 + t1;
83
+ const hl = twoSumError(t0, t1, hh) +
84
+ twoProductError(dph, ch, t0) +
85
+ twoProductError(dzh, s, t1) +
86
+ dph * cl +
87
+ dpl * ch +
88
+ dzl * s;
89
+ heightRegisters_[HEIGHT_RESULT_] = hh + hl;
90
+ }
91
+ export const HEIGHT_X_ = 0;
92
+ export const HEIGHT_Y_ = 1;
93
+ export const HEIGHT_Z_ = 2;
94
+ export const HEIGHT_SINE_ = 3;
95
+ export const HEIGHT_SEMI_MAJOR_AXIS_ = 4;
96
+ export const HEIGHT_FLATTENING_ = 5;
97
+ export const HEIGHT_RESULT_ = 6;
98
+ export const heightRegisters_ = new Float64Array(7);
99
+ //# sourceMappingURL=_ecef-height.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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@@ -0,0 +1,52 @@
1
+ import type { Brand_ } from "./_brand.js";
2
+ /**
3
+ * The reference ellipsoid of revolution: a parameter record, made only by
4
+ * {@link ellipsoidCreate} and frozen, not a value. It also carries, out of
5
+ * sight, the constants the geodesic solvers derive from it (a copy made by
6
+ * spread loses them and derives them again on first use).
7
+ */
8
+ export type Ellipsoid = {
9
+ /** The equatorial radius `a`, metres. */
10
+ readonly semiMajorAxisM: number;
11
+ /** The flattening `f`; `0` for a sphere. */
12
+ readonly flattening: number;
13
+ /** The polar radius `a(1 − f)`, metres. */
14
+ readonly semiMinorAxisM: number;
15
+ /** The first eccentricity squared, `f(2 − f)`. */
16
+ readonly eccentricitySquared: number;
17
+ /** The second eccentricity squared, `e² / (1 − e²)`. */
18
+ readonly secondEccentricitySquared: number;
19
+ /** The third flattening, `f / (2 − f)`. */
20
+ readonly thirdFlattening: number;
21
+ } & Brand_<"Ellipsoid">;
22
+ /**
23
+ * Creates the ellipsoid of equatorial radius `semiMajorAxisM` metres and
24
+ * flattening `flattening` (`1 / 298.257223563` for WGS 84), computing the
25
+ * constants of the geodesic solvers once. Allocates; keep it out of hot loops.
26
+ *
27
+ * @throws {RangeError} Unless `semiMajorAxisM` is finite and positive and `0 ≤
28
+ * flattening < 1`.
29
+ */
30
+ export declare function ellipsoidCreate(semiMajorAxisM: number, flattening: number): Ellipsoid;
31
+ /** The sphere of radius `radiusM` metres: flattening `0`. */
32
+ export declare function ellipsoidSphere(radiusM: number): Ellipsoid;
33
+ /** WGS 84: `a = 6 378 137 m`, `1/f = 298.257223563`. */
34
+ export declare const ELLIPSOID_WGS84: Ellipsoid;
35
+ /** GRS 80: `a = 6 378 137 m`, `1/f = 298.257222101`. */
36
+ export declare const ELLIPSOID_GRS80: Ellipsoid;
37
+ /**
38
+ * The radius of curvature of the meridian `M = a(1 − e²) / (1 − e²
39
+ * sin²φ)^(3/2)` at the geodetic latitude, metres, evaluated as `a(1 − f)² / w³`
40
+ * with `w² = 1 − e² sin²φ = (1 − f)² + e² cos²φ`, so an extreme flattening
41
+ * (whose `e²` rounds to 1) stays finite at the poles. A latitude beyond ±90° or
42
+ * not finite gives `NaN`.
43
+ */
44
+ export declare function ellipsoidMeridionalRadius(ellipsoid: Ellipsoid, latitudeDeg: number): number;
45
+ /**
46
+ * The radius of curvature of the prime vertical `N = a / √(1 − e² sin²φ)` at
47
+ * the geodetic latitude, metres, evaluated as `a / w` with `w² = (1 − f)² + e²
48
+ * cos²φ` (see {@link ellipsoidMeridionalRadius}). A latitude beyond ±90° or not
49
+ * finite gives `NaN`.
50
+ */
51
+ export declare function ellipsoidPrimeVerticalRadius(ellipsoid: Ellipsoid, latitudeDeg: number): number;
52
+ //# sourceMappingURL=ellipsoid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipsoid.d.ts","sourceRoot":"","sources":["../src/ellipsoid.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,yCAAyC;IACzC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,wDAAwD;IACxD,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,2CAA2C;IAC3C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CACjC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAExB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,GAChB,SAAS,CA0BX;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAE1D;AAED,wDAAwD;AACxD,eAAO,MAAM,eAAe,EAAE,SAG7B,CAAC;AAEF,wDAAwD;AACxD,eAAO,MAAM,eAAe,EAAE,SAG7B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,MAAM,GACjB,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,MAAM,GACjB,MAAM,CAQR"}
@@ -0,0 +1,75 @@
1
+ import { describeValue, isFinitePositive } from "@ac-kit/core";
2
+ import { cosDeg } from "@ac-kit/math-scalar";
3
+ import { CONSTANTS_KEY_, constantsCreate_ } from "./geodesic/_constants.js";
4
+ /**
5
+ * Creates the ellipsoid of equatorial radius `semiMajorAxisM` metres and
6
+ * flattening `flattening` (`1 / 298.257223563` for WGS 84), computing the
7
+ * constants of the geodesic solvers once. Allocates; keep it out of hot loops.
8
+ *
9
+ * @throws {RangeError} Unless `semiMajorAxisM` is finite and positive and `0 ≤
10
+ * flattening < 1`.
11
+ */
12
+ export function ellipsoidCreate(semiMajorAxisM, flattening) {
13
+ if (!isFinitePositive(semiMajorAxisM)) {
14
+ throw new RangeError(`ellipsoidCreate: semiMajorAxisM must be finite and positive, got ${describeValue(semiMajorAxisM)}.`);
15
+ }
16
+ if (!(flattening >= 0 && flattening < 1)) {
17
+ throw new RangeError(`ellipsoidCreate: flattening must be in [0, 1), got ${describeValue(flattening)}.`);
18
+ }
19
+ const eccentricitySquared = flattening * (2 - flattening);
20
+ const polarRatio = 1 - flattening;
21
+ const ellipsoid = {
22
+ semiMajorAxisM,
23
+ flattening,
24
+ semiMinorAxisM: semiMajorAxisM * polarRatio,
25
+ eccentricitySquared,
26
+ secondEccentricitySquared: eccentricitySquared / (polarRatio * polarRatio),
27
+ thirdFlattening: flattening / (2 - flattening),
28
+ };
29
+ Object.defineProperty(ellipsoid, CONSTANTS_KEY_, {
30
+ value: constantsCreate_(semiMajorAxisM, flattening),
31
+ enumerable: false,
32
+ });
33
+ return Object.freeze(ellipsoid);
34
+ }
35
+ /** The sphere of radius `radiusM` metres: flattening `0`. */
36
+ export function ellipsoidSphere(radiusM) {
37
+ return ellipsoidCreate(radiusM, 0);
38
+ }
39
+ /** WGS 84: `a = 6 378 137 m`, `1/f = 298.257223563`. */
40
+ export const ELLIPSOID_WGS84 = ellipsoidCreate(6378137, 1 / 298.257223563);
41
+ /** GRS 80: `a = 6 378 137 m`, `1/f = 298.257222101`. */
42
+ export const ELLIPSOID_GRS80 = ellipsoidCreate(6378137, 1 / 298.257222101);
43
+ /**
44
+ * The radius of curvature of the meridian `M = a(1 − e²) / (1 − e²
45
+ * sin²φ)^(3/2)` at the geodetic latitude, metres, evaluated as `a(1 − f)² / w³`
46
+ * with `w² = 1 − e² sin²φ = (1 − f)² + e² cos²φ`, so an extreme flattening
47
+ * (whose `e²` rounds to 1) stays finite at the poles. A latitude beyond ±90° or
48
+ * not finite gives `NaN`.
49
+ */
50
+ export function ellipsoidMeridionalRadius(ellipsoid, latitudeDeg) {
51
+ const polarRatio = 1 - ellipsoid.flattening;
52
+ const polarRatioSquared = polarRatio * polarRatio;
53
+ const w = curvatureDenominator_(ellipsoid, polarRatioSquared, latitudeDeg);
54
+ return (ellipsoid.semiMajorAxisM * polarRatioSquared) / (w * w * w);
55
+ }
56
+ /**
57
+ * The radius of curvature of the prime vertical `N = a / √(1 − e² sin²φ)` at
58
+ * the geodetic latitude, metres, evaluated as `a / w` with `w² = (1 − f)² + e²
59
+ * cos²φ` (see {@link ellipsoidMeridionalRadius}). A latitude beyond ±90° or not
60
+ * finite gives `NaN`.
61
+ */
62
+ export function ellipsoidPrimeVerticalRadius(ellipsoid, latitudeDeg) {
63
+ const polarRatio = 1 - ellipsoid.flattening;
64
+ const w = curvatureDenominator_(ellipsoid, polarRatio * polarRatio, latitudeDeg);
65
+ return ellipsoid.semiMajorAxisM / w;
66
+ }
67
+ /** `w = √((1 − f)² + e² cos²φ)`, `NaN` beyond ±90°. */
68
+ function curvatureDenominator_(ellipsoid, polarRatioSquared, latitudeDeg) {
69
+ if (!(Math.abs(latitudeDeg) <= 90)) {
70
+ return Number.NaN;
71
+ }
72
+ const cosine = cosDeg(latitudeDeg);
73
+ return Math.sqrt(polarRatioSquared + ellipsoid.eccentricitySquared * (cosine * cosine));
74
+ }
75
+ //# sourceMappingURL=ellipsoid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipsoid.js","sourceRoot":"","sources":["../src/ellipsoid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAuB5E;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC9B,cAAsB,EACtB,UAAkB;IAElB,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CACnB,oEAAoE,aAAa,CAAC,cAAc,CAAC,GAAG,CACpG,CAAC;IACH,CAAC;IACD,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,UAAU,CACnB,sDAAsD,aAAa,CAAC,UAAU,CAAC,GAAG,CAClF,CAAC;IACH,CAAC;IACD,MAAM,mBAAmB,GAAG,UAAU,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC;IAClC,MAAM,SAAS,GAAG;QACjB,cAAc;QACd,UAAU;QACV,cAAc,EAAE,cAAc,GAAG,UAAU;QAC3C,mBAAmB;QACnB,yBAAyB,EAAE,mBAAmB,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC;Q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OAAO,SAAS,CAAC,cAAc,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,uDAAuD;AACvD,SAAS,qBAAqB,CAC7B,SAAoB,EACpB,iBAAyB,EACzB,WAAmB;IAEnB,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,GAAG,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC,IAAI,CACf,iBAAiB,GAAG,SAAS,CAAC,mBAAmB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ /*! Derived from GeographicLib Math.js (geographiclib-geodesic 2.2.0), Copyright (c) 2011-2022, Charles Karney, MIT License — see LICENSE. */
2
+ /**
3
+ * A `Float64Array` the port uses as a record or a scratch buffer, indexed by
4
+ * named constants.
5
+ */
6
+ export type Scratch_ = Float64Array;
7
+ export declare function scratchCreate_(length: number): Scratch_;
8
+ /**
9
+ * The smallest sine or cosine the port keeps away from zero, `sqrt(min normal
10
+ * double)`, so a pole never gives a division by exactly zero.
11
+ */
12
+ export declare const TINY_: number;
13
+ /**
14
+ * {@link TINY_} in a buffer, read as `TINY_DOUBLE_[0]` where it is assigned to
15
+ * a variable that otherwise holds computed doubles: the module binding is a
16
+ * tagged value, and V8 then boxes that variable on every path.
17
+ */
18
+ export declare const TINY_DOUBLE_: Float64Array<ArrayBuffer>;
19
+ /**
20
+ * Snaps an angle within 1/16° of zero onto a grid of 2⁻⁵⁷°, so a latitude that
21
+ * is zero up to rounding is treated as the equator. Tiny negatives become `−0`,
22
+ * and `−0` becomes `+0`.
23
+ */
24
+ export declare function angleRound_(x: number): number;
25
+ /**
26
+ * `x` reduced to `[−180, 180]`; a result of ±180 or ±0 takes the sign of `x`.
27
+ *
28
+ * The rare result `copySign(180, x)` is computed on every path, here and in the
29
+ * functions below: a call that has never run has no type feedback, V8 cannot
30
+ * inline it, and merging its boxed result with a computed double makes V8 box
31
+ * that double on the common path too.
32
+ */
33
+ export declare function angleNormalize_(x: number): number;
34
+ /**
35
+ * `io[1] − io[0]` reduced to `[−180, 180]`, written back as `io[0] + io[1]`:
36
+ * `io[0]` is the nearest double and `io[1]` the rounding error, below 2⁻²⁶. A
37
+ * result of ±0 or ±180 takes the sign of the difference (of `−error` when the
38
+ * error is not zero). (Doubles travel in the buffer: a call passing them as
39
+ * arguments could box them.)
40
+ */
41
+ export declare function angleDifference_(io: Scratch_): void;
42
+ /**
43
+ * Sine and cosine, written to `io[0]` and `io[1]`, of `io[0] + io[1]` degrees,
44
+ * where `io[1]` is the small error term of {@link angleDifference_}. The
45
+ * argument is reduced to `[−45, 45]` before the conversion to radians and the
46
+ * reduced sum snapped by {@link angleRound_} (upstream's `sincosde`, whose
47
+ * contract no `math-scalar` function has); 30° and 45° give their exact
48
+ * algebraic values.
49
+ */
50
+ export declare function sineCosineCorrected_(io: Scratch_): void;
51
+ //# sourceMappingURL=_angle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_angle.d.ts","sourceRoot":"","sources":["../../src/geodesic/_angle.ts"],"names":[],"mappings":"AAAA,6IAA6I;AAI7I;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,CAAC;AAEpC,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,CAEvD;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,QAA+C,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,YAAY,2BAAyB,CAAC;AAWnD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7C;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAIjD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAgBnD;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA6CvD"}