@itowns/geographic 2.46.1-next.0 → 2.46.1-next.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/lib/Coordinates.js +13 -13
- package/lib/Ellipsoid.js +17 -17
- package/lib/Extent.js +19 -22
- package/lib/OrientationUtils.js +20 -21
- package/package.json +6 -6
- package/src/Coordinates.ts +23 -24
- package/src/Crs.ts +9 -9
- package/src/Ellipsoid.ts +31 -30
- package/src/Extent.ts +33 -27
- package/src/OrientationUtils.ts +21 -23
- package/src/{Main.ts → index.ts} +3 -2
- package/lib/CoordStars.d.ts +0 -13
- package/lib/Coordinates.d.ts +0 -196
- package/lib/Crs.d.ts +0 -93
- package/lib/Ellipsoid.d.ts +0 -74
- package/lib/Extent.d.ts +0 -246
- package/lib/Main.d.ts +0 -6
- package/lib/OrientationUtils.d.ts +0 -105
- /package/lib/{Main.js → index.js} +0 -0
package/src/Ellipsoid.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Vector3, type Vector3Like, type Ray, MathUtils } from 'three';
|
|
2
2
|
import proj4 from 'proj4';
|
|
3
3
|
import Coordinates from './Coordinates';
|
|
4
4
|
|
|
@@ -6,34 +6,35 @@ import Coordinates from './Coordinates';
|
|
|
6
6
|
* Length of the semi-axes of the WGS84 ellipsoid.
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export const ellipsoidSizes = new
|
|
9
|
+
export const ellipsoidSizes = /* @__PURE__ */ (() => new Vector3(
|
|
10
10
|
proj4.WGS84.a,
|
|
11
11
|
proj4.WGS84.a,
|
|
12
|
-
proj4.WGS84.b
|
|
12
|
+
proj4.WGS84.b,
|
|
13
|
+
))();
|
|
13
14
|
|
|
14
|
-
const normal = new
|
|
15
|
+
const normal = /* @__PURE__ */ new Vector3();
|
|
15
16
|
|
|
16
17
|
class Ellipsoid {
|
|
17
18
|
/**
|
|
18
19
|
* Length of the semi-axes of the ellipsoid.
|
|
19
20
|
*/
|
|
20
|
-
size:
|
|
21
|
+
size: Vector3;
|
|
21
22
|
/**
|
|
22
23
|
* Eccentricity of the ellipsoid.
|
|
23
24
|
*/
|
|
24
25
|
eccentricity: number;
|
|
25
26
|
|
|
26
|
-
private _radiiSquared:
|
|
27
|
-
private _invRadiiSquared:
|
|
27
|
+
private _radiiSquared: Vector3;
|
|
28
|
+
private _invRadiiSquared: Vector3;
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* @param size - Length of the semi-axes of the ellipsoid. Defaults to those
|
|
31
32
|
* defined by the WGS84 ellipsoid.
|
|
32
33
|
*/
|
|
33
|
-
constructor(size:
|
|
34
|
-
this.size = new
|
|
35
|
-
this._radiiSquared = new
|
|
36
|
-
this._invRadiiSquared = new
|
|
34
|
+
constructor(size: Vector3 = ellipsoidSizes) {
|
|
35
|
+
this.size = new Vector3();
|
|
36
|
+
this._radiiSquared = new Vector3();
|
|
37
|
+
this._invRadiiSquared = new Vector3();
|
|
37
38
|
this.eccentricity = 0;
|
|
38
39
|
|
|
39
40
|
this.setSize(size);
|
|
@@ -49,8 +50,8 @@ class Ellipsoid {
|
|
|
49
50
|
*/
|
|
50
51
|
geodeticSurfaceNormal(
|
|
51
52
|
cartesian: Coordinates,
|
|
52
|
-
target = new
|
|
53
|
-
):
|
|
53
|
+
target = new Vector3(),
|
|
54
|
+
): Vector3 {
|
|
54
55
|
return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -64,10 +65,10 @@ class Ellipsoid {
|
|
|
64
65
|
*/
|
|
65
66
|
geodeticSurfaceNormalCartographic(
|
|
66
67
|
coordCarto: Coordinates,
|
|
67
|
-
target = new
|
|
68
|
-
):
|
|
69
|
-
const longitude =
|
|
70
|
-
const latitude =
|
|
68
|
+
target = new Vector3(),
|
|
69
|
+
): Vector3 {
|
|
70
|
+
const longitude = MathUtils.degToRad(coordCarto.longitude);
|
|
71
|
+
const latitude = MathUtils.degToRad(coordCarto.latitude);
|
|
71
72
|
const cosLatitude = Math.cos(latitude);
|
|
72
73
|
|
|
73
74
|
return target.set(cosLatitude * Math.cos(longitude),
|
|
@@ -82,7 +83,7 @@ class Ellipsoid {
|
|
|
82
83
|
*
|
|
83
84
|
* @param size - The source vector.
|
|
84
85
|
*/
|
|
85
|
-
setSize(size:
|
|
86
|
+
setSize(size: Vector3Like): this {
|
|
86
87
|
this.size.set(size.x, size.y, size.z);
|
|
87
88
|
|
|
88
89
|
this._radiiSquared.multiplyVectors(size, size);
|
|
@@ -98,8 +99,8 @@ class Ellipsoid {
|
|
|
98
99
|
|
|
99
100
|
cartographicToCartesian(
|
|
100
101
|
coordCarto: Coordinates,
|
|
101
|
-
target = new
|
|
102
|
-
):
|
|
102
|
+
target = new Vector3(),
|
|
103
|
+
): Vector3 {
|
|
103
104
|
normal.copy(coordCarto.geodesicNormal);
|
|
104
105
|
|
|
105
106
|
target.multiplyVectors(this._radiiSquared, normal);
|
|
@@ -122,7 +123,7 @@ class Ellipsoid {
|
|
|
122
123
|
* angles are in degree
|
|
123
124
|
*/
|
|
124
125
|
cartesianToCartographic(
|
|
125
|
-
position:
|
|
126
|
+
position: Vector3Like,
|
|
126
127
|
target = new Coordinates('EPSG:4326', 0, 0, 0),
|
|
127
128
|
): Coordinates {
|
|
128
129
|
// for details, see for example http://www.linz.govt.nz/data/geodetic-system/coordinate-conversion/geodetic-datum-conversions/equations-used-datum
|
|
@@ -152,13 +153,13 @@ class Ellipsoid {
|
|
|
152
153
|
a * Math.sqrt(1 - e * Math.sin(phi) * Math.sin(phi));
|
|
153
154
|
|
|
154
155
|
return target.setFromValues(
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
MathUtils.radToDeg(theta),
|
|
157
|
+
MathUtils.radToDeg(phi),
|
|
157
158
|
h,
|
|
158
159
|
);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
|
-
cartographicToCartesianArray(coordCartoArray: Coordinates[]):
|
|
162
|
+
cartographicToCartesianArray(coordCartoArray: Coordinates[]): Vector3[] {
|
|
162
163
|
const cartesianArray = [];
|
|
163
164
|
for (let i = 0; i < coordCartoArray.length; i++) {
|
|
164
165
|
cartesianArray.push(this.cartographicToCartesian(coordCartoArray[i]));
|
|
@@ -167,7 +168,7 @@ class Ellipsoid {
|
|
|
167
168
|
return cartesianArray;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
|
-
intersection(ray:
|
|
171
|
+
intersection(ray: Ray): Vector3 | false {
|
|
171
172
|
const EPSILON = 0.0001;
|
|
172
173
|
const O_C = ray.origin;
|
|
173
174
|
const dir = ray.direction;
|
|
@@ -207,7 +208,7 @@ class Ellipsoid {
|
|
|
207
208
|
|
|
208
209
|
if (t < EPSILON) { return false; } // Too close to intersection
|
|
209
210
|
|
|
210
|
-
const inter = new
|
|
211
|
+
const inter = new Vector3();
|
|
211
212
|
|
|
212
213
|
inter.addVectors(ray.origin, dir.clone().setLength(t));
|
|
213
214
|
|
|
@@ -228,10 +229,10 @@ class Ellipsoid {
|
|
|
228
229
|
// The formula uses the distance on approximated sphere,
|
|
229
230
|
// with the nearest local radius of curvature of the ellipsoid
|
|
230
231
|
// https://geodesie.ign.fr/contenu/fichiers/Distance_longitude_latitude.pdf
|
|
231
|
-
const longitude1 =
|
|
232
|
-
const latitude1 =
|
|
233
|
-
const longitude2 =
|
|
234
|
-
const latitude2 =
|
|
232
|
+
const longitude1 = MathUtils.degToRad(coordCarto1.longitude);
|
|
233
|
+
const latitude1 = MathUtils.degToRad(coordCarto1.latitude);
|
|
234
|
+
const longitude2 = MathUtils.degToRad(coordCarto2.longitude);
|
|
235
|
+
const latitude2 = MathUtils.degToRad(coordCarto2.latitude);
|
|
235
236
|
|
|
236
237
|
const distRad = Math.acos(
|
|
237
238
|
Math.sin(latitude1) * Math.sin(latitude2) +
|
package/src/Extent.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Vector2, Vector3, Vector4, Box3, type Matrix4 } from 'three';
|
|
2
2
|
import Coordinates from './Coordinates';
|
|
3
3
|
import * as CRS from './Crs';
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { ProjectionLike } from './Crs';
|
|
6
6
|
|
|
7
|
-
const _dim = new
|
|
8
|
-
const _dim2 = new
|
|
9
|
-
const _box = new
|
|
10
|
-
const defaultScheme = new
|
|
7
|
+
const _dim = /* @__PURE__ */ new Vector2();
|
|
8
|
+
const _dim2 = /* @__PURE__ */ new Vector2();
|
|
9
|
+
const _box = /* @__PURE__ */ new Box3();
|
|
10
|
+
const defaultScheme = /* @__PURE__ */ new Vector2(2, 2);
|
|
11
11
|
|
|
12
|
-
const cNorthWest = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
13
|
-
const cSouthWest = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
14
|
-
const cNorthEast = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
12
|
+
const cNorthWest = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0);
|
|
13
|
+
const cSouthWest = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0);
|
|
14
|
+
const cNorthEast = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0);
|
|
15
15
|
|
|
16
|
-
const southWest = new
|
|
17
|
-
const northEast = new
|
|
16
|
+
const southWest = /* @__PURE__ */ new Vector3();
|
|
17
|
+
const northEast = /* @__PURE__ */ new Vector3();
|
|
18
18
|
|
|
19
19
|
let _extent: Extent;
|
|
20
20
|
|
|
21
|
-
const cardinals =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const cardinals = [
|
|
22
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
23
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
24
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
25
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
26
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
27
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
28
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
29
|
+
/* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0),
|
|
30
|
+
] as const;
|
|
25
31
|
|
|
26
|
-
const _c = new Coordinates('EPSG:4326', 0, 0);
|
|
32
|
+
const _c = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0);
|
|
27
33
|
|
|
28
34
|
export interface ExtentLike {
|
|
29
35
|
readonly west: number;
|
|
@@ -47,9 +53,9 @@ class Extent {
|
|
|
47
53
|
*/
|
|
48
54
|
readonly isExtent: true;
|
|
49
55
|
/**
|
|
50
|
-
* A default or user-defined CRS (see {@link
|
|
56
|
+
* A default or user-defined CRS (see {@link ProjectionLike}).
|
|
51
57
|
*/
|
|
52
|
-
crs:
|
|
58
|
+
crs: ProjectionLike;
|
|
53
59
|
/**
|
|
54
60
|
* West longitude bound of this extent.
|
|
55
61
|
*/
|
|
@@ -68,13 +74,13 @@ class Extent {
|
|
|
68
74
|
north: number;
|
|
69
75
|
|
|
70
76
|
/**
|
|
71
|
-
* @param crs - A default or user-defined CRS (see {@link
|
|
77
|
+
* @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
|
|
72
78
|
* @param west - the `west` value of this extent. Default is 0.
|
|
73
79
|
* @param east - the `east` value of this extent. Default is 0.
|
|
74
80
|
* @param south - the `south` value of this extent. Default is 0.
|
|
75
81
|
* @param north - the `north` value of this extent. Default is 0.
|
|
76
82
|
*/
|
|
77
|
-
constructor(crs:
|
|
83
|
+
constructor(crs: ProjectionLike, west = 0, east = 0, south = 0, north = 0) {
|
|
78
84
|
if (CRS.isGeocentric(crs)) {
|
|
79
85
|
throw new Error(
|
|
80
86
|
`Non-compatible geocentric projection ${crs} to build a geographical extent`,
|
|
@@ -167,7 +173,7 @@ class Extent {
|
|
|
167
173
|
*
|
|
168
174
|
* @param target - optional target
|
|
169
175
|
*/
|
|
170
|
-
planarDimensions(target = new
|
|
176
|
+
planarDimensions(target = new Vector2()) {
|
|
171
177
|
// Calculte the dimensions for x and y
|
|
172
178
|
return target.set(Math.abs(this.east - this.west), Math.abs(this.north - this.south));
|
|
173
179
|
}
|
|
@@ -180,7 +186,7 @@ class Extent {
|
|
|
180
186
|
*
|
|
181
187
|
* @param target - optional target
|
|
182
188
|
*/
|
|
183
|
-
geodeticDimensions(target = new
|
|
189
|
+
geodeticDimensions(target = new Vector2()) {
|
|
184
190
|
// set 3 corners extent
|
|
185
191
|
cNorthWest.crs = this.crs;
|
|
186
192
|
cSouthWest.crs = this.crs;
|
|
@@ -204,7 +210,7 @@ class Extent {
|
|
|
204
210
|
*
|
|
205
211
|
* @param target - optional target
|
|
206
212
|
*/
|
|
207
|
-
spatialEuclideanDimensions(target = new
|
|
213
|
+
spatialEuclideanDimensions(target = new Vector2()) {
|
|
208
214
|
// set 3 corners extent
|
|
209
215
|
cNorthWest.crs = this.crs;
|
|
210
216
|
cSouthWest.crs = this.crs;
|
|
@@ -267,7 +273,7 @@ class Extent {
|
|
|
267
273
|
* south-north, the `z` property the scale on west-east, the `w` property
|
|
268
274
|
* the scale on south-north.
|
|
269
275
|
*/
|
|
270
|
-
offsetToParent(extent: Extent, target = new
|
|
276
|
+
offsetToParent(extent: Extent, target = new Vector4()) {
|
|
271
277
|
if (this.crs != extent.crs) {
|
|
272
278
|
throw new Error('unsupported mix');
|
|
273
279
|
}
|
|
@@ -470,7 +476,7 @@ class Extent {
|
|
|
470
476
|
* @param crs - Projection of extent to instancied.
|
|
471
477
|
* @param box - Bounding-box
|
|
472
478
|
*/
|
|
473
|
-
static fromBox3(crs:
|
|
479
|
+
static fromBox3(crs: ProjectionLike, box: Box3) {
|
|
474
480
|
if (CRS.isGeocentric(crs)) {
|
|
475
481
|
// if geocentric reproject box on 'EPSG:4326'
|
|
476
482
|
crs = 'EPSG:4326';
|
|
@@ -539,7 +545,7 @@ class Extent {
|
|
|
539
545
|
* @param matrix - The matrix
|
|
540
546
|
* @returns return this extent instance.
|
|
541
547
|
*/
|
|
542
|
-
applyMatrix4(matrix:
|
|
548
|
+
applyMatrix4(matrix: Matrix4): this {
|
|
543
549
|
southWest.set(this.west, this.south, 0).applyMatrix4(matrix);
|
|
544
550
|
northEast.set(this.east, this.north, 0).applyMatrix4(matrix);
|
|
545
551
|
this.west = southWest.x;
|
|
@@ -597,6 +603,6 @@ class Extent {
|
|
|
597
603
|
}
|
|
598
604
|
}
|
|
599
605
|
|
|
600
|
-
_extent = new Extent('EPSG:4326');
|
|
606
|
+
_extent = /* @__PURE__ */ new Extent('EPSG:4326');
|
|
601
607
|
|
|
602
608
|
export default Extent;
|
package/src/OrientationUtils.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Euler, MathUtils, Matrix4, Quaternion, Vector3 } from 'three';
|
|
2
|
-
import proj4 from 'proj4';
|
|
3
|
-
import type { ProjectionDefinition } from 'proj4/dist/lib/defs';
|
|
2
|
+
import proj4, { type ProjectionDefinition } from 'proj4';
|
|
4
3
|
import Coordinates from './Coordinates';
|
|
5
4
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const quat = new Quaternion();
|
|
5
|
+
const matrix = /* @__PURE__ */ new Matrix4();
|
|
6
|
+
const north = /* @__PURE__ */ new Vector3();
|
|
7
|
+
const east = /* @__PURE__ */ new Vector3();
|
|
8
|
+
const axis = /* @__PURE__ */ new Vector3().set(0, 0, 1);
|
|
9
|
+
const coord = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0);
|
|
10
|
+
const euler = /* @__PURE__ */ new Euler();
|
|
11
|
+
const quat = /* @__PURE__ */ new Quaternion();
|
|
14
12
|
|
|
15
13
|
interface EulerAngles {
|
|
16
14
|
/** angle in degrees */
|
|
@@ -55,9 +53,9 @@ export function quaternionFromRollPitchHeading(
|
|
|
55
53
|
heading = 0,
|
|
56
54
|
target = new Quaternion(),
|
|
57
55
|
) {
|
|
58
|
-
roll *= DEG2RAD;
|
|
59
|
-
pitch *= DEG2RAD;
|
|
60
|
-
heading *= DEG2RAD;
|
|
56
|
+
roll *= MathUtils.DEG2RAD;
|
|
57
|
+
pitch *= MathUtils.DEG2RAD;
|
|
58
|
+
heading *= MathUtils.DEG2RAD;
|
|
61
59
|
// return setFromEuler(euler.set(pitch, roll, heading , 'ZXY')).conjugate();
|
|
62
60
|
// Below is optimized version of above line
|
|
63
61
|
return target.setFromEuler(euler.set(-pitch, -roll, -heading, 'YXZ'));
|
|
@@ -90,9 +88,9 @@ export function quaternionFromOmegaPhiKappa(
|
|
|
90
88
|
kappa = 0,
|
|
91
89
|
target = new Quaternion(),
|
|
92
90
|
) {
|
|
93
|
-
omega *= DEG2RAD;
|
|
94
|
-
phi *= DEG2RAD;
|
|
95
|
-
kappa *= DEG2RAD;
|
|
91
|
+
omega *= MathUtils.DEG2RAD;
|
|
92
|
+
phi *= MathUtils.DEG2RAD;
|
|
93
|
+
kappa *= MathUtils.DEG2RAD;
|
|
96
94
|
target.setFromEuler(euler.set(omega, phi, kappa, 'XYZ'));
|
|
97
95
|
target.set(target.w, target.z, -target.y, -target.x);
|
|
98
96
|
// <=> target.multiply(new THREE.Quaternion(1, 0, 0, 0));
|
|
@@ -202,7 +200,7 @@ export function quaternionFromLCCToEnu(
|
|
|
202
200
|
if (coordinates) { return quaternionFromLCCToEnu(proj)(coordinates, target); }
|
|
203
201
|
const sinlat0 = Math.sin(proj.lat0);
|
|
204
202
|
return (coordinates: Coordinates, target = new Quaternion()) => {
|
|
205
|
-
const long = coordinates.as(coord.crs, coord).longitude * DEG2RAD;
|
|
203
|
+
const long = coordinates.as(coord.crs, coord).longitude * MathUtils.DEG2RAD;
|
|
206
204
|
return target.setFromAxisAngle(axis, sinlat0 * (proj.long0 - long));
|
|
207
205
|
};
|
|
208
206
|
}
|
|
@@ -273,8 +271,8 @@ export function quaternionFromTMercToEnu(
|
|
|
273
271
|
}
|
|
274
272
|
return (coordinates: Coordinates, target = new Quaternion()) => {
|
|
275
273
|
coordinates.as(coord.crs, coord);
|
|
276
|
-
const long = coord.longitude * DEG2RAD;
|
|
277
|
-
const lat = coord.latitude * DEG2RAD;
|
|
274
|
+
const long = coord.longitude * MathUtils.DEG2RAD;
|
|
275
|
+
const lat = coord.latitude * MathUtils.DEG2RAD;
|
|
278
276
|
const dlong = proj.long0 - long;
|
|
279
277
|
const coslat = Math.cos(lat);
|
|
280
278
|
const sinlat = Math.sin(lat);
|
|
@@ -413,8 +411,8 @@ export function quaternionFromEnuToCRS(
|
|
|
413
411
|
const proj = typeof crsOrProj === 'string' ?
|
|
414
412
|
proj4(crsOrProj).oProj as ProjectionDefinition :
|
|
415
413
|
crsOrProj;
|
|
416
|
-
const
|
|
417
|
-
switch (names[0]) {
|
|
414
|
+
const projOrFalse = proj4.Proj.projections.get(proj.projName as string);
|
|
415
|
+
switch (projOrFalse && projOrFalse.names[0]) {
|
|
418
416
|
case 'Geocentric': return quaternionFromEnuToGeocent();
|
|
419
417
|
case 'Lambert Tangential Conformal Conic Projection':
|
|
420
418
|
return quaternionFromEnuToLCC(proj as LCCProjection);
|
|
@@ -450,8 +448,8 @@ export function quaternionFromCRSToEnu(
|
|
|
450
448
|
const proj = typeof crsOrProj === 'string' ?
|
|
451
449
|
proj4(crsOrProj).oProj as ProjectionDefinition :
|
|
452
450
|
crsOrProj;
|
|
453
|
-
const
|
|
454
|
-
switch (names[0]) {
|
|
451
|
+
const projOrFalse = proj4.Proj.projections.get(proj.projName as string);
|
|
452
|
+
switch (projOrFalse && projOrFalse.names[0]) {
|
|
455
453
|
case 'Geocentric': return quaternionFromGeocentToEnu();
|
|
456
454
|
case 'Lambert Tangential Conformal Conic Projection':
|
|
457
455
|
return quaternionFromLCCToEnu(proj as LCCProjection);
|
package/src/{Main.ts → index.ts}
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Geodesic tools
|
|
2
|
-
export { default as Extent } from './Extent';
|
|
3
|
-
export { default as Coordinates } from './Coordinates';
|
|
2
|
+
export { default as Extent, type ExtentLike } from './Extent';
|
|
3
|
+
export { default as Coordinates, type CoordinatesLike } from './Coordinates';
|
|
4
4
|
export * as CRS from './Crs';
|
|
5
|
+
export { type ProjectionLike } from './Crs';
|
|
5
6
|
export { default as CoordStars } from './CoordStars';
|
|
6
7
|
export * as OrientationUtils from './OrientationUtils';
|
|
7
8
|
export { default as Ellipsoid, ellipsoidSizes } from './Ellipsoid';
|
package/lib/CoordStars.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare const CoordStars: {
|
|
2
|
-
getSunPosition(): (date: Date | number, lat: number, lon: number) => {
|
|
3
|
-
EclipticLongitude: number;
|
|
4
|
-
declinaison: number;
|
|
5
|
-
ascension: number;
|
|
6
|
-
H: number;
|
|
7
|
-
SiderealTime: number;
|
|
8
|
-
altitude: number;
|
|
9
|
-
azimuth: number;
|
|
10
|
-
};
|
|
11
|
-
getSunPositionInScene(date: Date | number, lat: number, lon: number): import("three").Vector3;
|
|
12
|
-
};
|
|
13
|
-
export default CoordStars;
|
package/lib/Coordinates.d.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import * as THREE from 'three';
|
|
2
|
-
import type { ProjectionAlias } from './Crs';
|
|
3
|
-
export interface CoordinatesLike {
|
|
4
|
-
readonly crs: string;
|
|
5
|
-
readonly x: number;
|
|
6
|
-
readonly y: number;
|
|
7
|
-
readonly z: number;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A class representing a geographic or geocentric coordinate.
|
|
11
|
-
*
|
|
12
|
-
* A coordinate is defined by a [CRS](http://inspire.ec.europa.eu/theme/rs)
|
|
13
|
-
* (Coordinate Reference System) and a 3-dimensional vector `(x, y, z)`.
|
|
14
|
-
* For geocentric projections, it is recommended to use the `latitude`,
|
|
15
|
-
* `longitude` and `altitude` aliases to refer to vector components.
|
|
16
|
-
*
|
|
17
|
-
* To change a value, prefer the use of the `set*` methods.
|
|
18
|
-
*
|
|
19
|
-
* By default, the `EPSG:4978` and `EPSG:4326` projections are supported. To use
|
|
20
|
-
* a different projection, it must have been declared previously with `proj4`.
|
|
21
|
-
* A comprehensive list of projections and their corresponding proj4 string can
|
|
22
|
-
* be found at [epsg.io](https://epsg.io/).
|
|
23
|
-
*
|
|
24
|
-
* @example Geocentric coordinates
|
|
25
|
-
* ```js
|
|
26
|
-
* new Coordinates('EPSG:4978', 20885167, 849862, 23385912);
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @example Geographic coordinates
|
|
30
|
-
* ```js
|
|
31
|
-
* new Coordinates('EPSG:4326', 2.33, 48.24, 24999549);
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @example Defining the EPSG:2154 projection with proj4
|
|
35
|
-
* ```js
|
|
36
|
-
* proj4.defs('EPSG:2154', `+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44
|
|
37
|
-
* +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m
|
|
38
|
-
* +no_defs +type=crs`);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
declare class Coordinates {
|
|
42
|
-
/**
|
|
43
|
-
* Read-only flag to check if a given object is of type `Coordinates`.
|
|
44
|
-
*/
|
|
45
|
-
readonly isCoordinates: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* A default or user-defined CRS (see {@link ProjectionAlias}).
|
|
48
|
-
*/
|
|
49
|
-
crs: ProjectionAlias;
|
|
50
|
-
/** The x value (or longitude) of this coordinate. */
|
|
51
|
-
x: number;
|
|
52
|
-
/** The y value (or latitude) of this coordinate. */
|
|
53
|
-
y: number;
|
|
54
|
-
/** The z value (or altitude) of this coordinate. */
|
|
55
|
-
z: number;
|
|
56
|
-
private _normal;
|
|
57
|
-
private _normalNeedsUpdate;
|
|
58
|
-
/**
|
|
59
|
-
* @param crs - A default or user-defined CRS (see {@link ProjectionAlias}).
|
|
60
|
-
* @param x - x or longitude value.
|
|
61
|
-
* @param y - y or latitude value.
|
|
62
|
-
* @param z - z or altitude value.
|
|
63
|
-
*/
|
|
64
|
-
constructor(crs: ProjectionAlias, x?: number, y?: number, z?: number);
|
|
65
|
-
/**
|
|
66
|
-
* Sets the Coordinate Reference System.
|
|
67
|
-
* @param crs - Coordinate Reference System (e.g. 'EPSG:4978')
|
|
68
|
-
*/
|
|
69
|
-
setCrs(crs: ProjectionAlias): this;
|
|
70
|
-
/**
|
|
71
|
-
* Sets the x, y and z components of this coordinate.
|
|
72
|
-
*
|
|
73
|
-
* @param x - x or longitude value.
|
|
74
|
-
* @param y - y or latitude value.
|
|
75
|
-
* @param z - z or altitude value.
|
|
76
|
-
*/
|
|
77
|
-
setFromValues(x?: number, y?: number, z?: number): this;
|
|
78
|
-
/**
|
|
79
|
-
* Sets the coordinates's {@link Coordinates#x | x} component to
|
|
80
|
-
* `array[offset + 0]`, {@link Coordinates#y | y} component to
|
|
81
|
-
* `array[offset + 1]` and {@link Coordinates#z | z} component to
|
|
82
|
-
* `array[offset + 2]`.
|
|
83
|
-
*
|
|
84
|
-
* @param array - The source array.
|
|
85
|
-
* @param offset - Optional offset into the array. Default is 0.
|
|
86
|
-
*/
|
|
87
|
-
setFromArray(array: number[], offset?: number): this;
|
|
88
|
-
/**
|
|
89
|
-
* Sets the `(x, y, z)` vector of this coordinate from a 3-dimensional
|
|
90
|
-
* vector-like object. This object shall have both `x`, `y` and `z`
|
|
91
|
-
* properties.
|
|
92
|
-
*
|
|
93
|
-
* @param v - The source object.
|
|
94
|
-
*/
|
|
95
|
-
setFromVector3(v: THREE.Vector3Like): this;
|
|
96
|
-
/**
|
|
97
|
-
* Returns a new coordinate with the same `(x, y, z)` vector and crs as this
|
|
98
|
-
* one.
|
|
99
|
-
*/
|
|
100
|
-
clone(): Coordinates;
|
|
101
|
-
/**
|
|
102
|
-
* Copies the `(x, y, z)` vector components and crs of the passed coordinate
|
|
103
|
-
* to this coordinate.
|
|
104
|
-
*
|
|
105
|
-
* @param src - The source coordinate to copy from.
|
|
106
|
-
*/
|
|
107
|
-
copy(src: CoordinatesLike): this;
|
|
108
|
-
get longitude(): number;
|
|
109
|
-
get latitude(): number;
|
|
110
|
-
get altitude(): number;
|
|
111
|
-
set altitude(value: number);
|
|
112
|
-
/**
|
|
113
|
-
* The geodesic normal of the coordinate.
|
|
114
|
-
*/
|
|
115
|
-
get geodesicNormal(): THREE.Vector3;
|
|
116
|
-
/**
|
|
117
|
-
* Copies the `x`, `y` and `z` components into the provided `THREE.Vector3`.
|
|
118
|
-
*
|
|
119
|
-
* @param target - An object to store this vector to. If this is not
|
|
120
|
-
* specified, a new vector will be created.
|
|
121
|
-
*
|
|
122
|
-
* @returns A vector `(x, y, z)`, or copies x, y and z into the provided
|
|
123
|
-
* vector.
|
|
124
|
-
*/
|
|
125
|
-
toVector3(target?: THREE.Vector3): THREE.Vector3;
|
|
126
|
-
/**
|
|
127
|
-
* Copies the `x`, `y` and `z` components into the provided array.
|
|
128
|
-
*
|
|
129
|
-
* @param array - An array to store this vector to. If this is not
|
|
130
|
-
* provided a new array will be created.
|
|
131
|
-
* @param offset - An optional offset into the array.
|
|
132
|
-
*
|
|
133
|
-
* @returns An array [x, y, z], or copies x, y and z into the provided
|
|
134
|
-
* array.
|
|
135
|
-
*/
|
|
136
|
-
toArray(array?: number[], offset?: number): ArrayLike<number>;
|
|
137
|
-
/**
|
|
138
|
-
* Computes the planar distance from this coordinates to `coord`.
|
|
139
|
-
* **Planar distance** is the straight-line euclidean distance calculated in
|
|
140
|
-
* a 2D cartesian coordinate system.
|
|
141
|
-
*/
|
|
142
|
-
planarDistanceTo(coord: Coordinates): number;
|
|
143
|
-
/**
|
|
144
|
-
* Computes the geodetic distance from this coordinates to `coord`.
|
|
145
|
-
* **Geodetic distance** is calculated in an ellipsoid space as the shortest
|
|
146
|
-
* distance across the curved surface of the ellipsoid.
|
|
147
|
-
*/
|
|
148
|
-
geodeticDistanceTo(coord: Coordinates): number;
|
|
149
|
-
/**
|
|
150
|
-
* Computes the euclidean distance from this coordinates to `coord` in a
|
|
151
|
-
* WGS84 projection.
|
|
152
|
-
*
|
|
153
|
-
* @param coord - The coordinate
|
|
154
|
-
* @returns earth euclidean distance
|
|
155
|
-
*/
|
|
156
|
-
spatialEuclideanDistanceTo(coord: Coordinates): number;
|
|
157
|
-
/**
|
|
158
|
-
* Multiplies this coordinate (with an implicit 1 in the 4th dimension)
|
|
159
|
-
* by `mat`, and divides by perspective.
|
|
160
|
-
*
|
|
161
|
-
* @param mat - The matrix.
|
|
162
|
-
*/
|
|
163
|
-
applyMatrix4(mat: THREE.Matrix4): this;
|
|
164
|
-
/**
|
|
165
|
-
* Projects this coordinate to the specified
|
|
166
|
-
* [CRS](http://inspire.ec.europa.eu/theme/rs).
|
|
167
|
-
*
|
|
168
|
-
* @param crs - The target CRS to which the coordinate will be converted.
|
|
169
|
-
* @param target - The target to store the projected coordinate. If this not
|
|
170
|
-
* provided a new coordinate will be created.
|
|
171
|
-
*
|
|
172
|
-
* @returns The coordinate projected into the specified CRS.
|
|
173
|
-
*
|
|
174
|
-
* @example Conversion from a geographic to a geocentric reference system
|
|
175
|
-
* ```js
|
|
176
|
-
* const geographicCoords = new Coordinates('EPSG:4326',
|
|
177
|
-
* 2.33, // longitude
|
|
178
|
-
* 48.24, // latitude
|
|
179
|
-
* 24999549, // altitude
|
|
180
|
-
* );
|
|
181
|
-
* const geocentricCoords = geographicCoords.as('EPSG:4978');
|
|
182
|
-
* ```
|
|
183
|
-
*
|
|
184
|
-
* @example Conversion from a geocentric to a geographic reference system
|
|
185
|
-
* ```js
|
|
186
|
-
* const geocentricCoords = new Coordinates('EPSG:4978',
|
|
187
|
-
* 20885167, // x
|
|
188
|
-
* 849862, // y
|
|
189
|
-
* 23385912, // z
|
|
190
|
-
* );
|
|
191
|
-
* const geographicCoords = geocentricCoords.as('EPSG:4326');
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
as(crs: ProjectionAlias, target?: Coordinates): Coordinates;
|
|
195
|
-
}
|
|
196
|
-
export default Coordinates;
|