@math.gl/geospatial 4.1.0 → 4.2.0-alpha.3

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.
Files changed (44) hide show
  1. package/dist/ellipsoid-helpers/ellipsoid-transform.d.ts.map +1 -0
  2. package/dist/ellipsoid-helpers/ellipsoid-transform.js.map +1 -0
  3. package/dist/ellipsoid-helpers/scale-to-geodetic-surface.d.ts.map +1 -0
  4. package/dist/ellipsoid-helpers/scale-to-geodetic-surface.js.map +1 -0
  5. package/dist/ellipsoid-tangent-plane.d.ts +30 -0
  6. package/dist/ellipsoid-tangent-plane.d.ts.map +1 -0
  7. package/dist/ellipsoid-tangent-plane.js +75 -0
  8. package/dist/ellipsoid-tangent-plane.js.map +1 -0
  9. package/dist/{ellipsoid/ellipsoid.d.ts → ellipsoid.d.ts} +1 -1
  10. package/dist/ellipsoid.d.ts.map +1 -0
  11. package/dist/{ellipsoid/ellipsoid.js → ellipsoid.js} +4 -4
  12. package/dist/ellipsoid.js.map +1 -0
  13. package/dist/index.cjs +124 -4
  14. package/dist/index.cjs.map +4 -4
  15. package/dist/index.d.ts +3 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +3 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/lng-lat-rectangle.d.ts +27 -0
  20. package/dist/lng-lat-rectangle.d.ts.map +1 -0
  21. package/dist/lng-lat-rectangle.js +54 -0
  22. package/dist/lng-lat-rectangle.js.map +1 -0
  23. package/dist/make-obb-from-region.d.ts +11 -0
  24. package/dist/make-obb-from-region.d.ts.map +1 -0
  25. package/dist/make-obb-from-region.js +173 -0
  26. package/dist/make-obb-from-region.js.map +1 -0
  27. package/package.json +5 -4
  28. package/src/ellipsoid-tangent-plane.ts +98 -0
  29. package/src/{ellipsoid/ellipsoid.ts → ellipsoid.ts} +5 -5
  30. package/src/index.ts +3 -1
  31. package/src/lng-lat-rectangle.ts +67 -0
  32. package/src/make-obb-from-region.ts +303 -0
  33. package/dist/ellipsoid/ellipsoid.d.ts.map +0 -1
  34. package/dist/ellipsoid/ellipsoid.js.map +0 -1
  35. package/dist/ellipsoid/helpers/ellipsoid-transform.d.ts.map +0 -1
  36. package/dist/ellipsoid/helpers/ellipsoid-transform.js.map +0 -1
  37. package/dist/ellipsoid/helpers/scale-to-geodetic-surface.d.ts.map +0 -1
  38. package/dist/ellipsoid/helpers/scale-to-geodetic-surface.js.map +0 -1
  39. /package/dist/{ellipsoid/helpers → ellipsoid-helpers}/ellipsoid-transform.d.ts +0 -0
  40. /package/dist/{ellipsoid/helpers → ellipsoid-helpers}/ellipsoid-transform.js +0 -0
  41. /package/dist/{ellipsoid/helpers → ellipsoid-helpers}/scale-to-geodetic-surface.d.ts +0 -0
  42. /package/dist/{ellipsoid/helpers → ellipsoid-helpers}/scale-to-geodetic-surface.js +0 -0
  43. /package/src/{ellipsoid/helpers → ellipsoid-helpers}/ellipsoid-transform.ts +0 -0
  44. /package/src/{ellipsoid/helpers → ellipsoid-helpers}/scale-to-geodetic-surface.ts +0 -0
@@ -0,0 +1,54 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT and Apache-2.0
3
+ // Copyright (c) vis.gl contributors
4
+ // This file is derived from the Cesium library under Apache 2 license
5
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
6
+ import { Vector3, normalizeAngle, _MathUtils } from '@math.gl/core';
7
+ /** A two dimensional region specified as longitude and latitude coordinates. */
8
+ export class LngLatRectangle {
9
+ /**
10
+ * Creates a new two dimensional region specified as longitude and latitude coordinates.
11
+ *
12
+ * @param west The westernmost longitude, in radians, in the range [-Pi, Pi].
13
+ * @param south The southernmost latitude, in radians, in the range [-Pi/2, Pi/2].
14
+ * @param east The easternmost longitude, in radians, in the range [-Pi, Pi].
15
+ * @param north The northernmost latitude, in radians, in the range [-Pi/2, Pi/2].
16
+ */
17
+ constructor(west, south, east, north) {
18
+ this.west = west;
19
+ this.south = south;
20
+ this.east = east;
21
+ this.north = north;
22
+ }
23
+ /**
24
+ * Computes the center of a rectangle.
25
+ *
26
+ * @param rectangle The rectangle for which to find the center
27
+ * @param [result] The object onto which to store the result.
28
+ * @returns The modified result parameter or a new Cartographic instance if none was provided.
29
+ */
30
+ static center(rectangle, result) {
31
+ if (!result)
32
+ result = new Vector3();
33
+ let east = rectangle.east;
34
+ const west = rectangle.west;
35
+ if (east < west) {
36
+ east += _MathUtils.TWO_PI;
37
+ }
38
+ const longitude = normalizeAngle((west + east) * 0.5, 'negative-pi-to-pi');
39
+ const latitude = (rectangle.south + rectangle.north) * 0.5;
40
+ result.x = longitude;
41
+ result.y = latitude;
42
+ result.z = 0.0;
43
+ return result;
44
+ }
45
+ get width() {
46
+ let east = this.east;
47
+ const west = this.west;
48
+ if (east < west) {
49
+ east += _MathUtils.TWO_PI;
50
+ }
51
+ return east - west;
52
+ }
53
+ }
54
+ //# sourceMappingURL=lng-lat-rectangle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lng-lat-rectangle.js","sourceRoot":"","sources":["../src/lng-lat-rectangle.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,8CAA8C;AAC9C,oCAAoC;AAEpC,sEAAsE;AACtE,4FAA4F;AAE5F,OAAO,EAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AAElE,gFAAgF;AAChF,MAAM,OAAO,eAAe;IAM1B;;;;;;;OAOG;IACH,YAAY,IAAY,EAAE,KAAa,EAAE,IAAY,EAAE,KAAa;QAClE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,SAA0B,EAAE,MAAgB;QACxD,IAAI,CAAC,MAAM;YAAE,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAEpC,IAAI,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAC1B,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC;QAE5B,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;YAChB,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC;QAC5B,CAAC;QAED,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,GAAG,EAAE,mBAAmB,CAAC,CAAC;QAC3E,MAAM,QAAQ,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;QAE3D,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;QACrB,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC;QACpB,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,IAAI,IAAI,GAAG,IAAI,EAAE,CAAC;YAChB,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { OrientedBoundingBox } from '@math.gl/culling';
2
+ /**
3
+ * Computes an OrientedBoundingBox that bounds a region on the surface of the WGS84 ellipsoid.
4
+ * There are no guarantees about the orientation of the bounding box.
5
+ *
6
+ * @param {number[]} region The cartographic region ([west, south, east, north, minimum height, maximum height])
7
+ * on the surface of the ellipsoid.
8
+ * @returns {OrientedBoundingBox} The modified result parameter or a new OrientedBoundingBox instance if none was provided.
9
+ */
10
+ export declare function makeOBBfromRegion(region: number[]): OrientedBoundingBox;
11
+ //# sourceMappingURL=make-obb-from-region.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-obb-from-region.d.ts","sourceRoot":"","sources":["../src/make-obb-from-region.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,mBAAmB,EAAQ,MAAM,kBAAkB,CAAC;AAuC5D;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAmB,CA6MvE"}
@@ -0,0 +1,173 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT and Apache-2.0
3
+ // Copyright (c) vis.gl contributors
4
+ // This file is derived from the Cesium math library under Apache 2 license
5
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
6
+ import { Vector2, Vector3, degrees, _MathUtils } from '@math.gl/core';
7
+ import { OrientedBoundingBox, Plane } from '@math.gl/culling';
8
+ // @ts-ignore
9
+ // eslint-disable-next-line import/no-unresolved
10
+ import { LngLatRectangle } from "./lng-lat-rectangle.js";
11
+ import { Ellipsoid } from "./ellipsoid.js";
12
+ import { EllipsoidTangentPlane } from "./ellipsoid-tangent-plane.js";
13
+ const scratchOffset = new Vector3();
14
+ const scratchTangentPoint = new Vector3();
15
+ const scratchPerimeterCartographicNC = new Vector3();
16
+ const scratchPerimeterCartographicNW = new Vector3();
17
+ const scratchPerimeterCartographicCW = new Vector3();
18
+ const scratchPerimeterCartographicSW = new Vector3();
19
+ const scratchPerimeterCartographicSC = new Vector3();
20
+ const scratchPerimeterCartesianNC = new Vector3();
21
+ const scratchPerimeterCartesianNW = new Vector3();
22
+ const scratchPerimeterCartesianCW = new Vector3();
23
+ const scratchPerimeterCartesianSW = new Vector3();
24
+ const scratchPerimeterCartesianSC = new Vector3();
25
+ const scratchPerimeterProjectedNC = new Vector2();
26
+ const scratchPerimeterProjectedNW = new Vector2();
27
+ const scratchPerimeterProjectedCW = new Vector2();
28
+ const scratchPerimeterProjectedSW = new Vector2();
29
+ const scratchPerimeterProjectedSC = new Vector2();
30
+ const scratchPlane = new Plane();
31
+ const scratchPlaneOrigin = new Vector3();
32
+ const scratchPlaneNormal = new Vector3();
33
+ const scratchPlaneXAxis = new Vector3();
34
+ const scratchHorizonCartesian = new Vector3();
35
+ const scratchHorizonProjected = new Vector2();
36
+ const scratchMaxY = new Vector3();
37
+ const scratchMinY = new Vector3();
38
+ const scratchZ = new Vector3();
39
+ const VECTOR3_UNIT_X = new Vector3(1, 0, 0);
40
+ const VECTOR3_UNIT_Z = new Vector3(0, 0, 1);
41
+ /**
42
+ * Computes an OrientedBoundingBox that bounds a region on the surface of the WGS84 ellipsoid.
43
+ * There are no guarantees about the orientation of the bounding box.
44
+ *
45
+ * @param {number[]} region The cartographic region ([west, south, east, north, minimum height, maximum height])
46
+ * on the surface of the ellipsoid.
47
+ * @returns {OrientedBoundingBox} The modified result parameter or a new OrientedBoundingBox instance if none was provided.
48
+ */
49
+ // eslint-disable-next-line max-statements
50
+ export function makeOBBfromRegion(region) {
51
+ const obb = new OrientedBoundingBox();
52
+ const [west, south, east, north, minimumHeight, maximumHeight] = region;
53
+ const northDeg = degrees(north);
54
+ const southDeg = degrees(south);
55
+ let maxX;
56
+ let maxY;
57
+ let maxZ;
58
+ let minX;
59
+ let minY;
60
+ let minZ;
61
+ let plane;
62
+ const rectangle = new LngLatRectangle(west, south, east, north);
63
+ const tangentPoint = LngLatRectangle.center(rectangle, scratchTangentPoint);
64
+ const tangentPointCartographic = new Vector3([
65
+ degrees(tangentPoint.x),
66
+ degrees(tangentPoint.y),
67
+ 0.0
68
+ ]);
69
+ const lonCenter = tangentPoint.x;
70
+ const lonCenterDeg = tangentPointCartographic.x;
71
+ if (rectangle.width <= _MathUtils.PI) {
72
+ const westDeg = degrees(west);
73
+ const tangentPoint = Ellipsoid.WGS84.cartographicToCartesian(tangentPointCartographic);
74
+ const ellipsoidTangentPlane = new EllipsoidTangentPlane(tangentPoint);
75
+ const latCenter = southDeg < 0.0 && northDeg > 0.0 ? 0.0 : tangentPointCartographic.y;
76
+ const perimeterCartographicNC = scratchPerimeterCartographicNC.copy([
77
+ lonCenterDeg,
78
+ northDeg,
79
+ maximumHeight
80
+ ]);
81
+ const perimeterCartographicNW = scratchPerimeterCartographicNW.copy([
82
+ westDeg,
83
+ northDeg,
84
+ maximumHeight
85
+ ]);
86
+ const perimeterCartographicCW = scratchPerimeterCartographicCW.copy([
87
+ westDeg,
88
+ latCenter,
89
+ maximumHeight
90
+ ]);
91
+ const perimeterCartographicSW = scratchPerimeterCartographicSW.copy([
92
+ westDeg,
93
+ southDeg,
94
+ maximumHeight
95
+ ]);
96
+ const perimeterCartographicSC = scratchPerimeterCartographicSC.copy([
97
+ lonCenterDeg,
98
+ southDeg,
99
+ maximumHeight
100
+ ]);
101
+ const perimeterCartesianNC = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicNC, scratchPerimeterCartesianNC);
102
+ let perimeterCartesianNW = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicNW, scratchPerimeterCartesianNW);
103
+ const perimeterCartesianCW = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicCW, scratchPerimeterCartesianCW);
104
+ let perimeterCartesianSW = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicSW, scratchPerimeterCartesianSW);
105
+ const perimeterCartesianSC = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicSC, scratchPerimeterCartesianSC);
106
+ const perimeterProjectedNC = ellipsoidTangentPlane.projectPointToNearestOnPlane(perimeterCartesianNC, scratchPerimeterProjectedNC);
107
+ const perimeterProjectedNW = ellipsoidTangentPlane.projectPointToNearestOnPlane(perimeterCartesianNW, scratchPerimeterProjectedNW);
108
+ const perimeterProjectedCW = ellipsoidTangentPlane.projectPointToNearestOnPlane(perimeterCartesianCW, scratchPerimeterProjectedCW);
109
+ const perimeterProjectedSW = ellipsoidTangentPlane.projectPointToNearestOnPlane(perimeterCartesianSW, scratchPerimeterProjectedSW);
110
+ const perimeterProjectedSC = ellipsoidTangentPlane.projectPointToNearestOnPlane(perimeterCartesianSC, scratchPerimeterProjectedSC);
111
+ minX = Math.min(perimeterProjectedNW.x, perimeterProjectedCW.x, perimeterProjectedSW.x);
112
+ maxX = -minX;
113
+ maxY = Math.max(perimeterProjectedNW.y, perimeterProjectedNC.y);
114
+ minY = Math.min(perimeterProjectedSW.y, perimeterProjectedSC.y);
115
+ perimeterCartographicNW.z = perimeterCartographicSW.z = minimumHeight;
116
+ perimeterCartesianNW = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicNW, scratchPerimeterCartesianNW);
117
+ perimeterCartesianSW = Ellipsoid.WGS84.cartographicToCartesian(perimeterCartographicSW, scratchPerimeterCartesianSW);
118
+ plane = ellipsoidTangentPlane.plane;
119
+ minZ = Math.min(plane.getPointDistance(perimeterCartesianNW), plane.getPointDistance(perimeterCartesianSW));
120
+ maxZ = maximumHeight;
121
+ return fromPlaneExtents(ellipsoidTangentPlane.origin, ellipsoidTangentPlane.xAxis, ellipsoidTangentPlane.yAxis, ellipsoidTangentPlane.zAxis, minX, maxX, minY, maxY, minZ, maxZ, obb);
122
+ }
123
+ const eastDeg = degrees(east);
124
+ const fullyAboveEquator = south > 0.0;
125
+ const fullyBelowEquator = north < 0.0;
126
+ const latitudeNearestToEquator = fullyAboveEquator
127
+ ? southDeg
128
+ : fullyBelowEquator
129
+ ? northDeg
130
+ : 0.0;
131
+ const planeOrigin = Ellipsoid.WGS84.cartographicToCartesian([lonCenterDeg, latitudeNearestToEquator, maximumHeight], scratchPlaneOrigin);
132
+ planeOrigin.z = 0.0;
133
+ const isPole = Math.abs(planeOrigin.x) < _MathUtils.EPSILON10 &&
134
+ Math.abs(planeOrigin.y) < _MathUtils.EPSILON10;
135
+ const planeNormal = !isPole ? scratchPlaneNormal.copy(planeOrigin).normalize() : VECTOR3_UNIT_X;
136
+ const planeYAxis = VECTOR3_UNIT_Z;
137
+ const planeXAxis = scratchPlaneXAxis.copy(planeNormal).cross(planeYAxis);
138
+ plane = scratchPlane.fromPointNormal(planeOrigin, planeNormal);
139
+ const horizonCartesian = Ellipsoid.WGS84.cartographicToCartesian([degrees(lonCenter + _MathUtils.PI_OVER_TWO), latitudeNearestToEquator, maximumHeight], scratchHorizonCartesian);
140
+ const projectedPoint = plane.projectPointOntoPlane(horizonCartesian, scratchHorizonProjected);
141
+ maxX = projectedPoint.dot(planeXAxis);
142
+ minX = -maxX;
143
+ maxY = Ellipsoid.WGS84.cartographicToCartesian([0.0, northDeg, fullyBelowEquator ? minimumHeight : maximumHeight], scratchMaxY).z;
144
+ minY = Ellipsoid.WGS84.cartographicToCartesian([0.0, southDeg, fullyAboveEquator ? minimumHeight : maximumHeight], scratchMinY).z;
145
+ const farZ = Ellipsoid.WGS84.cartographicToCartesian([eastDeg, latitudeNearestToEquator, maximumHeight], scratchZ);
146
+ minZ = plane.getPointDistance(farZ);
147
+ maxZ = 0.0;
148
+ return fromPlaneExtents(planeOrigin, planeXAxis, planeYAxis, planeNormal, minX, maxX, minY, maxY, minZ, maxZ, obb);
149
+ }
150
+ const scratchScale = new Vector3();
151
+ /** helper function for OrientedBoundingBox.fromRegion() */
152
+ // eslint-disable-next-line max-params
153
+ function fromPlaneExtents(planeOrigin, planeXAxis, planeYAxis, planeZAxis, minimumX, maximumX, minimumY, maximumY, minimumZ, maximumZ, result) {
154
+ const center = result.center;
155
+ const halfAxes = result.halfAxes;
156
+ halfAxes.setColumn(0, planeXAxis);
157
+ halfAxes.setColumn(1, planeYAxis);
158
+ halfAxes.setColumn(2, planeZAxis);
159
+ let centerOffset = scratchOffset;
160
+ centerOffset.x = (minimumX + maximumX) / 2.0;
161
+ centerOffset.y = (minimumY + maximumY) / 2.0;
162
+ centerOffset.z = (minimumZ + maximumZ) / 2.0;
163
+ centerOffset = halfAxes.multiplyByVector(centerOffset, scratchOffset);
164
+ const scale = scratchScale;
165
+ scale.x = (maximumX - minimumX) / 2.0;
166
+ scale.y = (maximumY - minimumY) / 2.0;
167
+ scale.z = (maximumZ - minimumZ) / 2.0;
168
+ planeOrigin = center.copy(planeOrigin);
169
+ result.center = planeOrigin.add(centerOffset);
170
+ result.halfAxes = halfAxes.multiplyByScale(scale, halfAxes);
171
+ return result;
172
+ }
173
+ //# sourceMappingURL=make-obb-from-region.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"make-obb-from-region.js","sourceRoot":"","sources":["../src/make-obb-from-region.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,8CAA8C;AAC9C,oCAAoC;AAEpC,2EAA2E;AAC3E,4FAA4F;AAE5F,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAC,MAAM,eAAe,CAAC;AACpE,OAAO,EAAC,mBAAmB,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAC;AAC5D,aAAa;AACb,gDAAgD;AAChD,OAAO,EAAC,eAAe,EAAC,+BAA4B;AACpD,OAAO,EAAC,SAAS,EAAC,uBAAoB;AACtC,OAAO,EAAC,qBAAqB,EAAC,qCAAkC;AAEhE,MAAM,aAAa,GAAG,IAAI,OAAO,EAAE,CAAC;AAEpC,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAE,CAAC;AAC1C,MAAM,8BAA8B,GAAG,IAAI,OAAO,EAAE,CAAC;AACrD,MAAM,8BAA8B,GAAG,IAAI,OAAO,EAAE,CAAC;AACrD,MAAM,8BAA8B,GAAG,IAAI,OAAO,EAAE,CAAC;AACrD,MAAM,8BAA8B,GAAG,IAAI,OAAO,EAAE,CAAC;AACrD,MAAM,8BAA8B,GAAG,IAAI,OAAO,EAAE,CAAC;AACrD,MAAM,2BAA2B,GAAG,IAAI,OAAO,EAAE,CAAC;AAClD,MAAM,2BAA2B,GAAG,IAAI,OAAO,EAAE,CAAC;AAClD,MAAM,2BAA2B,GAAG,IAAI,OAAO,EAAE,CAAC;AAClD,MAAM,2BAA2B,GAAG,IAAI,OAAO,EAAE,CAAC;AAClD,MAAM,2BAA2B,GAAG,IAAI,OAAO,EAAE,CAAC;AAClD,MAAM,2BAA2B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AC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAElC,IAAI,YAAY,GAAG,aAAa,CAAC;IACjC,YAAY,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IAC7C,YAAY,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IAC7C,YAAY,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IAC7C,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAEtE,MAAM,KAAK,GAAG,YAAY,CAAC;IAC3B,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IACtC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IACtC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,GAAG,CAAC;IAEtC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE5D,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "4.1.0",
9
+ "version": "4.2.0-alpha.3",
10
10
  "keywords": [
11
11
  "webgl",
12
12
  "javascript",
@@ -39,8 +39,9 @@
39
39
  "src"
40
40
  ],
41
41
  "dependencies": {
42
- "@math.gl/core": "4.1.0",
43
- "@math.gl/types": "4.1.0"
42
+ "@math.gl/core": "4.2.0-alpha.3",
43
+ "@math.gl/culling": "4.2.0-alpha.3",
44
+ "@math.gl/types": "4.2.0-alpha.3"
44
45
  },
45
- "gitHead": "76820f54e2a9034b42bd24ffeb381cc4e01ad46e"
46
+ "gitHead": "4238aa95fb38da43a65c6e5f2b8343a875666d92"
46
47
  }
@@ -0,0 +1,98 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT and Apache-2.0
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // This file is derived from the Cesium library under Apache 2 license
6
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
7
+
8
+ import {Vector2, Vector3, Matrix4} from '@math.gl/core';
9
+ import {Plane, Ray} from '@math.gl/culling';
10
+ import {Ellipsoid} from './ellipsoid';
11
+
12
+ const scratchOrigin = new Vector3();
13
+ const scratchCart3 = new Vector3();
14
+ const scratchEastNorthUp = new Matrix4();
15
+ const scratchPlane = new Plane();
16
+
17
+ const scratchProjectPointOntoPlaneRay = new Ray();
18
+ const scratchProjectPointOntoPlaneCartesian3 = new Vector3();
19
+ const scratchDirection = new Vector3();
20
+
21
+ /** A plane tangent to the WGS84 ellipsoid at the provided origin */
22
+ export class EllipsoidTangentPlane {
23
+ private _origin: Vector3;
24
+ private _xAxis: Vector3;
25
+ private _yAxis: Vector3;
26
+ private _plane: Plane;
27
+
28
+ /**
29
+ * Creates a new plane tangent to the WGS84 ellipsoid at the provided origin.
30
+ * If origin is not on the surface of the ellipsoid, it's surface projection will be used.
31
+ *
32
+ * @param {Cartesian3} origin The point on the surface of the ellipsoid where the tangent plane touches.
33
+ */
34
+ constructor(origin: number[]) {
35
+ origin = Ellipsoid.WGS84.scaleToGeodeticSurface(origin, scratchOrigin);
36
+
37
+ const eastNorthUp = Ellipsoid.WGS84.eastNorthUpToFixedFrame(origin, scratchEastNorthUp);
38
+
39
+ this._origin = origin as Vector3;
40
+ this._xAxis = new Vector3(scratchCart3.from(eastNorthUp.getColumn(0)));
41
+ this._yAxis = new Vector3(scratchCart3.from(eastNorthUp.getColumn(1)));
42
+ const normal = new Vector3(scratchCart3.from(eastNorthUp.getColumn(2)));
43
+
44
+ this._plane = scratchPlane.fromPointNormal(origin, normal);
45
+ }
46
+
47
+ /**
48
+ * Computes the projection of the provided 3D position onto the 2D plane, along the plane normal.
49
+ *
50
+ * @param {Vector3} cartesian The point to project.
51
+ * @param {Vector2} [result] The object onto which to store the result.
52
+ * @returns {Vector2} The modified result parameter or a new Cartesian2 instance if none was provided.
53
+ */
54
+ projectPointToNearestOnPlane(cartesian: Vector3, result?: Vector2): Vector2 {
55
+ if (!result) result = new Vector2();
56
+
57
+ const plane = this._plane;
58
+
59
+ const ray = scratchProjectPointOntoPlaneRay;
60
+ scratchProjectPointOntoPlaneRay.origin = cartesian;
61
+ scratchProjectPointOntoPlaneRay.direction = scratchDirection.copy(plane.normal);
62
+
63
+ let intersectionPoint = plane.intersectWithRay(ray, scratchProjectPointOntoPlaneCartesian3);
64
+
65
+ if (!intersectionPoint) {
66
+ ray.direction = ray.direction.negate();
67
+ intersectionPoint = plane.intersectWithRay(ray, scratchProjectPointOntoPlaneCartesian3);
68
+ }
69
+
70
+ const v = intersectionPoint.subtract(this._origin);
71
+ const x = this._xAxis.dot(v);
72
+ const y = this._yAxis.dot(v);
73
+
74
+ result.x = x;
75
+ result.y = y;
76
+ return result;
77
+ }
78
+
79
+ get plane() {
80
+ return this._plane;
81
+ }
82
+
83
+ get origin() {
84
+ return this._origin;
85
+ }
86
+
87
+ get xAxis() {
88
+ return this._xAxis;
89
+ }
90
+
91
+ get yAxis() {
92
+ return this._yAxis;
93
+ }
94
+
95
+ get zAxis() {
96
+ return this._plane.normal;
97
+ }
98
+ }
@@ -8,12 +8,12 @@
8
8
  /* eslint-disable */
9
9
  import {Vector3, Matrix4, assert, equals, _MathUtils, NumericArray, vec3} from '@math.gl/core';
10
10
 
11
- import {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from '../constants';
12
- import {fromCartographicToRadians, toCartographicFromRadians} from '../type-utils';
11
+ import {WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z} from './constants';
12
+ import {fromCartographicToRadians, toCartographicFromRadians} from './type-utils';
13
13
 
14
- import type {AxisDirection} from './helpers/ellipsoid-transform';
15
- import {localFrameToFixedFrame} from './helpers/ellipsoid-transform';
16
- import {scaleToGeodeticSurface} from './helpers/scale-to-geodetic-surface';
14
+ import type {AxisDirection} from './ellipsoid-helpers/ellipsoid-transform';
15
+ import {localFrameToFixedFrame} from './ellipsoid-helpers/ellipsoid-transform';
16
+ import {scaleToGeodeticSurface} from './ellipsoid-helpers/scale-to-geodetic-surface';
17
17
 
18
18
  const scratchVector = new Vector3();
19
19
  const scratchNormal = new Vector3();
package/src/index.ts CHANGED
@@ -2,5 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- export {Ellipsoid} from './ellipsoid/ellipsoid';
5
+ export {Ellipsoid} from './ellipsoid';
6
+ export {EllipsoidTangentPlane} from './ellipsoid-tangent-plane';
7
+ export {LngLatRectangle} from './lng-lat-rectangle';
6
8
  export {isWGS84} from './type-utils';
@@ -0,0 +1,67 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT and Apache-2.0
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ // This file is derived from the Cesium library under Apache 2 license
6
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
7
+
8
+ import {Vector3, normalizeAngle, _MathUtils} from '@math.gl/core';
9
+
10
+ /** A two dimensional region specified as longitude and latitude coordinates. */
11
+ export class LngLatRectangle {
12
+ west: number;
13
+ south: number;
14
+ east: number;
15
+ north: number;
16
+
17
+ /**
18
+ * Creates a new two dimensional region specified as longitude and latitude coordinates.
19
+ *
20
+ * @param west The westernmost longitude, in radians, in the range [-Pi, Pi].
21
+ * @param south The southernmost latitude, in radians, in the range [-Pi/2, Pi/2].
22
+ * @param east The easternmost longitude, in radians, in the range [-Pi, Pi].
23
+ * @param north The northernmost latitude, in radians, in the range [-Pi/2, Pi/2].
24
+ */
25
+ constructor(west: number, south: number, east: number, north: number) {
26
+ this.west = west;
27
+ this.south = south;
28
+ this.east = east;
29
+ this.north = north;
30
+ }
31
+
32
+ /**
33
+ * Computes the center of a rectangle.
34
+ *
35
+ * @param rectangle The rectangle for which to find the center
36
+ * @param [result] The object onto which to store the result.
37
+ * @returns The modified result parameter or a new Cartographic instance if none was provided.
38
+ */
39
+ static center(rectangle: LngLatRectangle, result?: Vector3): Vector3 {
40
+ if (!result) result = new Vector3();
41
+
42
+ let east = rectangle.east;
43
+ const west = rectangle.west;
44
+
45
+ if (east < west) {
46
+ east += _MathUtils.TWO_PI;
47
+ }
48
+
49
+ const longitude = normalizeAngle((west + east) * 0.5, 'negative-pi-to-pi');
50
+ const latitude = (rectangle.south + rectangle.north) * 0.5;
51
+
52
+ result.x = longitude;
53
+ result.y = latitude;
54
+ result.z = 0.0;
55
+ return result;
56
+ }
57
+
58
+ get width() {
59
+ let east = this.east;
60
+ const west = this.west;
61
+
62
+ if (east < west) {
63
+ east += _MathUtils.TWO_PI;
64
+ }
65
+ return east - west;
66
+ }
67
+ }