@math.gl/geospatial 3.5.6 → 3.6.0-alpha.2
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/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +22 -0
- package/dist/ellipsoid/ellipsoid.d.ts +68 -0
- package/dist/ellipsoid/ellipsoid.d.ts.map +1 -0
- package/dist/ellipsoid/ellipsoid.js +142 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts +5 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts.map +1 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.js +125 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts +3 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts.map +1 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.js +70 -0
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/ellipsoid/ellipsoid.js +13 -8
- package/dist/es5/ellipsoid/ellipsoid.js.map +1 -1
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js.map +1 -1
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js +5 -13
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/type-utils.js +24 -23
- package/dist/es5/type-utils.js.map +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/ellipsoid/ellipsoid.js +23 -8
- package/dist/esm/ellipsoid/ellipsoid.js.map +1 -1
- package/dist/esm/ellipsoid/helpers/ellipsoid-transform.js.map +1 -1
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js +6 -7
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/type-utils.js +24 -22
- package/dist/esm/type-utils.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/type-utils.d.ts +24 -0
- package/dist/type-utils.d.ts.map +1 -0
- package/dist/type-utils.js +96 -0
- package/package.json +5 -5
- package/src/{constants.js → constants.ts} +0 -0
- package/src/ellipsoid/{ellipsoid.js → ellipsoid.ts} +96 -40
- package/src/ellipsoid/helpers/{ellipsoid-transform.js → ellipsoid-transform.ts} +18 -13
- package/src/ellipsoid/helpers/{scale-to-geodetic-surface.js → scale-to-geodetic-surface.ts} +11 -7
- package/src/{index.js → index.ts} +0 -0
- package/src/type-utils.ts +154 -0
- package/dist/es5/ellipsoid/ellipsoid.d.ts +0 -95
- package/dist/es5/index.d.ts +0 -1
- package/dist/es5/type-utils.d.ts +0 -55
- package/dist/esm/ellipsoid/ellipsoid.d.ts +0 -95
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/type-utils.d.ts +0 -55
- package/src/ellipsoid/ellipsoid.d.ts +0 -95
- package/src/index.d.ts +0 -1
- package/src/type-utils.d.ts +0 -55
- package/src/type-utils.js +0 -71
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// This file is derived from the Cesium math library under Apache 2 license
|
|
2
|
+
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
|
+
|
|
4
|
+
import type {NumericArray} from '@math.gl/core';
|
|
5
|
+
import {Vector3, toRadians, toDegrees, config} from '@math.gl/core';
|
|
6
|
+
import {WGS84_CONSTANTS} from './constants';
|
|
7
|
+
|
|
8
|
+
type LngLatHeightObject = {
|
|
9
|
+
longitude: number;
|
|
10
|
+
latitude: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type XYZObject = {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
z: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Cartographic = LngLatHeightObject | XYZObject | NumericArray;
|
|
21
|
+
|
|
22
|
+
function identity(x: number): number {
|
|
23
|
+
return x;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const scratchVector = new Vector3();
|
|
27
|
+
|
|
28
|
+
export function fromCartographic(cartographic: Cartographic): number[];
|
|
29
|
+
export function fromCartographic<NumArrayT>(
|
|
30
|
+
cartographic: Cartographic,
|
|
31
|
+
result: NumArrayT,
|
|
32
|
+
map?: (x: number) => number
|
|
33
|
+
): NumArrayT;
|
|
34
|
+
export function fromCartographic(
|
|
35
|
+
cartographic: Cartographic,
|
|
36
|
+
result = [] as number[],
|
|
37
|
+
map = identity
|
|
38
|
+
): number[] {
|
|
39
|
+
if ('longitude' in cartographic) {
|
|
40
|
+
result[0] = map(cartographic.longitude);
|
|
41
|
+
result[1] = map(cartographic.latitude);
|
|
42
|
+
result[2] = cartographic.height;
|
|
43
|
+
} else if ('x' in cartographic) {
|
|
44
|
+
result[0] = map(cartographic.x);
|
|
45
|
+
result[1] = map(cartographic.y);
|
|
46
|
+
result[2] = cartographic.z;
|
|
47
|
+
} else {
|
|
48
|
+
result[0] = map(cartographic[0]);
|
|
49
|
+
result[1] = map(cartographic[1]);
|
|
50
|
+
result[2] = cartographic[2];
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];
|
|
56
|
+
export function fromCartographicToRadians<TArray>(
|
|
57
|
+
cartographic: Cartographic,
|
|
58
|
+
result: TArray
|
|
59
|
+
): TArray;
|
|
60
|
+
export function fromCartographicToRadians(
|
|
61
|
+
cartographic: Cartographic,
|
|
62
|
+
vector = [] as number[]
|
|
63
|
+
): number[] {
|
|
64
|
+
return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];
|
|
68
|
+
export function fromCartographicToDegrees<TArray>(
|
|
69
|
+
cartographic: Cartographic,
|
|
70
|
+
result: TArray
|
|
71
|
+
): TArray;
|
|
72
|
+
export function fromCartographicToDegrees(
|
|
73
|
+
cartographic: Cartographic,
|
|
74
|
+
vector = [] as number[]
|
|
75
|
+
): number[] {
|
|
76
|
+
return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function toCartographic<T extends Cartographic>(
|
|
80
|
+
vector: Readonly<NumericArray>,
|
|
81
|
+
cartographic: T,
|
|
82
|
+
map: (x: number) => number = identity
|
|
83
|
+
): T {
|
|
84
|
+
if ('longitude' in cartographic) {
|
|
85
|
+
cartographic.longitude = map(vector[0]);
|
|
86
|
+
cartographic.latitude = map(vector[1]);
|
|
87
|
+
cartographic.height = vector[2];
|
|
88
|
+
} else if ('x' in cartographic) {
|
|
89
|
+
cartographic.x = map(vector[0]);
|
|
90
|
+
cartographic.y = map(vector[1]);
|
|
91
|
+
cartographic.z = vector[2];
|
|
92
|
+
} else {
|
|
93
|
+
cartographic[0] = map(vector[0]);
|
|
94
|
+
cartographic[1] = map(vector[1]);
|
|
95
|
+
cartographic[2] = vector[2];
|
|
96
|
+
}
|
|
97
|
+
return cartographic;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function toCartographicFromRadians<T extends Cartographic>(
|
|
101
|
+
vector: Readonly<NumericArray>,
|
|
102
|
+
cartographic: T
|
|
103
|
+
): T {
|
|
104
|
+
return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function toCartographicFromDegrees<T extends Cartographic>(
|
|
108
|
+
vector: Readonly<NumericArray>,
|
|
109
|
+
cartographic: T
|
|
110
|
+
): T {
|
|
111
|
+
return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : identity);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Estimates if a vector is close to the surface of the WGS84 Ellipsoid
|
|
115
|
+
export function isWGS84(vector: Readonly<NumericArray>): boolean {
|
|
116
|
+
if (!vector) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
scratchVector.from(vector);
|
|
120
|
+
const {oneOverRadiiSquared, centerToleranceSquared} = WGS84_CONSTANTS;
|
|
121
|
+
const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
|
|
122
|
+
const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
|
|
123
|
+
const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];
|
|
124
|
+
return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
|
|
129
|
+
export function fromCartographic(cartographic: Cartographic, result?: number[]): number[];
|
|
130
|
+
export function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;
|
|
131
|
+
export function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];
|
|
132
|
+
export function fromCartographicToRadians(
|
|
133
|
+
cartographic: Cartographic,
|
|
134
|
+
result: TypedArray
|
|
135
|
+
): TypedArray;
|
|
136
|
+
export function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];
|
|
137
|
+
export function fromCartographicToDegrees(
|
|
138
|
+
cartographic: Cartographic,
|
|
139
|
+
result: TypedArray
|
|
140
|
+
): TypedArray;
|
|
141
|
+
|
|
142
|
+
export function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];
|
|
143
|
+
export function toCartographicFromRadians(
|
|
144
|
+
vector: number[] | TypedArray,
|
|
145
|
+
result: Cartographic
|
|
146
|
+
): number[];
|
|
147
|
+
export function toCartographicFromDegrees(
|
|
148
|
+
vector: number[] | TypedArray,
|
|
149
|
+
result: Cartographic
|
|
150
|
+
): number[];
|
|
151
|
+
|
|
152
|
+
// Estimates if a vector is close to the surface of the WGS84 Ellipsoid
|
|
153
|
+
export function isWGS84(vector: number[] | TypedArray): boolean;
|
|
154
|
+
*/
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {Vector3, Matrix4} from '@math.gl/core';
|
|
2
|
-
|
|
3
|
-
/** A quadratic surface defined in Cartesian coordinates by the equation
|
|
4
|
-
* `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used
|
|
5
|
-
* to represent the shape of planetary bodies.
|
|
6
|
-
*/
|
|
7
|
-
export default class Ellipsoid {
|
|
8
|
-
/** An Ellipsoid instance initialized to the WGS84 standard. */
|
|
9
|
-
static readonly WGS84: Ellipsoid;
|
|
10
|
-
|
|
11
|
-
readonly radii: Vector3;
|
|
12
|
-
readonly radiiSquared: Vector3;
|
|
13
|
-
readonly radiiToTheFourth: Vector3;
|
|
14
|
-
readonly oneOverRadii: Vector3;
|
|
15
|
-
readonly oneOverRadiiSquared: Vector3;
|
|
16
|
-
readonly minimumRadius: number;
|
|
17
|
-
readonly maximumRadius: number;
|
|
18
|
-
readonly centerToleranceSquared: number;
|
|
19
|
-
readonly squaredXOverSquaredZ: number;
|
|
20
|
-
|
|
21
|
-
/** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */
|
|
22
|
-
constructor(x: number, y: number, z: number);
|
|
23
|
-
constructor();
|
|
24
|
-
|
|
25
|
-
/** Compares this Ellipsoid against the provided Ellipsoid componentwise */
|
|
26
|
-
equals(right: Ellipsoid): boolean;
|
|
27
|
-
/** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */
|
|
28
|
-
toString(): string;
|
|
29
|
-
|
|
30
|
-
/** Converts the provided cartographic to Cartesian representation. */
|
|
31
|
-
cartographicToCartesian(cartographic: number[], result?: Vector3): Vector3;
|
|
32
|
-
cartographicToCartesian(cartographic: number[], result?: number[]): number[];
|
|
33
|
-
|
|
34
|
-
/** Converts the provided cartesian to cartographic (lng/lat/z) representation.
|
|
35
|
-
* The cartesian is undefined at the center of the ellipsoid. */
|
|
36
|
-
cartesianToCartographic(cartesian: number[], result: Vector3): Vector3;
|
|
37
|
-
cartesianToCartographic(cartesian: number[], result?: number[]): number[];
|
|
38
|
-
|
|
39
|
-
/** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes
|
|
40
|
-
* centered at the provided origin to the provided ellipsoid's fixed reference frame. */
|
|
41
|
-
eastNorthUpToFixedFrame(origin: number[], result?: Matrix4): Matrix4;
|
|
42
|
-
eastNorthUpToFixedFrame(origin: number[], result: number[]): number[];
|
|
43
|
-
|
|
44
|
-
/** Computes a 4x4 transformation matrix from a reference frame centered at
|
|
45
|
-
* the provided origin to the ellipsoid's fixed reference frame.
|
|
46
|
-
*/
|
|
47
|
-
localFrameToFixedFrame(
|
|
48
|
-
firstAxis: string,
|
|
49
|
-
secondAxis: string,
|
|
50
|
-
thirdAxis: string,
|
|
51
|
-
origin: number[],
|
|
52
|
-
result?: Matrix4
|
|
53
|
-
): Matrix4;
|
|
54
|
-
localFrameToFixedFrame(
|
|
55
|
-
firstAxis: string,
|
|
56
|
-
secondAxis: string,
|
|
57
|
-
thirdAxis: string,
|
|
58
|
-
origin: number[],
|
|
59
|
-
result?: number[]
|
|
60
|
-
): number[];
|
|
61
|
-
|
|
62
|
-
/** Computes the unit vector directed from the center of this ellipsoid toward
|
|
63
|
-
* the provided Cartesian position. */
|
|
64
|
-
geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
65
|
-
|
|
66
|
-
/** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */
|
|
67
|
-
geodeticSurfaceNormalCartographic(cartographic: number[], result?: number[]): number[];
|
|
68
|
-
|
|
69
|
-
/** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */
|
|
70
|
-
geodeticSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
71
|
-
|
|
72
|
-
/** Scales the provided Cartesian position along the geodetic surface normal
|
|
73
|
-
* so that it is on the surface of this ellipsoid. If the position is
|
|
74
|
-
* at the center of the ellipsoid, this function returns undefined. */
|
|
75
|
-
scaleToGeodeticSurface(cartesian: number[], result?: number[]): number[];
|
|
76
|
-
|
|
77
|
-
/** Scales the provided Cartesian position along the geocentric surface normal
|
|
78
|
-
* so that it is on the surface of this ellipsoid. */
|
|
79
|
-
scaleToGeocentricSurface(cartesian: number[], result?: number[]): number[];
|
|
80
|
-
|
|
81
|
-
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
82
|
-
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
83
|
-
transformPositionToScaledSpace(position: number[], result?: number[]): number[];
|
|
84
|
-
|
|
85
|
-
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
86
|
-
* its components by the result of `Ellipsoid#radii`. */
|
|
87
|
-
transformPositionFromScaledSpace(position: number[], result?: number[]): number[];
|
|
88
|
-
|
|
89
|
-
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
90
|
-
getSurfaceNormalIntersectionWithZAxis(
|
|
91
|
-
position: number[],
|
|
92
|
-
buffer?: number,
|
|
93
|
-
result?: number[]
|
|
94
|
-
): number[];
|
|
95
|
-
}
|
package/dist/es5/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {default as Ellipsoid} from './ellipsoid/ellipsoid';
|
package/dist/es5/type-utils.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// This file is derived from the Cesium math library under Apache 2 license
|
|
2
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
|
-
|
|
4
|
-
// import {Vector3} from '@math.gl/core';
|
|
5
|
-
|
|
6
|
-
type TypedArray =
|
|
7
|
-
| Int8Array
|
|
8
|
-
| Uint8Array
|
|
9
|
-
| Int16Array
|
|
10
|
-
| Uint16Array
|
|
11
|
-
| Int32Array
|
|
12
|
-
| Uint32Array
|
|
13
|
-
| Uint8ClampedArray
|
|
14
|
-
| Float32Array
|
|
15
|
-
| Float64Array;
|
|
16
|
-
|
|
17
|
-
type LngLatHeightObject = {
|
|
18
|
-
longitude: number;
|
|
19
|
-
latitude: number;
|
|
20
|
-
height: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type XYZObject = {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
z: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type Cartographic = LngLatHeightObject | XYZObject | number[] | TypedArray;
|
|
30
|
-
|
|
31
|
-
export function fromCartographic(cartographic: Cartographic, result?: number[]): number[];
|
|
32
|
-
export function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;
|
|
33
|
-
export function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];
|
|
34
|
-
export function fromCartographicToRadians(
|
|
35
|
-
cartographic: Cartographic,
|
|
36
|
-
result: TypedArray
|
|
37
|
-
): TypedArray;
|
|
38
|
-
export function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];
|
|
39
|
-
export function fromCartographicToDegrees(
|
|
40
|
-
cartographic: Cartographic,
|
|
41
|
-
result: TypedArray
|
|
42
|
-
): TypedArray;
|
|
43
|
-
|
|
44
|
-
export function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];
|
|
45
|
-
export function toCartographicFromRadians(
|
|
46
|
-
vector: number[] | TypedArray,
|
|
47
|
-
result: Cartographic
|
|
48
|
-
): number[];
|
|
49
|
-
export function toCartographicFromDegrees(
|
|
50
|
-
vector: number[] | TypedArray,
|
|
51
|
-
result: Cartographic
|
|
52
|
-
): number[];
|
|
53
|
-
|
|
54
|
-
// Estimates if a vector is close to the surface of the WGS84 Ellipsoid
|
|
55
|
-
export function isWGS84(vector: number[] | TypedArray): boolean;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {Vector3, Matrix4} from '@math.gl/core';
|
|
2
|
-
|
|
3
|
-
/** A quadratic surface defined in Cartesian coordinates by the equation
|
|
4
|
-
* `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used
|
|
5
|
-
* to represent the shape of planetary bodies.
|
|
6
|
-
*/
|
|
7
|
-
export default class Ellipsoid {
|
|
8
|
-
/** An Ellipsoid instance initialized to the WGS84 standard. */
|
|
9
|
-
static readonly WGS84: Ellipsoid;
|
|
10
|
-
|
|
11
|
-
readonly radii: Vector3;
|
|
12
|
-
readonly radiiSquared: Vector3;
|
|
13
|
-
readonly radiiToTheFourth: Vector3;
|
|
14
|
-
readonly oneOverRadii: Vector3;
|
|
15
|
-
readonly oneOverRadiiSquared: Vector3;
|
|
16
|
-
readonly minimumRadius: number;
|
|
17
|
-
readonly maximumRadius: number;
|
|
18
|
-
readonly centerToleranceSquared: number;
|
|
19
|
-
readonly squaredXOverSquaredZ: number;
|
|
20
|
-
|
|
21
|
-
/** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */
|
|
22
|
-
constructor(x: number, y: number, z: number);
|
|
23
|
-
constructor();
|
|
24
|
-
|
|
25
|
-
/** Compares this Ellipsoid against the provided Ellipsoid componentwise */
|
|
26
|
-
equals(right: Ellipsoid): boolean;
|
|
27
|
-
/** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */
|
|
28
|
-
toString(): string;
|
|
29
|
-
|
|
30
|
-
/** Converts the provided cartographic to Cartesian representation. */
|
|
31
|
-
cartographicToCartesian(cartographic: number[], result?: Vector3): Vector3;
|
|
32
|
-
cartographicToCartesian(cartographic: number[], result?: number[]): number[];
|
|
33
|
-
|
|
34
|
-
/** Converts the provided cartesian to cartographic (lng/lat/z) representation.
|
|
35
|
-
* The cartesian is undefined at the center of the ellipsoid. */
|
|
36
|
-
cartesianToCartographic(cartesian: number[], result: Vector3): Vector3;
|
|
37
|
-
cartesianToCartographic(cartesian: number[], result?: number[]): number[];
|
|
38
|
-
|
|
39
|
-
/** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes
|
|
40
|
-
* centered at the provided origin to the provided ellipsoid's fixed reference frame. */
|
|
41
|
-
eastNorthUpToFixedFrame(origin: number[], result?: Matrix4): Matrix4;
|
|
42
|
-
eastNorthUpToFixedFrame(origin: number[], result: number[]): number[];
|
|
43
|
-
|
|
44
|
-
/** Computes a 4x4 transformation matrix from a reference frame centered at
|
|
45
|
-
* the provided origin to the ellipsoid's fixed reference frame.
|
|
46
|
-
*/
|
|
47
|
-
localFrameToFixedFrame(
|
|
48
|
-
firstAxis: string,
|
|
49
|
-
secondAxis: string,
|
|
50
|
-
thirdAxis: string,
|
|
51
|
-
origin: number[],
|
|
52
|
-
result?: Matrix4
|
|
53
|
-
): Matrix4;
|
|
54
|
-
localFrameToFixedFrame(
|
|
55
|
-
firstAxis: string,
|
|
56
|
-
secondAxis: string,
|
|
57
|
-
thirdAxis: string,
|
|
58
|
-
origin: number[],
|
|
59
|
-
result?: number[]
|
|
60
|
-
): number[];
|
|
61
|
-
|
|
62
|
-
/** Computes the unit vector directed from the center of this ellipsoid toward
|
|
63
|
-
* the provided Cartesian position. */
|
|
64
|
-
geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
65
|
-
|
|
66
|
-
/** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */
|
|
67
|
-
geodeticSurfaceNormalCartographic(cartographic: number[], result?: number[]): number[];
|
|
68
|
-
|
|
69
|
-
/** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */
|
|
70
|
-
geodeticSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
71
|
-
|
|
72
|
-
/** Scales the provided Cartesian position along the geodetic surface normal
|
|
73
|
-
* so that it is on the surface of this ellipsoid. If the position is
|
|
74
|
-
* at the center of the ellipsoid, this function returns undefined. */
|
|
75
|
-
scaleToGeodeticSurface(cartesian: number[], result?: number[]): number[];
|
|
76
|
-
|
|
77
|
-
/** Scales the provided Cartesian position along the geocentric surface normal
|
|
78
|
-
* so that it is on the surface of this ellipsoid. */
|
|
79
|
-
scaleToGeocentricSurface(cartesian: number[], result?: number[]): number[];
|
|
80
|
-
|
|
81
|
-
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
82
|
-
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
83
|
-
transformPositionToScaledSpace(position: number[], result?: number[]): number[];
|
|
84
|
-
|
|
85
|
-
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
86
|
-
* its components by the result of `Ellipsoid#radii`. */
|
|
87
|
-
transformPositionFromScaledSpace(position: number[], result?: number[]): number[];
|
|
88
|
-
|
|
89
|
-
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
90
|
-
getSurfaceNormalIntersectionWithZAxis(
|
|
91
|
-
position: number[],
|
|
92
|
-
buffer?: number,
|
|
93
|
-
result?: number[]
|
|
94
|
-
): number[];
|
|
95
|
-
}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {default as Ellipsoid} from './ellipsoid/ellipsoid';
|
package/dist/esm/type-utils.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// This file is derived from the Cesium math library under Apache 2 license
|
|
2
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
|
-
|
|
4
|
-
// import {Vector3} from '@math.gl/core';
|
|
5
|
-
|
|
6
|
-
type TypedArray =
|
|
7
|
-
| Int8Array
|
|
8
|
-
| Uint8Array
|
|
9
|
-
| Int16Array
|
|
10
|
-
| Uint16Array
|
|
11
|
-
| Int32Array
|
|
12
|
-
| Uint32Array
|
|
13
|
-
| Uint8ClampedArray
|
|
14
|
-
| Float32Array
|
|
15
|
-
| Float64Array;
|
|
16
|
-
|
|
17
|
-
type LngLatHeightObject = {
|
|
18
|
-
longitude: number;
|
|
19
|
-
latitude: number;
|
|
20
|
-
height: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type XYZObject = {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
z: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type Cartographic = LngLatHeightObject | XYZObject | number[] | TypedArray;
|
|
30
|
-
|
|
31
|
-
export function fromCartographic(cartographic: Cartographic, result?: number[]): number[];
|
|
32
|
-
export function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;
|
|
33
|
-
export function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];
|
|
34
|
-
export function fromCartographicToRadians(
|
|
35
|
-
cartographic: Cartographic,
|
|
36
|
-
result: TypedArray
|
|
37
|
-
): TypedArray;
|
|
38
|
-
export function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];
|
|
39
|
-
export function fromCartographicToDegrees(
|
|
40
|
-
cartographic: Cartographic,
|
|
41
|
-
result: TypedArray
|
|
42
|
-
): TypedArray;
|
|
43
|
-
|
|
44
|
-
export function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];
|
|
45
|
-
export function toCartographicFromRadians(
|
|
46
|
-
vector: number[] | TypedArray,
|
|
47
|
-
result: Cartographic
|
|
48
|
-
): number[];
|
|
49
|
-
export function toCartographicFromDegrees(
|
|
50
|
-
vector: number[] | TypedArray,
|
|
51
|
-
result: Cartographic
|
|
52
|
-
): number[];
|
|
53
|
-
|
|
54
|
-
// Estimates if a vector is close to the surface of the WGS84 Ellipsoid
|
|
55
|
-
export function isWGS84(vector: number[] | TypedArray): boolean;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {Vector3, Matrix4} from '@math.gl/core';
|
|
2
|
-
|
|
3
|
-
/** A quadratic surface defined in Cartesian coordinates by the equation
|
|
4
|
-
* `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used
|
|
5
|
-
* to represent the shape of planetary bodies.
|
|
6
|
-
*/
|
|
7
|
-
export default class Ellipsoid {
|
|
8
|
-
/** An Ellipsoid instance initialized to the WGS84 standard. */
|
|
9
|
-
static readonly WGS84: Ellipsoid;
|
|
10
|
-
|
|
11
|
-
readonly radii: Vector3;
|
|
12
|
-
readonly radiiSquared: Vector3;
|
|
13
|
-
readonly radiiToTheFourth: Vector3;
|
|
14
|
-
readonly oneOverRadii: Vector3;
|
|
15
|
-
readonly oneOverRadiiSquared: Vector3;
|
|
16
|
-
readonly minimumRadius: number;
|
|
17
|
-
readonly maximumRadius: number;
|
|
18
|
-
readonly centerToleranceSquared: number;
|
|
19
|
-
readonly squaredXOverSquaredZ: number;
|
|
20
|
-
|
|
21
|
-
/** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */
|
|
22
|
-
constructor(x: number, y: number, z: number);
|
|
23
|
-
constructor();
|
|
24
|
-
|
|
25
|
-
/** Compares this Ellipsoid against the provided Ellipsoid componentwise */
|
|
26
|
-
equals(right: Ellipsoid): boolean;
|
|
27
|
-
/** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */
|
|
28
|
-
toString(): string;
|
|
29
|
-
|
|
30
|
-
/** Converts the provided cartographic to Cartesian representation. */
|
|
31
|
-
cartographicToCartesian(cartographic: number[], result?: Vector3): Vector3;
|
|
32
|
-
cartographicToCartesian(cartographic: number[], result?: number[]): number[];
|
|
33
|
-
|
|
34
|
-
/** Converts the provided cartesian to cartographic (lng/lat/z) representation.
|
|
35
|
-
* The cartesian is undefined at the center of the ellipsoid. */
|
|
36
|
-
cartesianToCartographic(cartesian: number[], result: Vector3): Vector3;
|
|
37
|
-
cartesianToCartographic(cartesian: number[], result?: number[]): number[];
|
|
38
|
-
|
|
39
|
-
/** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes
|
|
40
|
-
* centered at the provided origin to the provided ellipsoid's fixed reference frame. */
|
|
41
|
-
eastNorthUpToFixedFrame(origin: number[], result?: Matrix4): Matrix4;
|
|
42
|
-
eastNorthUpToFixedFrame(origin: number[], result: number[]): number[];
|
|
43
|
-
|
|
44
|
-
/** Computes a 4x4 transformation matrix from a reference frame centered at
|
|
45
|
-
* the provided origin to the ellipsoid's fixed reference frame.
|
|
46
|
-
*/
|
|
47
|
-
localFrameToFixedFrame(
|
|
48
|
-
firstAxis: string,
|
|
49
|
-
secondAxis: string,
|
|
50
|
-
thirdAxis: string,
|
|
51
|
-
origin: number[],
|
|
52
|
-
result?: Matrix4
|
|
53
|
-
): Matrix4;
|
|
54
|
-
localFrameToFixedFrame(
|
|
55
|
-
firstAxis: string,
|
|
56
|
-
secondAxis: string,
|
|
57
|
-
thirdAxis: string,
|
|
58
|
-
origin: number[],
|
|
59
|
-
result?: number[]
|
|
60
|
-
): number[];
|
|
61
|
-
|
|
62
|
-
/** Computes the unit vector directed from the center of this ellipsoid toward
|
|
63
|
-
* the provided Cartesian position. */
|
|
64
|
-
geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
65
|
-
|
|
66
|
-
/** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */
|
|
67
|
-
geodeticSurfaceNormalCartographic(cartographic: number[], result?: number[]): number[];
|
|
68
|
-
|
|
69
|
-
/** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */
|
|
70
|
-
geodeticSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
71
|
-
|
|
72
|
-
/** Scales the provided Cartesian position along the geodetic surface normal
|
|
73
|
-
* so that it is on the surface of this ellipsoid. If the position is
|
|
74
|
-
* at the center of the ellipsoid, this function returns undefined. */
|
|
75
|
-
scaleToGeodeticSurface(cartesian: number[], result?: number[]): number[];
|
|
76
|
-
|
|
77
|
-
/** Scales the provided Cartesian position along the geocentric surface normal
|
|
78
|
-
* so that it is on the surface of this ellipsoid. */
|
|
79
|
-
scaleToGeocentricSurface(cartesian: number[], result?: number[]): number[];
|
|
80
|
-
|
|
81
|
-
/** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
|
|
82
|
-
* its components by the result of `Ellipsoid#oneOverRadii` */
|
|
83
|
-
transformPositionToScaledSpace(position: number[], result?: number[]): number[];
|
|
84
|
-
|
|
85
|
-
/** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
|
|
86
|
-
* its components by the result of `Ellipsoid#radii`. */
|
|
87
|
-
transformPositionFromScaledSpace(position: number[], result?: number[]): number[];
|
|
88
|
-
|
|
89
|
-
/** Computes a point which is the intersection of the surface normal with the z-axis. */
|
|
90
|
-
getSurfaceNormalIntersectionWithZAxis(
|
|
91
|
-
position: number[],
|
|
92
|
-
buffer?: number,
|
|
93
|
-
result?: number[]
|
|
94
|
-
): number[];
|
|
95
|
-
}
|
package/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {default as Ellipsoid} from './ellipsoid/ellipsoid';
|
package/src/type-utils.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// This file is derived from the Cesium math library under Apache 2 license
|
|
2
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
|
-
|
|
4
|
-
// import {Vector3} from '@math.gl/core';
|
|
5
|
-
|
|
6
|
-
type TypedArray =
|
|
7
|
-
| Int8Array
|
|
8
|
-
| Uint8Array
|
|
9
|
-
| Int16Array
|
|
10
|
-
| Uint16Array
|
|
11
|
-
| Int32Array
|
|
12
|
-
| Uint32Array
|
|
13
|
-
| Uint8ClampedArray
|
|
14
|
-
| Float32Array
|
|
15
|
-
| Float64Array;
|
|
16
|
-
|
|
17
|
-
type LngLatHeightObject = {
|
|
18
|
-
longitude: number;
|
|
19
|
-
latitude: number;
|
|
20
|
-
height: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type XYZObject = {
|
|
24
|
-
x: number;
|
|
25
|
-
y: number;
|
|
26
|
-
z: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
type Cartographic = LngLatHeightObject | XYZObject | number[] | TypedArray;
|
|
30
|
-
|
|
31
|
-
export function fromCartographic(cartographic: Cartographic, result?: number[]): number[];
|
|
32
|
-
export function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;
|
|
33
|
-
export function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];
|
|
34
|
-
export function fromCartographicToRadians(
|
|
35
|
-
cartographic: Cartographic,
|
|
36
|
-
result: TypedArray
|
|
37
|
-
): TypedArray;
|
|
38
|
-
export function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];
|
|
39
|
-
export function fromCartographicToDegrees(
|
|
40
|
-
cartographic: Cartographic,
|
|
41
|
-
result: TypedArray
|
|
42
|
-
): TypedArray;
|
|
43
|
-
|
|
44
|
-
export function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];
|
|
45
|
-
export function toCartographicFromRadians(
|
|
46
|
-
vector: number[] | TypedArray,
|
|
47
|
-
result: Cartographic
|
|
48
|
-
): number[];
|
|
49
|
-
export function toCartographicFromDegrees(
|
|
50
|
-
vector: number[] | TypedArray,
|
|
51
|
-
result: Cartographic
|
|
52
|
-
): number[];
|
|
53
|
-
|
|
54
|
-
// Estimates if a vector is close to the surface of the WGS84 Ellipsoid
|
|
55
|
-
export function isWGS84(vector: number[] | TypedArray): boolean;
|
package/src/type-utils.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// This file is derived from the Cesium math library under Apache 2 license
|
|
2
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
|
-
|
|
4
|
-
import {Vector3, isArray, toRadians, toDegrees, config} from '@math.gl/core';
|
|
5
|
-
import {WGS84_CONSTANTS} from './constants';
|
|
6
|
-
|
|
7
|
-
const noop = (x) => x;
|
|
8
|
-
|
|
9
|
-
const scratchVector = new Vector3();
|
|
10
|
-
|
|
11
|
-
export function fromCartographic(cartographic, result, map = noop) {
|
|
12
|
-
if (isArray(cartographic)) {
|
|
13
|
-
result[0] = map(cartographic[0]);
|
|
14
|
-
result[1] = map(cartographic[1]);
|
|
15
|
-
result[2] = cartographic[2];
|
|
16
|
-
} else if ('longitude' in cartographic) {
|
|
17
|
-
result[0] = map(cartographic.longitude);
|
|
18
|
-
result[1] = map(cartographic.latitude);
|
|
19
|
-
result[2] = cartographic.height;
|
|
20
|
-
} else {
|
|
21
|
-
result[0] = map(cartographic.x);
|
|
22
|
-
result[1] = map(cartographic.y);
|
|
23
|
-
result[2] = cartographic.z;
|
|
24
|
-
}
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function fromCartographicToRadians(cartographic, vector = scratchVector) {
|
|
29
|
-
return fromCartographic(cartographic, vector, config._cartographicRadians ? noop : toRadians);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function fromCartographicToDegrees(cartographic, vector = scratchVector) {
|
|
33
|
-
return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : noop);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function toCartographic(vector, cartographic, map = noop) {
|
|
37
|
-
if (isArray(cartographic)) {
|
|
38
|
-
cartographic[0] = map(vector[0]);
|
|
39
|
-
cartographic[1] = map(vector[1]);
|
|
40
|
-
cartographic[2] = vector[2];
|
|
41
|
-
} else if ('longitude' in cartographic) {
|
|
42
|
-
cartographic.longitude = map(vector[0]);
|
|
43
|
-
cartographic.latitude = map(vector[1]);
|
|
44
|
-
cartographic.height = vector[2];
|
|
45
|
-
} else {
|
|
46
|
-
cartographic.x = map(vector[0]);
|
|
47
|
-
cartographic.y = map(vector[1]);
|
|
48
|
-
cartographic.z = vector[2];
|
|
49
|
-
}
|
|
50
|
-
return cartographic;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function toCartographicFromRadians(vector, cartographic) {
|
|
54
|
-
return toCartographic(vector, cartographic, config._cartographicRadians ? noop : toDegrees);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function toCartographicFromDegrees(vector, cartographic) {
|
|
58
|
-
return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : noop);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function isWGS84(vector) {
|
|
62
|
-
if (!vector) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
scratchVector.from(vector);
|
|
66
|
-
const {oneOverRadiiSquared, centerToleranceSquared} = WGS84_CONSTANTS;
|
|
67
|
-
const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
|
|
68
|
-
const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
|
|
69
|
-
const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];
|
|
70
|
-
return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
|
|
71
|
-
}
|