@math.gl/geospatial 5.0.0-alpha.10 → 5.0.0-alpha.12
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/LICENSE +7 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -2
- package/dist/constants.js.map +1 -1
- package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts.map +1 -1
- package/dist/ellipsoid-helpers/ellipsoid-transform.js +4 -2
- package/dist/ellipsoid-helpers/ellipsoid-transform.js.map +1 -1
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.d.ts +2 -0
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.d.ts.map +1 -1
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js +46 -13
- package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/ellipsoid-tangent-plane.d.ts.map +1 -1
- package/dist/ellipsoid-tangent-plane.js +4 -2
- package/dist/ellipsoid-tangent-plane.js.map +1 -1
- package/dist/ellipsoid.d.ts +11 -0
- package/dist/ellipsoid.d.ts.map +1 -1
- package/dist/ellipsoid.js +79 -7
- package/dist/ellipsoid.js.map +1 -1
- package/dist/index.cjs +180 -27
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lng-lat-rectangle.d.ts.map +1 -1
- package/dist/lng-lat-rectangle.js +4 -2
- package/dist/lng-lat-rectangle.js.map +1 -1
- package/dist/make-obb-from-region.d.ts.map +1 -1
- package/dist/make-obb-from-region.js +4 -2
- package/dist/make-obb-from-region.js.map +1 -1
- package/dist/type-utils.d.ts +2 -0
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/type-utils.js +25 -2
- package/dist/type-utils.js.map +1 -1
- package/package.json +5 -5
- package/src/constants.ts +4 -2
- package/src/ellipsoid-helpers/ellipsoid-transform.ts +4 -2
- package/src/ellipsoid-helpers/scale-to-geodetic-surface.ts +48 -14
- package/src/ellipsoid-tangent-plane.ts +4 -2
- package/src/ellipsoid.ts +94 -7
- package/src/index.ts +3 -1
- package/src/lng-lat-rectangle.ts +4 -2
- package/src/make-obb-from-region.ts +4 -2
- package/src/type-utils.ts +30 -2
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"version": "5.0.0-alpha.
|
|
9
|
+
"version": "5.0.0-alpha.12",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"webgl",
|
|
12
12
|
"javascript",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"src"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@math.gl/core": "5.0.0-alpha.
|
|
43
|
-
"@math.gl/culling": "5.0.0-alpha.
|
|
44
|
-
"@math.gl/types": "5.0.0-alpha.
|
|
42
|
+
"@math.gl/core": "5.0.0-alpha.12",
|
|
43
|
+
"@math.gl/culling": "5.0.0-alpha.12",
|
|
44
|
+
"@math.gl/types": "5.0.0-alpha.12"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "9f9ed72b110b898a5e2df55984b6cff67f8feab2"
|
|
47
47
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
|
|
4
6
|
|
|
5
7
|
// This file is derived from the Cesium math library under Apache 2 license
|
|
6
8
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
|
|
4
6
|
|
|
5
7
|
import {NumericArray} from '@math.gl/types';
|
|
6
8
|
import {Vector3, assert, equals as equalsEpsilon} from '@math.gl/core';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms. Original math.gl follow-up bounds Newton iteration and commits numeric components without a temporary array.
|
|
4
6
|
|
|
5
7
|
/* eslint-disable */
|
|
6
|
-
import {Vector3, _MathUtils} from '@math.gl/core';
|
|
8
|
+
import {Vector3, _MathUtils, isArray} from '@math.gl/core';
|
|
7
9
|
import type {Ellipsoid} from '../ellipsoid';
|
|
8
10
|
|
|
9
11
|
const scratchVector = new Vector3();
|
|
@@ -20,11 +22,15 @@ export function scaleToGeodeticSurface(
|
|
|
20
22
|
): number[] {
|
|
21
23
|
const {oneOverRadii, oneOverRadiiSquared, centerToleranceSquared} = ellipsoid;
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const positionX =
|
|
26
|
-
const positionY =
|
|
27
|
-
const positionZ =
|
|
25
|
+
// Snapshot numeric inputs before touching scratch or debug-mode vectors.
|
|
26
|
+
const object = cartesian as unknown as {x: number; y: number; z: number};
|
|
27
|
+
const positionX = 'x' in cartesian ? object.x : cartesian[0];
|
|
28
|
+
const positionY = 'x' in cartesian ? object.y : cartesian[1];
|
|
29
|
+
const positionZ = 'x' in cartesian ? object.z : cartesian[2];
|
|
30
|
+
if (!Number.isFinite(positionX) || !Number.isFinite(positionY) || !Number.isFinite(positionZ)) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
scratchVector.set(positionX, positionY, positionZ);
|
|
28
34
|
|
|
29
35
|
const oneOverRadiiX = oneOverRadii.x;
|
|
30
36
|
const oneOverRadiiY = oneOverRadii.y;
|
|
@@ -39,17 +45,17 @@ export function scaleToGeodeticSurface(
|
|
|
39
45
|
const ratio = Math.sqrt(1.0 / squaredNorm);
|
|
40
46
|
|
|
41
47
|
// When very close to center or at center
|
|
42
|
-
if (!Number.isFinite(ratio)) {
|
|
48
|
+
if (!Number.isFinite(ratio) || !Number.isFinite(squaredNorm)) {
|
|
43
49
|
return undefined;
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
// As an initial approximation, assume that the radial intersection is the projection point.
|
|
47
53
|
const intersection = scaleToGeodeticSurfaceIntersection;
|
|
48
|
-
intersection.
|
|
54
|
+
intersection.set(positionX, positionY, positionZ).scale(ratio);
|
|
49
55
|
|
|
50
56
|
// If the position is near the center, the iteration will not converge.
|
|
51
57
|
if (squaredNorm < centerToleranceSquared) {
|
|
52
|
-
return intersection.
|
|
58
|
+
return writeResult(result, intersection.x, intersection.y, intersection.z);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
|
|
@@ -74,7 +80,8 @@ export function scaleToGeodeticSurface(
|
|
|
74
80
|
let zMultiplier;
|
|
75
81
|
let func;
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
// Bound the original Newton iteration; unsupported inputs leave caller output untouched.
|
|
84
|
+
for (let iteration = 0; iteration < 64; iteration++) {
|
|
78
85
|
lambda -= correction;
|
|
79
86
|
|
|
80
87
|
xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);
|
|
@@ -91,6 +98,17 @@ export function scaleToGeodeticSurface(
|
|
|
91
98
|
|
|
92
99
|
func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;
|
|
93
100
|
|
|
101
|
+
if (!Number.isFinite(func)) return undefined;
|
|
102
|
+
if (Math.abs(func) <= _MathUtils.EPSILON12) {
|
|
103
|
+
// Numeric components avoid the former temporary multiplier array.
|
|
104
|
+
return writeResult(
|
|
105
|
+
result,
|
|
106
|
+
positionX * xMultiplier,
|
|
107
|
+
positionY * yMultiplier,
|
|
108
|
+
positionZ * zMultiplier
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
94
112
|
// "denominator" here refers to the use of this expression in the velocity and acceleration
|
|
95
113
|
// computations in the sections to follow.
|
|
96
114
|
const denominator =
|
|
@@ -100,8 +118,24 @@ export function scaleToGeodeticSurface(
|
|
|
100
118
|
|
|
101
119
|
const derivative = -2.0 * denominator;
|
|
102
120
|
|
|
121
|
+
if (!Number.isFinite(derivative) || derivative === 0) return undefined;
|
|
103
122
|
correction = func / derivative;
|
|
104
|
-
|
|
123
|
+
if (!Number.isFinite(correction)) return undefined;
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
105
127
|
|
|
106
|
-
|
|
128
|
+
/** Original numeric commit: application setters cannot overwrite remaining scratch ordinates. */
|
|
129
|
+
export function writeResult(result: number[], x: number, y: number, z: number): number[] {
|
|
130
|
+
if (isArray(result)) {
|
|
131
|
+
result[0] = x;
|
|
132
|
+
result[1] = y;
|
|
133
|
+
result[2] = z;
|
|
134
|
+
} else {
|
|
135
|
+
const point = result as unknown as {x: number; y: number; z: number};
|
|
136
|
+
point.x = x;
|
|
137
|
+
point.y = y;
|
|
138
|
+
point.z = z;
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
107
141
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
|
|
4
6
|
|
|
5
7
|
// This file is derived from the Cesium library under Apache 2 license
|
|
6
8
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
package/src/ellipsoid.ts
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms. Original math.gl follow-up uses stable atan2 latitude and numeric cartographic output.
|
|
4
6
|
|
|
5
7
|
// This file is derived from the Cesium math library under Apache 2 license
|
|
6
8
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
7
9
|
|
|
8
10
|
/* eslint-disable */
|
|
9
11
|
import {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray} from '@math.gl/core';
|
|
12
|
+
import type {SpheroidParameters} from '@math.gl/types';
|
|
13
|
+
import {
|
|
14
|
+
spheroidToCartesian,
|
|
15
|
+
cartesianToSpheroid,
|
|
16
|
+
type SpheroidGeometry
|
|
17
|
+
} from '@math.gl/core/spheroid';
|
|
10
18
|
import * as vec3 from '@math.gl/core/vec3';
|
|
11
19
|
|
|
12
20
|
import {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from './constants';
|
|
13
|
-
import {fromCartographicToRadians,
|
|
21
|
+
import {fromCartographicToRadians, toCartographicFromRadiansComponents} from './type-utils';
|
|
14
22
|
|
|
15
23
|
import type {AxisDirection} from './ellipsoid-helpers/ellipsoid-transform';
|
|
16
24
|
import {localFrameToFixedFrame} from './ellipsoid-helpers/ellipsoid-transform';
|
|
17
|
-
import {scaleToGeodeticSurface} from './ellipsoid-helpers/scale-to-geodetic-surface';
|
|
25
|
+
import {scaleToGeodeticSurface, writeResult} from './ellipsoid-helpers/scale-to-geodetic-surface';
|
|
18
26
|
|
|
27
|
+
const spheroidScratch = {x: 0, y: 0, z: 0};
|
|
19
28
|
const scratchVector = new Vector3();
|
|
20
29
|
const scratchNormal = new Vector3();
|
|
21
30
|
const scratchK = new Vector3();
|
|
@@ -32,6 +41,15 @@ export class Ellipsoid {
|
|
|
32
41
|
/** An Ellipsoid instance initialized to the WGS84 standard. */
|
|
33
42
|
static readonly WGS84: Ellipsoid = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
|
|
34
43
|
|
|
44
|
+
/** Construct from two-axis geometry, including normalized projection ellipsoids.
|
|
45
|
+
* The equatorial X/Y radii are equal; no CRS or datum information is inferred.
|
|
46
|
+
*/
|
|
47
|
+
static fromSpheroid(parameters: SpheroidParameters): Ellipsoid {
|
|
48
|
+
const {semiMajorAxis, semiMinorAxis} = parameters;
|
|
49
|
+
validateSpheroid(semiMajorAxis, semiMinorAxis);
|
|
50
|
+
return new Ellipsoid(semiMajorAxis, semiMajorAxis, semiMinorAxis);
|
|
51
|
+
}
|
|
52
|
+
|
|
35
53
|
readonly radii: Vector3;
|
|
36
54
|
readonly radiiSquared: Vector3;
|
|
37
55
|
readonly radiiToTheFourth: Vector3;
|
|
@@ -41,6 +59,7 @@ export class Ellipsoid {
|
|
|
41
59
|
readonly maximumRadius: number;
|
|
42
60
|
readonly centerToleranceSquared: number = _MathUtils.EPSILON1;
|
|
43
61
|
readonly squaredXOverSquaredZ: number;
|
|
62
|
+
private readonly spheroidGeometry?: SpheroidGeometry;
|
|
44
63
|
|
|
45
64
|
/** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */
|
|
46
65
|
constructor(x: number, y: number, z: number);
|
|
@@ -77,9 +96,33 @@ export class Ellipsoid {
|
|
|
77
96
|
this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
|
|
78
97
|
}
|
|
79
98
|
|
|
99
|
+
// Setup only: retain the three-radius path for unsupported/lossy shapes.
|
|
100
|
+
if (
|
|
101
|
+
x === y &&
|
|
102
|
+
z > 0 &&
|
|
103
|
+
z <= x &&
|
|
104
|
+
Number.isFinite(this.radiiSquared.x) &&
|
|
105
|
+
this.radiiSquared.z > 0
|
|
106
|
+
)
|
|
107
|
+
this.spheroidGeometry = Object.freeze({
|
|
108
|
+
semiMajorAxis: x,
|
|
109
|
+
semiMinorAxis: z,
|
|
110
|
+
eccentricitySquared: 1 - this.radiiSquared.z / this.radiiSquared.x
|
|
111
|
+
});
|
|
80
112
|
Object.freeze(this);
|
|
81
113
|
}
|
|
82
114
|
|
|
115
|
+
/** Return an owned geometry snapshot for a sphere or oblate spheroid.
|
|
116
|
+
* Triaxial, prolate and degenerate ellipsoids cannot be represented by this contract.
|
|
117
|
+
* Call during setup, outside coordinate loops.
|
|
118
|
+
*/
|
|
119
|
+
toSpheroid(): SpheroidParameters {
|
|
120
|
+
const {x, y, z} = this.radii;
|
|
121
|
+
if (x !== y) throw new Error('Spheroid requires equal X/Y radii');
|
|
122
|
+
validateSpheroid(x, z);
|
|
123
|
+
return Object.freeze({semiMajorAxis: x, semiMinorAxis: z});
|
|
124
|
+
}
|
|
125
|
+
|
|
83
126
|
/** Compares this Ellipsoid against the provided Ellipsoid componentwise */
|
|
84
127
|
equals(right: Ellipsoid): boolean {
|
|
85
128
|
return this === right || Boolean(right && this.radii.equals(right.radii));
|
|
@@ -98,6 +141,14 @@ export class Ellipsoid {
|
|
|
98
141
|
cartographicToCartesian(cartographic: number[], result?: number[]): number[];
|
|
99
142
|
|
|
100
143
|
cartographicToCartesian(cartographic: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
144
|
+
if (this.spheroidGeometry) {
|
|
145
|
+
const llh = fromCartographicToRadians(cartographic, scratchCartesian);
|
|
146
|
+
spheroidScratch.x = llh[0];
|
|
147
|
+
spheroidScratch.y = llh[1];
|
|
148
|
+
spheroidScratch.z = llh[2];
|
|
149
|
+
if (!spheroidToCartesian(spheroidScratch, this.spheroidGeometry)) return undefined;
|
|
150
|
+
return writeResult(result, spheroidScratch.x, spheroidScratch.y, spheroidScratch.z);
|
|
151
|
+
}
|
|
101
152
|
const normal = scratchNormal;
|
|
102
153
|
const k = scratchK;
|
|
103
154
|
|
|
@@ -123,7 +174,36 @@ export class Ellipsoid {
|
|
|
123
174
|
cartesianToCartographic(cartesian: Readonly<NumericArray>, result?: number[]): number[];
|
|
124
175
|
|
|
125
176
|
cartesianToCartographic(cartesian: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
126
|
-
|
|
177
|
+
const object = cartesian as unknown as {x: number; y: number; z: number};
|
|
178
|
+
const x = 'x' in cartesian ? object.x : cartesian[0];
|
|
179
|
+
const y = 'x' in cartesian ? object.y : cartesian[1];
|
|
180
|
+
const z = 'x' in cartesian ? object.z : cartesian[2];
|
|
181
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) return undefined;
|
|
182
|
+
// Shared inverse is qualified for the unambiguous surface/exterior domain.
|
|
183
|
+
// Interior/radial-fallback and non-spheroid behavior retain the Cesium kernel.
|
|
184
|
+
const a = this.radii.x,
|
|
185
|
+
b = this.radii.z;
|
|
186
|
+
const normSquared = (x / a) ** 2 + (y / a) ** 2 + (z / b) ** 2;
|
|
187
|
+
if (
|
|
188
|
+
this.spheroidGeometry &&
|
|
189
|
+
Number.isFinite(normSquared) &&
|
|
190
|
+
normSquared >= 1 - 16 * Number.EPSILON &&
|
|
191
|
+
Number.isFinite(x * x + y * y + z * z)
|
|
192
|
+
) {
|
|
193
|
+
spheroidScratch.x = x;
|
|
194
|
+
spheroidScratch.y = y;
|
|
195
|
+
spheroidScratch.z = z;
|
|
196
|
+
if (!cartesianToSpheroid(spheroidScratch, this.spheroidGeometry)) return undefined;
|
|
197
|
+
// Preserve signed-zero atan2 at exact poles rather than projection's canonical zero.
|
|
198
|
+
const longitude = x === 0 && y === 0 ? Math.atan2(y, x) : spheroidScratch.x;
|
|
199
|
+
return toCartographicFromRadiansComponents(
|
|
200
|
+
longitude,
|
|
201
|
+
spheroidScratch.y,
|
|
202
|
+
spheroidScratch.z,
|
|
203
|
+
result
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
scratchCartesian.set(x, y, z);
|
|
127
207
|
const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
|
|
128
208
|
|
|
129
209
|
if (!point) {
|
|
@@ -136,10 +216,11 @@ export class Ellipsoid {
|
|
|
136
216
|
h.copy(scratchCartesian).subtract(point);
|
|
137
217
|
|
|
138
218
|
const longitude = Math.atan2(normal.y, normal.x);
|
|
139
|
-
|
|
219
|
+
// atan2 retains latitude precision when the normal is almost vertical.
|
|
220
|
+
const latitude = Math.atan2(normal.z, Math.hypot(normal.x, normal.y));
|
|
140
221
|
const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);
|
|
141
222
|
|
|
142
|
-
return
|
|
223
|
+
return toCartographicFromRadiansComponents(longitude, latitude, height, result);
|
|
143
224
|
}
|
|
144
225
|
|
|
145
226
|
/** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes
|
|
@@ -279,3 +360,9 @@ export class Ellipsoid {
|
|
|
279
360
|
return scratchPosition.set(0.0, 0.0, z).to(result);
|
|
280
361
|
}
|
|
281
362
|
}
|
|
363
|
+
|
|
364
|
+
// Original parameter adapter; conversion and surface kernels above retain Cesium attribution.
|
|
365
|
+
function validateSpheroid(a: number, b: number): void {
|
|
366
|
+
if (!Number.isFinite(a) || !Number.isFinite(b) || a <= 0 || b <= 0 || b > a)
|
|
367
|
+
throw new Error('Spheroid requires finite positive axes with semiMinorAxis <= semiMajorAxis');
|
|
368
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
export {Ellipsoid} from './ellipsoid';
|
|
6
6
|
export {EllipsoidTangentPlane} from './ellipsoid-tangent-plane';
|
|
@@ -8,3 +8,5 @@ export {LngLatRectangle} from './lng-lat-rectangle';
|
|
|
8
8
|
export {makeOBBFromRegion} from './make-obb-from-region';
|
|
9
9
|
export type {GeodeticRegion, MakeOBBFromRegionOptions} from './make-obb-from-region';
|
|
10
10
|
export {isWGS84} from './type-utils';
|
|
11
|
+
|
|
12
|
+
export type {SpheroidParameters} from '@math.gl/types';
|
package/src/lng-lat-rectangle.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
|
|
4
6
|
|
|
5
7
|
// This file is derived from the Cesium library under Apache 2 license
|
|
6
8
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms.
|
|
4
6
|
|
|
5
7
|
// This file is derived from the Cesium math library under Apache 2 license
|
|
6
8
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
package/src/type-utils.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// math.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright 2011-2018 CesiumJS Contributors
|
|
4
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
5
|
+
// SPDX-FileComment: Derived from Cesium. See the repository LICENSE for upstream attribution and Apache-2.0 terms. The numeric-component cartographic adapter is original math.gl code.
|
|
4
6
|
|
|
5
7
|
// This file is derived from the Cesium math library under Apache 2 license
|
|
6
8
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
@@ -114,6 +116,32 @@ export function toCartographicFromRadians<T extends Cartographic>(
|
|
|
114
116
|
return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);
|
|
115
117
|
}
|
|
116
118
|
|
|
119
|
+
/** Original numeric adapter: snapshot values before writing application-owned outputs. */
|
|
120
|
+
export function toCartographicFromRadiansComponents<T extends Cartographic>(
|
|
121
|
+
longitude: number,
|
|
122
|
+
latitude: number,
|
|
123
|
+
height: number,
|
|
124
|
+
cartographic: T
|
|
125
|
+
): T {
|
|
126
|
+
const map = config._cartographicRadians ? identity : toDegrees;
|
|
127
|
+
const mappedLongitude = map(longitude),
|
|
128
|
+
mappedLatitude = map(latitude);
|
|
129
|
+
if ('longitude' in cartographic) {
|
|
130
|
+
cartographic.longitude = mappedLongitude;
|
|
131
|
+
cartographic.latitude = mappedLatitude;
|
|
132
|
+
cartographic.height = height;
|
|
133
|
+
} else if ('x' in cartographic) {
|
|
134
|
+
cartographic.x = mappedLongitude;
|
|
135
|
+
cartographic.y = mappedLatitude;
|
|
136
|
+
cartographic.z = height;
|
|
137
|
+
} else {
|
|
138
|
+
cartographic[0] = mappedLongitude;
|
|
139
|
+
cartographic[1] = mappedLatitude;
|
|
140
|
+
cartographic[2] = height;
|
|
141
|
+
}
|
|
142
|
+
return cartographic;
|
|
143
|
+
}
|
|
144
|
+
|
|
117
145
|
export function toCartographicFromDegrees<T extends Cartographic>(
|
|
118
146
|
vector: Readonly<NumericArray>,
|
|
119
147
|
cartographic: T
|