itowns 2.44.3-next.21 → 2.44.3-next.22

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.
@@ -4,7 +4,6 @@ import { FEATURE_TYPES } from "../Core/Feature.js";
4
4
  import ReferLayerProperties from "../Layer/ReferencingLayerProperties.js";
5
5
  import { deprecatedFeature2MeshOptions } from "../Core/Deprecated/Undeprecator.js";
6
6
  import Extent from "../Core/Geographic/Extent.js";
7
- import Crs from "../Core/Geographic/Crs.js";
8
7
  import OrientationUtils from "../Utils/OrientationUtils.js";
9
8
  import Coordinates from "../Core/Geographic/Coordinates.js";
10
9
  import Style, { StyleContext } from "../Core/Style.js";
@@ -54,7 +53,7 @@ class FeatureMesh extends THREE.Group {
54
53
  } else {
55
54
  // calculate the scale transformation to transform the feature.extent
56
55
  // to feature.extent.as(crs)
57
- coord.crs = Crs.formatToEPSG(this.#originalCrs);
56
+ coord.crs = this.#originalCrs;
58
57
  // TODO: An extent here could be either a geographic extent (for
59
58
  // features from WFS) or a tiled extent (for features from MVT).
60
59
  // Unify both behavior.
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import Feature2Texture from "./Feature2Texture.js";
3
3
  import Extent from "../Core/Geographic/Extent.js";
4
- import CRS from "../Core/Geographic/Crs.js";
5
4
  const extentTexture = new Extent('EPSG:4326', [0, 0, 0, 0]);
6
5
  const textureLayer = (texture, layer) => {
7
6
  texture.generateMipmaps = false;
@@ -20,7 +19,7 @@ export default {
20
19
  if (data.isFeatureCollection) {
21
20
  const backgroundLayer = layer.source.backgroundLayer;
22
21
  const backgroundColor = backgroundLayer && backgroundLayer.paint ? new THREE.Color(backgroundLayer.paint['background-color']) : undefined;
23
- destinationTile.toExtent(CRS.formatToEPSG(layer.crs), extentTexture);
22
+ destinationTile.toExtent(layer.crs, extentTexture);
24
23
  texture = Feature2Texture.createTextureFromFeature(data, extentTexture, layer.subdivisionThreshold, layer.style, backgroundColor);
25
24
  texture.features = data;
26
25
  texture.extent = destinationTile;
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import Extent from "./Geographic/Extent.js";
3
3
  import Coordinates from "./Geographic/Coordinates.js";
4
- import CRS from "./Geographic/Crs.js";
5
4
  import Style from "./Style.js";
6
5
  function defaultExtent(crs) {
7
6
  return new Extent(crs, Infinity, -Infinity, Infinity, -Infinity);
@@ -340,7 +339,7 @@ export class FeatureCollection extends THREE.Object3D {
340
339
  constructor(options) {
341
340
  super();
342
341
  this.isFeatureCollection = true;
343
- this.crs = CRS.formatToEPSG(options.accurate || !options.source?.crs ? options.crs : options.source.crs);
342
+ this.crs = options.accurate || !options.source?.crs ? options.crs : options.source.crs;
344
343
  this.features = [];
345
344
  this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
346
345
  this.size = options.structure == '3d' ? 3 : 2;
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import proj4 from 'proj4';
3
- import CRS from "./Crs.js";
3
+ import * as CRS from "./Crs.js";
4
4
  import Ellipsoid from "../Math/Ellipsoid.js";
5
5
  proj4.defs('EPSG:4978', '+proj=geocent +datum=WGS84 +units=m +no_defs');
6
6
  const ellipsoid = new Ellipsoid();
@@ -1,5 +1,12 @@
1
1
  import proj4 from 'proj4';
2
2
  proj4.defs('EPSG:4978', '+proj=geocent +datum=WGS84 +units=m +no_defs');
3
+
4
+ /**
5
+ * A projection as a CRS identifier string. This identifier references a
6
+ * projection definition previously defined with
7
+ * [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections).
8
+ */
9
+
3
10
  function isString(s) {
4
11
  return typeof s === 'string' || s instanceof String;
5
12
  }
@@ -8,168 +15,131 @@ function mustBeString(crs) {
8
15
  throw new Error(`Crs parameter value must be a string: '${crs}'`);
9
16
  }
10
17
  }
11
- function isTms(crs) {
12
- return isString(crs) && crs.startsWith('TMS');
13
- }
14
- function isEpsg(crs) {
15
- return isString(crs) && crs.startsWith('EPSG');
16
- }
17
- function formatToTms(crs) {
18
- mustBeString(crs);
19
- return isTms(crs) ? crs : `TMS:${crs.match(/\d+/)[0]}`;
20
- }
21
- function formatToEPSG(crs) {
22
- mustBeString(crs);
23
- return isEpsg(crs) ? crs : `EPSG:${crs.match(/\d+/)[0]}`;
24
- }
25
- const UNIT = {
18
+
19
+ /**
20
+ * System units supported for a coordinate system. See
21
+ * [proj](https://proj4.org/en/9.5/operations/conversions/unitconvert.html#angular-units).
22
+ * Note that only degree and meters units are supported for now.
23
+ */
24
+ export const UNIT = {
25
+ /**
26
+ * Angular unit in degree.
27
+ */
26
28
  DEGREE: 1,
29
+ /**
30
+ * Distance unit in meter.
31
+ */
27
32
  METER: 2
28
33
  };
29
- function is4326(crs) {
34
+
35
+ /**
36
+ * Checks that the CRS is EPSG:4326.
37
+ * @internal
38
+ *
39
+ * @param crs - The CRS to test.
40
+ */
41
+ export function is4326(crs) {
30
42
  return crs === 'EPSG:4326';
31
43
  }
32
- function isGeocentric(crs) {
33
- mustBeString(crs);
34
- const projection = proj4.defs(crs);
35
- return !projection ? false : projection.projName == 'geocent';
36
- }
37
- function _unitFromProj4Unit(projunit) {
38
- if (projunit === 'degrees') {
44
+ function unitFromProj4Unit(proj) {
45
+ if (proj.units === 'degrees') {
39
46
  return UNIT.DEGREE;
40
- } else if (projunit === 'm') {
47
+ } else if (proj.units === 'm') {
48
+ return UNIT.METER;
49
+ } else if (proj.units === undefined && proj.to_meter === undefined) {
50
+ // See https://proj.org/en/9.4/usage/projections.html [17/10/2024]
51
+ // > The default unit for projected coordinates is the meter.
41
52
  return UNIT.METER;
42
53
  } else {
43
54
  return undefined;
44
55
  }
45
56
  }
46
- function toUnit(crs) {
57
+
58
+ /**
59
+ * Returns the horizontal coordinates system units associated with this CRS.
60
+ *
61
+ * @param crs - The CRS to extract the unit from.
62
+ * @returns Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
63
+ */
64
+ export function getUnit(crs) {
47
65
  mustBeString(crs);
48
- switch (crs) {
49
- case 'EPSG:4326':
50
- return UNIT.DEGREE;
51
- case 'EPSG:4978':
52
- return UNIT.METER;
53
- default:
54
- {
55
- const p = proj4.defs(formatToEPSG(crs));
56
- if (!p) {
57
- return undefined;
58
- }
59
- return _unitFromProj4Unit(p.units);
60
- }
66
+ const p = proj4.defs(crs);
67
+ if (!p) {
68
+ return undefined;
61
69
  }
70
+ return unitFromProj4Unit(p);
71
+ }
72
+
73
+ /**
74
+ * Asserts that the CRS is using metric units.
75
+ *
76
+ * @param crs - The CRS to check.
77
+ * @throws {@link Error} if the CRS is not valid.
78
+ */
79
+ export function isMetricUnit(crs) {
80
+ return getUnit(crs) === UNIT.METER;
81
+ }
82
+
83
+ /**
84
+ * Asserts that the CRS is geographic.
85
+ *
86
+ * @param crs - The CRS to check.
87
+ * @throws {@link Error} if the CRS is not valid.
88
+ */
89
+ export function isGeographic(crs) {
90
+ return getUnit(crs) === UNIT.DEGREE;
62
91
  }
63
- function toUnitWithError(crs) {
92
+
93
+ /**
94
+ * Asserts that the CRS is geocentric.
95
+ *
96
+ * @param crs - The CRS to test.
97
+ * @returns false if the crs isn't defined.
98
+ */
99
+ export function isGeocentric(crs) {
64
100
  mustBeString(crs);
65
- const u = toUnit(crs);
66
- if (u === undefined) {
67
- throw new Error(`No unit found for crs: '${crs}'`);
101
+ const projection = proj4.defs(crs);
102
+ return !projection ? false : projection.projName == 'geocent';
103
+ }
104
+
105
+ /**
106
+ * Asserts that the CRS is valid, meaning it has been previously defined and
107
+ * includes an unit.
108
+ *
109
+ * @param crs - The CRS to test.
110
+ * @throws {@link Error} if the crs is not valid.
111
+ */
112
+ export function isValid(crs) {
113
+ const proj = proj4.defs(crs);
114
+ if (!proj) {
115
+ throw new Error(`Undefined crs '${crs}'. Add it with proj4.defs('${crs}', string)`);
116
+ }
117
+ if (!unitFromProj4Unit(proj)) {
118
+ throw new Error(`No valid unit found for crs '${crs}', found ${proj.units}`);
68
119
  }
69
- return u;
70
120
  }
71
121
 
72
122
  /**
73
- * This module provides basic methods to manipulate a CRS (as a string).
123
+ * Gives a reasonable epsilon for this CRS.
74
124
  *
75
- * @module CRS
125
+ * @param crs - The CRS to use.
126
+ * @returns 0.01 if the CRS is EPSG:4326, 0.001 otherwise.
76
127
  */
77
- export default {
78
- /**
79
- * Units that can be used for a CRS.
80
- *
81
- * @enum {number}
82
- */
83
- UNIT,
84
- /**
85
- * Assert that the CRS is valid one.
86
- *
87
- * @param {string} crs - The CRS to validate.
88
- *
89
- * @throws {Error} if the CRS is not valid.
90
- */
91
- isValid(crs) {
92
- toUnitWithError(crs);
93
- },
94
- /**
95
- * Assert that the CRS is geographic.
96
- *
97
- * @param {string} crs - The CRS to validate.
98
- * @return {boolean}
99
- * @throws {Error} if the CRS is not valid.
100
- */
101
- isGeographic(crs) {
102
- return toUnitWithError(crs) == UNIT.DEGREE;
103
- },
104
- /**
105
- * Assert that the CRS is using metric units.
106
- *
107
- * @param {string} crs - The CRS to validate.
108
- * @return {boolean}
109
- * @throws {Error} if the CRS is not valid.
110
- */
111
- isMetricUnit(crs) {
112
- return toUnit(crs) == UNIT.METER;
113
- },
114
- /**
115
- * Get the unit to use with the CRS.
116
- *
117
- * @param {string} crs - The CRS to get the unit from.
118
- * @return {number} Either `UNIT.METER`, `UNIT.DEGREE` or `undefined`.
119
- */
120
- toUnit,
121
- /**
122
- * Is the CRS EPSG:4326 ?
123
- *
124
- * @param {string} crs - The CRS to test.
125
- * @return {boolean}
126
- */
127
- is4326,
128
- /**
129
- * Is the CRS geocentric ?
130
- * if crs isn't defined the method returns false.
131
- *
132
- * @param {string} crs - The CRS to test.
133
- * @return {boolean}
134
- */
135
- isGeocentric,
136
- /**
137
- * Give a reasonnable epsilon to use with this CRS.
138
- *
139
- * @param {string} crs - The CRS to use.
140
- * @return {number} 0.01 if the CRS is EPSG:4326, 0.001 otherwise.
141
- */
142
- reasonnableEpsilon(crs) {
143
- if (is4326(crs)) {
144
- return 0.01;
145
- } else {
146
- return 0.001;
147
- }
148
- },
149
- /**
150
- * format crs to European Petroleum Survey Group notation : EPSG:XXXX.
151
- *
152
- * @param {string} crs The crs to format
153
- * @return {string} formated crs
154
- */
155
- formatToEPSG,
156
- /**
157
- * format crs to tile matrix set notation : TMS:XXXX.
158
- *
159
- * @param {string} crs The crs to format
160
- * @return {string} formated crs
161
- */
162
- formatToTms,
163
- isTms,
164
- isEpsg,
165
- tms_3857: 'TMS:3857',
166
- tms_4326: 'TMS:4326',
167
- /**
168
- * Define a proj4 projection as a string and reference.
169
- *
170
- * @param {string} code code is the projection's SRS code (only used internally by the Proj4js library)
171
- * @param {string} proj4def is the Proj4 definition string for the projection to use
172
- * @return {undefined}
173
- */
174
- defs: (code, proj4def) => proj4.defs(code, proj4def)
175
- };
128
+ export function reasonableEpsilon(crs) {
129
+ if (is4326(crs)) {
130
+ return 0.01;
131
+ } else {
132
+ return 0.001;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Defines a proj4 projection as a named alias.
138
+ * This function is a specialized wrapper over the
139
+ * [`proj4.defs`](https://github.com/proj4js/proj4js#named-projections)
140
+ * function.
141
+ *
142
+ * @param code - Named alias of the currently defined projection.
143
+ * @param proj4def - Proj4 or WKT string of the defined projection.
144
+ */
145
+ export const defs = (code, proj4def) => proj4.defs(code, proj4def);
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
+ import * as CRS from "./Crs.js";
2
3
  import Coordinates from "./Coordinates.js";
3
- import CRS from "./Crs.js";
4
4
 
5
5
  /**
6
6
  * Extent is a SIG-area (so 2D)
@@ -43,9 +43,6 @@ class Extent {
43
43
  if (CRS.isGeocentric(crs)) {
44
44
  throw new Error(`${crs} is a geocentric projection, it doesn't make sense with a geographical extent`);
45
45
  }
46
- if (CRS.isTms(crs)) {
47
- throw new Error(`${crs} is a tiled projection, use Tile instead`);
48
- }
49
46
  this.isExtent = true;
50
47
  this.crs = crs;
51
48
  this.west = 0;
@@ -220,7 +217,7 @@ class Extent {
220
217
  */
221
218
  isInside(extent, epsilon) {
222
219
  extent.as(this.crs, _extent);
223
- epsilon = epsilon == undefined ? CRS.reasonnableEpsilon(this.crs) : epsilon;
220
+ epsilon = epsilon ?? CRS.reasonableEpsilon(this.crs);
224
221
  return this.east - _extent.east <= epsilon && _extent.west - this.west <= epsilon && this.north - _extent.north <= epsilon && _extent.south - this.south <= epsilon;
225
222
  }
226
223
 
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
+ import * as CRS from "./Crs.js";
2
3
  import Coordinates from "./Coordinates.js";
3
- import CRS from "./Crs.js";
4
4
  const coord = new Coordinates('EPSG:4326');
5
5
  const indexes = new THREE.Vector2();
6
6
  function biLinearInterpolation(indexes, getData) {
@@ -3,7 +3,6 @@ import TiledGeometryLayer from "../../../Layer/TiledGeometryLayer.js";
3
3
  import { ellipsoidSizes } from "../../Math/Ellipsoid.js";
4
4
  import { globalExtentTMS, schemeTiles } from "../../Tile/TileGrid.js";
5
5
  import BuilderEllipsoidTile from "./BuilderEllipsoidTile.js";
6
- import CRS from "../../Geographic/Crs.js";
7
6
 
8
7
  // matrix to convert sphere to ellipsoid
9
8
  const worldToScaledEllipsoid = new THREE.Matrix4();
@@ -49,11 +48,11 @@ class GlobeLayer extends TiledGeometryLayer {
49
48
  constructor(id, object3d) {
50
49
  let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
51
50
  // Configure tiles
52
- const scheme = schemeTiles.get(CRS.tms_4326);
51
+ const scheme = schemeTiles.get('EPSG:4326');
53
52
  const schemeTile = globalExtentTMS.get('EPSG:4326').subdivisionByScheme(scheme);
54
53
 
55
54
  // Supported tile matrix set for color/elevation layer
56
- config.tileMatrixSets = [CRS.tms_4326, CRS.tms_3857];
55
+ config.tileMatrixSets = ['EPSG:4326', 'EPSG:3857'];
57
56
  const uvCount = config.tileMatrixSets.length;
58
57
  const builder = new BuilderEllipsoidTile({
59
58
  crs: 'EPSG:4978',
@@ -97,7 +96,7 @@ class GlobeLayer extends TiledGeometryLayer {
97
96
  }
98
97
  subdivision(context, layer, node) {
99
98
  if (node.level == 5) {
100
- const row = node.getExtentsByProjection(CRS.tms_4326)[0].row;
99
+ const row = node.getExtentsByProjection('EPSG:4326')[0].row;
101
100
  if (row == 31 || row == 0) {
102
101
  // doesn't subdivise the pole
103
102
  return false;
@@ -5,7 +5,6 @@ import Coordinates from "../Geographic/Coordinates.js";
5
5
  import GlobeLayer from "./Globe/GlobeLayer.js";
6
6
  import Atmosphere from "./Globe/Atmosphere.js";
7
7
  import CameraUtils from "../../Utils/CameraUtils.js";
8
- import CRS from "../Geographic/Crs.js";
9
8
  import { ellipsoidSizes } from "../Math/Ellipsoid.js";
10
9
 
11
10
  /**
@@ -129,11 +128,11 @@ class GlobeView extends View {
129
128
  return Promise.reject(new Error('Add Layer type object'));
130
129
  }
131
130
  if (layer.isColorLayer) {
132
- if (!this.tileLayer.tileMatrixSets.includes(CRS.formatToTms(layer.source.crs))) {
131
+ if (!this.tileLayer.tileMatrixSets.includes(layer.source.crs)) {
133
132
  return layer._reject(`Only ${this.tileLayer.tileMatrixSets} tileMatrixSet are currently supported for color layers`);
134
133
  }
135
134
  } else if (layer.isElevationLayer) {
136
- if (CRS.formatToTms(layer.source.crs) !== this.tileLayer.tileMatrixSets[0]) {
135
+ if (layer.source.crs !== this.tileLayer.tileMatrixSets[0]) {
137
136
  return layer._reject(`Only ${this.tileLayer.tileMatrixSets[0]} tileMatrixSet is currently supported for elevation layers`);
138
137
  }
139
138
  }
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import TiledGeometryLayer from "../../../Layer/TiledGeometryLayer.js";
3
3
  import { globalExtentTMS } from "../../Tile/TileGrid.js";
4
- import CRS from "../../Geographic/Crs.js";
5
4
  import PlanarTileBuilder from "./PlanarTileBuilder.js";
6
5
 
7
6
  /**
@@ -35,12 +34,12 @@ class PlanarLayer extends TiledGeometryLayer {
35
34
  */
36
35
  constructor(id, extent, object3d) {
37
36
  let config = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
38
- const tms = CRS.formatToTms(extent.crs);
37
+ const tileMatrixSets = [extent.crs];
39
38
  if (!globalExtentTMS.get(extent.crs)) {
40
39
  // Add new global extent for this new crs projection.
41
40
  globalExtentTMS.set(extent.crs, extent);
42
41
  }
43
- config.tileMatrixSets = [tms];
42
+ config.tileMatrixSets = tileMatrixSets;
44
43
  super(id, object3d || new THREE.Group(), [extent], new PlanarTileBuilder({
45
44
  crs: extent.crs
46
45
  }), config);
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
+ import * as CRS from "../Geographic/Crs.js";
2
3
  import Coordinates from "../Geographic/Coordinates.js";
3
- import CRS from "../Geographic/Crs.js";
4
4
  import Extent from "../Geographic/Extent.js";
5
5
  import { getInfoTms, getCountTiles } from "./TileGrid.js";
6
6
  const _tmsCoord = new THREE.Vector2();
@@ -169,14 +169,14 @@ class Tile {
169
169
  * @returns {Tile[]}
170
170
  */
171
171
  export function tiledCovering(e, tms) {
172
- if (e.crs == 'EPSG:4326' && tms == CRS.tms_3857) {
172
+ if (e.crs == 'EPSG:4326' && tms == 'EPSG:3857') {
173
173
  const WMTS_PM = [];
174
- const extent = _extent.copy(e).as(CRS.formatToEPSG(tms), _extent2);
174
+ const extent = _extent.copy(e).as(tms, _extent2);
175
175
  const {
176
176
  globalExtent,
177
177
  globalDimension,
178
178
  sTs
179
- } = getInfoTms(CRS.formatToEPSG(tms));
179
+ } = getInfoTms(tms);
180
180
  extent.clampByExtent(globalExtent);
181
181
  extent.planarDimensions(_dimensionTile);
182
182
  const zoom = e.zoom + 1 || Math.floor(Math.log2(Math.round(globalDimension.x / (_dimensionTile.x * sTs.x))));
@@ -1,5 +1,4 @@
1
1
  import * as THREE from 'three';
2
- import CRS from "../Geographic/Crs.js";
3
2
  import Extent from "../Geographic/Extent.js";
4
3
  const _countTiles = new THREE.Vector2();
5
4
  const _dim = new THREE.Vector2();
@@ -15,23 +14,21 @@ const extent3857 = extent4326.as('EPSG:3857');
15
14
  extent3857.clampSouthNorth(extent3857.west, extent3857.east);
16
15
  globalExtentTMS.set('EPSG:3857', extent3857);
17
16
  schemeTiles.set('default', new THREE.Vector2(1, 1));
18
- schemeTiles.set(CRS.tms_3857, schemeTiles.get('default'));
19
- schemeTiles.set(CRS.tms_4326, new THREE.Vector2(2, 1));
17
+ schemeTiles.set('EPSG:3857', schemeTiles.get('default'));
18
+ schemeTiles.set('EPSG:4326', new THREE.Vector2(2, 1));
20
19
  export function getInfoTms(/** @type {string} */crs) {
21
- const epsg = CRS.formatToEPSG(crs);
22
- const globalExtent = globalExtentTMS.get(epsg);
20
+ const globalExtent = globalExtentTMS.get(crs);
23
21
  const globalDimension = globalExtent.planarDimensions(_dim);
24
- const tms = CRS.formatToTms(crs);
25
- const sTs = schemeTiles.get(tms) || schemeTiles.get('default');
22
+ const sTs = schemeTiles.get(crs) || schemeTiles.get('default');
26
23
  // The isInverted parameter is to be set to the correct value, true or false
27
24
  // (default being false) if the computation of the coordinates needs to be
28
25
  // inverted to match the same scheme as OSM, Google Maps or other system.
29
26
  // See link below for more information
30
27
  // https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
31
28
  // in crs includes ':NI' => tms isn't inverted (NOT INVERTED)
32
- const isInverted = !tms.includes(':NI');
29
+ const isInverted = !crs.includes(':NI');
33
30
  return {
34
- epsg,
31
+ epsg: crs,
35
32
  globalExtent,
36
33
  globalDimension,
37
34
  sTs,
@@ -39,7 +36,7 @@ export function getInfoTms(/** @type {string} */crs) {
39
36
  };
40
37
  }
41
38
  export function getCountTiles(/** @type {string} */crs, /** @type {number} */zoom) {
42
- const sTs = schemeTiles.get(CRS.formatToTms(crs)) || schemeTiles.get('default');
39
+ const sTs = schemeTiles.get(crs) || schemeTiles.get('default');
43
40
  const count = 2 ** zoom;
44
41
  _countTiles.set(count, count).multiply(sTs);
45
42
  return _countTiles;
@@ -1,5 +1,4 @@
1
1
  import * as THREE from 'three';
2
- import CRS from "./Geographic/Crs.js";
3
2
  import { geoidLayerIsVisible } from "../Layer/GeoidLayer.js";
4
3
  import { tiledCovering } from "./Tile/Tile.js";
5
4
 
@@ -71,7 +70,7 @@ class TileMesh extends THREE.Mesh {
71
70
  this.obb.box3D.getBoundingSphere(this.boundingSphere);
72
71
  }
73
72
  getExtentsByProjection(crs) {
74
- return this.#_tms.get(CRS.formatToTms(crs));
73
+ return this.#_tms.get(crs);
75
74
  }
76
75
 
77
76
  /**
package/lib/Core/View.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as THREE from 'three';
2
+ import * as CRS from "./Geographic/Crs.js";
2
3
  import Camera from "../Renderer/Camera.js";
3
4
  import initializeWebXR from "../Renderer/WebXR.js";
4
5
  import MainLoop, { MAIN_LOOP_EVENTS, RENDERING_PAUSED } from "./MainLoop.js";
@@ -6,7 +7,6 @@ import Capabilities from "./System/Capabilities.js";
6
7
  import { COLOR_LAYERS_ORDER_CHANGED } from "../Renderer/ColorLayersOrdering.js";
7
8
  import c3DEngine from "../Renderer/c3DEngine.js";
8
9
  import RenderMode from "../Renderer/RenderMode.js";
9
- import CRS from "./Geographic/Crs.js";
10
10
  import Coordinates from "./Geographic/Coordinates.js";
11
11
  import FeaturesUtils from "../Utils/FeaturesUtils.js";
12
12
  import { getMaxColorSamplerUnitsCount } from "../Renderer/LayeredMaterial.js";
@@ -53,7 +53,7 @@ function _preprocessLayer(view, layer, parentLayer) {
53
53
  // Find crs projection layer, this is projection destination
54
54
  layer.crs = view.referenceCrs;
55
55
  } else if (!layer.crs) {
56
- if (parentLayer && parentLayer.tileMatrixSets && parentLayer.tileMatrixSets.includes(CRS.formatToTms(source.crs))) {
56
+ if (parentLayer && parentLayer.tileMatrixSets && parentLayer.tileMatrixSets.includes(source.crs)) {
57
57
  layer.crs = source.crs;
58
58
  } else {
59
59
  layer.crs = parentLayer && parentLayer.extent.crs;
package/lib/Main.js CHANGED
@@ -7,7 +7,7 @@ export const REVISION = conf.version;
7
7
  export { default as Extent } from "./Core/Geographic/Extent.js";
8
8
  export { default as Coordinates } from "./Core/Geographic/Coordinates.js";
9
9
  export { default as GeoidGrid } from "./Core/Geographic/GeoidGrid.js";
10
- export { default as CRS } from "./Core/Geographic/Crs.js";
10
+ export * as CRS from "./Core/Geographic/Crs.js";
11
11
  export { default as Ellipsoid, ellipsoidSizes } from "./Core/Math/Ellipsoid.js";
12
12
  export { default as GlobeView, GLOBE_VIEW_EVENTS } from "./Core/Prefab/GlobeView.js";
13
13
  export { default as PlanarView } from "./Core/Prefab/PlanarView.js";
@@ -1,8 +1,8 @@
1
1
  import * as THREE from 'three';
2
+ import * as CRS from "../Core/Geographic/Crs.js";
2
3
  import TileGeometry from "../Core/TileGeometry.js";
3
4
  import BuilderEllipsoidTile from "../Core/Prefab/Globe/BuilderEllipsoidTile.js";
4
5
  import Coordinates from "../Core/Geographic/Coordinates.js";
5
- import CRS from "../Core/Geographic/Crs.js";
6
6
 
7
7
  // get oriented bounding box of tile
8
8
  const builder = new BuilderEllipsoidTile({
@@ -137,7 +137,7 @@ class OBB extends THREE.Object3D {
137
137
  this.position.copy(position);
138
138
  this.quaternion.copy(quaternion);
139
139
  this.updateMatrixWorld(true);
140
- } else if (!CRS.isTms(extent.crs) && CRS.isMetricUnit(extent.crs)) {
140
+ } else if (CRS.isMetricUnit(extent.crs)) {
141
141
  extent.center(coord).toVector3(this.position);
142
142
  extent.planarDimensions(dimension);
143
143
  size.set(dimension.x, dimension.y, Math.abs(maxHeight - minHeight));
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import { ELEVATION_MODES } from "./LayeredMaterial.js";
3
3
  import { checkNodeElevationTextureValidity, insertSignificantValuesFromParent, computeMinMaxElevation } from "../Parser/XbilParser.js";
4
- import CRS from "../Core/Geographic/Crs.js";
5
4
  export const EMPTY_TEXTURE_ZOOM = -1;
6
5
  const pitch = new THREE.Vector4();
7
6
  function getIndiceWithPitch(i, pitch, w) {
@@ -29,7 +28,7 @@ class RasterTile extends THREE.EventDispatcher {
29
28
  constructor(material, layer) {
30
29
  super();
31
30
  this.layer = layer;
32
- this.crs = layer.parent.tileMatrixSets.indexOf(CRS.formatToTms(layer.crs));
31
+ this.crs = layer.parent.tileMatrixSets.indexOf(layer.crs);
33
32
  if (this.crs == -1) {
34
33
  console.error('Unknown crs:', layer.crs);
35
34
  }
@@ -1,6 +1,5 @@
1
1
  import Source from "./Source.js";
2
2
  import Cache from "../Core/Scheduler/Cache.js";
3
- import CRS from "../Core/Geographic/Crs.js";
4
3
 
5
4
  /**
6
5
  * An object defining the source of a single resource to get from a direct
@@ -155,7 +154,7 @@ class FileSource extends Source {
155
154
  if (!features) {
156
155
  options.out.buildExtent = this.crs != 'EPSG:4978';
157
156
  if (options.out.buildExtent) {
158
- options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : CRS.formatToEPSG(this.crs);
157
+ options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : this.crs;
159
158
  }
160
159
  features = this.parser(this.fetchedData, options);
161
160
  this._featuresCaches[options.out.crs].setByArray(features, [0]);
@@ -1,3 +1,4 @@
1
+ import * as CRS from "../Core/Geographic/Crs.js";
1
2
  import Extent from "../Core/Geographic/Extent.js";
2
3
  import GeoJsonParser from "../Parser/GeoJsonParser.js";
3
4
  import KMLParser from "../Parser/KMLParser.js";
@@ -8,7 +9,6 @@ import ISGParser from "../Parser/ISGParser.js";
8
9
  import VectorTileParser from "../Parser/VectorTileParser.js";
9
10
  import Fetcher from "../Provider/Fetcher.js";
10
11
  import Cache from "../Core/Scheduler/Cache.js";
11
- import CRS from "../Core/Geographic/Crs.js";
12
12
 
13
13
  /** @private */
14
14
  export const supportedParsers = new Map([['application/geo+json', GeoJsonParser.parse], ['application/json', GeoJsonParser.parse], ['application/kml', KMLParser.parse], ['application/gpx', GpxParser.parse], ['application/x-protobuf;type=mapbox-vector', VectorTileParser.parse], ['application/gtx', GTXParser.parse], ['application/isg', ISGParser.parse], ['application/gdf', GDFParser.parse]]);