@math.gl/geospatial 4.0.0-beta.1 → 4.0.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.
@@ -1,66 +1,70 @@
1
+ /* eslint-disable */
1
2
  import { Vector3, _MathUtils } from '@math.gl/core';
2
3
  const scratchVector = new Vector3();
3
4
  const scaleToGeodeticSurfaceIntersection = new Vector3();
4
5
  const scaleToGeodeticSurfaceGradient = new Vector3();
6
+ // Scales the provided Cartesian position along the geodetic surface normal
7
+ // so that it is on the surface of this ellipsoid. If the position is
8
+ // at the center of the ellipsoid, this function returns undefined.
5
9
  export function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
6
- const {
7
- oneOverRadii,
8
- oneOverRadiiSquared,
9
- centerToleranceSquared
10
- } = ellipsoid;
11
- scratchVector.from(cartesian);
12
- const positionX = scratchVector.x;
13
- const positionY = scratchVector.y;
14
- const positionZ = scratchVector.z;
15
- const oneOverRadiiX = oneOverRadii.x;
16
- const oneOverRadiiY = oneOverRadii.y;
17
- const oneOverRadiiZ = oneOverRadii.z;
18
- const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
19
- const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
20
- const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
21
- const squaredNorm = x2 + y2 + z2;
22
- const ratio = Math.sqrt(1.0 / squaredNorm);
23
-
24
- if (!Number.isFinite(ratio)) {
25
- return undefined;
26
- }
27
-
28
- const intersection = scaleToGeodeticSurfaceIntersection;
29
- intersection.copy(cartesian).scale(ratio);
30
-
31
- if (squaredNorm < centerToleranceSquared) {
32
- return intersection.to(result);
33
- }
34
-
35
- const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
36
- const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
37
- const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
38
- const gradient = scaleToGeodeticSurfaceGradient;
39
- gradient.set(intersection.x * oneOverRadiiSquaredX * 2.0, intersection.y * oneOverRadiiSquaredY * 2.0, intersection.z * oneOverRadiiSquaredZ * 2.0);
40
- let lambda = (1.0 - ratio) * scratchVector.len() / (0.5 * gradient.len());
41
- let correction = 0.0;
42
- let xMultiplier;
43
- let yMultiplier;
44
- let zMultiplier;
45
- let func;
46
-
47
- do {
48
- lambda -= correction;
49
- xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);
50
- yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY);
51
- zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ);
52
- const xMultiplier2 = xMultiplier * xMultiplier;
53
- const yMultiplier2 = yMultiplier * yMultiplier;
54
- const zMultiplier2 = zMultiplier * zMultiplier;
55
- const xMultiplier3 = xMultiplier2 * xMultiplier;
56
- const yMultiplier3 = yMultiplier2 * yMultiplier;
57
- const zMultiplier3 = zMultiplier2 * zMultiplier;
58
- func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;
59
- const denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
60
- const derivative = -2.0 * denominator;
61
- correction = func / derivative;
62
- } while (Math.abs(func) > _MathUtils.EPSILON12);
63
-
64
- return scratchVector.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
10
+ const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;
11
+ scratchVector.from(cartesian);
12
+ const positionX = scratchVector.x;
13
+ const positionY = scratchVector.y;
14
+ const positionZ = scratchVector.z;
15
+ const oneOverRadiiX = oneOverRadii.x;
16
+ const oneOverRadiiY = oneOverRadii.y;
17
+ const oneOverRadiiZ = oneOverRadii.z;
18
+ const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
19
+ const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
20
+ const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
21
+ // Compute the squared ellipsoid norm.
22
+ const squaredNorm = x2 + y2 + z2;
23
+ const ratio = Math.sqrt(1.0 / squaredNorm);
24
+ // When very close to center or at center
25
+ if (!Number.isFinite(ratio)) {
26
+ return undefined;
27
+ }
28
+ // As an initial approximation, assume that the radial intersection is the projection point.
29
+ const intersection = scaleToGeodeticSurfaceIntersection;
30
+ intersection.copy(cartesian).scale(ratio);
31
+ // If the position is near the center, the iteration will not converge.
32
+ if (squaredNorm < centerToleranceSquared) {
33
+ return intersection.to(result);
34
+ }
35
+ const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
36
+ const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
37
+ const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
38
+ // Use the gradient at the intersection point in place of the true unit normal.
39
+ // The difference in magnitude will be absorbed in the multiplier.
40
+ const gradient = scaleToGeodeticSurfaceGradient;
41
+ gradient.set(intersection.x * oneOverRadiiSquaredX * 2.0, intersection.y * oneOverRadiiSquaredY * 2.0, intersection.z * oneOverRadiiSquaredZ * 2.0);
42
+ // Compute the initial guess at the normal vector multiplier, lambda.
43
+ let lambda = ((1.0 - ratio) * scratchVector.len()) / (0.5 * gradient.len());
44
+ let correction = 0.0;
45
+ let xMultiplier;
46
+ let yMultiplier;
47
+ let zMultiplier;
48
+ let func;
49
+ do {
50
+ lambda -= correction;
51
+ xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);
52
+ yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY);
53
+ zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ);
54
+ const xMultiplier2 = xMultiplier * xMultiplier;
55
+ const yMultiplier2 = yMultiplier * yMultiplier;
56
+ const zMultiplier2 = zMultiplier * zMultiplier;
57
+ const xMultiplier3 = xMultiplier2 * xMultiplier;
58
+ const yMultiplier3 = yMultiplier2 * yMultiplier;
59
+ const zMultiplier3 = zMultiplier2 * zMultiplier;
60
+ func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;
61
+ // "denominator" here refers to the use of this expression in the velocity and acceleration
62
+ // computations in the sections to follow.
63
+ const denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX +
64
+ y2 * yMultiplier3 * oneOverRadiiSquaredY +
65
+ z2 * zMultiplier3 * oneOverRadiiSquaredZ;
66
+ const derivative = -2.0 * denominator;
67
+ correction = func / derivative;
68
+ } while (Math.abs(func) > _MathUtils.EPSILON12);
69
+ return scratchVector.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
65
70
  }
66
- //# sourceMappingURL=scale-to-geodetic-surface.js.map
package/dist/index.cjs CHANGED
@@ -16,18 +16,18 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/index.ts
20
- var src_exports = {};
21
- __export(src_exports, {
19
+ // dist/index.js
20
+ var dist_exports = {};
21
+ __export(dist_exports, {
22
22
  Ellipsoid: () => Ellipsoid,
23
23
  isWGS84: () => isWGS84
24
24
  });
25
- module.exports = __toCommonJS(src_exports);
25
+ module.exports = __toCommonJS(dist_exports);
26
26
 
27
- // src/ellipsoid/ellipsoid.ts
27
+ // dist/ellipsoid/ellipsoid.js
28
28
  var import_core4 = require("@math.gl/core");
29
29
 
30
- // src/constants.ts
30
+ // dist/constants.js
31
31
  var WGS84_RADIUS_X = 6378137;
32
32
  var WGS84_RADIUS_Y = 6378137;
33
33
  var WGS84_RADIUS_Z = 6356752314245179e-9;
@@ -48,7 +48,7 @@ var WGS84_CONSTANTS = {
48
48
  centerToleranceSquared: 0.1
49
49
  };
50
50
 
51
- // src/type-utils.ts
51
+ // dist/type-utils.js
52
52
  var import_core = require("@math.gl/core");
53
53
  function identity(x) {
54
54
  return x;
@@ -104,7 +104,7 @@ function isWGS84(vector) {
104
104
  return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
105
105
  }
106
106
 
107
- // src/ellipsoid/helpers/ellipsoid-transform.ts
107
+ // dist/ellipsoid/helpers/ellipsoid-transform.js
108
108
  var import_core2 = require("@math.gl/core");
109
109
  var EPSILON14 = 1e-14;
110
110
  var scratchOrigin = new import_core2.Vector3();
@@ -219,7 +219,7 @@ function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, car
219
219
  return result;
220
220
  }
221
221
 
222
- // src/ellipsoid/helpers/scale-to-geodetic-surface.ts
222
+ // dist/ellipsoid/helpers/scale-to-geodetic-surface.js
223
223
  var import_core3 = require("@math.gl/core");
224
224
  var scratchVector4 = new import_core3.Vector3();
225
225
  var scaleToGeodeticSurfaceIntersection = new import_core3.Vector3();
@@ -250,11 +250,7 @@ function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
250
250
  const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
251
251
  const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
252
252
  const gradient = scaleToGeodeticSurfaceGradient;
253
- gradient.set(
254
- intersection.x * oneOverRadiiSquaredX * 2,
255
- intersection.y * oneOverRadiiSquaredY * 2,
256
- intersection.z * oneOverRadiiSquaredZ * 2
257
- );
253
+ gradient.set(intersection.x * oneOverRadiiSquaredX * 2, intersection.y * oneOverRadiiSquaredY * 2, intersection.z * oneOverRadiiSquaredZ * 2);
258
254
  let lambda = (1 - ratio) * scratchVector4.len() / (0.5 * gradient.len());
259
255
  let correction = 0;
260
256
  let xMultiplier;
@@ -280,14 +276,14 @@ function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
280
276
  return scratchVector4.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
281
277
  }
282
278
 
283
- // src/ellipsoid/ellipsoid.ts
279
+ // dist/ellipsoid/ellipsoid.js
284
280
  var scratchVector5 = new import_core4.Vector3();
285
281
  var scratchNormal = new import_core4.Vector3();
286
282
  var scratchK = new import_core4.Vector3();
287
283
  var scratchPosition = new import_core4.Vector3();
288
284
  var scratchHeight = new import_core4.Vector3();
289
285
  var scratchCartesian = new import_core4.Vector3();
290
- var _Ellipsoid = class {
286
+ var Ellipsoid = class {
291
287
  constructor(x = 0, y = 0, z = 0) {
292
288
  this.centerToleranceSquared = import_core4._MathUtils.EPSILON1;
293
289
  (0, import_core4.assert)(x >= 0);
@@ -296,16 +292,8 @@ var _Ellipsoid = class {
296
292
  this.radii = new import_core4.Vector3(x, y, z);
297
293
  this.radiiSquared = new import_core4.Vector3(x * x, y * y, z * z);
298
294
  this.radiiToTheFourth = new import_core4.Vector3(x * x * x * x, y * y * y * y, z * z * z * z);
299
- this.oneOverRadii = new import_core4.Vector3(
300
- x === 0 ? 0 : 1 / x,
301
- y === 0 ? 0 : 1 / y,
302
- z === 0 ? 0 : 1 / z
303
- );
304
- this.oneOverRadiiSquared = new import_core4.Vector3(
305
- x === 0 ? 0 : 1 / (x * x),
306
- y === 0 ? 0 : 1 / (y * y),
307
- z === 0 ? 0 : 1 / (z * z)
308
- );
295
+ this.oneOverRadii = new import_core4.Vector3(x === 0 ? 0 : 1 / x, y === 0 ? 0 : 1 / y, z === 0 ? 0 : 1 / z);
296
+ this.oneOverRadiiSquared = new import_core4.Vector3(x === 0 ? 0 : 1 / (x * x), y === 0 ? 0 : 1 / (y * y), z === 0 ? 0 : 1 / (z * z));
309
297
  this.minimumRadius = Math.min(x, y, z);
310
298
  this.maximumRadius = Math.max(x, y, z);
311
299
  if (this.radiiSquared.z !== 0) {
@@ -374,9 +362,7 @@ var _Ellipsoid = class {
374
362
  const positionY = scratchPosition.y;
375
363
  const positionZ = scratchPosition.z;
376
364
  const oneOverRadiiSquared = this.oneOverRadiiSquared;
377
- const beta = 1 / Math.sqrt(
378
- positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z
379
- );
365
+ const beta = 1 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
380
366
  return scratchPosition.multiplyScalar(beta).to(result);
381
367
  }
382
368
  transformPositionToScaledSpace(position, result = [0, 0, 0]) {
@@ -396,5 +382,5 @@ var _Ellipsoid = class {
396
382
  return scratchPosition.set(0, 0, z).to(result);
397
383
  }
398
384
  };
399
- var Ellipsoid = _Ellipsoid;
400
- Ellipsoid.WGS84 = new _Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
385
+ Ellipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
386
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.js", "ellipsoid/ellipsoid.js", "constants.js", "type-utils.js", "ellipsoid/helpers/ellipsoid-transform.js", "ellipsoid/helpers/scale-to-geodetic-surface.js"],
4
+ "sourcesContent": ["export { Ellipsoid } from \"./ellipsoid/ellipsoid.js\";\nexport { isWGS84 } from \"./type-utils.js\";\n", "// 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/* eslint-disable */\nimport { Vector3, Matrix4, assert, equals, _MathUtils, vec3 } from '@math.gl/core';\nimport { WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z } from \"../constants.js\";\nimport { fromCartographicToRadians, toCartographicFromRadians } from \"../type-utils.js\";\nimport { localFrameToFixedFrame } from \"./helpers/ellipsoid-transform.js\";\nimport { scaleToGeodeticSurface } from \"./helpers/scale-to-geodetic-surface.js\";\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/**\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 class Ellipsoid {\n constructor(x = 0.0, y = 0.0, z = 0.0) {\n this.centerToleranceSquared = _MathUtils.EPSILON1;\n assert(x >= 0.0);\n assert(y >= 0.0);\n assert(z >= 0.0);\n this.radii = new Vector3(x, y, z);\n this.radiiSquared = new Vector3(x * x, y * y, z * z);\n this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);\n this.oneOverRadii = new 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);\n this.oneOverRadiiSquared = new 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));\n this.minimumRadius = Math.min(x, y, z);\n this.maximumRadius = Math.max(x, y, z);\n if (this.radiiSquared.z !== 0) {\n this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;\n }\n Object.freeze(this);\n }\n /** Compares this Ellipsoid against the provided Ellipsoid componentwise */\n equals(right) {\n return this === right || Boolean(right && this.radii.equals(right.radii));\n }\n /** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */\n toString() {\n return this.radii.toString();\n }\n cartographicToCartesian(cartographic, result = [0, 0, 0]) {\n const normal = scratchNormal;\n const k = scratchK;\n const [, , height] = cartographic;\n this.geodeticSurfaceNormalCartographic(cartographic, normal);\n k.copy(this.radiiSquared).scale(normal);\n const gamma = Math.sqrt(normal.dot(k));\n k.scale(1 / gamma);\n normal.scale(height);\n k.add(normal);\n return k.to(result);\n }\n cartesianToCartographic(cartesian, result = [0, 0, 0]) {\n scratchCartesian.from(cartesian);\n const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);\n if (!point) {\n return undefined;\n }\n const normal = this.geodeticSurfaceNormal(point, scratchNormal);\n const h = scratchHeight;\n h.copy(scratchCartesian).subtract(point);\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 return toCartographicFromRadians([longitude, latitude, height], result);\n }\n eastNorthUpToFixedFrame(origin, result = new Matrix4()) {\n return localFrameToFixedFrame(this, 'east', 'north', 'up', origin, result);\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 geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).normalize().to(result);\n }\n geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {\n const cartographicVectorRadians = fromCartographicToRadians(cartographic);\n const longitude = cartographicVectorRadians[0];\n const latitude = cartographicVectorRadians[1];\n const cosLatitude = Math.cos(latitude);\n scratchVector\n .set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude))\n .normalize();\n return scratchVector.to(result);\n }\n geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {\n return scratchVector.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);\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, result) {\n return scaleToGeodeticSurface(cartesian, this, result);\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, result = [0, 0, 0]) {\n scratchPosition.from(cartesian);\n const positionX = scratchPosition.x;\n const positionY = scratchPosition.y;\n const positionZ = scratchPosition.z;\n const oneOverRadiiSquared = this.oneOverRadiiSquared;\n const beta = 1.0 /\n Math.sqrt(positionX * positionX * oneOverRadiiSquared.x +\n positionY * positionY * oneOverRadiiSquared.y +\n positionZ * positionZ * oneOverRadiiSquared.z);\n return scratchPosition.multiplyScalar(beta).to(result);\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, result = [0, 0, 0]) {\n return scratchPosition.from(position).scale(this.oneOverRadii).to(result);\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, result = [0, 0, 0]) {\n return scratchPosition.from(position).scale(this.radii).to(result);\n }\n /** Computes a point which is the intersection of the surface normal with the z-axis. */\n getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {\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 scratchPosition.from(position);\n const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);\n if (Math.abs(z) >= this.radii.z - buffer) {\n return undefined;\n }\n return scratchPosition.set(0.0, 0.0, z).to(result);\n }\n}\n/** An Ellipsoid instance initialized to the WGS84 standard. */\nEllipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);\n", "// 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\nexport const WGS84_RADIUS_X = 6378137.0;\nexport const WGS84_RADIUS_Y = 6378137.0;\nexport const WGS84_RADIUS_Z = 6356752.3142451793;\n// Pre-calculated ellipsoid defaults to avoid utils depending on `ellipsoid.js`\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", "// 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\nimport { Vector3, toRadians, toDegrees, config } from '@math.gl/core';\nimport { WGS84_CONSTANTS } from \"./constants.js\";\nfunction identity(x) {\n return x;\n}\nconst scratchVector = new Vector3();\nexport function fromCartographic(cartographic, result = [], map = identity) {\n if ('longitude' in cartographic) {\n result[0] = map(cartographic.longitude);\n result[1] = map(cartographic.latitude);\n result[2] = cartographic.height;\n }\n else if ('x' in cartographic) {\n result[0] = map(cartographic.x);\n result[1] = map(cartographic.y);\n result[2] = cartographic.z;\n }\n else {\n result[0] = map(cartographic[0]);\n result[1] = map(cartographic[1]);\n result[2] = cartographic[2];\n }\n return result;\n}\nexport function fromCartographicToRadians(cartographic, vector = []) {\n return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);\n}\nexport function fromCartographicToDegrees(cartographic, vector = []) {\n return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);\n}\nexport function toCartographic(vector, cartographic, map = identity) {\n if ('longitude' in cartographic) {\n cartographic.longitude = map(vector[0]);\n cartographic.latitude = map(vector[1]);\n cartographic.height = vector[2];\n }\n else if ('x' in cartographic) {\n cartographic.x = map(vector[0]);\n cartographic.y = map(vector[1]);\n cartographic.z = vector[2];\n }\n else {\n cartographic[0] = map(vector[0]);\n cartographic[1] = map(vector[1]);\n cartographic[2] = vector[2];\n }\n return cartographic;\n}\nexport function toCartographicFromRadians(vector, cartographic) {\n return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);\n}\nexport function toCartographicFromDegrees(vector, cartographic) {\n return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : identity);\n}\n// Estimates if a vector is close to the surface of the WGS84 Ellipsoid\nexport function isWGS84(vector) {\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\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", "import { Vector3, assert, equals as equalsEpsilon } from '@math.gl/core';\nconst EPSILON14 = 1e-14;\nconst scratchOrigin = new Vector3();\n// Caclulate third axis from given two axii\nconst VECTOR_PRODUCT_LOCAL_FRAME = {\n up: {\n south: 'east',\n north: 'west',\n west: 'south',\n east: 'north'\n },\n down: {\n south: 'west',\n north: 'east',\n west: 'north',\n east: 'south'\n },\n south: {\n up: 'west',\n down: 'east',\n west: 'down',\n east: 'up'\n },\n north: {\n up: 'east',\n down: 'west',\n west: 'up',\n east: 'down'\n },\n west: {\n up: 'north',\n down: 'south',\n north: 'down',\n south: 'up'\n },\n east: {\n up: 'south',\n down: 'north',\n north: 'up',\n south: 'down'\n }\n};\nconst degeneratePositionLocalFrame = {\n north: [-1, 0, 0],\n east: [0, 1, 0],\n up: [0, 0, 1],\n south: [1, 0, 0],\n west: [0, -1, 0],\n down: [0, 0, -1]\n};\nconst scratchAxisVectors = {\n east: new Vector3(),\n north: new Vector3(),\n up: new Vector3(),\n west: new Vector3(),\n south: new Vector3(),\n down: new Vector3()\n};\nconst scratchVector1 = new Vector3();\nconst scratchVector2 = new Vector3();\nconst scratchVector3 = new Vector3();\n// Computes a 4x4 transformation matrix from a reference frame\n// centered at the provided origin to the provided ellipsoid's fixed reference frame.\n// eslint-disable-next-line max-statements, max-params, complexity\nexport function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {\n const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];\n // firstAxis and secondAxis must be east, north, up, west, south or down.');\n assert(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));\n let firstAxisVector;\n let secondAxisVector;\n let thirdAxisVector;\n const origin = scratchOrigin.copy(cartesianOrigin);\n // If x and y are zero, assume origin is at a pole, which is a special case.\n const atPole = equalsEpsilon(origin.x, 0.0, EPSILON14) && equalsEpsilon(origin.y, 0.0, EPSILON14);\n if (atPole) {\n // Look up axis value and adjust\n const sign = Math.sign(origin.z);\n firstAxisVector = scratchVector1.fromArray(degeneratePositionLocalFrame[firstAxis]);\n if (firstAxis !== 'east' && firstAxis !== 'west') {\n firstAxisVector.scale(sign);\n }\n secondAxisVector = scratchVector2.fromArray(degeneratePositionLocalFrame[secondAxis]);\n if (secondAxis !== 'east' && secondAxis !== 'west') {\n secondAxisVector.scale(sign);\n }\n thirdAxisVector = scratchVector3.fromArray(degeneratePositionLocalFrame[thirdAxis]);\n if (thirdAxis !== 'east' && thirdAxis !== 'west') {\n thirdAxisVector.scale(sign);\n }\n }\n else {\n // Calculate all axis\n const { up, east, north } = scratchAxisVectors;\n east.set(-origin.y, origin.x, 0.0).normalize();\n ellipsoid.geodeticSurfaceNormal(origin, up);\n north.copy(up).cross(east);\n const { down, west, south } = scratchAxisVectors;\n down.copy(up).scale(-1);\n west.copy(east).scale(-1);\n south.copy(north).scale(-1);\n // Pick three axis based on desired orientation\n firstAxisVector = scratchAxisVectors[firstAxis];\n secondAxisVector = scratchAxisVectors[secondAxis];\n thirdAxisVector = scratchAxisVectors[thirdAxis];\n }\n // TODO - assuming the result is column-major\n result[0] = firstAxisVector.x;\n result[1] = firstAxisVector.y;\n result[2] = firstAxisVector.z;\n result[3] = 0.0;\n result[4] = secondAxisVector.x;\n result[5] = secondAxisVector.y;\n result[6] = secondAxisVector.z;\n result[7] = 0.0;\n result[8] = thirdAxisVector.x;\n result[9] = thirdAxisVector.y;\n result[10] = thirdAxisVector.z;\n result[11] = 0.0;\n result[12] = origin.x;\n result[13] = origin.y;\n result[14] = origin.z;\n result[15] = 1.0;\n return result;\n}\n", "/* eslint-disable */\nimport { Vector3, _MathUtils } from '@math.gl/core';\nconst scratchVector = new Vector3();\nconst scaleToGeodeticSurfaceIntersection = new Vector3();\nconst scaleToGeodeticSurfaceGradient = new Vector3();\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.\nexport function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {\n const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;\n scratchVector.from(cartesian);\n const positionX = scratchVector.x;\n const positionY = scratchVector.y;\n const positionZ = scratchVector.z;\n const oneOverRadiiX = oneOverRadii.x;\n const oneOverRadiiY = oneOverRadii.y;\n const oneOverRadiiZ = oneOverRadii.z;\n const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;\n const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;\n const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;\n // Compute the squared ellipsoid norm.\n const squaredNorm = x2 + y2 + z2;\n const ratio = Math.sqrt(1.0 / squaredNorm);\n // When very close to center or at center\n if (!Number.isFinite(ratio)) {\n return undefined;\n }\n // As an initial approximation, assume that the radial intersection is the projection point.\n const intersection = scaleToGeodeticSurfaceIntersection;\n intersection.copy(cartesian).scale(ratio);\n // If the position is near the center, the iteration will not converge.\n if (squaredNorm < centerToleranceSquared) {\n return intersection.to(result);\n }\n const oneOverRadiiSquaredX = oneOverRadiiSquared.x;\n const oneOverRadiiSquaredY = oneOverRadiiSquared.y;\n const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;\n // Use the gradient at the intersection point in place of the true unit normal.\n // The difference in magnitude will be absorbed in the multiplier.\n const gradient = scaleToGeodeticSurfaceGradient;\n gradient.set(intersection.x * oneOverRadiiSquaredX * 2.0, intersection.y * oneOverRadiiSquaredY * 2.0, intersection.z * oneOverRadiiSquaredZ * 2.0);\n // Compute the initial guess at the normal vector multiplier, lambda.\n let lambda = ((1.0 - ratio) * scratchVector.len()) / (0.5 * gradient.len());\n let correction = 0.0;\n let xMultiplier;\n let yMultiplier;\n let zMultiplier;\n let func;\n do {\n lambda -= correction;\n xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX);\n yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY);\n zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ);\n const xMultiplier2 = xMultiplier * xMultiplier;\n const yMultiplier2 = yMultiplier * yMultiplier;\n const zMultiplier2 = zMultiplier * zMultiplier;\n const xMultiplier3 = xMultiplier2 * xMultiplier;\n const yMultiplier3 = yMultiplier2 * yMultiplier;\n const zMultiplier3 = zMultiplier2 * zMultiplier;\n func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;\n // \"denominator\" here refers to the use of this expression in the velocity and acceleration\n // computations in the sections to follow.\n const denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX +\n y2 * yMultiplier3 * oneOverRadiiSquaredY +\n z2 * zMultiplier3 * oneOverRadiiSquaredZ;\n const derivative = -2.0 * denominator;\n correction = func / derivative;\n } while (Math.abs(func) > _MathUtils.EPSILON12);\n return scratchVector.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,IAAAA,eAAmE;;;ACD5D,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AAEvB,IAAM,kBAAkB;AAAA,EAC3B,OAAO,CAAC,gBAAgB,gBAAgB,cAAc;AAAA,EACtD,cAAc;AAAA,IACV,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,EACrB;AAAA,EACA,cAAc,CAAC,IAAM,gBAAgB,IAAM,gBAAgB,IAAM,cAAc;AAAA,EAC/E,qBAAqB;AAAA,IACjB,KAAO,iBAAiB;AAAA,IACxB,KAAO,iBAAiB;AAAA,IACxB,KAAO,iBAAiB;AAAA,EAC5B;AAAA,EACA,eAAe,KAAK,IAAI,gBAAgB,gBAAgB,cAAc;AAAA,EACtE,wBAAwB;AAC5B;;;ACnBA,kBAAsD;AAEtD,SAAS,SAAS,GAAG;AACjB,SAAO;AACX;AACA,IAAM,gBAAgB,IAAI,oBAAQ;AAC3B,SAAS,iBAAiB,cAAc,SAAS,CAAC,GAAG,MAAM,UAAU;AACxE,MAAI,eAAe,cAAc;AAC7B,WAAO,KAAK,IAAI,aAAa,SAAS;AACtC,WAAO,KAAK,IAAI,aAAa,QAAQ;AACrC,WAAO,KAAK,aAAa;AAAA,EAC7B,WACS,O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AO,KAAK,MAAM,GAAG,KAAK,MAAM,GAAG,wBAAW,SAAS,CAAC;AAC/D,6BAAO,KAAK,MAAM,IAAI,CAAC;AACvB,oBAAgB,KAAK,QAAQ;AAC7B,UAAM,IAAI,gBAAgB,KAAK,IAAI,KAAK;AACxC,QAAI,KAAK,IAAI,CAAC,KAAK,KAAK,MAAM,IAAI,QAAQ;AACtC,aAAO;AAAA,IACX;AACA,WAAO,gBAAgB,IAAI,GAAK,GAAK,CAAC,EAAE,GAAG,MAAM;AAAA,EACrD;AACJ;AAEA,UAAU,QAAQ,IAAI,UAAU,gBAAgB,gBAAgB,cAAc;",
6
+ "names": ["import_core", "import_core", "equalsEpsilon", "import_core", "scratchVector", "scratchVector"]
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- export { Ellipsoid } from './ellipsoid/ellipsoid';
2
- export { isWGS84 } from './type-utils';
3
- //# sourceMappingURL=index.d.ts.map
1
+ export { Ellipsoid } from "./ellipsoid/ellipsoid.js";
2
+ export { isWGS84 } from "./type-utils.js";
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export { Ellipsoid } from "./ellipsoid/ellipsoid.js";
2
2
  export { isWGS84 } from "./type-utils.js";
3
- //# sourceMappingURL=index.js.map
@@ -1,15 +1,15 @@
1
1
  import type { NumericArray } from '@math.gl/core';
2
- declare type LngLatHeightObject = {
2
+ type LngLatHeightObject = {
3
3
  longitude: number;
4
4
  latitude: number;
5
5
  height: number;
6
6
  };
7
- declare type XYZObject = {
7
+ type XYZObject = {
8
8
  x: number;
9
9
  y: number;
10
10
  z: number;
11
11
  };
12
- declare type Cartographic = LngLatHeightObject | XYZObject | NumericArray;
12
+ type Cartographic = LngLatHeightObject | XYZObject | NumericArray;
13
13
  export declare function fromCartographic(cartographic: Readonly<Cartographic>): number[];
14
14
  export declare function fromCartographic<NumArrayT>(cartographic: Readonly<Cartographic>, result: NumArrayT, map?: (x: number) => number): NumArrayT;
15
15
  export declare function fromCartographicToRadians(cartographic: Readonly<Cartographic>, result?: number[]): number[];
@@ -21,4 +21,3 @@ export declare function toCartographicFromRadians<T extends Cartographic>(vector
21
21
  export declare function toCartographicFromDegrees<T extends Cartographic>(vector: Readonly<NumericArray>, cartographic: T): T;
22
22
  export declare function isWGS84(vector: Readonly<NumericArray>): boolean;
23
23
  export {};
24
- //# sourceMappingURL=type-utils.d.ts.map
@@ -1,70 +1,96 @@
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
1
3
  import { Vector3, toRadians, toDegrees, config } from '@math.gl/core';
2
4
  import { WGS84_CONSTANTS } from "./constants.js";
3
-
4
5
  function identity(x) {
5
- return x;
6
+ return x;
6
7
  }
7
-
8
8
  const scratchVector = new Vector3();
9
9
  export function fromCartographic(cartographic, result = [], map = identity) {
10
- if ('longitude' in cartographic) {
11
- result[0] = map(cartographic.longitude);
12
- result[1] = map(cartographic.latitude);
13
- result[2] = cartographic.height;
14
- } else if ('x' in cartographic) {
15
- result[0] = map(cartographic.x);
16
- result[1] = map(cartographic.y);
17
- result[2] = cartographic.z;
18
- } else {
19
- result[0] = map(cartographic[0]);
20
- result[1] = map(cartographic[1]);
21
- result[2] = cartographic[2];
22
- }
23
-
24
- return result;
10
+ if ('longitude' in cartographic) {
11
+ result[0] = map(cartographic.longitude);
12
+ result[1] = map(cartographic.latitude);
13
+ result[2] = cartographic.height;
14
+ }
15
+ else if ('x' in cartographic) {
16
+ result[0] = map(cartographic.x);
17
+ result[1] = map(cartographic.y);
18
+ result[2] = cartographic.z;
19
+ }
20
+ else {
21
+ result[0] = map(cartographic[0]);
22
+ result[1] = map(cartographic[1]);
23
+ result[2] = cartographic[2];
24
+ }
25
+ return result;
25
26
  }
26
27
  export function fromCartographicToRadians(cartographic, vector = []) {
27
- return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);
28
+ return fromCartographic(cartographic, vector, config._cartographicRadians ? identity : toRadians);
28
29
  }
29
30
  export function fromCartographicToDegrees(cartographic, vector = []) {
30
- return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);
31
+ return fromCartographic(cartographic, vector, config._cartographicRadians ? toDegrees : identity);
31
32
  }
32
33
  export function toCartographic(vector, cartographic, map = identity) {
33
- if ('longitude' in cartographic) {
34
- cartographic.longitude = map(vector[0]);
35
- cartographic.latitude = map(vector[1]);
36
- cartographic.height = vector[2];
37
- } else if ('x' in cartographic) {
38
- cartographic.x = map(vector[0]);
39
- cartographic.y = map(vector[1]);
40
- cartographic.z = vector[2];
41
- } else {
42
- cartographic[0] = map(vector[0]);
43
- cartographic[1] = map(vector[1]);
44
- cartographic[2] = vector[2];
45
- }
46
-
47
- return cartographic;
34
+ if ('longitude' in cartographic) {
35
+ cartographic.longitude = map(vector[0]);
36
+ cartographic.latitude = map(vector[1]);
37
+ cartographic.height = vector[2];
38
+ }
39
+ else if ('x' in cartographic) {
40
+ cartographic.x = map(vector[0]);
41
+ cartographic.y = map(vector[1]);
42
+ cartographic.z = vector[2];
43
+ }
44
+ else {
45
+ cartographic[0] = map(vector[0]);
46
+ cartographic[1] = map(vector[1]);
47
+ cartographic[2] = vector[2];
48
+ }
49
+ return cartographic;
48
50
  }
49
51
  export function toCartographicFromRadians(vector, cartographic) {
50
- return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);
52
+ return toCartographic(vector, cartographic, config._cartographicRadians ? identity : toDegrees);
51
53
  }
52
54
  export function toCartographicFromDegrees(vector, cartographic) {
53
- return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : identity);
55
+ return toCartographic(vector, cartographic, config._cartographicRadians ? toRadians : identity);
54
56
  }
57
+ // Estimates if a vector is close to the surface of the WGS84 Ellipsoid
55
58
  export function isWGS84(vector) {
56
- if (!vector) {
57
- return false;
58
- }
59
-
60
- scratchVector.from(vector);
61
- const {
62
- oneOverRadiiSquared,
63
- centerToleranceSquared
64
- } = WGS84_CONSTANTS;
65
- const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
66
- const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
67
- const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];
68
- return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
59
+ if (!vector) {
60
+ return false;
61
+ }
62
+ scratchVector.from(vector);
63
+ const { oneOverRadiiSquared, centerToleranceSquared } = WGS84_CONSTANTS;
64
+ const x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
65
+ const y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
66
+ const z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];
67
+ return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
69
68
  }
70
- //# sourceMappingURL=type-utils.js.map
69
+ /*
70
+
71
+ export function fromCartographic(cartographic: Cartographic, result?: number[]): number[];
72
+ export function fromCartographic(cartographic: Cartographic, result: TypedArray): TypedArray;
73
+ export function fromCartographicToRadians(cartographic: Cartographic, result?: number[]): number[];
74
+ export function fromCartographicToRadians(
75
+ cartographic: Cartographic,
76
+ result: TypedArray
77
+ ): TypedArray;
78
+ export function fromCartographicToDegrees(cartographic: Cartographic, result?: number[]): number[];
79
+ export function fromCartographicToDegrees(
80
+ cartographic: Cartographic,
81
+ result: TypedArray
82
+ ): TypedArray;
83
+
84
+ export function toCartographic(vector: number[] | TypedArray, result: Cartographic): number[];
85
+ export function toCartographicFromRadians(
86
+ vector: number[] | TypedArray,
87
+ result: Cartographic
88
+ ): number[];
89
+ export function toCartographicFromDegrees(
90
+ vector: number[] | TypedArray,
91
+ result: Cartographic
92
+ ): number[];
93
+
94
+ // Estimates if a vector is close to the surface of the WGS84 Ellipsoid
95
+ export function isWGS84(vector: number[] | TypedArray): boolean;
96
+ */
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "4.0.0-beta.1",
9
+ "version": "4.0.1",
10
10
  "keywords": [
11
11
  "webgl",
12
12
  "javascript",
@@ -29,9 +29,9 @@
29
29
  "module": "dist/index.js",
30
30
  "exports": {
31
31
  ".": {
32
+ "types": "./dist/index.d.ts",
32
33
  "import": "./dist/index.js",
33
- "require": "./dist/index.cjs",
34
- "types": "./dist/index.d.ts"
34
+ "require": "./dist/index.cjs"
35
35
  }
36
36
  },
37
37
  "files": [
@@ -39,8 +39,7 @@
39
39
  "src"
40
40
  ],
41
41
  "dependencies": {
42
- "@babel/runtime": "^7.12.0",
43
- "@math.gl/core": "4.0.0-beta.1"
42
+ "@math.gl/core": "4.0.1"
44
43
  },
45
- "gitHead": "5a2364216b6aadbece690e05b9b5b71753aee472"
44
+ "gitHead": "33f369ba3a259f79acc3fa8181190c9da8841648"
46
45
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,UAAY,CAAC;AACxC,eAAO,MAAM,cAAc,UAAY,CAAC;AACxC,eAAO,MAAM,cAAc,oBAAqB,CAAC;AAIjD,eAAO,MAAM,eAAe;;;;;;;CAe3B,CAAC"}
@@ -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":"AAGA,OAAO,MAAMA,cAAc,GAAG,SAAvB;AACP,OAAO,MAAMC,cAAc,GAAG,SAAvB;AACP,OAAO,MAAMC,cAAc,GAAG,kBAAvB;AAIP,OAAO,MAAMC,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 +0,0 @@
1
- {"version":3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AAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAKpD;;0EAEsE;IACtE,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAIxE;yDACqD;IACrD,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAmBrF;kEAC8D;IAC9D,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAI1F;4DACwD;IACxD,gCAAgC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,GAAE,MAAM,EAAc,GAAG,MAAM,EAAE;IAI5F,wFAAwF;IACxF,qCAAqC,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAM,EAAc,GAC3B,MAAM,EAAE;CAcZ"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/ellipsoid/ellipsoid.ts"],"names":["Vector3","Matrix4","assert","equals","_MathUtils","vec3","WGS84_RADIUS_X","WGS84_RADIUS_Y","WGS84_RADIUS_Z","fromCartographicToRadians","toCartographicFromRadians","localFrameToFixedFrame","scaleToGeodeticSurface","scratchVector","scratchNormal","scratchK","scratchPosition","scratchHeight","scratchCartesian","Ellipsoid","constructor","x","y","z","EPSILON1","radii","radiiSquared","radiiToTheFourth","oneOverRadii","oneOverRadiiSquared","minimumRadius","Math","min","maximumRadius","max","squaredXOverSquaredZ","Object","freeze","right","Boolean","toString","cartographicToCartesian","cartographic","result","normal","k","height","geodeticSurfaceNormalCartographic","copy","scale","gamma","sqrt","dot","add","to","cartesianToCartographic","cartesian","from","point","undefined","geodeticSurfaceNormal","h","subtract","longitude","atan2","latitude","asin","sign","length","eastNorthUpToFixedFrame","origin","firstAxis","secondAxis","thirdAxis","geocentricSurfaceNormal","normalize","cartographicVectorRadians","cosLatitude","cos","set","sin","scaleToGeocentricSurface","positionX","positionY","positionZ","beta","multiplyScalar","transformPositionToScaledSpace","position","transformPositionFromScaledSpace","getSurfaceNormalIntersectionWithZAxis","buffer","EPSILON15","abs"],"mappings":";AAIA,SAAQA,OAAR,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,MAAlC,EAA0CC,UAA1C,EAAoEC,IAApE,QAA+E,eAA/E;SAEQC,c,EAAgBC,c,EAAgBC,c;SAChCC,yB,EAA2BC,yB;SAG3BC,sB;SACAC,sB;AAER,MAAMC,aAAa,GAAG,IAAIb,OAAJ,EAAtB;AACA,MAAMc,aAAa,GAAG,IAAId,OAAJ,EAAtB;AACA,MAAMe,QAAQ,GAAG,IAAIf,OAAJ,EAAjB;AACA,MAAMgB,eAAe,GAAG,IAAIhB,OAAJ,EAAxB;AACA,MAAMiB,aAAa,GAAG,IAAIjB,OAAJ,EAAtB;AACA,MAAMkB,gBAAgB,GAAG,IAAIlB,OAAJ,EAAzB;AAOA,OAAO,MAAMmB,SAAN,CAAgB;AAkBrBC,EAAAA,WAAW,CAACC,CAAC,GAAG,GAAL,EAAUC,CAAC,GAAG,GAAd,EAAmBC,CAAC,GAAG,GAAvB,EAA4B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,oDAPGnB,UAAU,CAACoB,QAOd;;AAAA;;AACrCtB,IAAAA,MAAM,CAACmB,CAAC,IAAI,GAAN,CAAN;AACAnB,IAAAA,MAAM,CAACoB,CAAC,IAAI,GAAN,CAAN;AACApB,IAAAA,MAAM,CAACqB,CAAC,IAAI,GAAN,CAAN;AAEA,SAAKE,KAAL,GAAa,IAAIzB,OAAJ,CAAYqB,CAAZ,EAAeC,CAAf,EAAkBC,CAAlB,CAAb;AAEA,SAAKG,YAAL,GAAoB,IAAI1B,OAAJ,CAAYqB,CAAC,GAAGA,CAAhB,EAAmBC,CAAC,GAAGA,CAAvB,EAA0BC,CAAC,GAAGA,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AAN;AACA1F,IAAAA,MAAM,CAAC,KAAKuB,KAAL,CAAWF,CAAX,GAAe,CAAhB,CAAN;AAEAP,IAAAA,eAAe,CAACyC,IAAhB,CAAqB+B,QAArB;AACA,UAAMjE,CAAC,GAAGP,eAAe,CAACO,CAAhB,IAAqB,IAAI,KAAKY,oBAA9B,CAAV;;AAEA,QAAIJ,IAAI,CAAC8D,GAAL,CAAStE,CAAT,KAAe,KAAKE,KAAL,CAAWF,CAAX,GAAeoE,MAAlC,EAA0C;AACxC,aAAOhC,SAAP;AACD;;AAED,WAAO3C,eAAe,CAAC+D,GAAhB,CAAoB,GAApB,EAAyB,GAAzB,EAA8BxD,CAA9B,EAAiC+B,EAAjC,CAAoCX,MAApC,CAAP;AACD;;AAlPoB;;gBAAVxB,S,WAEwB,IAAIA,SAAJ,CAAcb,cAAd,EAA8BC,cAA9B,EAA8CC,cAA9C,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 {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray, vec3} from '@math.gl/core';\n\nimport {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';\nimport {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';\n\nimport type {AxisDirection} from './helpers/ellipsoid-transform';\nimport {localFrameToFixedFrame} from './helpers/ellipsoid-transform';\nimport {scaleToGeodeticSurface} from './helpers/scale-to-geodetic-surface';\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\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 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: Readonly<NumericArray>, 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: Readonly<NumericArray>, result: Vector3): Vector3;\n cartesianToCartographic(cartesian: Readonly<NumericArray>, result?: number[]): number[];\n\n cartesianToCartographic(cartesian: Readonly<NumericArray>, 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: Readonly<NumericArray>, result?: Matrix4): Matrix4;\n eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, result: number[]): number[];\n\n eastNorthUpToFixedFrame(origin: Readonly<NumericArray>, 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: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\n origin: Readonly<NumericArray>,\n result?: Matrix4\n ): Matrix4;\n localFrameToFixedFrame<Matrix4T>(\n firstAxis: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\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(\n firstAxis: AxisDirection,\n secondAxis: AxisDirection,\n thirdAxis: AxisDirection,\n origin: Readonly<NumericArray>,\n result = new Matrix4()\n ) {\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: Readonly<NumericArray>, 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>(\n cartographic: Readonly<NumericArray>,\n result: NumArray\n ): NumArray;\n geodeticSurfaceNormalCartographic(cartographic: number[]): number[];\n geodeticSurfaceNormalCartographic(cartographic: Readonly<NumericArray>, 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: Readonly<NumericArray>, 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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ellipsoid-transform.d.ts","sourceRoot":"","sources":["../../../src/ellipsoid/helpers/ellipsoid-transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAA2C,MAAM,eAAe,CAAC;AAErF,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAM5C,oBAAY,aAAa,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAsEhF,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,SAAS,EAAE,aAAa,EACxB,eAAe,EAAE,QAAQ,CAAC,YAAY,CAAC,EACvC,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,EAAE,CAuEV"}