@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.
- package/CHANGELOG.md +61 -0
- package/LICENSE +57 -0
- package/README.md +89 -2
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_ecef-forward-bound.d.ts +7 -0
- package/dist/_ecef-forward-bound.d.ts.map +1 -0
- package/dist/_ecef-forward-bound.js +7 -0
- package/dist/_ecef-forward-bound.js.map +1 -0
- package/dist/_ecef-height.d.ts +31 -0
- package/dist/_ecef-height.d.ts.map +1 -0
- package/dist/_ecef-height.js +99 -0
- package/dist/_ecef-height.js.map +1 -0
- package/dist/ellipsoid.d.ts +52 -0
- package/dist/ellipsoid.d.ts.map +1 -0
- package/dist/ellipsoid.js +75 -0
- package/dist/ellipsoid.js.map +1 -0
- package/dist/geodesic/_angle.d.ts +51 -0
- package/dist/geodesic/_angle.d.ts.map +1 -0
- package/dist/geodesic/_angle.js +129 -0
- package/dist/geodesic/_angle.js.map +1 -0
- package/dist/geodesic/_constants.d.ts +38 -0
- package/dist/geodesic/_constants.d.ts.map +1 -0
- package/dist/geodesic/_constants.js +141 -0
- package/dist/geodesic/_constants.js.map +1 -0
- package/dist/geodesic/_inverse.d.ts +22 -0
- package/dist/geodesic/_inverse.d.ts.map +1 -0
- package/dist/geodesic/_inverse.js +714 -0
- package/dist/geodesic/_inverse.js.map +1 -0
- package/dist/geodesic/_line.d.ts +38 -0
- package/dist/geodesic/_line.d.ts.map +1 -0
- package/dist/geodesic/_line.js +214 -0
- package/dist/geodesic/_line.js.map +1 -0
- package/dist/geodesic/_series.d.ts +69 -0
- package/dist/geodesic/_series.d.ts.map +1 -0
- package/dist/geodesic/_series.js +203 -0
- package/dist/geodesic/_series.js.map +1 -0
- package/dist/geodesic.d.ts +84 -0
- package/dist/geodesic.d.ts.map +1 -0
- package/dist/geodesic.js +197 -0
- package/dist/geodesic.js.map +1 -0
- package/dist/geodetic.d.ts +194 -0
- package/dist/geodetic.d.ts.map +1 -0
- package/dist/geodetic.js +430 -0
- package/dist/geodetic.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/local-frame.d.ts +19 -0
- package/dist/local-frame.d.ts.map +1 -0
- package/dist/local-frame.js +35 -0
- package/dist/local-frame.js.map +1 -0
- package/package.json +72 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Ellipsoid } from "./ellipsoid.js";
|
|
2
|
+
import { type Geodetic, type GeodesicInverse, type ReadonlyGeodetic } from "./geodetic.js";
|
|
3
|
+
declare const geodesicLineBrand_: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* A geodesic line on an ellipsoid: an opaque handle over the precomputed state
|
|
6
|
+
* (Karney's `GeodesicLine`). Make one with {@link geodesicLine} or
|
|
7
|
+
* {@link geodesicLineBetween}; read it with the `geodesicLine…` functions.
|
|
8
|
+
*/
|
|
9
|
+
export type GeodesicLine = {
|
|
10
|
+
readonly [geodesicLineBrand_]: true;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Solves the inverse geodesic problem on `ellipsoid`: the shortest path from
|
|
14
|
+
* `from` to `to`, writing its length in metres and its azimuths at both ends,
|
|
15
|
+
* degrees clockwise from north in `(−180, 180]`, into `out`. Heights are
|
|
16
|
+
* ignored.
|
|
17
|
+
*
|
|
18
|
+
* Coincident points give a distance of `0` and `NaN` azimuths; a non-finite
|
|
19
|
+
* longitude or latitude, or a latitude beyond ±90°, gives all `NaN`. Accurate
|
|
20
|
+
* to 15 nanometres on WGS 84, nearly antipodal points included. Allocates no
|
|
21
|
+
* object. O(1).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const out = geodesicInverseCreate();
|
|
26
|
+
* const origin = geodeticOf(0, 0, 0);
|
|
27
|
+
* geodesicInverse(out, origin, geodeticOf(-1, 0, 0), ELLIPSOID_WGS84);
|
|
28
|
+
* // out[0] ≈ 111319.49 m, out[1] = out[2] = -90 (due west)
|
|
29
|
+
* ```;
|
|
30
|
+
*/
|
|
31
|
+
export declare function geodesicInverse(out: GeodesicInverse, from: ReadonlyGeodetic, to: ReadonlyGeodetic, ellipsoid: Ellipsoid): GeodesicInverse;
|
|
32
|
+
/**
|
|
33
|
+
* Solves the direct geodesic problem on `ellipsoid`: the end point, at height
|
|
34
|
+
* `0`, of the geodesic leaving `from` at `azimuthDeg` (degrees clockwise from
|
|
35
|
+
* north) and running `distanceM` metres (negative goes backwards). The
|
|
36
|
+
* longitude is in `[−180, 180]`. A non-finite input, or a latitude beyond ±90°,
|
|
37
|
+
* gives `NaN`s. Runs through a line; allocates no object. O(1).
|
|
38
|
+
*/
|
|
39
|
+
export declare function geodesicDirect(out: Geodetic, from: ReadonlyGeodetic, azimuthDeg: number, distanceM: number, ellipsoid: Ellipsoid): Geodetic;
|
|
40
|
+
/**
|
|
41
|
+
* Creates the geodesic line leaving `from` at `azimuthDeg`, to query with
|
|
42
|
+
* {@link geodesicLinePosition}, {@link geodesicLineAzimuth} and
|
|
43
|
+
* {@link geodesicLinePositions}. Its length is unknown:
|
|
44
|
+
* {@link geodesicLineDistance} gives `NaN`. Allocates; build it once and query
|
|
45
|
+
* it many times.
|
|
46
|
+
*
|
|
47
|
+
* @throws {RangeError} For a non-finite start or azimuth, or a latitude beyond
|
|
48
|
+
* ±90°.
|
|
49
|
+
*/
|
|
50
|
+
export declare function geodesicLine(from: ReadonlyGeodetic, azimuthDeg: number, ellipsoid: Ellipsoid): GeodesicLine;
|
|
51
|
+
/**
|
|
52
|
+
* Creates the geodesic joining `from` to `to` (Karney's `InverseLine`), whose
|
|
53
|
+
* length {@link geodesicLineDistance} gives and whose position at that distance
|
|
54
|
+
* is `to`. Allocates.
|
|
55
|
+
*
|
|
56
|
+
* @throws {RangeError} For a non-finite position, or a latitude beyond ±90°.
|
|
57
|
+
*/
|
|
58
|
+
export declare function geodesicLineBetween(from: ReadonlyGeodetic, to: ReadonlyGeodetic, ellipsoid: Ellipsoid): GeodesicLine;
|
|
59
|
+
/**
|
|
60
|
+
* The length in metres of a line made by {@link geodesicLineBetween}; `NaN` for
|
|
61
|
+
* one made by {@link geodesicLine}.
|
|
62
|
+
*/
|
|
63
|
+
export declare function geodesicLineDistance(line: GeodesicLine): number;
|
|
64
|
+
/**
|
|
65
|
+
* Writes the position, at height `0`, `distanceM` metres along `line` (negative
|
|
66
|
+
* goes backwards) into `out`. A non-finite distance gives `NaN`s. Allocates no
|
|
67
|
+
* object. O(1).
|
|
68
|
+
*/
|
|
69
|
+
export declare function geodesicLinePosition(out: Geodetic, line: GeodesicLine, distanceM: number): Geodetic;
|
|
70
|
+
/**
|
|
71
|
+
* The azimuth in degrees, clockwise from north in `(−180, 180]`, of `line`
|
|
72
|
+
* `distanceM` metres along it. A non-finite distance gives `NaN`. O(1).
|
|
73
|
+
*/
|
|
74
|
+
export declare function geodesicLineAzimuth(line: GeodesicLine, distanceM: number): number;
|
|
75
|
+
/**
|
|
76
|
+
* Writes the position at each distance of `distancesM` along `line` into `out`
|
|
77
|
+
* as geodetic triples `[longitudeDeg, latitudeDeg, 0, …]`: ready for the
|
|
78
|
+
* caller's heights and `ecefArrayFromGeodetic`, with no copy. O(n).
|
|
79
|
+
*
|
|
80
|
+
* @throws {RangeError} Unless `out` holds three numbers per distance.
|
|
81
|
+
*/
|
|
82
|
+
export declare function geodesicLinePositions<T extends Float64Array>(out: T, line: GeodesicLine, distancesM: Float64Array): T;
|
|
83
|
+
export {};
|
|
84
|
+
//# sourceMappingURL=geodesic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geodesic.d.ts","sourceRoot":"","sources":["../src/geodesic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE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;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,YAAY,EAC3D,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,YAAY,EAClB,UAAU,EAAE,YAAY,GACtB,CAAC,CAkBH"}
|
package/dist/geodesic.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { atan2Deg } from "@ac-kit/math-scalar";
|
|
2
|
+
import { scratchCreate_ } from "./geodesic/_angle.js";
|
|
3
|
+
import { constantsOf_ } from "./geodesic/_constants.js";
|
|
4
|
+
import { INVERSE_COS_ALPHA1_, INVERSE_COS_ALPHA2_, INVERSE_DISTANCE_, INVERSE_LATITUDE1_, INVERSE_LATITUDE2_, INVERSE_LENGTH_, INVERSE_LONGITUDE1_, INVERSE_LONGITUDE2_, INVERSE_SIN_ALPHA1_, INVERSE_SIN_ALPHA2_, inverse_, } from "./geodesic/_inverse.js";
|
|
5
|
+
import { lineDistance_, lineInitialize_, linePosition_, lineRecordCreate_, lineSetDistance_, POSITION_AZIMUTH_, POSITION_DISTANCE_, POSITION_LATITUDE_, POSITION_LENGTH_, POSITION_LONGITUDE_, START_AZIMUTH_, START_COS_ALPHA_, START_LATITUDE_, START_LENGTH_, START_LONGITUDE_, START_SIN_ALPHA_, } from "./geodesic/_line.js";
|
|
6
|
+
const inverseScratch_ = scratchCreate_(INVERSE_LENGTH_);
|
|
7
|
+
const positionScratch_ = scratchCreate_(POSITION_LENGTH_);
|
|
8
|
+
const startScratch_ = scratchCreate_(START_LENGTH_);
|
|
9
|
+
const directLineScratch_ = lineRecordCreate_();
|
|
10
|
+
function isValidPosition_(longitude, latitude) {
|
|
11
|
+
return Number.isFinite(longitude) && Math.abs(latitude) <= 90;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Solves the inverse geodesic problem on `ellipsoid`: the shortest path from
|
|
15
|
+
* `from` to `to`, writing its length in metres and its azimuths at both ends,
|
|
16
|
+
* degrees clockwise from north in `(−180, 180]`, into `out`. Heights are
|
|
17
|
+
* ignored.
|
|
18
|
+
*
|
|
19
|
+
* Coincident points give a distance of `0` and `NaN` azimuths; a non-finite
|
|
20
|
+
* longitude or latitude, or a latitude beyond ±90°, gives all `NaN`. Accurate
|
|
21
|
+
* to 15 nanometres on WGS 84, nearly antipodal points included. Allocates no
|
|
22
|
+
* object. O(1).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const out = geodesicInverseCreate();
|
|
27
|
+
* const origin = geodeticOf(0, 0, 0);
|
|
28
|
+
* geodesicInverse(out, origin, geodeticOf(-1, 0, 0), ELLIPSOID_WGS84);
|
|
29
|
+
* // out[0] ≈ 111319.49 m, out[1] = out[2] = -90 (due west)
|
|
30
|
+
* ```;
|
|
31
|
+
*/
|
|
32
|
+
export function geodesicInverse(out, from, to, ellipsoid) {
|
|
33
|
+
const longitude1 = from[0];
|
|
34
|
+
const latitude1 = from[1];
|
|
35
|
+
const longitude2 = to[0];
|
|
36
|
+
const latitude2 = to[1];
|
|
37
|
+
if (!(isValidPosition_(longitude1, latitude1) &&
|
|
38
|
+
isValidPosition_(longitude2, latitude2))) {
|
|
39
|
+
out[0] = Number.NaN;
|
|
40
|
+
out[1] = Number.NaN;
|
|
41
|
+
out[2] = Number.NaN;
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
inverseScratch_[INVERSE_LATITUDE1_] = latitude1;
|
|
45
|
+
inverseScratch_[INVERSE_LONGITUDE1_] = longitude1;
|
|
46
|
+
inverseScratch_[INVERSE_LATITUDE2_] = latitude2;
|
|
47
|
+
inverseScratch_[INVERSE_LONGITUDE2_] = longitude2;
|
|
48
|
+
inverse_(constantsOf_(ellipsoid), inverseScratch_);
|
|
49
|
+
const distance = inverseScratch_[INVERSE_DISTANCE_];
|
|
50
|
+
out[0] = distance;
|
|
51
|
+
if (distance === 0) {
|
|
52
|
+
out[1] = Number.NaN;
|
|
53
|
+
out[2] = Number.NaN;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// `+ 0` turns a −0 azimuth (due north from a west-going frame) into 0.
|
|
57
|
+
out[1] =
|
|
58
|
+
atan2Deg(inverseScratch_[INVERSE_SIN_ALPHA1_], inverseScratch_[INVERSE_COS_ALPHA1_]) + 0;
|
|
59
|
+
out[2] =
|
|
60
|
+
atan2Deg(inverseScratch_[INVERSE_SIN_ALPHA2_], inverseScratch_[INVERSE_COS_ALPHA2_]) + 0;
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
function writeNaN_(out) {
|
|
65
|
+
out[0] = Number.NaN;
|
|
66
|
+
out[1] = Number.NaN;
|
|
67
|
+
out[2] = Number.NaN;
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Solves the direct geodesic problem on `ellipsoid`: the end point, at height
|
|
72
|
+
* `0`, of the geodesic leaving `from` at `azimuthDeg` (degrees clockwise from
|
|
73
|
+
* north) and running `distanceM` metres (negative goes backwards). The
|
|
74
|
+
* longitude is in `[−180, 180]`. A non-finite input, or a latitude beyond ±90°,
|
|
75
|
+
* gives `NaN`s. Runs through a line; allocates no object. O(1).
|
|
76
|
+
*/
|
|
77
|
+
export function geodesicDirect(out, from, azimuthDeg, distanceM, ellipsoid) {
|
|
78
|
+
if (!(isValidPosition_(from[0], from[1]) &&
|
|
79
|
+
Number.isFinite(azimuthDeg) &&
|
|
80
|
+
Number.isFinite(distanceM))) {
|
|
81
|
+
return writeNaN_(out);
|
|
82
|
+
}
|
|
83
|
+
startScratch_[START_LATITUDE_] = from[1];
|
|
84
|
+
startScratch_[START_LONGITUDE_] = from[0];
|
|
85
|
+
startScratch_[START_AZIMUTH_] = azimuthDeg;
|
|
86
|
+
startScratch_[START_SIN_ALPHA_] = Number.NaN;
|
|
87
|
+
lineInitialize_(directLineScratch_, constantsOf_(ellipsoid), startScratch_);
|
|
88
|
+
positionScratch_[POSITION_DISTANCE_] = distanceM;
|
|
89
|
+
linePosition_(directLineScratch_, positionScratch_);
|
|
90
|
+
out[0] = positionScratch_[POSITION_LONGITUDE_];
|
|
91
|
+
out[1] = positionScratch_[POSITION_LATITUDE_];
|
|
92
|
+
out[2] = 0;
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Creates the geodesic line leaving `from` at `azimuthDeg`, to query with
|
|
97
|
+
* {@link geodesicLinePosition}, {@link geodesicLineAzimuth} and
|
|
98
|
+
* {@link geodesicLinePositions}. Its length is unknown:
|
|
99
|
+
* {@link geodesicLineDistance} gives `NaN`. Allocates; build it once and query
|
|
100
|
+
* it many times.
|
|
101
|
+
*
|
|
102
|
+
* @throws {RangeError} For a non-finite start or azimuth, or a latitude beyond
|
|
103
|
+
* ±90°.
|
|
104
|
+
*/
|
|
105
|
+
export function geodesicLine(from, azimuthDeg, ellipsoid) {
|
|
106
|
+
if (!(isValidPosition_(from[0], from[1]) && Number.isFinite(azimuthDeg))) {
|
|
107
|
+
throw new RangeError(`geodesicLine: the start (${from[0]}, ${from[1]}) and the azimuth ${azimuthDeg} must be finite, with a latitude within ±90°.`);
|
|
108
|
+
}
|
|
109
|
+
const line = lineRecordCreate_();
|
|
110
|
+
startScratch_[START_LATITUDE_] = from[1];
|
|
111
|
+
startScratch_[START_LONGITUDE_] = from[0];
|
|
112
|
+
startScratch_[START_AZIMUTH_] = azimuthDeg;
|
|
113
|
+
startScratch_[START_SIN_ALPHA_] = Number.NaN;
|
|
114
|
+
lineInitialize_(line, constantsOf_(ellipsoid), startScratch_);
|
|
115
|
+
return line;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Creates the geodesic joining `from` to `to` (Karney's `InverseLine`), whose
|
|
119
|
+
* length {@link geodesicLineDistance} gives and whose position at that distance
|
|
120
|
+
* is `to`. Allocates.
|
|
121
|
+
*
|
|
122
|
+
* @throws {RangeError} For a non-finite position, or a latitude beyond ±90°.
|
|
123
|
+
*/
|
|
124
|
+
export function geodesicLineBetween(from, to, ellipsoid) {
|
|
125
|
+
if (!(isValidPosition_(from[0], from[1]) && isValidPosition_(to[0], to[1]))) {
|
|
126
|
+
throw new RangeError(`geodesicLineBetween: both positions must be finite, with a latitude within ±90° (got (${from[0]}, ${from[1]}) and (${to[0]}, ${to[1]})).`);
|
|
127
|
+
}
|
|
128
|
+
const constants = constantsOf_(ellipsoid);
|
|
129
|
+
inverseScratch_[INVERSE_LATITUDE1_] = from[1];
|
|
130
|
+
inverseScratch_[INVERSE_LONGITUDE1_] = from[0];
|
|
131
|
+
inverseScratch_[INVERSE_LATITUDE2_] = to[1];
|
|
132
|
+
inverseScratch_[INVERSE_LONGITUDE2_] = to[0];
|
|
133
|
+
inverse_(constants, inverseScratch_);
|
|
134
|
+
const line = lineRecordCreate_();
|
|
135
|
+
startScratch_[START_LATITUDE_] = from[1];
|
|
136
|
+
startScratch_[START_LONGITUDE_] = from[0];
|
|
137
|
+
startScratch_[START_SIN_ALPHA_] = inverseScratch_[INVERSE_SIN_ALPHA1_];
|
|
138
|
+
startScratch_[START_COS_ALPHA_] = inverseScratch_[INVERSE_COS_ALPHA1_];
|
|
139
|
+
lineInitialize_(line, constants, startScratch_);
|
|
140
|
+
lineSetDistance_(line, inverseScratch_[INVERSE_DISTANCE_]);
|
|
141
|
+
return line;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The length in metres of a line made by {@link geodesicLineBetween}; `NaN` for
|
|
145
|
+
* one made by {@link geodesicLine}.
|
|
146
|
+
*/
|
|
147
|
+
export function geodesicLineDistance(line) {
|
|
148
|
+
return lineDistance_(line);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Writes the position, at height `0`, `distanceM` metres along `line` (negative
|
|
152
|
+
* goes backwards) into `out`. A non-finite distance gives `NaN`s. Allocates no
|
|
153
|
+
* object. O(1).
|
|
154
|
+
*/
|
|
155
|
+
export function geodesicLinePosition(out, line, distanceM) {
|
|
156
|
+
positionScratch_[POSITION_DISTANCE_] = distanceM;
|
|
157
|
+
linePosition_(line, positionScratch_);
|
|
158
|
+
out[0] = positionScratch_[POSITION_LONGITUDE_];
|
|
159
|
+
out[1] = positionScratch_[POSITION_LATITUDE_];
|
|
160
|
+
// Height 0, or NaN with the rest when the distance was not finite.
|
|
161
|
+
out[2] = Number.isFinite(out[0] + out[1]) ? 0 : Number.NaN;
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The azimuth in degrees, clockwise from north in `(−180, 180]`, of `line`
|
|
166
|
+
* `distanceM` metres along it. A non-finite distance gives `NaN`. O(1).
|
|
167
|
+
*/
|
|
168
|
+
export function geodesicLineAzimuth(line, distanceM) {
|
|
169
|
+
positionScratch_[POSITION_DISTANCE_] = distanceM;
|
|
170
|
+
linePosition_(line, positionScratch_);
|
|
171
|
+
return positionScratch_[POSITION_AZIMUTH_];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Writes the position at each distance of `distancesM` along `line` into `out`
|
|
175
|
+
* as geodetic triples `[longitudeDeg, latitudeDeg, 0, …]`: ready for the
|
|
176
|
+
* caller's heights and `ecefArrayFromGeodetic`, with no copy. O(n).
|
|
177
|
+
*
|
|
178
|
+
* @throws {RangeError} Unless `out` holds three numbers per distance.
|
|
179
|
+
*/
|
|
180
|
+
export function geodesicLinePositions(out, line, distancesM) {
|
|
181
|
+
if (out.length !== distancesM.length * 3) {
|
|
182
|
+
throw new RangeError(`geodesicLinePositions: out must hold 3 numbers per distance (expected ${distancesM.length * 3}, got ${out.length}).`);
|
|
183
|
+
}
|
|
184
|
+
const record = line;
|
|
185
|
+
for (let index = 0; index < distancesM.length; index++) {
|
|
186
|
+
positionScratch_[POSITION_DISTANCE_] = distancesM[index];
|
|
187
|
+
linePosition_(record, positionScratch_);
|
|
188
|
+
const base = index * 3;
|
|
189
|
+
out[base] = positionScratch_[POSITION_LONGITUDE_];
|
|
190
|
+
out[base + 1] = positionScratch_[POSITION_LATITUDE_];
|
|
191
|
+
out[base + 2] = Number.isFinite(out[base] + out[base + 1])
|
|
192
|
+
? 0
|
|
193
|
+
: Number.NaN;
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=geodesic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geodesic.js","sourceRoot":"","sources":["../src/geodesic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,OAAO,EAAiB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,QAAQ,GACR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,aAAa,EACb,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAoB7B,MAAM,eAAe,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;AACxD,MAAM,gBAAgB,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AACpD,MAAM,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAE/C,SAAS,gBAAgB,CAAC,SAAiB,EAAE,QAAgB;IAC5D,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;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MAAM,GAAG,IAA2B,CAAC;IAC3C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACxD,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC,KAAK,CAAE,CAAC;QAC1D,aAAa,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;QACvB,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,mBAAmB,CAAE,CAAC;QACnD,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAC,kBAAkB,CAAE,CAAC;QACtD,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAE,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;YAC3D,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACf,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { ReadonlyVec3, Vec3 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { Brand_ } from "./_brand.js";
|
|
3
|
+
import type { Ellipsoid } from "./ellipsoid.js";
|
|
4
|
+
/**
|
|
5
|
+
* A position on the Earth in degrees and metres: `[longitudeDeg, latitudeDeg,
|
|
6
|
+
* heightM]`, the height above the ellipsoid along its normal. Longitude first,
|
|
7
|
+
* like a GeoJSON position, so a buffer of GeoJSON positions is already a buffer
|
|
8
|
+
* of these.
|
|
9
|
+
*
|
|
10
|
+
* A plain array of 3 binary64 numbers carrying a type-level brand, holding
|
|
11
|
+
* exactly the numbers one element of a geodetic buffer holds. Only
|
|
12
|
+
* {@link geodeticCreate}, {@link geodeticOf}, {@link geodeticClone},
|
|
13
|
+
* {@link geodeticFromArray} and the functions that write an `out` make one; see
|
|
14
|
+
* `Vec3` in `@ac-kit/math-linear` for the rules that bind callers who bypass
|
|
15
|
+
* the types.
|
|
16
|
+
*/
|
|
17
|
+
export type Geodetic = [
|
|
18
|
+
longitudeDeg: number,
|
|
19
|
+
latitudeDeg: number,
|
|
20
|
+
heightM: number
|
|
21
|
+
] & Brand_<"Geodetic">;
|
|
22
|
+
/** A {@link Geodetic} that is only read. */
|
|
23
|
+
export type ReadonlyGeodetic = readonly [
|
|
24
|
+
longitudeDeg: number,
|
|
25
|
+
latitudeDeg: number,
|
|
26
|
+
heightM: number
|
|
27
|
+
] & Brand_<"Geodetic">;
|
|
28
|
+
/**
|
|
29
|
+
* The solution of an inverse geodesic problem: the distance in metres, then the
|
|
30
|
+
* azimuths at both ends in degrees clockwise from north, in `(−180, 180]`.
|
|
31
|
+
*/
|
|
32
|
+
export type GeodesicInverse = [
|
|
33
|
+
distanceM: number,
|
|
34
|
+
azimuth1Deg: number,
|
|
35
|
+
azimuth2Deg: number
|
|
36
|
+
] & Brand_<"GeodesicInverse">;
|
|
37
|
+
/** A {@link GeodesicInverse} that is only read. */
|
|
38
|
+
export type ReadonlyGeodesicInverse = readonly [
|
|
39
|
+
distanceM: number,
|
|
40
|
+
azimuth1Deg: number,
|
|
41
|
+
azimuth2Deg: number
|
|
42
|
+
] & Brand_<"GeodesicInverse">;
|
|
43
|
+
/**
|
|
44
|
+
* Creates the position `[0, 0, 0]`.
|
|
45
|
+
*
|
|
46
|
+
* Allocates; keep it out of hot loops.
|
|
47
|
+
*/
|
|
48
|
+
export declare function geodeticCreate(): Geodetic;
|
|
49
|
+
/**
|
|
50
|
+
* Creates the position `longitudeDeg, latitudeDeg, heightM`.
|
|
51
|
+
*
|
|
52
|
+
* Allocates; keep it out of hot loops.
|
|
53
|
+
*/
|
|
54
|
+
export declare function geodeticOf(longitudeDeg: number, latitudeDeg: number, heightM: number): Geodetic;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a copy of `a`. Like every creator it starts from a clean array.
|
|
57
|
+
*
|
|
58
|
+
* Allocates; keep it out of hot loops.
|
|
59
|
+
*/
|
|
60
|
+
export declare function geodeticClone(a: ReadonlyGeodetic): Geodetic;
|
|
61
|
+
/** Writes the components, in storage order, into `out`. */
|
|
62
|
+
export declare function geodeticSet(out: Geodetic, longitudeDeg: number, latitudeDeg: number, heightM: number): Geodetic;
|
|
63
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
64
|
+
export declare function geodeticCopy(out: Geodetic, a: ReadonlyGeodetic): Geodetic;
|
|
65
|
+
/**
|
|
66
|
+
* Exact component-wise equality: `−0` equals `+0`, `NaN` equals nothing, itself
|
|
67
|
+
* included. A longitude of 180° and one of −180° are different numbers. See
|
|
68
|
+
* {@link geodeticIsClose} for a tolerant test.
|
|
69
|
+
*/
|
|
70
|
+
export declare function geodeticEquals(a: ReadonlyGeodetic, b: ReadonlyGeodetic): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Component-wise approximate equality: every pair differs by at most
|
|
73
|
+
* `tolerance`, the same absolute bound for degrees and metres (pass one that
|
|
74
|
+
* suits both, or compare the parts yourself). Longitudes are compared as
|
|
75
|
+
* numbers, not around the antimeridian.
|
|
76
|
+
*
|
|
77
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function geodeticIsClose(a: ReadonlyGeodetic, b: ReadonlyGeodetic, tolerance?: number): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The checked way in from untyped data: `source[offset … offset + 3)` copied
|
|
82
|
+
* into `out`, each element that is not a number written as `NaN`, an index past
|
|
83
|
+
* the end too. A cold path: buffers use {@link geodeticLoad}. `source` may be
|
|
84
|
+
* `out`. O(1).
|
|
85
|
+
*/
|
|
86
|
+
export declare function geodeticFromArray(out: Geodetic, source: ArrayLike<number>, offset?: number): Geodetic;
|
|
87
|
+
/**
|
|
88
|
+
* Whether every component is a finite number: the check after parsing untrusted
|
|
89
|
+
* data.
|
|
90
|
+
*/
|
|
91
|
+
export declare function geodeticIsFinite(value: ReadonlyGeodetic): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Writes element `index` of `array`, the numbers at `[index·3, index·3 + 3)`,
|
|
94
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
95
|
+
* end gives `NaN`, never `undefined`. O(1).
|
|
96
|
+
*/
|
|
97
|
+
export declare function geodeticLoad(out: Geodetic, array: Float64Array, index: number): Geodetic;
|
|
98
|
+
/**
|
|
99
|
+
* Writes `value` into `array` as element `index`. An element past the end of
|
|
100
|
+
* `array` writes nothing. O(1).
|
|
101
|
+
*/
|
|
102
|
+
export declare function geodeticStore(array: Float64Array, index: number, value: ReadonlyGeodetic): void;
|
|
103
|
+
/**
|
|
104
|
+
* Like {@link geodeticLoad} for interleaved data: element `index` starts at
|
|
105
|
+
* `offset + index·stride`, both counted in numbers. O(1).
|
|
106
|
+
*/
|
|
107
|
+
export declare function geodeticLoadStrided(out: Geodetic, array: Float64Array, offset: number, stride: number, index: number): Geodetic;
|
|
108
|
+
/**
|
|
109
|
+
* Like {@link geodeticStore} for interleaved data: element `index` starts at
|
|
110
|
+
* `offset + index·stride`, both counted in numbers. O(1).
|
|
111
|
+
*/
|
|
112
|
+
export declare function geodeticStoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyGeodetic): void;
|
|
113
|
+
/**
|
|
114
|
+
* Whether every number of `array` is finite (`vec3ArrayIsFinite`: a buffer of
|
|
115
|
+
* triples). O(n).
|
|
116
|
+
*/
|
|
117
|
+
export declare function geodeticArrayIsFinite(array: Float64Array): boolean;
|
|
118
|
+
/** Creates the result `[0, 0, 0]`. Allocates; keep it out of hot loops. */
|
|
119
|
+
export declare function geodesicInverseCreate(): GeodesicInverse;
|
|
120
|
+
/** Creates the result `distanceM, azimuth1Deg, azimuth2Deg`. Allocates. */
|
|
121
|
+
export declare function geodesicInverseOf(distanceM: number, azimuth1Deg: number, azimuth2Deg: number): GeodesicInverse;
|
|
122
|
+
/** Creates a copy of `a`. Allocates. */
|
|
123
|
+
export declare function geodesicInverseClone(a: ReadonlyGeodesicInverse): GeodesicInverse;
|
|
124
|
+
/** Writes the components into `out`. */
|
|
125
|
+
export declare function geodesicInverseSet(out: GeodesicInverse, distanceM: number, azimuth1Deg: number, azimuth2Deg: number): GeodesicInverse;
|
|
126
|
+
/** Writes a copy of `a` into `out`. `out` may be `a`. */
|
|
127
|
+
export declare function geodesicInverseCopy(out: GeodesicInverse, a: ReadonlyGeodesicInverse): GeodesicInverse;
|
|
128
|
+
/** Exact component-wise equality: `NaN` equals nothing, itself included. */
|
|
129
|
+
export declare function geodesicInverseEquals(a: ReadonlyGeodesicInverse, b: ReadonlyGeodesicInverse): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Component-wise approximate equality with one absolute `tolerance` for the
|
|
132
|
+
* metres and the degrees. Azimuths are compared as numbers, not around ±180°.
|
|
133
|
+
*
|
|
134
|
+
* @param tolerance Defaults to `geometryConfig.defaultLinearTolerance`.
|
|
135
|
+
*/
|
|
136
|
+
export declare function geodesicInverseIsClose(a: ReadonlyGeodesicInverse, b: ReadonlyGeodesicInverse, tolerance?: number): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Whether every component is a finite number: `false` for the `NaN` result of
|
|
139
|
+
* an undefined problem.
|
|
140
|
+
*/
|
|
141
|
+
export declare function geodesicInverseIsFinite(value: ReadonlyGeodesicInverse): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Writes the Earth-centred, Earth-fixed coordinates, metres, of the geodetic
|
|
144
|
+
* `position` on `ellipsoid` into `out`: x through the equator at longitude 0, z
|
|
145
|
+
* through the north pole.
|
|
146
|
+
*
|
|
147
|
+
* The closed form `x = (N + h)·cosφ·cosλ`, `y = (N + h)·cosφ·sinλ`, `z = (N(1 −
|
|
148
|
+
* e²) + h)·sinφ` with the prime-vertical radius `N = a / √(cos²φ + (1 −
|
|
149
|
+
* f)²·sin²φ)`, using the polar ratio `1 − f` itself so that an extreme
|
|
150
|
+
* flattening (whose `e²` rounds to 1) still works. Each angle is reduced
|
|
151
|
+
* exactly in degrees to within 45° of a multiple of 90°, as `sinDeg` does; the
|
|
152
|
+
* remainder's sine comes from `Math.sin` and its cosine from `√(1 − sin²)`, so
|
|
153
|
+
* the poles and the cardinal meridians are exact. Each coordinate is within
|
|
154
|
+
* `5·2⁻⁵³·(a + |h|)` of the exact value, 3.5 nm at sea level (see the README).
|
|
155
|
+
* A component that is not finite gives `NaN` in all three; any finite height
|
|
156
|
+
* works. O(1).
|
|
157
|
+
*/
|
|
158
|
+
export declare function ecefFromGeodetic(out: Vec3, position: ReadonlyGeodetic, ellipsoid: Ellipsoid): Vec3;
|
|
159
|
+
/**
|
|
160
|
+
* Writes the geodetic position of the Earth-centred point `point`, metres, on
|
|
161
|
+
* `ellipsoid` into `out`: longitude in `(−180, 180]`, latitude in `[−90, 90]`,
|
|
162
|
+
* and the height along the ellipsoid normal.
|
|
163
|
+
*
|
|
164
|
+
* Vermeille's closed form (J. Geodesy 76 (2002) 451–454, which solves a quartic
|
|
165
|
+
* for the latitude without iteration) gives the latitude, to 1e−13°. The height
|
|
166
|
+
* is the offset of the point from its foot on the ellipsoid along the normal,
|
|
167
|
+
* which is stationary in the latitude, evaluated in double-double arithmetic
|
|
168
|
+
* (`_ecef-height.ts`): the rounding of 6 400 km terms, 1 to 3 nm in plain
|
|
169
|
+
* doubles, costs nothing. Against 80-digit references of the exact point, for
|
|
170
|
+
* heights from −6 000 km to 10 000 km: see the README. The centre of the Earth
|
|
171
|
+
* has no geodetic position, and a component that is not finite gives `NaN` in
|
|
172
|
+
* all three. Valid for coordinates within `[1e−150, 1e150]`: the squares stay
|
|
173
|
+
* finite, and far from the Earth the quartic, which depends only on `p/e⁴` and
|
|
174
|
+
* `q/e⁴`, is scaled by a power of two so its cubes do not overflow. O(1).
|
|
175
|
+
*/
|
|
176
|
+
export declare function geodeticFromEcef(out: Geodetic, point: ReadonlyVec3, ellipsoid: Ellipsoid): Geodetic;
|
|
177
|
+
/**
|
|
178
|
+
* Writes the Earth-centred coordinates of every geodetic triple of `input`
|
|
179
|
+
* (`[longitudeDeg, latitudeDeg, heightM, …]`) into `out` (as
|
|
180
|
+
* {@link ecefFromGeodetic}), the count taken from the length. `out` may be
|
|
181
|
+
* `input` (in place). O(n).
|
|
182
|
+
*
|
|
183
|
+
* @throws {RangeError} Unless both have the same length, a multiple of 3.
|
|
184
|
+
*/
|
|
185
|
+
export declare function ecefArrayFromGeodetic<T extends Float64Array>(out: T, input: Float64Array, ellipsoid: Ellipsoid): T;
|
|
186
|
+
/**
|
|
187
|
+
* Writes the geodetic triple of every Earth-centred point of `input` into `out`
|
|
188
|
+
* (as {@link geodeticFromEcef}), the count taken from the length. `out` may be
|
|
189
|
+
* `input` (in place). O(n).
|
|
190
|
+
*
|
|
191
|
+
* @throws {RangeError} Unless both have the same length, a multiple of 3.
|
|
192
|
+
*/
|
|
193
|
+
export declare function geodeticArrayFromEcef<T extends Float64Array>(out: T, input: Float64Array, ellipsoid: Ellipsoid): T;
|
|
194
|
+
//# sourceMappingURL=geodetic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geodetic.d.ts","sourceRoot":"","sources":["../src/geodetic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAI9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAY1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQhD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,MAAM;CACf,GACA,MAAM,CAAC,UAAU,CAAC,CAAC;AAEpB,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GAAG,SAAS;IACvC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