@math.gl/geospatial 3.6.2 → 4.0.0-alpha.1
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/{esm/constants.js → constants.js} +0 -0
- package/dist/constants.js.map +1 -0
- package/dist/ellipsoid/ellipsoid.d.ts +8 -7
- package/dist/ellipsoid/ellipsoid.d.ts.map +1 -1
- package/dist/{esm/ellipsoid → ellipsoid}/ellipsoid.js +4 -5
- package/dist/ellipsoid/ellipsoid.js.map +1 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts +3 -3
- package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts.map +1 -1
- package/dist/{esm/ellipsoid → ellipsoid}/helpers/ellipsoid-transform.js +0 -0
- package/dist/ellipsoid/helpers/ellipsoid-transform.js.map +1 -0
- package/dist/{esm/ellipsoid → ellipsoid}/helpers/scale-to-geodetic-surface.js +0 -0
- package/dist/ellipsoid/helpers/scale-to-geodetic-surface.js.map +1 -0
- package/dist/index.cjs +407 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/type-utils.d.ts +9 -9
- package/dist/type-utils.d.ts.map +1 -1
- package/dist/{esm/type-utils.js → type-utils.js} +1 -1
- package/dist/type-utils.js.map +1 -0
- package/package.json +7 -6
- package/src/ellipsoid/ellipsoid.ts +31 -31
- package/src/ellipsoid/helpers/ellipsoid-transform.ts +12 -10
- package/src/type-utils.ts +15 -9
- package/dist/es5/constants.js +0 -22
- package/dist/es5/constants.js.map +0 -1
- package/dist/es5/ellipsoid/ellipsoid.js +0 -210
- package/dist/es5/ellipsoid/ellipsoid.js.map +0 -1
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js +0 -134
- package/dist/es5/ellipsoid/helpers/ellipsoid-transform.js.map +0 -1
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js +0 -74
- package/dist/es5/ellipsoid/helpers/scale-to-geodetic-surface.js.map +0 -1
- package/dist/es5/index.js +0 -24
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/type-utils.js +0 -96
- package/dist/es5/type-utils.js.map +0 -1
- package/dist/esm/constants.js.map +0 -1
- package/dist/esm/ellipsoid/ellipsoid.js.map +0 -1
- package/dist/esm/ellipsoid/helpers/ellipsoid-transform.js.map +0 -1
- package/dist/esm/ellipsoid/helpers/scale-to-geodetic-surface.js.map +0 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/type-utils.js.map +0 -1
package/dist/type-utils.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { NumericArray } from '@math.gl/core';
|
|
2
|
-
|
|
2
|
+
type LngLatHeightObject = {
|
|
3
3
|
longitude: number;
|
|
4
4
|
latitude: number;
|
|
5
5
|
height: number;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type XYZObject = {
|
|
8
8
|
x: number;
|
|
9
9
|
y: number;
|
|
10
10
|
z: number;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
export declare function fromCartographic(cartographic: Cartographic): number[];
|
|
14
|
-
export declare function fromCartographic<NumArrayT>(cartographic: Cartographic
|
|
15
|
-
export declare function fromCartographicToRadians(cartographic: Cartographic
|
|
16
|
-
export declare function fromCartographicToRadians<TArray>(cartographic: Cartographic
|
|
17
|
-
export declare function fromCartographicToDegrees(cartographic: Cartographic
|
|
18
|
-
export declare function fromCartographicToDegrees<TArray>(cartographic: Cartographic
|
|
12
|
+
type Cartographic = LngLatHeightObject | XYZObject | NumericArray;
|
|
13
|
+
export declare function fromCartographic(cartographic: Readonly<Cartographic>): number[];
|
|
14
|
+
export declare function fromCartographic<NumArrayT>(cartographic: Readonly<Cartographic>, result: NumArrayT, map?: (x: number) => number): NumArrayT;
|
|
15
|
+
export declare function fromCartographicToRadians(cartographic: Readonly<Cartographic>, result?: number[]): number[];
|
|
16
|
+
export declare function fromCartographicToRadians<TArray>(cartographic: Readonly<Cartographic>, result: TArray): TArray;
|
|
17
|
+
export declare function fromCartographicToDegrees(cartographic: Readonly<Cartographic>, result?: number[]): number[];
|
|
18
|
+
export declare function fromCartographicToDegrees<TArray>(cartographic: Readonly<Cartographic>, result: TArray): TArray;
|
|
19
19
|
export declare function toCartographic<T extends Cartographic>(vector: Readonly<NumericArray>, cartographic: T, map?: (x: number) => number): T;
|
|
20
20
|
export declare function toCartographicFromRadians<T extends Cartographic>(vector: Readonly<NumericArray>, cartographic: T): T;
|
|
21
21
|
export declare function toCartographicFromDegrees<T extends Cartographic>(vector: Readonly<NumericArray>, cartographic: T): T;
|
package/dist/type-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAIhD,
|
|
1
|
+
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAIhD,KAAK,kBAAkB,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,KAAK,YAAY,GAAG,kBAAkB,GAAG,SAAS,GAAG,YAAY,CAAC;AAQlE,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,MAAM,EAAE,CAAC;AACjF,wBAAgB,gBAAgB,CAAC,SAAS,EACxC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,MAAM,EAAE,SAAS,EACjB,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAC1B,SAAS,CAAC;AAsBb,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,MAAM,EAAE,CAAC;AACZ,wBAAgB,yBAAyB,CAAC,MAAM,EAC9C,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,MAAM,CAAC;AAQV,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,MAAM,EAAE,CAAC;AACZ,wBAAgB,yBAAyB,CAAC,MAAM,EAC9C,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,MAAM,CAAC;AAQV,wBAAgB,cAAc,CAAC,CAAC,SAAS,YAAY,EACnD,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,YAAY,EAAE,CAAC,EACf,GAAG,GAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAiB,GACpC,CAAC,CAeH;AAED,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,YAAY,EAC9D,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,YAAY,EAAE,CAAC,GACd,CAAC,CAEH;AAED,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,YAAY,EAC9D,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC9B,YAAY,EAAE,CAAC,GACd,CAAC,CAEH;AAGD,wBAAgB,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,OAAO,CAU/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/type-utils.ts"],"names":["Vector3","toRadians","toDegrees","config","WGS84_CONSTANTS","identity","x","scratchVector","fromCartographic","cartographic","result","map","longitude","latitude","height","y","z","fromCartographicToRadians","vector","_cartographicRadians","fromCartographicToDegrees","toCartographic","toCartographicFromRadians","toCartographicFromDegrees","isWGS84","from","oneOverRadiiSquared","centerToleranceSquared","x2","y2","z2","Math","abs"],"mappings":"AAIA,SAAQA,OAAR,EAAiBC,SAAjB,EAA4BC,SAA5B,EAAuCC,MAAvC,QAAoD,eAApD;SACQC,e;;AAgBR,SAASC,QAAT,CAAkBC,CAAlB,EAAqC;AACnC,SAAOA,CAAP;AACD;;AAED,MAAMC,aAAa,GAAG,IAAIP,OAAJ,EAAtB;AAQA,OAAO,SAASQ,gBAAT,CACLC,YADK,EAELC,MAAM,GAAG,EAFJ,EAGLC,GAAG,GAAGN,QAHD,EAIK;AACV,MAAI,eAAeI,YAAnB,EAAiC;AAC/BC,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAACG,SAAd,CAAf;AACAF,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAACI,QAAd,CAAf;AACAH,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYD,YAAY,CAACK,MAAzB;AACD,GAJD,MAIO,IAAI,OAAOL,YAAX,EAAyB;AAC9BC,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAACH,CAAd,CAAf;AACAI,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAACM,CAAd,CAAf;AACAL,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYD,YAAY,CAACO,CAAzB;AACD,GAJM,MAIA;AACLN,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAAC,CAAD,CAAb,CAAf;AACAC,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYC,GAAG,CAACF,YAAY,CAAC,CAAD,CAAb,CAAf;AACAC,IAAAA,MAAM,CAAC,CAAD,CAAN,GAAYD,YAAY,CAAC,CAAD,CAAxB;AACD;;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AY,CAAC,CAAD,CAAZ,GAAkBS,MAAM,CAAC,CAAD,CAAxB;AACD;;AACD,SAAOT,YAAP;AACD;AAED,OAAO,SAASa,yBAAT,CACLJ,MADK,EAELT,YAFK,EAGF;AACH,SAAOY,cAAc,CAACH,MAAD,EAAST,YAAT,EAAuBN,MAAM,CAACgB,oBAAP,GAA8Bd,QAA9B,GAAyCH,SAAhE,CAArB;AACD;AAED,OAAO,SAASqB,yBAAT,CACLL,MADK,EAELT,YAFK,EAGF;AACH,SAAOY,cAAc,CAACH,MAAD,EAAST,YAAT,EAAuBN,MAAM,CAACgB,oBAAP,GAA8BlB,SAA9B,GAA0CI,QAAjE,CAArB;AACD;AAGD,OAAO,SAASmB,OAAT,CAAiBN,MAAjB,EAA0D;AAC/D,MAAI,CAACA,MAAL,EAAa;AACX,WAAO,KAAP;AACD;;AACDX,EAAAA,aAAa,CAACkB,IAAd,CAAmBP,MAAnB;AACA,QAAM;AAACQ,IAAAA,mBAAD;AAAsBC,IAAAA;AAAtB,MAAgDvB,eAAtD;AACA,QAAMwB,EAAE,GAAGV,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAlB,GAAwBQ,mBAAmB,CAAC,CAAD,CAAtD;AACA,QAAMG,EAAE,GAAGX,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAlB,GAAwBQ,mBAAmB,CAAC,CAAD,CAAtD;AACA,QAAMI,EAAE,GAAGZ,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAAlB,GAAwBQ,mBAAmB,CAAC,CAAD,CAAtD;AACA,SAAOK,IAAI,CAACC,GAAL,CAASJ,EAAE,GAAGC,EAAL,GAAUC,EAAV,GAAe,CAAxB,IAA6BH,sBAApC;AACD","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport type {NumericArray} from '@math.gl/core';\nimport {Vector3, toRadians, toDegrees, config} from '@math.gl/core';\nimport {WGS84_CONSTANTS} from './constants';\n\ntype LngLatHeightObject = {\n longitude: number;\n latitude: number;\n height: number;\n};\n\ntype XYZObject = {\n x: number;\n y: number;\n z: number;\n};\n\ntype Cartographic = LngLatHeightObject | XYZObject | NumericArray;\n\nfunction identity(x: number): number {\n return x;\n}\n\nconst scratchVector = new Vector3();\n\nexport function fromCartographic(cartographic: Readonly<Cartographic>): number[];\nexport function fromCartographic<NumArrayT>(\n cartographic: Readonly<Cartographic>,\n result: NumArrayT,\n map?: (x: number) => number\n): NumArrayT;\nexport function fromCartographic(\n cartographic: Readonly<Cartographic>,\n result = [] as number[],\n map = identity\n): number[] {\n if ('longitude' in cartographic) {\n result[0] = map(cartographic.longitude);\n result[1] = map(cartographic.latitude);\n result[2] = cartographic.height;\n } else if ('x' in cartographic) {\n result[0] = map(cartographic.x);\n result[1] = map(cartographic.y);\n result[2] = cartographic.z;\n } else {\n result[0] = map(cartographic[0]);\n result[1] = map(cartographic[1]);\n result[2] = cartographic[2];\n }\n return result;\n}\n\nexport function fromCartographicToRadians(\n cartographic: Readonly<Cartographic>,\n result?: number[]\n): number[];\nexport function fromCartographicToRadians<TArray>(\n cartographic: Readonly<Cartographic>,\n result: TArray\n): TArray;\nexport function fromCartographicToRadians(\n cartographic: Readonly<Cartographic>,\n vector = [] as number[]\n): number[] {\n return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);\n}\n\nexport function fromCartographicToDegrees(\n cartographic: Readonly<Cartographic>,\n result?: number[]\n): number[];\nexport function fromCartographicToDegrees<TArray>(\n cartographic: Readonly<Cartographic>,\n result: TArray\n): TArray;\nexport function fromCartographicToDegrees(\n cartographic: Readonly<Cartographic>,\n vector = [] as number[]\n): number[] {\n return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);\n}\n\nexport function toCartographic<T extends Cartographic>(\n vector: Readonly<NumericArray>,\n cartographic: T,\n map: (x: number) => number = identity\n): T {\n if ('longitude' in cartographic) {\n cartographic.longitude = map(vector[0]);\n cartographic.latitude = map(vector[1]);\n cartographic.height = vector[2];\n } else if ('x' in cartographic) {\n cartographic.x = map(vector[0]);\n cartographic.y = map(vector[1]);\n cartographic.z = vector[2];\n } else {\n cartographic[0] = map(vector[0]);\n cartographic[1] = map(vector[1]);\n cartographic[2] = vector[2];\n }\n return cartographic;\n}\n\nexport function toCartographicFromRadians<T extends Cartographic>(\n vector: Readonly<NumericArray>,\n cartographic: T\n): T {\n return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);\n}\n\nexport function toCartographicFromDegrees<T extends Cartographic>(\n vector: Readonly<NumericArray>,\n cartographic: T\n): T {\n return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : identity);\n}\n\n// Estimates if a vector is close to the surface of the WGS84 Ellipsoid\nexport function isWGS84(vector: Readonly<NumericArray>): boolean {\n if (!vector) {\n return false;\n }\n scratchVector.from(vector);\n const {oneOverRadiiSquared, centerToleranceSquared} = WGS84_CONSTANTS;\n const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];\n const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];\n const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];\n return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;\n}\n\n/*\n\nexport function fromCartographic(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;\nexport function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographicToRadians(\n cartographic: Cartographic,\n result: TypedArray\n): TypedArray;\nexport function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];\nexport function fromCartographicToDegrees(\n cartographic: Cartographic,\n result: TypedArray\n): TypedArray;\n\nexport function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];\nexport function toCartographicFromRadians(\n vector: number[] | TypedArray,\n result: Cartographic\n): number[];\nexport function toCartographicFromDegrees(\n vector: number[] | TypedArray,\n result: Cartographic\n): number[];\n\n// Estimates if a vector is close to the surface of the WGS84 Ellipsoid\nexport function isWGS84(vector: number[] | TypedArray): boolean;\n*/\n"],"file":"type-utils.js"}
|
package/package.json
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
"name": "@math.gl/geospatial",
|
|
3
3
|
"description": "Geospatial classes",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
8
|
-
"version": "
|
|
9
|
+
"version": "4.0.0-alpha.1",
|
|
9
10
|
"keywords": [
|
|
10
11
|
"webgl",
|
|
11
12
|
"javascript",
|
|
@@ -24,16 +25,16 @@
|
|
|
24
25
|
"url": "https://github.com/uber-web/math.gl.git"
|
|
25
26
|
},
|
|
26
27
|
"types": "dist/index.d.ts",
|
|
27
|
-
"main": "dist/
|
|
28
|
-
"module": "dist/
|
|
28
|
+
"main": "dist/index.cjs",
|
|
29
|
+
"module": "dist/index.js",
|
|
29
30
|
"files": [
|
|
30
31
|
"dist",
|
|
31
32
|
"src"
|
|
32
33
|
],
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@babel/runtime": "^7.12.0",
|
|
35
|
-
"@math.gl/core": "
|
|
36
|
-
"gl-matrix": "^3.4.
|
|
36
|
+
"@math.gl/core": "4.0.0-alpha.1",
|
|
37
|
+
"gl-matrix": "^3.4.3"
|
|
37
38
|
},
|
|
38
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "66f872ea615a3ef81431595727cdf58dcadf3670"
|
|
39
40
|
}
|
|
@@ -2,23 +2,16 @@
|
|
|
2
2
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
3
3
|
|
|
4
4
|
/* eslint-disable */
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
Matrix4,
|
|
8
|
-
toRadians,
|
|
9
|
-
toDegrees,
|
|
10
|
-
assert,
|
|
11
|
-
equals,
|
|
12
|
-
_MathUtils,
|
|
13
|
-
NumericArray
|
|
14
|
-
} from '@math.gl/core';
|
|
5
|
+
import {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray} from '@math.gl/core';
|
|
6
|
+
// @ts-ignore gl-matrix typings...
|
|
15
7
|
import * as vec3 from 'gl-matrix/vec3';
|
|
16
8
|
|
|
17
9
|
import {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';
|
|
18
10
|
import {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';
|
|
19
11
|
|
|
20
|
-
import
|
|
12
|
+
import type {AxisDirection} from './helpers/ellipsoid-transform';
|
|
21
13
|
import localFrameToFixedFrame from './helpers/ellipsoid-transform';
|
|
14
|
+
import scaleToGeodeticSurface from './helpers/scale-to-geodetic-surface';
|
|
22
15
|
|
|
23
16
|
const scratchVector = new Vector3();
|
|
24
17
|
const scratchNormal = new Vector3();
|
|
@@ -27,8 +20,6 @@ const scratchPosition = new Vector3();
|
|
|
27
20
|
const scratchHeight = new Vector3();
|
|
28
21
|
const scratchCartesian = new Vector3();
|
|
29
22
|
|
|
30
|
-
let wgs84;
|
|
31
|
-
|
|
32
23
|
/**
|
|
33
24
|
* A quadratic surface defined in Cartesian coordinates by the equation
|
|
34
25
|
* `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used
|
|
@@ -100,7 +91,7 @@ export default class Ellipsoid {
|
|
|
100
91
|
cartographicToCartesian(cartographic: number[], result: Vector3): Vector3;
|
|
101
92
|
cartographicToCartesian(cartographic: number[], result?: number[]): number[];
|
|
102
93
|
|
|
103
|
-
cartographicToCartesian(cartographic
|
|
94
|
+
cartographicToCartesian(cartographic: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
104
95
|
const normal = scratchNormal;
|
|
105
96
|
const k = scratchK;
|
|
106
97
|
|
|
@@ -120,10 +111,10 @@ export default class Ellipsoid {
|
|
|
120
111
|
|
|
121
112
|
/** Converts the provided cartesian to cartographic (lng/lat/z) representation.
|
|
122
113
|
* The cartesian is undefined at the center of the ellipsoid. */
|
|
123
|
-
cartesianToCartographic(cartesian:
|
|
124
|
-
cartesianToCartographic(cartesian:
|
|
114
|
+
cartesianToCartographic(cartesian: Readonly<NumericArray>, result: Vector3): Vector3;
|
|
115
|
+
cartesianToCartographic(cartesian: Readonly<NumericArray>, result?: number[]): number[];
|
|
125
116
|
|
|
126
|
-
cartesianToCartographic(cartesian
|
|
117
|
+
cartesianToCartographic(cartesian: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
127
118
|
scratchCartesian.from(cartesian);
|
|
128
119
|
const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
|
|
129
120
|
|
|
@@ -145,10 +136,10 @@ export default class Ellipsoid {
|
|
|
145
136
|
|
|
146
137
|
/** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes
|
|
147
138
|
* centered at the provided origin to the provided ellipsoid's fixed reference frame. */
|
|
148
|
-
eastNorthUpToFixedFrame(origin:
|
|
149
|
-
eastNorthUpToFixedFrame(origin:
|
|
139
|
+
eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result?: Matrix4): Matrix4;
|
|
140
|
+
eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result: number[]): number[];
|
|
150
141
|
|
|
151
|
-
eastNorthUpToFixedFrame(origin
|
|
142
|
+
eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result = new Matrix4()) {
|
|
152
143
|
return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);
|
|
153
144
|
}
|
|
154
145
|
|
|
@@ -156,23 +147,29 @@ export default class Ellipsoid {
|
|
|
156
147
|
* the provided origin to the ellipsoid's fixed reference frame.
|
|
157
148
|
*/
|
|
158
149
|
localFrameToFixedFrame(
|
|
159
|
-
firstAxis:
|
|
160
|
-
secondAxis:
|
|
161
|
-
thirdAxis:
|
|
150
|
+
firstAxis: AxisDirection,
|
|
151
|
+
secondAxis: AxisDirection,
|
|
152
|
+
thirdAxis: AxisDirection,
|
|
162
153
|
origin: Readonly<NumericArray>,
|
|
163
154
|
result?: Matrix4
|
|
164
155
|
): Matrix4;
|
|
165
156
|
localFrameToFixedFrame<Matrix4T>(
|
|
166
|
-
firstAxis:
|
|
167
|
-
secondAxis:
|
|
168
|
-
thirdAxis:
|
|
157
|
+
firstAxis: AxisDirection,
|
|
158
|
+
secondAxis: AxisDirection,
|
|
159
|
+
thirdAxis: AxisDirection,
|
|
169
160
|
origin: Readonly<NumericArray>,
|
|
170
161
|
result: number[]
|
|
171
162
|
): number[];
|
|
172
163
|
|
|
173
164
|
// Computes a 4x4 transformation matrix from a reference frame centered at
|
|
174
165
|
// the provided origin to the ellipsoid's fixed reference frame.
|
|
175
|
-
localFrameToFixedFrame(
|
|
166
|
+
localFrameToFixedFrame(
|
|
167
|
+
firstAxis: AxisDirection,
|
|
168
|
+
secondAxis: AxisDirection,
|
|
169
|
+
thirdAxis: AxisDirection,
|
|
170
|
+
origin: Readonly<NumericArray>,
|
|
171
|
+
result = new Matrix4()
|
|
172
|
+
) {
|
|
176
173
|
return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
177
174
|
}
|
|
178
175
|
|
|
@@ -180,14 +177,17 @@ export default class Ellipsoid {
|
|
|
180
177
|
* the provided Cartesian position. */
|
|
181
178
|
geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];
|
|
182
179
|
geocentricSurfaceNormal<NumArray>(cartesian: number[], result: NumArray): NumArray;
|
|
183
|
-
geocentricSurfaceNormal(cartesian
|
|
180
|
+
geocentricSurfaceNormal(cartesian: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
184
181
|
return scratchVector.from(cartesian).normalize().to(result);
|
|
185
182
|
}
|
|
186
183
|
|
|
187
184
|
/** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */
|
|
188
|
-
geodeticSurfaceNormalCartographic<NumArray>(
|
|
185
|
+
geodeticSurfaceNormalCartographic<NumArray>(
|
|
186
|
+
cartographic: Readonly<NumericArray>,
|
|
187
|
+
result: NumArray
|
|
188
|
+
): NumArray;
|
|
189
189
|
geodeticSurfaceNormalCartographic(cartographic: number[]): number[];
|
|
190
|
-
geodeticSurfaceNormalCartographic(cartographic
|
|
190
|
+
geodeticSurfaceNormalCartographic(cartographic: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
191
191
|
const cartographicVectorRadians = fromCartographicToRadians(cartographic);
|
|
192
192
|
|
|
193
193
|
const longitude = cartographicVectorRadians[0];
|
|
@@ -205,7 +205,7 @@ export default class Ellipsoid {
|
|
|
205
205
|
/** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */
|
|
206
206
|
geodeticSurfaceNormal<NumArrayT>(cartesian: number[], result: NumArrayT): NumArrayT;
|
|
207
207
|
geodeticSurfaceNormal(cartesian: number[]): number[];
|
|
208
|
-
geodeticSurfaceNormal(cartesian
|
|
208
|
+
geodeticSurfaceNormal(cartesian: Readonly<NumericArray>, result = [0, 0, 0]) {
|
|
209
209
|
return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Vector3, assert, equals as equalsEpsilon} from '@math.gl/core';
|
|
1
|
+
import {NumericArray, Vector3, assert, equals as equalsEpsilon} from '@math.gl/core';
|
|
2
2
|
|
|
3
3
|
import type Ellipsoid from '../ellipsoid';
|
|
4
4
|
|
|
@@ -6,8 +6,13 @@ const EPSILON14 = 1e-14;
|
|
|
6
6
|
|
|
7
7
|
const scratchOrigin = new Vector3();
|
|
8
8
|
|
|
9
|
+
export type AxisDirection = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';
|
|
10
|
+
|
|
9
11
|
// Caclulate third axis from given two axii
|
|
10
|
-
const VECTOR_PRODUCT_LOCAL_FRAME
|
|
12
|
+
const VECTOR_PRODUCT_LOCAL_FRAME: Record<
|
|
13
|
+
AxisDirection,
|
|
14
|
+
Partial<Record<AxisDirection, AxisDirection>>
|
|
15
|
+
> = {
|
|
11
16
|
up: {
|
|
12
17
|
south: 'east',
|
|
13
18
|
north: 'west',
|
|
@@ -68,22 +73,19 @@ const scratchVector1 = new Vector3();
|
|
|
68
73
|
const scratchVector2 = new Vector3();
|
|
69
74
|
const scratchVector3 = new Vector3();
|
|
70
75
|
|
|
71
|
-
type Axis = 'up' | 'down' | 'north' | 'east' | 'south' | 'west';
|
|
72
|
-
|
|
73
76
|
// Computes a 4x4 transformation matrix from a reference frame
|
|
74
77
|
// centered at the provided origin to the provided ellipsoid's fixed reference frame.
|
|
75
78
|
// eslint-disable-next-line max-statements, max-params, complexity
|
|
76
79
|
export default function localFrameToFixedFrame(
|
|
77
80
|
ellipsoid: Ellipsoid,
|
|
78
|
-
firstAxis:
|
|
79
|
-
secondAxis:
|
|
80
|
-
thirdAxis:
|
|
81
|
-
cartesianOrigin:
|
|
81
|
+
firstAxis: AxisDirection,
|
|
82
|
+
secondAxis: AxisDirection,
|
|
83
|
+
thirdAxis: AxisDirection,
|
|
84
|
+
cartesianOrigin: Readonly<NumericArray>,
|
|
82
85
|
result: number[]
|
|
83
86
|
): number[] {
|
|
84
87
|
const thirdAxisInferred =
|
|
85
|
-
VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] &&
|
|
86
|
-
(VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis] as Axis);
|
|
88
|
+
VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
|
|
87
89
|
// firstAxis and secondAxis must be east, north, up, west, south or down.');
|
|
88
90
|
assert(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
|
|
89
91
|
|
package/src/type-utils.ts
CHANGED
|
@@ -25,14 +25,14 @@ function identity(x: number): number {
|
|
|
25
25
|
|
|
26
26
|
const scratchVector = new Vector3();
|
|
27
27
|
|
|
28
|
-
export function fromCartographic(cartographic: Cartographic): number[];
|
|
28
|
+
export function fromCartographic(cartographic: Readonly<Cartographic>): number[];
|
|
29
29
|
export function fromCartographic<NumArrayT>(
|
|
30
|
-
cartographic: Cartographic
|
|
30
|
+
cartographic: Readonly<Cartographic>,
|
|
31
31
|
result: NumArrayT,
|
|
32
32
|
map?: (x: number) => number
|
|
33
33
|
): NumArrayT;
|
|
34
34
|
export function fromCartographic(
|
|
35
|
-
cartographic: Cartographic
|
|
35
|
+
cartographic: Readonly<Cartographic>,
|
|
36
36
|
result = [] as number[],
|
|
37
37
|
map = identity
|
|
38
38
|
): number[] {
|
|
@@ -52,25 +52,31 @@ export function fromCartographic(
|
|
|
52
52
|
return result;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export function fromCartographicToRadians(
|
|
55
|
+
export function fromCartographicToRadians(
|
|
56
|
+
cartographic: Readonly<Cartographic>,
|
|
57
|
+
result?: number[]
|
|
58
|
+
): number[];
|
|
56
59
|
export function fromCartographicToRadians<TArray>(
|
|
57
|
-
cartographic: Cartographic
|
|
60
|
+
cartographic: Readonly<Cartographic>,
|
|
58
61
|
result: TArray
|
|
59
62
|
): TArray;
|
|
60
63
|
export function fromCartographicToRadians(
|
|
61
|
-
cartographic: Cartographic
|
|
64
|
+
cartographic: Readonly<Cartographic>,
|
|
62
65
|
vector = [] as number[]
|
|
63
66
|
): number[] {
|
|
64
67
|
return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);
|
|
65
68
|
}
|
|
66
69
|
|
|
67
|
-
export function fromCartographicToDegrees(
|
|
70
|
+
export function fromCartographicToDegrees(
|
|
71
|
+
cartographic: Readonly<Cartographic>,
|
|
72
|
+
result?: number[]
|
|
73
|
+
): number[];
|
|
68
74
|
export function fromCartographicToDegrees<TArray>(
|
|
69
|
-
cartographic: Cartographic
|
|
75
|
+
cartographic: Readonly<Cartographic>,
|
|
70
76
|
result: TArray
|
|
71
77
|
): TArray;
|
|
72
78
|
export function fromCartographicToDegrees(
|
|
73
|
-
cartographic: Cartographic
|
|
79
|
+
cartographic: Readonly<Cartographic>,
|
|
74
80
|
vector = [] as number[]
|
|
75
81
|
): number[] {
|
|
76
82
|
return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);
|
package/dist/es5/constants.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WGS84_CONSTANTS = exports.WGS84_RADIUS_Z = exports.WGS84_RADIUS_Y = exports.WGS84_RADIUS_X = void 0;
|
|
7
|
-
var WGS84_RADIUS_X = 6378137.0;
|
|
8
|
-
exports.WGS84_RADIUS_X = WGS84_RADIUS_X;
|
|
9
|
-
var WGS84_RADIUS_Y = 6378137.0;
|
|
10
|
-
exports.WGS84_RADIUS_Y = WGS84_RADIUS_Y;
|
|
11
|
-
var WGS84_RADIUS_Z = 6356752.3142451793;
|
|
12
|
-
exports.WGS84_RADIUS_Z = WGS84_RADIUS_Z;
|
|
13
|
-
var WGS84_CONSTANTS = {
|
|
14
|
-
radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],
|
|
15
|
-
radiiSquared: [WGS84_RADIUS_X * WGS84_RADIUS_X, WGS84_RADIUS_Y * WGS84_RADIUS_Y, WGS84_RADIUS_Z * WGS84_RADIUS_Z],
|
|
16
|
-
oneOverRadii: [1.0 / WGS84_RADIUS_X, 1.0 / WGS84_RADIUS_Y, 1.0 / WGS84_RADIUS_Z],
|
|
17
|
-
oneOverRadiiSquared: [1.0 / (WGS84_RADIUS_X * WGS84_RADIUS_X), 1.0 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y), 1.0 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)],
|
|
18
|
-
maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),
|
|
19
|
-
centerToleranceSquared: 1e-1
|
|
20
|
-
};
|
|
21
|
-
exports.WGS84_CONSTANTS = WGS84_CONSTANTS;
|
|
22
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/constants.ts"],"names":["WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","WGS84_CONSTANTS","radii","radiiSquared","oneOverRadii","oneOverRadiiSquared","maximumRadius","Math","max","centerToleranceSquared"],"mappings":";;;;;;AAGO,IAAMA,cAAc,GAAG,SAAvB;;AACA,IAAMC,cAAc,GAAG,SAAvB;;AACA,IAAMC,cAAc,GAAG,kBAAvB;;AAIA,IAAMC,eAAe,GAAG;AAC7BC,EAAAA,KAAK,EAAE,CAACJ,cAAD,EAAiBC,cAAjB,EAAiCC,cAAjC,CADsB;AAE7BG,EAAAA,YAAY,EAAE,CACZL,cAAc,GAAGA,cADL,EAEZC,cAAc,GAAGA,cAFL,EAGZC,cAAc,GAAGA,cAHL,CAFe;AAO7BI,EAAAA,YAAY,EAAE,CAAC,MAAMN,cAAP,EAAuB,MAAMC,cAA7B,EAA6C,MAAMC,cAAnD,CAPe;AAQ7BK,EAAAA,mBAAmB,EAAE,CACnB,OAAOP,cAAc,GAAGA,cAAxB,CADmB,EAEnB,OAAOC,cAAc,GAAGA,cAAxB,CAFmB,EAGnB,OAAOC,cAAc,GAAGA,cAAxB,CAHmB,CARQ;AAa7BM,EAAAA,aAAa,EAAEC,IAAI,CAACC,GAAL,CAASV,cAAT,EAAyBC,cAAzB,EAAyCC,cAAzC,CAbc;AAc7BS,EAAAA,sBAAsB,EAAE;AAdK,CAAxB","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nexport const WGS84_RADIUS_X = 6378137.0;\nexport const WGS84_RADIUS_Y = 6378137.0;\nexport const WGS84_RADIUS_Z = 6356752.3142451793;\n\n// Pre-calculated ellipsoid defaults to avoid utils depending on `ellipsoid.js`\n\nexport const WGS84_CONSTANTS = {\n radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],\n radiiSquared: [\n WGS84_RADIUS_X * WGS84_RADIUS_X,\n WGS84_RADIUS_Y * WGS84_RADIUS_Y,\n WGS84_RADIUS_Z * WGS84_RADIUS_Z\n ],\n oneOverRadii: [1.0 / WGS84_RADIUS_X, 1.0 / WGS84_RADIUS_Y, 1.0 / WGS84_RADIUS_Z],\n oneOverRadiiSquared: [\n 1.0 / (WGS84_RADIUS_X * WGS84_RADIUS_X),\n 1.0 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y),\n 1.0 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)\n ],\n maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),\n centerToleranceSquared: 1e-1 // EPSILON1;\n};\n"],"file":"constants.js"}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.default = void 0;
|
|
11
|
-
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
|
-
var _core = require("@math.gl/core");
|
|
21
|
-
|
|
22
|
-
var vec3 = _interopRequireWildcard(require("gl-matrix/vec3"));
|
|
23
|
-
|
|
24
|
-
var _constants = require("../constants");
|
|
25
|
-
|
|
26
|
-
var _typeUtils = require("../type-utils");
|
|
27
|
-
|
|
28
|
-
var _scaleToGeodeticSurface2 = _interopRequireDefault(require("./helpers/scale-to-geodetic-surface"));
|
|
29
|
-
|
|
30
|
-
var _ellipsoidTransform = _interopRequireDefault(require("./helpers/ellipsoid-transform"));
|
|
31
|
-
|
|
32
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
-
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
36
|
-
var scratchVector = new _core.Vector3();
|
|
37
|
-
var scratchNormal = new _core.Vector3();
|
|
38
|
-
var scratchK = new _core.Vector3();
|
|
39
|
-
var scratchPosition = new _core.Vector3();
|
|
40
|
-
var scratchHeight = new _core.Vector3();
|
|
41
|
-
var scratchCartesian = new _core.Vector3();
|
|
42
|
-
var wgs84;
|
|
43
|
-
|
|
44
|
-
var Ellipsoid = function () {
|
|
45
|
-
function Ellipsoid() {
|
|
46
|
-
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.0;
|
|
47
|
-
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.0;
|
|
48
|
-
var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.0;
|
|
49
|
-
(0, _classCallCheck2.default)(this, Ellipsoid);
|
|
50
|
-
(0, _defineProperty2.default)(this, "radii", void 0);
|
|
51
|
-
(0, _defineProperty2.default)(this, "radiiSquared", void 0);
|
|
52
|
-
(0, _defineProperty2.default)(this, "radiiToTheFourth", void 0);
|
|
53
|
-
(0, _defineProperty2.default)(this, "oneOverRadii", void 0);
|
|
54
|
-
(0, _defineProperty2.default)(this, "oneOverRadiiSquared", void 0);
|
|
55
|
-
(0, _defineProperty2.default)(this, "minimumRadius", void 0);
|
|
56
|
-
(0, _defineProperty2.default)(this, "maximumRadius", void 0);
|
|
57
|
-
(0, _defineProperty2.default)(this, "centerToleranceSquared", _core._MathUtils.EPSILON1);
|
|
58
|
-
(0, _defineProperty2.default)(this, "squaredXOverSquaredZ", void 0);
|
|
59
|
-
(0, _core.assert)(x >= 0.0);
|
|
60
|
-
(0, _core.assert)(y >= 0.0);
|
|
61
|
-
(0, _core.assert)(z >= 0.0);
|
|
62
|
-
this.radii = new _core.Vector3(x, y, z);
|
|
63
|
-
this.radiiSquared = new _core.Vector3(x * x, y * y, z * z);
|
|
64
|
-
this.radiiToTheFourth = new _core.Vector3(x * x * x * x, y * y * y * y, z * z * z * z);
|
|
65
|
-
this.oneOverRadii = new _core.Vector3(x === 0.0 ? 0.0 : 1.0 / x, y === 0.0 ? 0.0 : 1.0 / y, z === 0.0 ? 0.0 : 1.0 / z);
|
|
66
|
-
this.oneOverRadiiSquared = new _core.Vector3(x === 0.0 ? 0.0 : 1.0 / (x * x), y === 0.0 ? 0.0 : 1.0 / (y * y), z === 0.0 ? 0.0 : 1.0 / (z * z));
|
|
67
|
-
this.minimumRadius = Math.min(x, y, z);
|
|
68
|
-
this.maximumRadius = Math.max(x, y, z);
|
|
69
|
-
|
|
70
|
-
if (this.radiiSquared.z !== 0) {
|
|
71
|
-
this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
Object.freeze(this);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
(0, _createClass2.default)(Ellipsoid, [{
|
|
78
|
-
key: "equals",
|
|
79
|
-
value: function equals(right) {
|
|
80
|
-
return this === right || Boolean(right && this.radii.equals(right.radii));
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "toString",
|
|
84
|
-
value: function toString() {
|
|
85
|
-
return this.radii.toString();
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "cartographicToCartesian",
|
|
89
|
-
value: function cartographicToCartesian(cartographic) {
|
|
90
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
91
|
-
var normal = scratchNormal;
|
|
92
|
-
var k = scratchK;
|
|
93
|
-
|
|
94
|
-
var _cartographic = (0, _slicedToArray2.default)(cartographic, 3),
|
|
95
|
-
height = _cartographic[2];
|
|
96
|
-
|
|
97
|
-
this.geodeticSurfaceNormalCartographic(cartographic, normal);
|
|
98
|
-
k.copy(this.radiiSquared).scale(normal);
|
|
99
|
-
var gamma = Math.sqrt(normal.dot(k));
|
|
100
|
-
k.scale(1 / gamma);
|
|
101
|
-
normal.scale(height);
|
|
102
|
-
k.add(normal);
|
|
103
|
-
return k.to(result);
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "cartesianToCartographic",
|
|
107
|
-
value: function cartesianToCartographic(cartesian) {
|
|
108
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
109
|
-
scratchCartesian.from(cartesian);
|
|
110
|
-
var point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
|
|
111
|
-
|
|
112
|
-
if (!point) {
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
var normal = this.geodeticSurfaceNormal(point, scratchNormal);
|
|
117
|
-
var h = scratchHeight;
|
|
118
|
-
h.copy(scratchCartesian).subtract(point);
|
|
119
|
-
var longitude = Math.atan2(normal.y, normal.x);
|
|
120
|
-
var latitude = Math.asin(normal.z);
|
|
121
|
-
var height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);
|
|
122
|
-
return (0, _typeUtils.toCartographicFromRadians)([longitude, latitude, height], result);
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "eastNorthUpToFixedFrame",
|
|
126
|
-
value: function eastNorthUpToFixedFrame(origin) {
|
|
127
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _core.Matrix4();
|
|
128
|
-
return (0, _ellipsoidTransform.default)(this, 'east', 'north', 'up', origin, result);
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "localFrameToFixedFrame",
|
|
132
|
-
value: function localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin) {
|
|
133
|
-
var result = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4();
|
|
134
|
-
return (0, _ellipsoidTransform.default)(this, firstAxis, secondAxis, thirdAxis, origin, result);
|
|
135
|
-
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "geocentricSurfaceNormal",
|
|
138
|
-
value: function geocentricSurfaceNormal(cartesian) {
|
|
139
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
140
|
-
return scratchVector.from(cartesian).normalize().to(result);
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
key: "geodeticSurfaceNormalCartographic",
|
|
144
|
-
value: function geodeticSurfaceNormalCartographic(cartographic) {
|
|
145
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
146
|
-
var cartographicVectorRadians = (0, _typeUtils.fromCartographicToRadians)(cartographic);
|
|
147
|
-
var longitude = cartographicVectorRadians[0];
|
|
148
|
-
var latitude = cartographicVectorRadians[1];
|
|
149
|
-
var cosLatitude = Math.cos(latitude);
|
|
150
|
-
scratchVector.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
|
|
151
|
-
return scratchVector.to(result);
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "geodeticSurfaceNormal",
|
|
155
|
-
value: function geodeticSurfaceNormal(cartesian) {
|
|
156
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
157
|
-
return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "scaleToGeodeticSurface",
|
|
161
|
-
value: function scaleToGeodeticSurface(cartesian, result) {
|
|
162
|
-
return (0, _scaleToGeodeticSurface2.default)(cartesian, this, result);
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "scaleToGeocentricSurface",
|
|
166
|
-
value: function scaleToGeocentricSurface(cartesian) {
|
|
167
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
168
|
-
scratchPosition.from(cartesian);
|
|
169
|
-
var positionX = scratchPosition.x;
|
|
170
|
-
var positionY = scratchPosition.y;
|
|
171
|
-
var positionZ = scratchPosition.z;
|
|
172
|
-
var oneOverRadiiSquared = this.oneOverRadiiSquared;
|
|
173
|
-
var beta = 1.0 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
|
|
174
|
-
return scratchPosition.multiplyScalar(beta).to(result);
|
|
175
|
-
}
|
|
176
|
-
}, {
|
|
177
|
-
key: "transformPositionToScaledSpace",
|
|
178
|
-
value: function transformPositionToScaledSpace(position) {
|
|
179
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
180
|
-
return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
key: "transformPositionFromScaledSpace",
|
|
184
|
-
value: function transformPositionFromScaledSpace(position) {
|
|
185
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0, 0];
|
|
186
|
-
return scratchPosition.from(position).scale(this.radii).to(result);
|
|
187
|
-
}
|
|
188
|
-
}, {
|
|
189
|
-
key: "getSurfaceNormalIntersectionWithZAxis",
|
|
190
|
-
value: function getSurfaceNormalIntersectionWithZAxis(position) {
|
|
191
|
-
var buffer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
192
|
-
var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [0, 0, 0];
|
|
193
|
-
(0, _core.assert)((0, _core.equals)(this.radii.x, this.radii.y, _core._MathUtils.EPSILON15));
|
|
194
|
-
(0, _core.assert)(this.radii.z > 0);
|
|
195
|
-
scratchPosition.from(position);
|
|
196
|
-
var z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);
|
|
197
|
-
|
|
198
|
-
if (Math.abs(z) >= this.radii.z - buffer) {
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return scratchPosition.set(0.0, 0.0, z).to(result);
|
|
203
|
-
}
|
|
204
|
-
}]);
|
|
205
|
-
return Ellipsoid;
|
|
206
|
-
}();
|
|
207
|
-
|
|
208
|
-
exports.default = Ellipsoid;
|
|
209
|
-
(0, _defineProperty2.default)(Ellipsoid, "WGS84", new Ellipsoid(_constants.WGS84_RADIUS_X, _constants.WGS84_RADIUS_Y, _constants.WGS84_RADIUS_Z));
|
|
210
|
-
//# sourceMappingURL=ellipsoid.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ellipsoid/ellipsoid.ts"],"names":["scratchVector","Vector3","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","wgs84","Ellipsoid","x","y","z","_MathUtils","EPSILON1","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","squaredXOverSquaredZ","Object","freeze","right","Boolean","equals","toString","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesian","from","point","scaleToGeodeticSurface","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","vec3","length","origin","Matrix4","firstAxis","secondAxis","thirdAxis","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","positionX","positionY","positionZ","beta","multiplyScalar","position","buffer","EPSILON15","abs","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA;;AAUA;;AAEA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,IAAIC,aAAJ,EAAtB;AACA,IAAMC,aAAa,GAAG,IAAID,aAAJ,EAAtB;AACA,IAAME,QAAQ,GAAG,IAAIF,aAAJ,EAAjB;AACA,IAAMG,eAAe,GAAG,IAAIH,aAAJ,EAAxB;AACA,IAAMI,aAAa,GAAG,IAAIJ,aAAJ,EAAtB;AACA,IAAMK,gBAAgB,GAAG,IAAIL,aAAJ,EAAzB;AAEA,IAAIM,KAAJ;;IAOqBC,S;AAkBnB,uBAAuC;AAAA,QAA3BC,CAA2B,uEAAvB,GAAuB;AAAA,QAAlBC,CAAkB,uEAAd,GAAc;AAAA,QAATC,CAAS,uEAAL,GAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kEAPGC,iBAAWC,QAOd;AAAA;AACrC,sBAAOJ,CAAC,IAAI,GAAZ;AACA,sBAAOC,CAAC,IAAI,GAAZ;AACA,sBAAOC,CAAC,IAAI,GAAZ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K,KAAL,CAAWJ,CAAhC,EAAmCE,iBAAWiE,SAA9C,CAAP;AACA,wBAAO,KAAK/D,KAAL,CAAWH,CAAX,GAAe,CAAtB;AAEAP,MAAAA,eAAe,CAACyC,IAAhB,CAAqB8B,QAArB;AACA,UAAMhE,CAAC,GAAGP,eAAe,CAACO,CAAhB,IAAqB,IAAI,KAAKa,oBAA9B,CAAV;;AAEA,UAAIJ,IAAI,CAAC0D,GAAL,CAASnE,CAAT,KAAe,KAAKG,KAAL,CAAWH,CAAX,GAAeiE,MAAlC,EAA0C;AACxC,eAAO5B,SAAP;AACD;;AAED,aAAO5C,eAAe,CAACgE,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BzD,CAA9B,EAAiCgC,EAAjC,CAAoCX,MAApC,CAAP;AACD;;;;;;8BAzOkBxB,S,WAEgB,IAAIA,SAAJ,CAAcuE,yBAAd,EAA8BC,yBAA9B,EAA8CC,yBAA9C,C","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {\n Vector3,\n Matrix4,\n toRadians,\n toDegrees,\n assert,\n equals,\n _MathUtils,\n NumericArray\n} from '@math.gl/core';\nimport * as vec3 from 'gl-matrix/vec3';\n\nimport {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';\nimport {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';\n\nimport scaleToGeodeticSurface from './helpers/scale-to-geodetic-surface';\nimport localFrameToFixedFrame from './helpers/ellipsoid-transform';\n\nconst scratchVector = new Vector3();\nconst scratchNormal = new Vector3();\nconst scratchK = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchHeight = new Vector3();\nconst scratchCartesian = new Vector3();\n\nlet wgs84;\n\n/**\n * A quadratic surface defined in Cartesian coordinates by the equation\n * `(x / a)^2 + (y / b)^2 + (z / c)^2 = 1`. Primarily used\n * to represent the shape of planetary bodies.\n */\nexport default class Ellipsoid {\n /** An Ellipsoid instance initialized to the WGS84 standard. */\n static readonly WGS84: Ellipsoid = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n\n readonly radii: Vector3;\n readonly radiiSquared: Vector3;\n readonly radiiToTheFourth: Vector3;\n readonly oneOverRadii: Vector3;\n readonly oneOverRadiiSquared: Vector3;\n readonly minimumRadius: number;\n readonly maximumRadius: number;\n readonly centerToleranceSquared: number = _MathUtils.EPSILON1;\n readonly squaredXOverSquaredZ: number;\n\n /** Creates an Ellipsoid from a Cartesian specifying the radii in x, y, and z directions. */\n constructor(x: number, y: number, z: number);\n constructor();\n\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n assert(x >= 0.0);\n assert(y >= 0.0);\n assert(z >= 0.0);\n\n this.radii = new Vector3(x, y, z);\n\n this.radiiSquared = new Vector3(x * x, y * y, z * z);\n\n this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);\n\n this.oneOverRadii = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / x,\n y === 0.0 ? 0.0 : 1.0 / y,\n z === 0.0 ? 0.0 : 1.0 / z\n );\n\n this.oneOverRadiiSquared = new Vector3(\n x === 0.0 ? 0.0 : 1.0 / (x * x),\n y === 0.0 ? 0.0 : 1.0 / (y * y),\n z === 0.0 ? 0.0 : 1.0 / (z * z)\n );\n\n this.minimumRadius = Math.min(x, y, z);\n\n this.maximumRadius = Math.max(x, y, z);\n\n if (this.radiiSquared.z !== 0) {\n this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;\n }\n\n Object.freeze(this);\n }\n\n /** Compares this Ellipsoid against the provided Ellipsoid componentwise */\n equals(right: Ellipsoid): boolean {\n return this === right || Boolean(right && this.radii.equals(right.radii));\n }\n\n /** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */\n toString(): string {\n return this.radii.toString();\n }\n\n /** Converts the provided cartographic to Cartesian representation. */\n cartographicToCartesian(cartographic: number[], result: Vector3): Vector3;\n cartographicToCartesian(cartographic: number[], result?: number[]): number[];\n\n cartographicToCartesian(cartographic, result = [0, 0, 0]) {\n const normal = scratchNormal;\n const k = scratchK;\n\n const [, , height] = cartographic;\n this.geodeticSurfaceNormalCartographic(cartographic, normal);\n k.copy(this.radiiSquared).scale(normal);\n\n const gamma = Math.sqrt(normal.dot(k));\n k.scale(1 / gamma);\n\n normal.scale(height);\n\n k.add(normal);\n\n return k.to(result);\n }\n\n /** Converts the provided cartesian to cartographic (lng/lat/z) representation.\n * The cartesian is undefined at the center of the ellipsoid. */\n cartesianToCartographic(cartesian: number[], result: Vector3): Vector3;\n cartesianToCartographic(cartesian: number[], result?: number[]): number[];\n\n cartesianToCartographic(cartesian, result = [0, 0, 0]) {\n scratchCartesian.from(cartesian);\n const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);\n\n if (!point) {\n return undefined;\n }\n\n const normal = this.geodeticSurfaceNormal(point, scratchNormal);\n\n const h = scratchHeight;\n h.copy(scratchCartesian).subtract(point);\n\n const longitude = Math.atan2(normal.y, normal.x);\n const latitude = Math.asin(normal.z);\n const height = Math.sign(vec3.dot(h, scratchCartesian)) * vec3.length(h);\n\n return toCartographicFromRadians([longitude, latitude, height], result);\n }\n\n /** Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes\n * centered at the provided origin to the provided ellipsoid's fixed reference frame. */\n eastNorthUpToFixedFrame(origin: number[], result?: Matrix4): Matrix4;\n eastNorthUpToFixedFrame(origin: number[], result: number[]): number[];\n\n eastNorthUpToFixedFrame(origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);\n }\n\n /** Computes a 4x4 transformation matrix from a reference frame centered at\n * the provided origin to the ellipsoid's fixed reference frame.\n */\n localFrameToFixedFrame(\n firstAxis: string,\n secondAxis: string,\n thirdAxis: string,\n origin: Readonly<NumericArray>,\n result?: Matrix4\n ): Matrix4;\n localFrameToFixedFrame<Matrix4T>(\n firstAxis: string,\n secondAxis: string,\n thirdAxis: string,\n origin: Readonly<NumericArray>,\n result: number[]\n ): number[];\n\n // Computes a 4x4 transformation matrix from a reference frame centered at\n // the provided origin to the ellipsoid's fixed reference frame.\n localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);\n }\n\n /** Computes the unit vector directed from the center of this ellipsoid toward\n * the provided Cartesian position. */\n geocentricSurfaceNormal(cartesian: number[], result?: number[]): number[];\n geocentricSurfaceNormal<NumArray>(cartesian: number[], result: NumArray): NumArray;\n geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).normalize().to(result);\n }\n\n /** Computes the normal of the plane tangent to the surface of the ellipsoid at provided position. */\n geodeticSurfaceNormalCartographic<NumArray>(cartographic: number[], result: NumArray): NumArray;\n geodeticSurfaceNormalCartographic(cartographic: number[]): number[];\n geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {\n const cartographicVectorRadians = fromCartographicToRadians(cartographic);\n\n const longitude = cartographicVectorRadians[0];\n const latitude = cartographicVectorRadians[1];\n\n const cosLatitude = Math.cos(latitude);\n\n scratchVector\n .set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude))\n .normalize();\n\n return scratchVector.to(result);\n }\n\n /** Computes the normal of the plane tangent to the surface of the ellipsoid at the provided position. */\n geodeticSurfaceNormal<NumArrayT>(cartesian: number[], result: NumArrayT): NumArrayT;\n geodeticSurfaceNormal(cartesian: number[]): number[];\n geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);\n }\n\n /** Scales the provided Cartesian position along the geodetic surface normal\n * so that it is on the surface of this ellipsoid. If the position is\n * at the center of the ellipsoid, this function returns undefined. */\n scaleToGeodeticSurface(cartesian: number[], result?: number[]): number[] {\n return scaleToGeodeticSurface(cartesian, this, result);\n }\n\n /** Scales the provided Cartesian position along the geocentric surface normal\n * so that it is on the surface of this ellipsoid. */\n scaleToGeocentricSurface(cartesian: number[], result: number[] = [0, 0, 0]): number[] {\n scratchPosition.from(cartesian);\n\n const positionX = scratchPosition.x;\n const positionY = scratchPosition.y;\n const positionZ = scratchPosition.z;\n const oneOverRadiiSquared = this.oneOverRadiiSquared;\n\n const beta =\n 1.0 /\n Math.sqrt(\n positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z\n );\n\n return scratchPosition.multiplyScalar(beta).to(result);\n }\n\n /** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying\n * its components by the result of `Ellipsoid#oneOverRadii` */\n transformPositionToScaledSpace(position: number[], result: number[] = [0, 0, 0]): number[] {\n return scratchPosition.from(position).scale(this.oneOverRadii).to(result);\n }\n\n /** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying\n * its components by the result of `Ellipsoid#radii`. */\n transformPositionFromScaledSpace(position: number[], result: number[] = [0, 0, 0]): number[] {\n return scratchPosition.from(position).scale(this.radii).to(result);\n }\n\n /** Computes a point which is the intersection of the surface normal with the z-axis. */\n getSurfaceNormalIntersectionWithZAxis(\n position: number[],\n buffer: number = 0,\n result: number[] = [0, 0, 0]\n ): number[] {\n // Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)\n assert(equals(this.radii.x, this.radii.y, _MathUtils.EPSILON15));\n assert(this.radii.z > 0);\n\n scratchPosition.from(position);\n const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);\n\n if (Math.abs(z) >= this.radii.z - buffer) {\n return undefined;\n }\n\n return scratchPosition.set(0.0, 0.0, z).to(result);\n }\n}\n"],"file":"ellipsoid.js"}
|