@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.
@@ -1,11 +1,11 @@
1
- import * as THREE from 'three';
1
+ import { Vector3, MathUtils } from 'three';
2
2
  import proj4 from 'proj4';
3
3
  import Ellipsoid from "./Ellipsoid.js";
4
4
  import * as CRS from "./Crs.js";
5
- const ellipsoid = new Ellipsoid();
5
+ const ellipsoid = /* @__PURE__ */new Ellipsoid();
6
6
  const projectionCache = {};
7
- const v0 = new THREE.Vector3();
8
- const v1 = new THREE.Vector3();
7
+ const v0 = /* @__PURE__ */new Vector3();
8
+ const v1 = /* @__PURE__ */new Vector3();
9
9
  let coord0;
10
10
  let coord1;
11
11
  function proj4cache(crsIn, crsOut) {
@@ -56,7 +56,7 @@ class Coordinates {
56
56
  */
57
57
 
58
58
  /**
59
- * A default or user-defined CRS (see {@link ProjectionAlias}).
59
+ * A default or user-defined CRS (see {@link ProjectionLike}).
60
60
  */
61
61
 
62
62
  /** The x value (or longitude) of this coordinate. */
@@ -66,7 +66,7 @@ class Coordinates {
66
66
  /** The z value (or altitude) of this coordinate. */
67
67
 
68
68
  /**
69
- * @param crs - A default or user-defined CRS (see {@link ProjectionAlias}).
69
+ * @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
70
70
  * @param x - x or longitude value.
71
71
  * @param y - y or latitude value.
72
72
  * @param z - z or altitude value.
@@ -86,7 +86,7 @@ class Coordinates {
86
86
  this.z = 0;
87
87
 
88
88
  // Normal
89
- this._normal = new THREE.Vector3();
89
+ this._normal = new Vector3();
90
90
 
91
91
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
92
  if (x.length > 0) {
@@ -216,7 +216,7 @@ class Coordinates {
216
216
  * vector.
217
217
  */
218
218
  toVector3() {
219
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector3();
219
+ let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Vector3();
220
220
  return target.copy(this);
221
221
  }
222
222
 
@@ -233,7 +233,7 @@ class Coordinates {
233
233
  toArray() {
234
234
  let array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
235
235
  let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
236
- return THREE.Vector3.prototype.toArray.call(this, array, offset);
236
+ return Vector3.prototype.toArray.call(this, array, offset);
237
237
  }
238
238
 
239
239
  /**
@@ -278,7 +278,7 @@ class Coordinates {
278
278
  * @param mat - The matrix.
279
279
  */
280
280
  applyMatrix4(mat) {
281
- THREE.Vector3.prototype.applyMatrix4.call(this, mat);
281
+ Vector3.prototype.applyMatrix4.call(this, mat);
282
282
  return this;
283
283
  }
284
284
 
@@ -318,7 +318,7 @@ class Coordinates {
318
318
  target.copy(this);
319
319
  } else {
320
320
  if (CRS.is4326(this.crs) && crs == 'EPSG:3857') {
321
- this.y = THREE.MathUtils.clamp(this.y, -89.999999, 89.999999);
321
+ this.y = MathUtils.clamp(this.y, -89.999999, 89.999999);
322
322
  }
323
323
  target.setFromArray(proj4cache(this.crs, crs).forward([this.x, this.y, this.z]));
324
324
  }
@@ -326,6 +326,6 @@ class Coordinates {
326
326
  return target;
327
327
  }
328
328
  }
329
- coord0 = new Coordinates('EPSG:4326', 0, 0, 0);
330
- coord1 = new Coordinates('EPSG:4326', 0, 0, 0);
329
+ coord0 = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
330
+ coord1 = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
331
331
  export default Coordinates;
package/lib/Ellipsoid.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as THREE from 'three';
1
+ import { Vector3, MathUtils } from 'three';
2
2
  import proj4 from 'proj4';
3
3
  import Coordinates from "./Coordinates.js";
4
4
 
@@ -6,8 +6,8 @@ import Coordinates from "./Coordinates.js";
6
6
  * Length of the semi-axes of the WGS84 ellipsoid.
7
7
  * @internal
8
8
  */
9
- export const ellipsoidSizes = new THREE.Vector3(proj4.WGS84.a, proj4.WGS84.a, proj4.WGS84.b);
10
- const normal = new THREE.Vector3();
9
+ export const ellipsoidSizes = /* @__PURE__ */(() => new Vector3(proj4.WGS84.a, proj4.WGS84.a, proj4.WGS84.b))();
10
+ const normal = /* @__PURE__ */new Vector3();
11
11
  class Ellipsoid {
12
12
  /**
13
13
  * Length of the semi-axes of the ellipsoid.
@@ -23,9 +23,9 @@ class Ellipsoid {
23
23
  */
24
24
  constructor() {
25
25
  let size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ellipsoidSizes;
26
- this.size = new THREE.Vector3();
27
- this._radiiSquared = new THREE.Vector3();
28
- this._invRadiiSquared = new THREE.Vector3();
26
+ this.size = new Vector3();
27
+ this._radiiSquared = new Vector3();
28
+ this._invRadiiSquared = new Vector3();
29
29
  this.eccentricity = 0;
30
30
  this.setSize(size);
31
31
  }
@@ -39,7 +39,7 @@ class Ellipsoid {
39
39
  * specified, a new vector will be created.
40
40
  */
41
41
  geodeticSurfaceNormal(cartesian) {
42
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3();
42
+ let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Vector3();
43
43
  return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
44
44
  }
45
45
 
@@ -52,9 +52,9 @@ class Ellipsoid {
52
52
  * specified, a new vector will be created.
53
53
  */
54
54
  geodeticSurfaceNormalCartographic(coordCarto) {
55
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3();
56
- const longitude = THREE.MathUtils.degToRad(coordCarto.longitude);
57
- const latitude = THREE.MathUtils.degToRad(coordCarto.latitude);
55
+ let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Vector3();
56
+ const longitude = MathUtils.degToRad(coordCarto.longitude);
57
+ const latitude = MathUtils.degToRad(coordCarto.latitude);
58
58
  const cosLatitude = Math.cos(latitude);
59
59
  return target.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude));
60
60
  }
@@ -76,7 +76,7 @@ class Ellipsoid {
76
76
  return this;
77
77
  }
78
78
  cartographicToCartesian(coordCarto) {
79
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3();
79
+ let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Vector3();
80
80
  normal.copy(coordCarto.geodesicNormal);
81
81
  target.multiplyVectors(this._radiiSquared, normal);
82
82
  const gamma = Math.sqrt(normal.dot(target));
@@ -110,7 +110,7 @@ class Ellipsoid {
110
110
  const cosu = Math.cos(nu);
111
111
  const phi = Math.atan((position.z * (1 - f) + e * a * sinu * sinu * sinu) / ((1 - f) * (rsqXY - e * a * cosu * cosu * cosu)));
112
112
  const h = rsqXY * Math.cos(phi) + position.z * Math.sin(phi) - a * Math.sqrt(1 - e * Math.sin(phi) * Math.sin(phi));
113
- return target.setFromValues(THREE.MathUtils.radToDeg(theta), THREE.MathUtils.radToDeg(phi), h);
113
+ return target.setFromValues(MathUtils.radToDeg(theta), MathUtils.radToDeg(phi), h);
114
114
  }
115
115
  cartographicToCartesianArray(coordCartoArray) {
116
116
  const cartesianArray = [];
@@ -151,7 +151,7 @@ class Ellipsoid {
151
151
  return false;
152
152
  } // Too close to intersection
153
153
 
154
- const inter = new THREE.Vector3();
154
+ const inter = new Vector3();
155
155
  inter.addVectors(ray.origin, dir.clone().setLength(t));
156
156
  return inter;
157
157
  }
@@ -170,10 +170,10 @@ class Ellipsoid {
170
170
  // The formula uses the distance on approximated sphere,
171
171
  // with the nearest local radius of curvature of the ellipsoid
172
172
  // https://geodesie.ign.fr/contenu/fichiers/Distance_longitude_latitude.pdf
173
- const longitude1 = THREE.MathUtils.degToRad(coordCarto1.longitude);
174
- const latitude1 = THREE.MathUtils.degToRad(coordCarto1.latitude);
175
- const longitude2 = THREE.MathUtils.degToRad(coordCarto2.longitude);
176
- const latitude2 = THREE.MathUtils.degToRad(coordCarto2.latitude);
173
+ const longitude1 = MathUtils.degToRad(coordCarto1.longitude);
174
+ const latitude1 = MathUtils.degToRad(coordCarto1.latitude);
175
+ const longitude2 = MathUtils.degToRad(coordCarto2.longitude);
176
+ const latitude2 = MathUtils.degToRad(coordCarto2.latitude);
177
177
  const distRad = Math.acos(Math.sin(latitude1) * Math.sin(latitude2) + Math.cos(latitude1) * Math.cos(latitude2) * Math.cos(longitude2 - longitude1));
178
178
  const e = this.eccentricity;
179
179
  const latMoy = (latitude1 + latitude2) * 0.5;
package/lib/Extent.js CHANGED
@@ -1,21 +1,18 @@
1
- import * as THREE from 'three';
1
+ import { Vector2, Vector3, Vector4, Box3 } from 'three';
2
2
  import Coordinates from "./Coordinates.js";
3
3
  import * as CRS from "./Crs.js";
4
- const _dim = new THREE.Vector2();
5
- const _dim2 = new THREE.Vector2();
6
- const _box = new THREE.Box3();
7
- const defaultScheme = new THREE.Vector2(2, 2);
8
- const cNorthWest = new Coordinates('EPSG:4326', 0, 0, 0);
9
- const cSouthWest = new Coordinates('EPSG:4326', 0, 0, 0);
10
- const cNorthEast = new Coordinates('EPSG:4326', 0, 0, 0);
11
- const southWest = new THREE.Vector3();
12
- const northEast = new THREE.Vector3();
4
+ const _dim = /* @__PURE__ */new Vector2();
5
+ const _dim2 = /* @__PURE__ */new Vector2();
6
+ const _box = /* @__PURE__ */new Box3();
7
+ const defaultScheme = /* @__PURE__ */new Vector2(2, 2);
8
+ const cNorthWest = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
9
+ const cSouthWest = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
10
+ const cNorthEast = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
11
+ const southWest = /* @__PURE__ */new Vector3();
12
+ const northEast = /* @__PURE__ */new Vector3();
13
13
  let _extent;
14
- const cardinals = new Array(8);
15
- for (let i = cardinals.length - 1; i >= 0; i--) {
16
- cardinals[i] = new Coordinates('EPSG:4326', 0, 0, 0);
17
- }
18
- const _c = new Coordinates('EPSG:4326', 0, 0);
14
+ const cardinals = [/* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0), /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0)];
15
+ const _c = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0);
19
16
  /**
20
17
  * A class representing a geographical extent.
21
18
  *
@@ -31,7 +28,7 @@ class Extent {
31
28
  */
32
29
 
33
30
  /**
34
- * A default or user-defined CRS (see {@link ProjectionAlias}).
31
+ * A default or user-defined CRS (see {@link ProjectionLike}).
35
32
  */
36
33
 
37
34
  /**
@@ -51,7 +48,7 @@ class Extent {
51
48
  */
52
49
 
53
50
  /**
54
- * @param crs - A default or user-defined CRS (see {@link ProjectionAlias}).
51
+ * @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
55
52
  * @param west - the `west` value of this extent. Default is 0.
56
53
  * @param east - the `east` value of this extent. Default is 0.
57
54
  * @param south - the `south` value of this extent. Default is 0.
@@ -146,7 +143,7 @@ class Extent {
146
143
  * @param target - optional target
147
144
  */
148
145
  planarDimensions() {
149
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
146
+ let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Vector2();
150
147
  // Calculte the dimensions for x and y
151
148
  return target.set(Math.abs(this.east - this.west), Math.abs(this.north - this.south));
152
149
  }
@@ -160,7 +157,7 @@ class Extent {
160
157
  * @param target - optional target
161
158
  */
162
159
  geodeticDimensions() {
163
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
160
+ let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Vector2();
164
161
  // set 3 corners extent
165
162
  cNorthWest.crs = this.crs;
166
163
  cSouthWest.crs = this.crs;
@@ -181,7 +178,7 @@ class Extent {
181
178
  * @param target - optional target
182
179
  */
183
180
  spatialEuclideanDimensions() {
184
- let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
181
+ let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Vector2();
185
182
  // set 3 corners extent
186
183
  cNorthWest.crs = this.crs;
187
184
  cSouthWest.crs = this.crs;
@@ -237,7 +234,7 @@ class Extent {
237
234
  * the scale on south-north.
238
235
  */
239
236
  offsetToParent(extent) {
240
- let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
237
+ let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Vector4();
241
238
  if (this.crs != extent.crs) {
242
239
  throw new Error('unsupported mix');
243
240
  }
@@ -546,5 +543,5 @@ class Extent {
546
543
  return this.clampWestEast(extent.west, extent.east);
547
544
  }
548
545
  }
549
- _extent = new Extent('EPSG:4326');
546
+ _extent = /* @__PURE__ */new Extent('EPSG:4326');
550
547
  export default Extent;
@@ -1,14 +1,13 @@
1
1
  import { Euler, MathUtils, Matrix4, Quaternion, Vector3 } from 'three';
2
2
  import proj4 from 'proj4';
3
3
  import Coordinates from "./Coordinates.js";
4
- const DEG2RAD = MathUtils.DEG2RAD;
5
- const matrix = new Matrix4();
6
- const north = new Vector3();
7
- const east = new Vector3();
8
- const axis = new Vector3().set(0, 0, 1);
9
- const coord = new Coordinates('EPSG:4326', 0, 0, 0);
10
- const euler = new Euler();
11
- const quat = new Quaternion();
4
+ const matrix = /* @__PURE__ */new Matrix4();
5
+ const north = /* @__PURE__ */new Vector3();
6
+ const east = /* @__PURE__ */new Vector3();
7
+ const axis = /* @__PURE__ */new Vector3().set(0, 0, 1);
8
+ const coord = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
9
+ const euler = /* @__PURE__ */new Euler();
10
+ const quat = /* @__PURE__ */new Quaternion();
12
11
  /**
13
12
  * The transform from the platform frame to the local East, North, Up (ENU)
14
13
  * frame is `RotationZ(heading).RotationX(pitch).RotationY(roll)`.
@@ -25,9 +24,9 @@ export function quaternionFromRollPitchHeading() {
25
24
  let pitch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
26
25
  let heading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
27
26
  let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Quaternion();
28
- roll *= DEG2RAD;
29
- pitch *= DEG2RAD;
30
- heading *= DEG2RAD;
27
+ roll *= MathUtils.DEG2RAD;
28
+ pitch *= MathUtils.DEG2RAD;
29
+ heading *= MathUtils.DEG2RAD;
31
30
  // return setFromEuler(euler.set(pitch, roll, heading , 'ZXY')).conjugate();
32
31
  // Below is optimized version of above line
33
32
  return target.setFromEuler(euler.set(-pitch, -roll, -heading, 'YXZ'));
@@ -59,9 +58,9 @@ export function quaternionFromOmegaPhiKappa() {
59
58
  let phi = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
60
59
  let kappa = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
61
60
  let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new Quaternion();
62
- omega *= DEG2RAD;
63
- phi *= DEG2RAD;
64
- kappa *= DEG2RAD;
61
+ omega *= MathUtils.DEG2RAD;
62
+ phi *= MathUtils.DEG2RAD;
63
+ kappa *= MathUtils.DEG2RAD;
65
64
  target.setFromEuler(euler.set(omega, phi, kappa, 'XYZ'));
66
65
  target.set(target.w, target.z, -target.y, -target.x);
67
66
  // <=> target.multiply(new THREE.Quaternion(1, 0, 0, 0));
@@ -161,7 +160,7 @@ export function quaternionFromLCCToEnu(proj, coordinates) {
161
160
  const sinlat0 = Math.sin(proj.lat0);
162
161
  return function (coordinates) {
163
162
  let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Quaternion();
164
- const long = coordinates.as(coord.crs, coord).longitude * DEG2RAD;
163
+ const long = coordinates.as(coord.crs, coord).longitude * MathUtils.DEG2RAD;
165
164
  return target.setFromAxisAngle(axis, sinlat0 * (proj.long0 - long));
166
165
  };
167
166
  }
@@ -219,8 +218,8 @@ export function quaternionFromTMercToEnu(proj, coordinates) {
219
218
  return function (coordinates) {
220
219
  let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Quaternion();
221
220
  coordinates.as(coord.crs, coord);
222
- const long = coord.longitude * DEG2RAD;
223
- const lat = coord.latitude * DEG2RAD;
221
+ const long = coord.longitude * MathUtils.DEG2RAD;
222
+ const lat = coord.latitude * MathUtils.DEG2RAD;
224
223
  const dlong = proj.long0 - long;
225
224
  const coslat = Math.cos(lat);
226
225
  const sinlat = Math.sin(lat);
@@ -326,8 +325,8 @@ export function quaternionFromEnuToCRS(crsOrProj, coordinates) {
326
325
  return quaternionFromEnuToCRS(crsOrProj)(coordinates, target);
327
326
  }
328
327
  const proj = typeof crsOrProj === 'string' ? proj4(crsOrProj).oProj : crsOrProj;
329
- const names = proj4.Proj.projections.get(proj.projName).names;
330
- switch (names[0]) {
328
+ const projOrFalse = proj4.Proj.projections.get(proj.projName);
329
+ switch (projOrFalse && projOrFalse.names[0]) {
331
330
  case 'Geocentric':
332
331
  return quaternionFromEnuToGeocent();
333
332
  case 'Lambert Tangential Conformal Conic Projection':
@@ -357,8 +356,8 @@ export function quaternionFromCRSToEnu(crsOrProj, coordinates) {
357
356
  return quaternionFromCRSToEnu(crsOrProj)(coordinates, target);
358
357
  }
359
358
  const proj = typeof crsOrProj === 'string' ? proj4(crsOrProj).oProj : crsOrProj;
360
- const names = proj4.Proj.projections.get(proj.projName).names;
361
- switch (names[0]) {
359
+ const projOrFalse = proj4.Proj.projections.get(proj.projName);
360
+ switch (projOrFalse && projOrFalse.names[0]) {
362
361
  case 'Geocentric':
363
362
  return quaternionFromGeocentToEnu();
364
363
  case 'Lambert Tangential Conformal Conic Projection':
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@itowns/geographic",
3
- "version": "2.46.1-next.0",
3
+ "version": "2.46.1-next.1",
4
4
  "description": "Geodesy",
5
5
  "type": "module",
6
- "main": "lib/Main.js",
6
+ "main": "lib/index.js",
7
7
  "exports": {
8
- "types": "./src/Main.ts",
9
- "default": "./lib/Main.js"
8
+ "types": "./src/index.ts",
9
+ "default": "./lib/index.js"
10
10
  },
11
- "types": "./src/Main.ts",
11
+ "types": "./src/index.ts",
12
12
  "scripts": {
13
13
  "build": "",
14
14
  "lint": "eslint \"src/**/*.{js,ts,tsx}\" \"test/**/*.js\"",
@@ -35,7 +35,7 @@
35
35
  "url": "https://github.com/itowns/itowns/issues"
36
36
  },
37
37
  "peerDependencies": {
38
- "proj4": "^2.19.3",
38
+ "proj4": "^2.19.10",
39
39
  "three": "^0.174.0"
40
40
  },
41
41
  "homepage": "https://itowns.github.io/"
@@ -1,16 +1,15 @@
1
- import * as THREE from 'three';
2
- import proj4 from 'proj4';
3
- import type { Converter } from 'proj4/dist/lib/core';
1
+ import { Vector3, type Vector3Like, type Matrix4, MathUtils } from 'three';
2
+ import proj4, { type Converter } from 'proj4';
4
3
  import Ellipsoid from './Ellipsoid';
5
4
  import * as CRS from './Crs';
6
5
 
7
- import type { ProjectionAlias } from './Crs';
6
+ import type { ProjectionLike } from './Crs';
8
7
 
9
- const ellipsoid = new Ellipsoid();
8
+ const ellipsoid = /* @__PURE__ */ new Ellipsoid();
10
9
  const projectionCache: Record<string, Record<string, Converter>> = {};
11
10
 
12
- const v0 = new THREE.Vector3();
13
- const v1 = new THREE.Vector3();
11
+ const v0 = /* @__PURE__ */ new Vector3();
12
+ const v1 = /* @__PURE__ */ new Vector3();
14
13
 
15
14
  let coord0: Coordinates;
16
15
  let coord1: Coordinates;
@@ -22,7 +21,7 @@ export interface CoordinatesLike {
22
21
  readonly z: number;
23
22
  }
24
23
 
25
- function proj4cache(crsIn: ProjectionAlias, crsOut: ProjectionAlias): Converter {
24
+ function proj4cache(crsIn: ProjectionLike, crsOut: ProjectionLike): Converter {
26
25
  if (!projectionCache[crsIn]) {
27
26
  projectionCache[crsIn] = {};
28
27
  }
@@ -72,9 +71,9 @@ class Coordinates {
72
71
  */
73
72
  readonly isCoordinates: boolean;
74
73
  /**
75
- * A default or user-defined CRS (see {@link ProjectionAlias}).
74
+ * A default or user-defined CRS (see {@link ProjectionLike}).
76
75
  */
77
- crs: ProjectionAlias;
76
+ crs: ProjectionLike;
78
77
 
79
78
  /** The x value (or longitude) of this coordinate. */
80
79
  x: number;
@@ -83,16 +82,16 @@ class Coordinates {
83
82
  /** The z value (or altitude) of this coordinate. */
84
83
  z: number;
85
84
 
86
- private _normal: THREE.Vector3;
85
+ private _normal: Vector3;
87
86
  private _normalNeedsUpdate: boolean;
88
87
 
89
88
  /**
90
- * @param crs - A default or user-defined CRS (see {@link ProjectionAlias}).
89
+ * @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
91
90
  * @param x - x or longitude value.
92
91
  * @param y - y or latitude value.
93
92
  * @param z - z or altitude value.
94
93
  */
95
- constructor(crs: ProjectionAlias, x: number = 0, y: number = 0, z: number = 0) {
94
+ constructor(crs: ProjectionLike, x: number = 0, y: number = 0, z: number = 0) {
96
95
  this.isCoordinates = true;
97
96
 
98
97
  CRS.isValid(crs);
@@ -105,7 +104,7 @@ class Coordinates {
105
104
  this.z = 0;
106
105
 
107
106
  // Normal
108
- this._normal = new THREE.Vector3();
107
+ this._normal = new Vector3();
109
108
 
110
109
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
110
  if ((x as any).length > 0) { // deepscan-disable-line
@@ -134,7 +133,7 @@ class Coordinates {
134
133
  * Sets the Coordinate Reference System.
135
134
  * @param crs - Coordinate Reference System (e.g. 'EPSG:4978')
136
135
  */
137
- setCrs(crs: ProjectionAlias): this {
136
+ setCrs(crs: ProjectionLike): this {
138
137
  CRS.isValid(crs);
139
138
  this.crs = crs;
140
139
  return this;
@@ -180,7 +179,7 @@ class Coordinates {
180
179
  *
181
180
  * @param v - The source object.
182
181
  */
183
- setFromVector3(v: THREE.Vector3Like): this {
182
+ setFromVector3(v: Vector3Like): this {
184
183
  return this.setFromValues(v.x, v.y, v.z);
185
184
  }
186
185
 
@@ -247,7 +246,7 @@ class Coordinates {
247
246
  * @returns A vector `(x, y, z)`, or copies x, y and z into the provided
248
247
  * vector.
249
248
  */
250
- toVector3(target: THREE.Vector3 = new THREE.Vector3()): THREE.Vector3 {
249
+ toVector3(target: Vector3 = new Vector3()): Vector3 {
251
250
  return target.copy(this);
252
251
  }
253
252
 
@@ -262,7 +261,7 @@ class Coordinates {
262
261
  * array.
263
262
  */
264
263
  toArray(array: number[] = [], offset: number = 0): ArrayLike<number> {
265
- return THREE.Vector3.prototype.toArray.call(this, array, offset);
264
+ return Vector3.prototype.toArray.call(this, array, offset);
266
265
  }
267
266
 
268
267
  /**
@@ -306,8 +305,8 @@ class Coordinates {
306
305
  *
307
306
  * @param mat - The matrix.
308
307
  */
309
- applyMatrix4(mat: THREE.Matrix4): this {
310
- THREE.Vector3.prototype.applyMatrix4.call(this, mat);
308
+ applyMatrix4(mat: Matrix4): this {
309
+ Vector3.prototype.applyMatrix4.call(this, mat);
311
310
  return this;
312
311
  }
313
312
 
@@ -341,12 +340,12 @@ class Coordinates {
341
340
  * const geographicCoords = geocentricCoords.as('EPSG:4326');
342
341
  * ```
343
342
  */
344
- as(crs: ProjectionAlias, target = new Coordinates(crs)): Coordinates {
343
+ as(crs: ProjectionLike, target = new Coordinates(crs)): Coordinates {
345
344
  if (this.crs == crs) {
346
345
  target.copy(this);
347
346
  } else {
348
347
  if (CRS.is4326(this.crs) && crs == 'EPSG:3857') {
349
- this.y = THREE.MathUtils.clamp(this.y, -89.999999, 89.999999);
348
+ this.y = MathUtils.clamp(this.y, -89.999999, 89.999999);
350
349
  }
351
350
 
352
351
  target.setFromArray(proj4cache(this.crs, crs)
@@ -359,7 +358,7 @@ class Coordinates {
359
358
  }
360
359
  }
361
360
 
362
- coord0 = new Coordinates('EPSG:4326', 0, 0, 0);
363
- coord1 = new Coordinates('EPSG:4326', 0, 0, 0);
361
+ coord0 = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0);
362
+ coord1 = /* @__PURE__ */ new Coordinates('EPSG:4326', 0, 0, 0);
364
363
 
365
364
  export default Coordinates;
package/src/Crs.ts CHANGED
@@ -15,7 +15,7 @@ proj4.defs('WGS84').axis = 'neu';
15
15
  * projection definition previously defined with
16
16
  * [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections).
17
17
  */
18
- export type ProjectionAlias = string;
18
+ export type ProjectionLike = string;
19
19
 
20
20
  function isString(s: unknown): s is string {
21
21
  return typeof s === 'string' || s instanceof String;
@@ -53,7 +53,7 @@ export const UNIT = {
53
53
  *
54
54
  * @param crs - The CRS to test.
55
55
  */
56
- export function is4326(crs: ProjectionAlias) {
56
+ export function is4326(crs: ProjectionLike) {
57
57
  return crs === 'EPSG:4326';
58
58
  }
59
59
 
@@ -79,7 +79,7 @@ function unitFromProj4Unit(proj: ProjectionDefinition) {
79
79
  * @param crs - The CRS to extract the unit from.
80
80
  * @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
81
81
  */
82
- export function getUnit(crs: ProjectionAlias) {
82
+ export function getUnit(crs: ProjectionLike) {
83
83
  mustBeString(crs);
84
84
  const p = proj4.defs(crs);
85
85
  if (!p) {
@@ -94,7 +94,7 @@ export function getUnit(crs: ProjectionAlias) {
94
94
  * @param crs - The CRS to check.
95
95
  * @throws {@link Error} if the CRS is not valid.
96
96
  */
97
- export function isMetricUnit(crs: ProjectionAlias) {
97
+ export function isMetricUnit(crs: ProjectionLike) {
98
98
  return getUnit(crs) === UNIT.METER;
99
99
  }
100
100
 
@@ -104,7 +104,7 @@ export function isMetricUnit(crs: ProjectionAlias) {
104
104
  * @param crs - The CRS to check.
105
105
  * @throws {@link Error} if the CRS is not valid.
106
106
  */
107
- export function isGeographic(crs: ProjectionAlias) {
107
+ export function isGeographic(crs: ProjectionLike) {
108
108
  return getUnit(crs) === UNIT.DEGREE;
109
109
  }
110
110
 
@@ -114,7 +114,7 @@ export function isGeographic(crs: ProjectionAlias) {
114
114
  * @param crs - The CRS to test.
115
115
  * @returns false if the crs isn't defined.
116
116
  */
117
- export function isGeocentric(crs: ProjectionAlias) {
117
+ export function isGeocentric(crs: ProjectionLike) {
118
118
  mustBeString(crs);
119
119
  const projection = proj4.defs(crs);
120
120
  return !projection ? false : projection.projName == 'geocent';
@@ -127,7 +127,7 @@ export function isGeocentric(crs: ProjectionAlias) {
127
127
  * @param crs - The CRS to test.
128
128
  * @throws {@link Error} if the crs is not valid.
129
129
  */
130
- export function isValid(crs: ProjectionAlias) {
130
+ export function isValid(crs: ProjectionLike) {
131
131
  const proj = proj4.defs(crs);
132
132
  if (!proj) {
133
133
  throw new Error(`Undefined crs '${crs}'. Add it with proj4.defs('${crs}', string)`);
@@ -143,7 +143,7 @@ export function isValid(crs: ProjectionAlias) {
143
143
  * @param crs - The CRS to use.
144
144
  * @returns 0.01 if the CRS is EPSG:4326, 0.001 otherwise.
145
145
  */
146
- export function reasonableEpsilon(crs: ProjectionAlias) {
146
+ export function reasonableEpsilon(crs: ProjectionLike) {
147
147
  if (is4326(crs)) {
148
148
  return 0.01;
149
149
  } else {
@@ -158,7 +158,7 @@ export function reasonableEpsilon(crs: ProjectionAlias) {
158
158
  * @param crs - The CRS to get axis from.
159
159
  * @returns the matching proj4 axis string, 'enu' for instance (east, north, up)
160
160
  */
161
- export function axisOrder(crs: ProjectionAlias) {
161
+ export function axisOrder(crs: ProjectionLike) {
162
162
  mustBeString(crs);
163
163
  const projection = proj4.defs(crs);
164
164
  return !projection ? undefined : projection.axis;