@itowns/geographic 2.46.1-next.0 → 2.46.1-next.10
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 +18 -29
- package/lib/Crs.js +18 -1
- package/lib/Ellipsoid.js +19 -24
- package/lib/Extent.js +29 -51
- package/lib/OrientationUtils.js +46 -95
- package/package.json +7 -7
- package/src/Coordinates.ts +23 -24
- package/src/Crs.ts +35 -10
- 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/lib/Coordinates.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
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
|
|
8
|
-
const v1 = new
|
|
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
|
|
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,15 +66,12 @@ 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
|
|
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.
|
|
73
73
|
*/
|
|
74
|
-
constructor(crs) {
|
|
75
|
-
let x = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
76
|
-
let y = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
77
|
-
let z = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
74
|
+
constructor(crs, x = 0, y = 0, z = 0) {
|
|
78
75
|
this.isCoordinates = true;
|
|
79
76
|
CRS.isValid(crs);
|
|
80
77
|
this.crs = crs;
|
|
@@ -86,7 +83,7 @@ class Coordinates {
|
|
|
86
83
|
this.z = 0;
|
|
87
84
|
|
|
88
85
|
// Normal
|
|
89
|
-
this._normal = new
|
|
86
|
+
this._normal = new Vector3();
|
|
90
87
|
|
|
91
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
89
|
if (x.length > 0) {
|
|
@@ -122,10 +119,7 @@ class Coordinates {
|
|
|
122
119
|
* @param y - y or latitude value.
|
|
123
120
|
* @param z - z or altitude value.
|
|
124
121
|
*/
|
|
125
|
-
setFromValues() {
|
|
126
|
-
let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
127
|
-
let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
128
|
-
let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
122
|
+
setFromValues(x = 0, y = 0, z = 0) {
|
|
129
123
|
this.x = x;
|
|
130
124
|
this.y = y;
|
|
131
125
|
this.z = z;
|
|
@@ -142,8 +136,7 @@ class Coordinates {
|
|
|
142
136
|
* @param array - The source array.
|
|
143
137
|
* @param offset - Optional offset into the array. Default is 0.
|
|
144
138
|
*/
|
|
145
|
-
setFromArray(array) {
|
|
146
|
-
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
139
|
+
setFromArray(array, offset = 0) {
|
|
147
140
|
return this.setFromValues(array[offset], array[offset + 1], array[offset + 2]);
|
|
148
141
|
}
|
|
149
142
|
|
|
@@ -215,8 +208,7 @@ class Coordinates {
|
|
|
215
208
|
* @returns A vector `(x, y, z)`, or copies x, y and z into the provided
|
|
216
209
|
* vector.
|
|
217
210
|
*/
|
|
218
|
-
toVector3() {
|
|
219
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector3();
|
|
211
|
+
toVector3(target = new Vector3()) {
|
|
220
212
|
return target.copy(this);
|
|
221
213
|
}
|
|
222
214
|
|
|
@@ -230,10 +222,8 @@ class Coordinates {
|
|
|
230
222
|
* @returns An array [x, y, z], or copies x, y and z into the provided
|
|
231
223
|
* array.
|
|
232
224
|
*/
|
|
233
|
-
toArray() {
|
|
234
|
-
|
|
235
|
-
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
236
|
-
return THREE.Vector3.prototype.toArray.call(this, array, offset);
|
|
225
|
+
toArray(array = [], offset = 0) {
|
|
226
|
+
return Vector3.prototype.toArray.call(this, array, offset);
|
|
237
227
|
}
|
|
238
228
|
|
|
239
229
|
/**
|
|
@@ -278,7 +268,7 @@ class Coordinates {
|
|
|
278
268
|
* @param mat - The matrix.
|
|
279
269
|
*/
|
|
280
270
|
applyMatrix4(mat) {
|
|
281
|
-
|
|
271
|
+
Vector3.prototype.applyMatrix4.call(this, mat);
|
|
282
272
|
return this;
|
|
283
273
|
}
|
|
284
274
|
|
|
@@ -312,13 +302,12 @@ class Coordinates {
|
|
|
312
302
|
* const geographicCoords = geocentricCoords.as('EPSG:4326');
|
|
313
303
|
* ```
|
|
314
304
|
*/
|
|
315
|
-
as(crs) {
|
|
316
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Coordinates(crs);
|
|
305
|
+
as(crs, target = new Coordinates(crs)) {
|
|
317
306
|
if (this.crs == crs) {
|
|
318
307
|
target.copy(this);
|
|
319
308
|
} else {
|
|
320
309
|
if (CRS.is4326(this.crs) && crs == 'EPSG:3857') {
|
|
321
|
-
this.y =
|
|
310
|
+
this.y = MathUtils.clamp(this.y, -89.999999, 89.999999);
|
|
322
311
|
}
|
|
323
312
|
target.setFromArray(proj4cache(this.crs, crs).forward([this.x, this.y, this.z]));
|
|
324
313
|
}
|
|
@@ -326,6 +315,6 @@ class Coordinates {
|
|
|
326
315
|
return target;
|
|
327
316
|
}
|
|
328
317
|
}
|
|
329
|
-
coord0 = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
330
|
-
coord1 = new Coordinates('EPSG:4326', 0, 0, 0);
|
|
318
|
+
coord0 = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
|
|
319
|
+
coord1 = /* @__PURE__ */new Coordinates('EPSG:4326', 0, 0, 0);
|
|
331
320
|
export default Coordinates;
|
package/lib/Crs.js
CHANGED
|
@@ -167,4 +167,21 @@ export function axisOrder(crs) {
|
|
|
167
167
|
* @param code - Named alias of the currently defined projection.
|
|
168
168
|
* @param proj4def - Proj4 or WKT string of the defined projection.
|
|
169
169
|
*/
|
|
170
|
-
export const defs = (code, proj4def) => proj4.defs(code, proj4def);
|
|
170
|
+
export const defs = (code, proj4def) => proj4.defs(code, proj4def);
|
|
171
|
+
export function defsFromWkt(wkt) {
|
|
172
|
+
proj4.defs('unknown', wkt);
|
|
173
|
+
const proj4Defs = proj4.defs;
|
|
174
|
+
let projCS;
|
|
175
|
+
if (proj4Defs('unknown').type === 'COMPD_CS') {
|
|
176
|
+
console.warn('Compound coordinate system is not yet supported.');
|
|
177
|
+
projCS = proj4Defs('unknown').PROJCS;
|
|
178
|
+
} else {
|
|
179
|
+
projCS = proj4Defs('unknown');
|
|
180
|
+
}
|
|
181
|
+
const crsAlias = projCS.title || projCS.name || 'EPSG:XXXX';
|
|
182
|
+
if (!(crsAlias in proj4.defs)) {
|
|
183
|
+
proj4.defs(crsAlias, projCS);
|
|
184
|
+
}
|
|
185
|
+
delete proj4Defs.unknown;
|
|
186
|
+
return crsAlias;
|
|
187
|
+
}
|
package/lib/Ellipsoid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
|
10
|
-
const normal = new
|
|
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.
|
|
@@ -21,11 +21,10 @@ class Ellipsoid {
|
|
|
21
21
|
* @param size - Length of the semi-axes of the ellipsoid. Defaults to those
|
|
22
22
|
* defined by the WGS84 ellipsoid.
|
|
23
23
|
*/
|
|
24
|
-
constructor() {
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this._invRadiiSquared = new THREE.Vector3();
|
|
24
|
+
constructor(size = ellipsoidSizes) {
|
|
25
|
+
this.size = new Vector3();
|
|
26
|
+
this._radiiSquared = new Vector3();
|
|
27
|
+
this._invRadiiSquared = new Vector3();
|
|
29
28
|
this.eccentricity = 0;
|
|
30
29
|
this.setSize(size);
|
|
31
30
|
}
|
|
@@ -38,8 +37,7 @@ class Ellipsoid {
|
|
|
38
37
|
* @param target - An object to store this vector to. If this is not
|
|
39
38
|
* specified, a new vector will be created.
|
|
40
39
|
*/
|
|
41
|
-
geodeticSurfaceNormal(cartesian) {
|
|
42
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3();
|
|
40
|
+
geodeticSurfaceNormal(cartesian, target = new Vector3()) {
|
|
43
41
|
return cartesian.toVector3(target).multiply(this._invRadiiSquared).normalize();
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -51,10 +49,9 @@ class Ellipsoid {
|
|
|
51
49
|
* @param target - An object to store this vector to. If this is not
|
|
52
50
|
* specified, a new vector will be created.
|
|
53
51
|
*/
|
|
54
|
-
geodeticSurfaceNormalCartographic(coordCarto) {
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const latitude = THREE.MathUtils.degToRad(coordCarto.latitude);
|
|
52
|
+
geodeticSurfaceNormalCartographic(coordCarto, target = new Vector3()) {
|
|
53
|
+
const longitude = MathUtils.degToRad(coordCarto.longitude);
|
|
54
|
+
const latitude = MathUtils.degToRad(coordCarto.latitude);
|
|
58
55
|
const cosLatitude = Math.cos(latitude);
|
|
59
56
|
return target.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude));
|
|
60
57
|
}
|
|
@@ -75,8 +72,7 @@ class Ellipsoid {
|
|
|
75
72
|
this.eccentricity = Math.sqrt(this._radiiSquared.x - this._radiiSquared.z) / this.size.x;
|
|
76
73
|
return this;
|
|
77
74
|
}
|
|
78
|
-
cartographicToCartesian(coordCarto) {
|
|
79
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3();
|
|
75
|
+
cartographicToCartesian(coordCarto, target = new Vector3()) {
|
|
80
76
|
normal.copy(coordCarto.geodesicNormal);
|
|
81
77
|
target.multiplyVectors(this._radiiSquared, normal);
|
|
82
78
|
const gamma = Math.sqrt(normal.dot(target));
|
|
@@ -93,8 +89,7 @@ class Ellipsoid {
|
|
|
93
89
|
* @returns an object describing the coordinates on the reference ellipsoid,
|
|
94
90
|
* angles are in degree
|
|
95
91
|
*/
|
|
96
|
-
cartesianToCartographic(position) {
|
|
97
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Coordinates('EPSG:4326', 0, 0, 0);
|
|
92
|
+
cartesianToCartographic(position, target = new Coordinates('EPSG:4326', 0, 0, 0)) {
|
|
98
93
|
// for details, see for example http://www.linz.govt.nz/data/geodetic-system/coordinate-conversion/geodetic-datum-conversions/equations-used-datum
|
|
99
94
|
// TODO the following is only valable for oblate ellipsoid of
|
|
100
95
|
// revolution. do we want to support triaxial ellipsoid?
|
|
@@ -110,7 +105,7 @@ class Ellipsoid {
|
|
|
110
105
|
const cosu = Math.cos(nu);
|
|
111
106
|
const phi = Math.atan((position.z * (1 - f) + e * a * sinu * sinu * sinu) / ((1 - f) * (rsqXY - e * a * cosu * cosu * cosu)));
|
|
112
107
|
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(
|
|
108
|
+
return target.setFromValues(MathUtils.radToDeg(theta), MathUtils.radToDeg(phi), h);
|
|
114
109
|
}
|
|
115
110
|
cartographicToCartesianArray(coordCartoArray) {
|
|
116
111
|
const cartesianArray = [];
|
|
@@ -151,7 +146,7 @@ class Ellipsoid {
|
|
|
151
146
|
return false;
|
|
152
147
|
} // Too close to intersection
|
|
153
148
|
|
|
154
|
-
const inter = new
|
|
149
|
+
const inter = new Vector3();
|
|
155
150
|
inter.addVectors(ray.origin, dir.clone().setLength(t));
|
|
156
151
|
return inter;
|
|
157
152
|
}
|
|
@@ -170,10 +165,10 @@ class Ellipsoid {
|
|
|
170
165
|
// The formula uses the distance on approximated sphere,
|
|
171
166
|
// with the nearest local radius of curvature of the ellipsoid
|
|
172
167
|
// https://geodesie.ign.fr/contenu/fichiers/Distance_longitude_latitude.pdf
|
|
173
|
-
const longitude1 =
|
|
174
|
-
const latitude1 =
|
|
175
|
-
const longitude2 =
|
|
176
|
-
const latitude2 =
|
|
168
|
+
const longitude1 = MathUtils.degToRad(coordCarto1.longitude);
|
|
169
|
+
const latitude1 = MathUtils.degToRad(coordCarto1.latitude);
|
|
170
|
+
const longitude2 = MathUtils.degToRad(coordCarto2.longitude);
|
|
171
|
+
const latitude2 = MathUtils.degToRad(coordCarto2.latitude);
|
|
177
172
|
const distRad = Math.acos(Math.sin(latitude1) * Math.sin(latitude2) + Math.cos(latitude1) * Math.cos(latitude2) * Math.cos(longitude2 - longitude1));
|
|
178
173
|
const e = this.eccentricity;
|
|
179
174
|
const latMoy = (latitude1 + latitude2) * 0.5;
|
package/lib/Extent.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import
|
|
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
|
|
5
|
-
const _dim2 = new
|
|
6
|
-
const _box = new
|
|
7
|
-
const defaultScheme = new
|
|
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
|
|
12
|
-
const northEast = new
|
|
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
|
|
15
|
-
|
|
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
|
|
31
|
+
* A default or user-defined CRS (see {@link ProjectionLike}).
|
|
35
32
|
*/
|
|
36
33
|
|
|
37
34
|
/**
|
|
@@ -51,17 +48,13 @@ class Extent {
|
|
|
51
48
|
*/
|
|
52
49
|
|
|
53
50
|
/**
|
|
54
|
-
* @param crs - A default or user-defined CRS (see {@link
|
|
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.
|
|
58
55
|
* @param north - the `north` value of this extent. Default is 0.
|
|
59
56
|
*/
|
|
60
|
-
constructor(crs) {
|
|
61
|
-
let west = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
62
|
-
let east = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
63
|
-
let south = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
64
|
-
let north = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
57
|
+
constructor(crs, west = 0, east = 0, south = 0, north = 0) {
|
|
65
58
|
if (CRS.isGeocentric(crs)) {
|
|
66
59
|
throw new Error(`Non-compatible geocentric projection ${crs} to build a geographical extent`);
|
|
67
60
|
}
|
|
@@ -88,8 +81,7 @@ class Extent {
|
|
|
88
81
|
* @param target - The target to store the projected extent. If this not
|
|
89
82
|
* provided a new extent will be created.
|
|
90
83
|
*/
|
|
91
|
-
as(crs) {
|
|
92
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Extent('EPSG:4326');
|
|
84
|
+
as(crs, target = new Extent('EPSG:4326')) {
|
|
93
85
|
CRS.isValid(crs);
|
|
94
86
|
if (this.crs != crs) {
|
|
95
87
|
// Compute min/max in x/y by projecting 8 cardinal points,
|
|
@@ -129,8 +121,7 @@ class Extent {
|
|
|
129
121
|
* @param target - The target to store the center coordinate. If this not
|
|
130
122
|
* provided a new coordinate will be created.
|
|
131
123
|
*/
|
|
132
|
-
center() {
|
|
133
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Coordinates(this.crs);
|
|
124
|
+
center(target = new Coordinates(this.crs)) {
|
|
134
125
|
this.planarDimensions(_dim);
|
|
135
126
|
target.crs = this.crs;
|
|
136
127
|
target.setFromValues(this.west + _dim.x * 0.5, this.south + _dim.y * 0.5);
|
|
@@ -145,8 +136,7 @@ class Extent {
|
|
|
145
136
|
*
|
|
146
137
|
* @param target - optional target
|
|
147
138
|
*/
|
|
148
|
-
planarDimensions() {
|
|
149
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
139
|
+
planarDimensions(target = new Vector2()) {
|
|
150
140
|
// Calculte the dimensions for x and y
|
|
151
141
|
return target.set(Math.abs(this.east - this.west), Math.abs(this.north - this.south));
|
|
152
142
|
}
|
|
@@ -159,8 +149,7 @@ class Extent {
|
|
|
159
149
|
*
|
|
160
150
|
* @param target - optional target
|
|
161
151
|
*/
|
|
162
|
-
geodeticDimensions() {
|
|
163
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
152
|
+
geodeticDimensions(target = new Vector2()) {
|
|
164
153
|
// set 3 corners extent
|
|
165
154
|
cNorthWest.crs = this.crs;
|
|
166
155
|
cSouthWest.crs = this.crs;
|
|
@@ -180,8 +169,7 @@ class Extent {
|
|
|
180
169
|
*
|
|
181
170
|
* @param target - optional target
|
|
182
171
|
*/
|
|
183
|
-
spatialEuclideanDimensions() {
|
|
184
|
-
let target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new THREE.Vector2();
|
|
172
|
+
spatialEuclideanDimensions(target = new Vector2()) {
|
|
185
173
|
// set 3 corners extent
|
|
186
174
|
cNorthWest.crs = this.crs;
|
|
187
175
|
cSouthWest.crs = this.crs;
|
|
@@ -201,8 +189,7 @@ class Extent {
|
|
|
201
189
|
* @param epsilon - error margin when comparing to the coordinates.
|
|
202
190
|
* Default is 0.
|
|
203
191
|
*/
|
|
204
|
-
isPointInside(coord) {
|
|
205
|
-
let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
192
|
+
isPointInside(coord, epsilon = 0) {
|
|
206
193
|
if (this.crs == coord.crs) {
|
|
207
194
|
_c.copy(coord);
|
|
208
195
|
} else {
|
|
@@ -219,8 +206,7 @@ class Extent {
|
|
|
219
206
|
* @param extent - the extent to check
|
|
220
207
|
* @param epsilon - error margin when comparing the extent bounds.
|
|
221
208
|
*/
|
|
222
|
-
isInside(extent) {
|
|
223
|
-
let epsilon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CRS.reasonableEpsilon(this.crs);
|
|
209
|
+
isInside(extent, epsilon = CRS.reasonableEpsilon(this.crs)) {
|
|
224
210
|
extent.as(this.crs, _extent);
|
|
225
211
|
return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
|
|
226
212
|
}
|
|
@@ -236,8 +222,7 @@ class Extent {
|
|
|
236
222
|
* south-north, the `z` property the scale on west-east, the `w` property
|
|
237
223
|
* the scale on south-north.
|
|
238
224
|
*/
|
|
239
|
-
offsetToParent(extent) {
|
|
240
|
-
let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector4();
|
|
225
|
+
offsetToParent(extent, target = new Vector4()) {
|
|
241
226
|
if (this.crs != extent.crs) {
|
|
242
227
|
throw new Error('unsupported mix');
|
|
243
228
|
}
|
|
@@ -317,8 +302,7 @@ class Extent {
|
|
|
317
302
|
* @param array - the source array
|
|
318
303
|
* @param offset - offset into the array. Default is 0.
|
|
319
304
|
*/
|
|
320
|
-
setFromArray(array) {
|
|
321
|
-
let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
305
|
+
setFromArray(array, offset = 0) {
|
|
322
306
|
this.west = array[offset];
|
|
323
307
|
this.east = array[offset + 1];
|
|
324
308
|
this.south = array[offset + 2];
|
|
@@ -442,8 +426,7 @@ class Extent {
|
|
|
442
426
|
* Return values of extent in string, separated by the separator input.
|
|
443
427
|
* @param sep - string separator
|
|
444
428
|
*/
|
|
445
|
-
toString() {
|
|
446
|
-
let sep = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
429
|
+
toString(sep = '') {
|
|
447
430
|
return `${this.east}${sep}${this.north}${sep}${this.west}${sep}${this.south}`;
|
|
448
431
|
}
|
|
449
432
|
|
|
@@ -464,8 +447,7 @@ class Extent {
|
|
|
464
447
|
* @param scheme - The scheme to subdivise.
|
|
465
448
|
* @returns subdivised extents.
|
|
466
449
|
*/
|
|
467
|
-
subdivisionByScheme() {
|
|
468
|
-
let scheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultScheme;
|
|
450
|
+
subdivisionByScheme(scheme = defaultScheme) {
|
|
469
451
|
const subdivisedExtents = [];
|
|
470
452
|
const dimSub = this.planarDimensions(_dim).divide(scheme);
|
|
471
453
|
for (let x = scheme.x - 1; x >= 0; x--) {
|
|
@@ -512,9 +494,7 @@ class Extent {
|
|
|
512
494
|
* @param north - The max north
|
|
513
495
|
* @returns this extent
|
|
514
496
|
*/
|
|
515
|
-
clampSouthNorth() {
|
|
516
|
-
let south = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.south;
|
|
517
|
-
let north = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.north;
|
|
497
|
+
clampSouthNorth(south = this.south, north = this.north) {
|
|
518
498
|
this.south = Math.max(this.south, south);
|
|
519
499
|
this.north = Math.min(this.north, north);
|
|
520
500
|
return this;
|
|
@@ -527,9 +507,7 @@ class Extent {
|
|
|
527
507
|
* @param east - The max east
|
|
528
508
|
* @returns this extent
|
|
529
509
|
*/
|
|
530
|
-
clampWestEast() {
|
|
531
|
-
let west = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.west;
|
|
532
|
-
let east = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.east;
|
|
510
|
+
clampWestEast(west = this.west, east = this.east) {
|
|
533
511
|
this.west = Math.max(this.west, west);
|
|
534
512
|
this.east = Math.min(this.east, east);
|
|
535
513
|
return this;
|
|
@@ -546,5 +524,5 @@ class Extent {
|
|
|
546
524
|
return this.clampWestEast(extent.west, extent.east);
|
|
547
525
|
}
|
|
548
526
|
}
|
|
549
|
-
_extent = new Extent('EPSG:4326');
|
|
527
|
+
_extent = /* @__PURE__ */new Extent('EPSG:4326');
|
|
550
528
|
export default Extent;
|