@itowns/geographic 2.46.1-next.45 → 2.46.1-next.46
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/CoordStars.d.ts +13 -0
- package/lib/Coordinates.d.ts +196 -0
- package/lib/Crs.d.ts +108 -0
- package/lib/Ellipsoid.d.ts +74 -0
- package/lib/Extent.d.ts +246 -0
- package/lib/OrientationUtils.d.ts +105 -0
- package/lib/index.d.ts +7 -0
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Vector3, type Vector3Like, type Matrix4 } from 'three';
|
|
2
|
+
import type { ProjectionLike } 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 ProjectionLike}).
|
|
48
|
+
*/
|
|
49
|
+
crs: ProjectionLike;
|
|
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 ProjectionLike}).
|
|
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: ProjectionLike, 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: ProjectionLike): 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: 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(): 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?: Vector3): 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: 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: ProjectionLike, target?: Coordinates): Coordinates;
|
|
195
|
+
}
|
|
196
|
+
export default Coordinates;
|
package/lib/Crs.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Converter } from 'proj4';
|
|
2
|
+
import type { ProjectionDefinition } from 'proj4/dist/lib/defs';
|
|
3
|
+
/**
|
|
4
|
+
* A projection as a CRS identifier string. This identifier references a
|
|
5
|
+
* projection definition previously defined with
|
|
6
|
+
* [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections).
|
|
7
|
+
*/
|
|
8
|
+
export type ProjectionLike = string;
|
|
9
|
+
export declare function transform(crsIn: ProjectionLike, crsOut: ProjectionLike): Converter;
|
|
10
|
+
/**
|
|
11
|
+
* System units supported for a coordinate system. See
|
|
12
|
+
* [proj](https://proj4.org/en/9.5/operations/conversions/unitconvert.html#angular-units).
|
|
13
|
+
* Note that only degree and meters units are supported for now.
|
|
14
|
+
*/
|
|
15
|
+
export declare const UNIT: {
|
|
16
|
+
/**
|
|
17
|
+
* Angular unit in degree.
|
|
18
|
+
*/
|
|
19
|
+
readonly DEGREE: 1;
|
|
20
|
+
/**
|
|
21
|
+
* Distance unit in meter.
|
|
22
|
+
*/
|
|
23
|
+
readonly METER: 2;
|
|
24
|
+
/**
|
|
25
|
+
* Distance unit in foot.
|
|
26
|
+
*/
|
|
27
|
+
readonly FOOT: 3;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Checks that the CRS is EPSG:4326.
|
|
31
|
+
* @internal
|
|
32
|
+
*
|
|
33
|
+
* @param crs - The CRS to test.
|
|
34
|
+
*/
|
|
35
|
+
export declare function is4326(crs: ProjectionLike): crs is "EPSG:4326";
|
|
36
|
+
/**
|
|
37
|
+
* Returns the horizontal coordinates system units associated with this CRS.
|
|
38
|
+
*
|
|
39
|
+
* @param crs - The CRS to extract the unit from.
|
|
40
|
+
* @returns Either `UNIT.METER`, `UNIT.DEGREE`, `UNIT.FOOT` or `undefined`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getUnit(crs: ProjectionLike): 1 | 2 | 3 | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Asserts that the CRS is using metric units.
|
|
45
|
+
*
|
|
46
|
+
* @param crs - The CRS to check.
|
|
47
|
+
* @throws {@link Error} if the CRS is not valid.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isMetricUnit(crs: ProjectionLike): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Asserts that the CRS is geographic.
|
|
52
|
+
*
|
|
53
|
+
* @param crs - The CRS to check.
|
|
54
|
+
* @throws {@link Error} if the CRS is not valid.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isGeographic(crs: ProjectionLike): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Asserts that the CRS is geocentric.
|
|
59
|
+
*
|
|
60
|
+
* @param crs - The CRS to test.
|
|
61
|
+
* @returns false if the crs isn't defined.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isGeocentric(crs: ProjectionLike): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Asserts that the CRS is valid, meaning it has been previously defined and
|
|
66
|
+
* includes an unit.
|
|
67
|
+
*
|
|
68
|
+
* @param crs - The CRS to test.
|
|
69
|
+
* @throws {@link Error} if the crs is not valid.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isValid(crs: ProjectionLike): void;
|
|
72
|
+
/**
|
|
73
|
+
* Gives a reasonable epsilon for this CRS.
|
|
74
|
+
*
|
|
75
|
+
* @param crs - The CRS to use.
|
|
76
|
+
* @returns 0.01 if the CRS is EPSG:4326, 0.001 otherwise.
|
|
77
|
+
*/
|
|
78
|
+
export declare function reasonableEpsilon(crs: ProjectionLike): 0.01 | 0.001;
|
|
79
|
+
/**
|
|
80
|
+
* Returns the axis parameter defined in proj4 for the provided crs.
|
|
81
|
+
* Might be undefined depending on crs definition.
|
|
82
|
+
*
|
|
83
|
+
* @param crs - The CRS to get axis from.
|
|
84
|
+
* @returns the matching proj4 axis string, 'enu' for instance (east, north, up)
|
|
85
|
+
*/
|
|
86
|
+
export declare function axisOrder(crs: ProjectionLike): string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Defines a proj4 projection as a named alias.
|
|
89
|
+
* This function is an alias for the
|
|
90
|
+
* [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections) function.
|
|
91
|
+
*/
|
|
92
|
+
export declare const defs: typeof import("proj4/dist/lib/defs").default;
|
|
93
|
+
/**
|
|
94
|
+
* Fetches a CRS definition from epsg.io and registers it with proj4.
|
|
95
|
+
* If the CRS is already defined, returns the existing definition.
|
|
96
|
+
*
|
|
97
|
+
* @param crs - The EPSG code string (e.g. "EPSG:2154").
|
|
98
|
+
* @returns The proj4 projection definition.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* // Register EPSG:2154 (RGF93 / Lambert-93)
|
|
102
|
+
* await CRS.fromEPSG('EPSG:2154');
|
|
103
|
+
*
|
|
104
|
+
* // Register EPSG:4269 (NAD83)
|
|
105
|
+
* await CRS.fromEPSG('EPSG:4269');
|
|
106
|
+
*/
|
|
107
|
+
export declare function fromEPSG(crs: string): Promise<ProjectionDefinition>;
|
|
108
|
+
export declare function defsFromWkt(wkt: string): string;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Vector3, type Vector3Like, type Ray } from 'three';
|
|
2
|
+
import Coordinates from './Coordinates';
|
|
3
|
+
/**
|
|
4
|
+
* Length of the semi-axes of the WGS84 ellipsoid.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const ellipsoidSizes: Vector3;
|
|
8
|
+
declare class Ellipsoid {
|
|
9
|
+
/**
|
|
10
|
+
* Length of the semi-axes of the ellipsoid.
|
|
11
|
+
*/
|
|
12
|
+
size: Vector3;
|
|
13
|
+
/**
|
|
14
|
+
* Eccentricity of the ellipsoid.
|
|
15
|
+
*/
|
|
16
|
+
eccentricity: number;
|
|
17
|
+
private _radiiSquared;
|
|
18
|
+
private _invRadiiSquared;
|
|
19
|
+
/**
|
|
20
|
+
* @param size - Length of the semi-axes of the ellipsoid. Defaults to those
|
|
21
|
+
* defined by the WGS84 ellipsoid.
|
|
22
|
+
*/
|
|
23
|
+
constructor(size?: Vector3);
|
|
24
|
+
/**
|
|
25
|
+
* Computes the normal vector to an ellipsoid at the given cartesian
|
|
26
|
+
* coordinate `(x, y, z)`.
|
|
27
|
+
*
|
|
28
|
+
* @param cartesian - The given cartesian coordinate.
|
|
29
|
+
* @param target - An object to store this vector to. If this is not
|
|
30
|
+
* specified, a new vector will be created.
|
|
31
|
+
*/
|
|
32
|
+
geodeticSurfaceNormal(cartesian: Coordinates, target?: Vector3): Vector3;
|
|
33
|
+
/**
|
|
34
|
+
* Computes the normal vector to an ellipsoid at the given geographic
|
|
35
|
+
* coordinate `(longitude, latitude, altitude)`.
|
|
36
|
+
*
|
|
37
|
+
* @param coordCarto - The given geographic coordinate.
|
|
38
|
+
* @param target - An object to store this vector to. If this is not
|
|
39
|
+
* specified, a new vector will be created.
|
|
40
|
+
*/
|
|
41
|
+
geodeticSurfaceNormalCartographic(coordCarto: Coordinates, target?: Vector3): Vector3;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the length of the semi-axes of this ellipsoid from a 3-dimensional
|
|
44
|
+
* vector-like object. The object shall have both `x`, `y` and `z`
|
|
45
|
+
* properties.
|
|
46
|
+
*
|
|
47
|
+
* @param size - The source vector.
|
|
48
|
+
*/
|
|
49
|
+
setSize(size: Vector3Like): this;
|
|
50
|
+
cartographicToCartesian(coordCarto: Coordinates, target?: Vector3): Vector3;
|
|
51
|
+
/**
|
|
52
|
+
* Convert cartesian coordinates to geographic according to the current
|
|
53
|
+
* ellipsoid of revolution.
|
|
54
|
+
* @param position - The coordinate to convert
|
|
55
|
+
* @param target - coordinate to copy result
|
|
56
|
+
* @returns an object describing the coordinates on the reference ellipsoid,
|
|
57
|
+
* angles are in degree
|
|
58
|
+
*/
|
|
59
|
+
cartesianToCartographic(position: Vector3Like, target?: Coordinates): Coordinates;
|
|
60
|
+
cartographicToCartesianArray(coordCartoArray: Coordinates[]): Vector3[];
|
|
61
|
+
intersection(ray: Ray): Vector3 | false;
|
|
62
|
+
/**
|
|
63
|
+
* Calculate the geodesic distance, between coordCarto1 and coordCarto2.
|
|
64
|
+
* It's most short distance on ellipsoid surface between coordCarto1 and
|
|
65
|
+
* coordCarto2.
|
|
66
|
+
* It's called orthodromy.
|
|
67
|
+
*
|
|
68
|
+
* @param coordCarto1 - The coordinate carto 1
|
|
69
|
+
* @param coordCarto2 - The coordinate carto 2
|
|
70
|
+
* @returns The orthodromic distance between the two given coordinates.
|
|
71
|
+
*/
|
|
72
|
+
geodesicDistance(coordCarto1: Coordinates, coordCarto2: Coordinates): number;
|
|
73
|
+
}
|
|
74
|
+
export default Ellipsoid;
|
package/lib/Extent.d.ts
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Vector2, Vector4, Box3, type Matrix4 } from 'three';
|
|
2
|
+
import Coordinates from './Coordinates';
|
|
3
|
+
import type { ProjectionLike } from './Crs';
|
|
4
|
+
export interface ExtentLike {
|
|
5
|
+
readonly west: number;
|
|
6
|
+
readonly east: number;
|
|
7
|
+
readonly south: number;
|
|
8
|
+
readonly north: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A class representing a geographical extent.
|
|
12
|
+
*
|
|
13
|
+
* An extent is a geographical bounding rectangle defined by 4 limits: west,
|
|
14
|
+
* east, south and north.
|
|
15
|
+
*
|
|
16
|
+
* **Warning**: Using a geocentric projection is not suitable for representing a
|
|
17
|
+
* geographical extent. Please use a geographic projection.
|
|
18
|
+
*/
|
|
19
|
+
declare class Extent {
|
|
20
|
+
/**
|
|
21
|
+
* Read-only flag to check if a given object is of type `Extent`.
|
|
22
|
+
*/
|
|
23
|
+
readonly isExtent: true;
|
|
24
|
+
/**
|
|
25
|
+
* A default or user-defined CRS (see {@link ProjectionLike}).
|
|
26
|
+
*/
|
|
27
|
+
crs: ProjectionLike;
|
|
28
|
+
/**
|
|
29
|
+
* West longitude bound of this extent.
|
|
30
|
+
*/
|
|
31
|
+
west: number;
|
|
32
|
+
/**
|
|
33
|
+
* East longitude bound of this extent.
|
|
34
|
+
*/
|
|
35
|
+
east: number;
|
|
36
|
+
/**
|
|
37
|
+
* South latitude bound of this extent.
|
|
38
|
+
*/
|
|
39
|
+
south: number;
|
|
40
|
+
/**
|
|
41
|
+
* North latitude bound of this extent.
|
|
42
|
+
*/
|
|
43
|
+
north: number;
|
|
44
|
+
/**
|
|
45
|
+
* @param crs - A default or user-defined CRS (see {@link ProjectionLike}).
|
|
46
|
+
* @param west - the `west` value of this extent. Default is 0.
|
|
47
|
+
* @param east - the `east` value of this extent. Default is 0.
|
|
48
|
+
* @param south - the `south` value of this extent. Default is 0.
|
|
49
|
+
* @param north - the `north` value of this extent. Default is 0.
|
|
50
|
+
*/
|
|
51
|
+
constructor(crs: ProjectionLike, west?: number, east?: number, south?: number, north?: number);
|
|
52
|
+
/**
|
|
53
|
+
* Returns a new extent with the same bounds and crs as this one.
|
|
54
|
+
*/
|
|
55
|
+
clone(): Extent;
|
|
56
|
+
/**
|
|
57
|
+
* Projects this extent to the specified projection.
|
|
58
|
+
*
|
|
59
|
+
* @param crs - target's projection.
|
|
60
|
+
* @param target - The target to store the projected extent. If this not
|
|
61
|
+
* provided a new extent will be created.
|
|
62
|
+
*/
|
|
63
|
+
as(crs: string, target?: Extent): Extent;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the center of the extent.
|
|
66
|
+
*
|
|
67
|
+
* @param target - The target to store the center coordinate. If this not
|
|
68
|
+
* provided a new coordinate will be created.
|
|
69
|
+
*/
|
|
70
|
+
center(target?: Coordinates): Coordinates;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the planar dimensions as two-vector planar distances west/east
|
|
73
|
+
* and south/north.
|
|
74
|
+
* The planar distance is a straight-line Euclidean distance calculated in a
|
|
75
|
+
* 2D Cartesian coordinate system.
|
|
76
|
+
*
|
|
77
|
+
* @param target - optional target
|
|
78
|
+
*/
|
|
79
|
+
planarDimensions(target?: Vector2): Vector2;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the geodetic dimensions as two-vector planar distances west/east
|
|
82
|
+
* and south/north.
|
|
83
|
+
* Geodetic distance is calculated in an ellispoid space as the distance
|
|
84
|
+
* across the curved surface of the ellipsoid.
|
|
85
|
+
*
|
|
86
|
+
* @param target - optional target
|
|
87
|
+
*/
|
|
88
|
+
geodeticDimensions(target?: Vector2): Vector2;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the spatial euclidean dimensions as a two-vector spatial
|
|
91
|
+
* euclidean distances between west/east corner and south/north corner.
|
|
92
|
+
* Spatial euclidean distance chord is calculated in an ellispoid space.
|
|
93
|
+
*
|
|
94
|
+
* @param target - optional target
|
|
95
|
+
*/
|
|
96
|
+
spatialEuclideanDimensions(target?: Vector2): Vector2;
|
|
97
|
+
/**
|
|
98
|
+
* Checks whether a coordinates is inside the extent.
|
|
99
|
+
*
|
|
100
|
+
* @param coord - the given coordinates.
|
|
101
|
+
* @param epsilon - error margin when comparing to the coordinates.
|
|
102
|
+
* Default is 0.
|
|
103
|
+
*/
|
|
104
|
+
isPointInside(coord: Coordinates, epsilon?: number): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Checks whether another extent is inside the extent.
|
|
107
|
+
*
|
|
108
|
+
* @param extent - the extent to check
|
|
109
|
+
* @param epsilon - error margin when comparing the extent bounds.
|
|
110
|
+
*/
|
|
111
|
+
isInside(extent: Extent, epsilon?: number): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Return the translation and scale to transform this extent to the input
|
|
114
|
+
* extent.
|
|
115
|
+
*
|
|
116
|
+
* @param extent - input extent
|
|
117
|
+
* @param target - copy the result to target.
|
|
118
|
+
* @returns A {@link THREE.Vector4} where the `x` property encodes the
|
|
119
|
+
* translation on west-east, the `y` property the translation on
|
|
120
|
+
* south-north, the `z` property the scale on west-east, the `w` property
|
|
121
|
+
* the scale on south-north.
|
|
122
|
+
*/
|
|
123
|
+
offsetToParent(extent: Extent, target?: Vector4): Vector4;
|
|
124
|
+
/**
|
|
125
|
+
* Checks wheter this bounding box intersects with the given extent
|
|
126
|
+
* parameter.
|
|
127
|
+
* @param extent - the provided extent
|
|
128
|
+
*/
|
|
129
|
+
intersectsExtent(extent: Extent): boolean;
|
|
130
|
+
static intersectsExtent(extentA: Extent, extentB: Extent): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Returns the intersection of this extent with another one.
|
|
133
|
+
* @param extent - extent to intersect
|
|
134
|
+
*/
|
|
135
|
+
intersect(extent: Extent): Extent;
|
|
136
|
+
/**
|
|
137
|
+
* Set west, east, south and north values.
|
|
138
|
+
*
|
|
139
|
+
* @param v0 - the `west` value of this extent. Default is 0.
|
|
140
|
+
* @param v1 - the `east` value of this extent. Default is 0.
|
|
141
|
+
* @param v2 - the `south` value of this extent. Default is 0.
|
|
142
|
+
* @param v3 - the `north` value of this extent. Default is 0.
|
|
143
|
+
*/
|
|
144
|
+
set(v0: number, v1: number, v2: number, v3: number): this;
|
|
145
|
+
/**
|
|
146
|
+
* Sets this extent `west` property to `array[offset + 0]`, `east` property
|
|
147
|
+
* to `array[offset + 1]`, `south` property to `array[offset + 2]` and
|
|
148
|
+
* `north` property to `array[offset + 3]`.
|
|
149
|
+
* @param array - the source array
|
|
150
|
+
* @param offset - offset into the array. Default is 0.
|
|
151
|
+
*/
|
|
152
|
+
setFromArray(array: ArrayLike<number>, offset?: number): this;
|
|
153
|
+
/**
|
|
154
|
+
* Sets this extent `west`, `east`, `south` and `north` properties from an
|
|
155
|
+
* `extent` bounds.
|
|
156
|
+
* @param extent - the source extent
|
|
157
|
+
*/
|
|
158
|
+
setFromExtent(extent: ExtentLike): this;
|
|
159
|
+
/**
|
|
160
|
+
* Copies the passed extent to this extent.
|
|
161
|
+
* @param extent - extent to copy.
|
|
162
|
+
*/
|
|
163
|
+
copy(extent: Extent): this;
|
|
164
|
+
/**
|
|
165
|
+
* Union this extent with the input extent.
|
|
166
|
+
* @param extent - the extent to union.
|
|
167
|
+
*/
|
|
168
|
+
union(extent: Extent): void;
|
|
169
|
+
/**
|
|
170
|
+
* expandByCoordinates perfoms the minimal extension
|
|
171
|
+
* for the coordinates to belong to this Extent object
|
|
172
|
+
* @param coordinates - The coordinates to belong
|
|
173
|
+
*/
|
|
174
|
+
expandByCoordinates(coordinates: Coordinates): void;
|
|
175
|
+
/**
|
|
176
|
+
* expandByValuesCoordinates perfoms the minimal extension
|
|
177
|
+
* for the coordinates values to belong to this Extent object
|
|
178
|
+
* @param we - The coordinate on west-east
|
|
179
|
+
* @param sn - The coordinate on south-north
|
|
180
|
+
*
|
|
181
|
+
*/
|
|
182
|
+
expandByValuesCoordinates(we: number, sn: number): void;
|
|
183
|
+
/**
|
|
184
|
+
* Instance Extent with THREE.Box3.
|
|
185
|
+
*
|
|
186
|
+
* If crs is a geocentric projection, the `box3.min` and `box3.max`
|
|
187
|
+
* should be the geocentric coordinates of `min` and `max` of a `box3`
|
|
188
|
+
* in local tangent plane.
|
|
189
|
+
*
|
|
190
|
+
* @param crs - Projection of extent to instancied.
|
|
191
|
+
* @param box - Bounding-box
|
|
192
|
+
*/
|
|
193
|
+
static fromBox3(crs: ProjectionLike, box: Box3): Extent;
|
|
194
|
+
/**
|
|
195
|
+
* Return values of extent in string, separated by the separator input.
|
|
196
|
+
* @param sep - string separator
|
|
197
|
+
*/
|
|
198
|
+
toString(sep?: string): string;
|
|
199
|
+
/**
|
|
200
|
+
* Subdivide equally an extent from its center to return four extents:
|
|
201
|
+
* north-west, north-east, south-west and south-east.
|
|
202
|
+
*
|
|
203
|
+
* @returns An array containing the four sections of the extent. The order
|
|
204
|
+
* of the sections is [NW, NE, SW, SE].
|
|
205
|
+
*/
|
|
206
|
+
subdivision(): Extent[];
|
|
207
|
+
/**
|
|
208
|
+
* subdivise extent by scheme.x on west-east and scheme.y on south-north.
|
|
209
|
+
*
|
|
210
|
+
* @param scheme - The scheme to subdivise.
|
|
211
|
+
* @returns subdivised extents.
|
|
212
|
+
*/
|
|
213
|
+
subdivisionByScheme(scheme?: Vector2): Extent[];
|
|
214
|
+
/**
|
|
215
|
+
* Multiplies all extent `coordinates` (with an implicit 1 in the 4th
|
|
216
|
+
* dimension) and `matrix`.
|
|
217
|
+
*
|
|
218
|
+
* @param matrix - The matrix
|
|
219
|
+
* @returns return this extent instance.
|
|
220
|
+
*/
|
|
221
|
+
applyMatrix4(matrix: Matrix4): this;
|
|
222
|
+
/**
|
|
223
|
+
* clamp south and north values
|
|
224
|
+
*
|
|
225
|
+
* @param south - The min south
|
|
226
|
+
* @param north - The max north
|
|
227
|
+
* @returns this extent
|
|
228
|
+
*/
|
|
229
|
+
clampSouthNorth(south?: number, north?: number): this;
|
|
230
|
+
/**
|
|
231
|
+
* clamp west and east values
|
|
232
|
+
*
|
|
233
|
+
* @param west - The min west
|
|
234
|
+
* @param east - The max east
|
|
235
|
+
* @returns this extent
|
|
236
|
+
*/
|
|
237
|
+
clampWestEast(west?: number, east?: number): this;
|
|
238
|
+
/**
|
|
239
|
+
* clamp this extent by passed extent
|
|
240
|
+
*
|
|
241
|
+
* @param extent - The maximum extent.
|
|
242
|
+
* @returns this extent.
|
|
243
|
+
*/
|
|
244
|
+
clampByExtent(extent: ExtentLike): this;
|
|
245
|
+
}
|
|
246
|
+
export default Extent;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Quaternion } from 'three';
|
|
2
|
+
import { type ProjectionDefinition } from 'proj4';
|
|
3
|
+
import Coordinates from './Coordinates';
|
|
4
|
+
interface EulerAngles {
|
|
5
|
+
/** angle in degrees */
|
|
6
|
+
roll: number;
|
|
7
|
+
/** angle in degrees */
|
|
8
|
+
pitch: number;
|
|
9
|
+
/** angle in degrees */
|
|
10
|
+
heading: number;
|
|
11
|
+
}
|
|
12
|
+
interface PhotogrammetryAngles {
|
|
13
|
+
/** angle in degrees */
|
|
14
|
+
omega: number;
|
|
15
|
+
/** angle in degrees */
|
|
16
|
+
phi: number;
|
|
17
|
+
/** angle in degrees */
|
|
18
|
+
kappa: number;
|
|
19
|
+
}
|
|
20
|
+
type Attitude = Partial<EulerAngles> | Partial<PhotogrammetryAngles>;
|
|
21
|
+
type QuaternionFunction = (coords: Coordinates, target?: Quaternion) => Quaternion;
|
|
22
|
+
type ProjectionLike = ProjectionDefinition | string;
|
|
23
|
+
type LCCProjection = {
|
|
24
|
+
long0: number;
|
|
25
|
+
lat0: number;
|
|
26
|
+
};
|
|
27
|
+
type TMercProjection = {
|
|
28
|
+
a: number;
|
|
29
|
+
b: number;
|
|
30
|
+
e?: number;
|
|
31
|
+
long0: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The transform from the platform frame to the local East, North, Up (ENU)
|
|
35
|
+
* frame is `RotationZ(heading).RotationX(pitch).RotationY(roll)`.
|
|
36
|
+
*
|
|
37
|
+
* @param roll - angle in degrees. Default is 0.
|
|
38
|
+
* @param pitch - angle in degrees. Default is 0.
|
|
39
|
+
* @param heading - angle in degrees. Default is 0
|
|
40
|
+
* @param target - output Quaternion
|
|
41
|
+
*
|
|
42
|
+
* @returns The target quaternion
|
|
43
|
+
*/
|
|
44
|
+
export declare function quaternionFromRollPitchHeading(roll?: number, pitch?: number, heading?: number, target?: Quaternion): Quaternion;
|
|
45
|
+
/**
|
|
46
|
+
* From
|
|
47
|
+
* [DocMicMac](https://github.com/micmacIGN/Documentation/raw/master/DocMicMac.pdf),
|
|
48
|
+
* the transform from the platform frame to the local East, North, Up (ENU)
|
|
49
|
+
* frame is:
|
|
50
|
+
*
|
|
51
|
+
* ```
|
|
52
|
+
* RotationX(omega).RotationY(phi).RotationZ(kappa).RotationX(PI)
|
|
53
|
+
* Converts between the 2 conventions for the camera local frame:
|
|
54
|
+
* RotationX(PI) <=> Quaternion(1,0,0,0)
|
|
55
|
+
* X right, Y bottom, Z front : convention in photogrammetry and computer vision
|
|
56
|
+
* X right, Y top, Z back : convention in webGL, threejs
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param omega - angle in degrees. Default is 0.
|
|
60
|
+
* @param phi - angle in degrees. Default is 0.
|
|
61
|
+
* @param kappa - angle in degrees. Default is 0.
|
|
62
|
+
* @param target - output quaternion
|
|
63
|
+
*
|
|
64
|
+
* @returns The target quaternion
|
|
65
|
+
*/
|
|
66
|
+
export declare function quaternionFromOmegaPhiKappa(omega?: number, phi?: number, kappa?: number, target?: Quaternion): Quaternion;
|
|
67
|
+
/**
|
|
68
|
+
* Sets the quaternion according to the rotation from the platform frame to the
|
|
69
|
+
* local frame.
|
|
70
|
+
*
|
|
71
|
+
* @param attitude - either euler angles or photogrammetry angles
|
|
72
|
+
* @param target - output Quaternion
|
|
73
|
+
*
|
|
74
|
+
* @returns The target quaternion
|
|
75
|
+
*/
|
|
76
|
+
export declare function quaternionFromAttitude(attitude: Attitude, target?: Quaternion): Quaternion;
|
|
77
|
+
export declare function quaternionFromEnuToGeocent(): QuaternionFunction;
|
|
78
|
+
export declare function quaternionFromEnuToGeocent(coords: Coordinates, target?: Quaternion): Quaternion;
|
|
79
|
+
export declare function quaternionFromGeocentToEnu(): QuaternionFunction;
|
|
80
|
+
export declare function quaternionFromGeocentToEnu(coords: Coordinates, target?: Quaternion): Quaternion;
|
|
81
|
+
export declare function quaternionFromLCCToEnu(proj: LCCProjection): QuaternionFunction;
|
|
82
|
+
export declare function quaternionFromLCCToEnu(proj: LCCProjection, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
83
|
+
export declare function quaternionFromEnuToLCC(proj: LCCProjection): QuaternionFunction;
|
|
84
|
+
export declare function quaternionFromEnuToLCC(proj: LCCProjection, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
85
|
+
export declare function quaternionFromTMercToEnu(proj: TMercProjection): QuaternionFunction;
|
|
86
|
+
export declare function quaternionFromTMercToEnu(proj: TMercProjection, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
87
|
+
export declare function quaternionFromEnuToTMerc(proj: TMercProjection): QuaternionFunction;
|
|
88
|
+
export declare function quaternionFromEnuToTMerc(proj: TMercProjection, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
89
|
+
export declare function quaternionFromLongLatToEnu(): QuaternionFunction;
|
|
90
|
+
export declare function quaternionFromLongLatToEnu(coords: Coordinates, target?: Quaternion): Quaternion;
|
|
91
|
+
export declare function quaternionFromEnuToLongLat(): QuaternionFunction;
|
|
92
|
+
export declare function quaternionFromEnuToLongLat(coords: Coordinates, target?: Quaternion): Quaternion;
|
|
93
|
+
export declare function quaternionUnimplemented(proj: {
|
|
94
|
+
projName?: string;
|
|
95
|
+
}): QuaternionFunction;
|
|
96
|
+
export declare function quaternionUnimplemented(proj: {
|
|
97
|
+
projName?: string;
|
|
98
|
+
}, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
99
|
+
export declare function quaternionFromEnuToCRS(proj: ProjectionLike): QuaternionFunction;
|
|
100
|
+
export declare function quaternionFromEnuToCRS(proj: ProjectionLike, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
101
|
+
export declare function quaternionFromCRSToEnu(proj: ProjectionLike): QuaternionFunction;
|
|
102
|
+
export declare function quaternionFromCRSToEnu(proj: ProjectionLike, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
103
|
+
export declare function quaternionFromCRSToCRS(crsIn: string, crsOut: string): QuaternionFunction;
|
|
104
|
+
export declare function quaternionFromCRSToCRS(crsIn: string, crsOut: string, coords: Coordinates, target?: Quaternion): Quaternion;
|
|
105
|
+
export {};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Extent, type ExtentLike } from './Extent';
|
|
2
|
+
export { default as Coordinates, type CoordinatesLike } from './Coordinates';
|
|
3
|
+
export * as CRS from './Crs';
|
|
4
|
+
export { type ProjectionLike } from './Crs';
|
|
5
|
+
export { default as CoordStars } from './CoordStars';
|
|
6
|
+
export * as OrientationUtils from './OrientationUtils';
|
|
7
|
+
export { default as Ellipsoid, ellipsoidSizes } from './Ellipsoid';
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itowns/geographic",
|
|
3
|
-
"version": "2.46.1-next.
|
|
3
|
+
"version": "2.46.1-next.46",
|
|
4
4
|
"description": "Proj4-based three.js geodesy toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|
|
8
|
-
"types": "./
|
|
8
|
+
"types": "./lib/index.d.ts",
|
|
9
9
|
"default": "./lib/index.js"
|
|
10
10
|
},
|
|
11
|
-
"types": "./
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "",
|
|
14
14
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\" \"test/**/*.js\"",
|