itowns 2.44.3-next.3 → 2.44.3-next.30

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.
Files changed (92) hide show
  1. package/CODING.md +1 -1
  2. package/CONTRIBUTORS.md +1 -0
  3. package/dist/debug.js +1 -1
  4. package/dist/debug.js.map +1 -1
  5. package/dist/itowns.js +1 -1
  6. package/dist/itowns.js.LICENSE.txt +0 -2
  7. package/dist/itowns.js.map +1 -1
  8. package/dist/itowns_widgets.js +1 -1
  9. package/dist/itowns_widgets.js.map +1 -1
  10. package/examples/3dtiles_loader.html +109 -45
  11. package/examples/config.json +2 -10
  12. package/examples/entwine_3d_loader.html +3 -1
  13. package/examples/entwine_simple_loader.html +1 -1
  14. package/examples/images/itowns_logo.svg +123 -0
  15. package/examples/js/plugins/COGParser.js +1 -1
  16. package/examples/jsm/OGC3DTilesHelper.js +1 -1
  17. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  18. package/examples/source_file_geojson_3d.html +0 -1
  19. package/examples/source_stream_wfs_raster.html +0 -7
  20. package/lib/Controls/GlobeControls.js +45 -28
  21. package/lib/Controls/StateControl.js +5 -2
  22. package/lib/Converter/Feature2Mesh.js +10 -4
  23. package/lib/Converter/Feature2Texture.js +3 -1
  24. package/lib/Converter/convertToTile.js +3 -8
  25. package/lib/Converter/textureConverter.js +3 -4
  26. package/lib/Core/Deprecated/Undeprecator.js +0 -1
  27. package/lib/Core/Feature.js +1 -2
  28. package/lib/Core/Geographic/Coordinates.js +143 -132
  29. package/lib/Core/Geographic/Crs.js +140 -145
  30. package/lib/Core/Geographic/Extent.js +72 -267
  31. package/lib/Core/Geographic/GeoidGrid.js +1 -1
  32. package/lib/Core/Math/Ellipsoid.js +62 -21
  33. package/lib/Core/Prefab/Globe/Atmosphere.js +4 -8
  34. package/lib/Core/Prefab/Globe/GlobeLayer.js +22 -15
  35. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +111 -0
  36. package/lib/Core/Prefab/GlobeView.js +2 -7
  37. package/lib/Core/Prefab/Planar/PlanarLayer.js +17 -11
  38. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +43 -43
  39. package/lib/Core/Prefab/TileBuilder.js +27 -32
  40. package/lib/Core/Prefab/computeBufferTileGeometry.js +189 -130
  41. package/lib/Core/Style.js +3 -3
  42. package/lib/Core/Tile/Tile.js +219 -0
  43. package/lib/Core/Tile/TileGrid.js +43 -0
  44. package/lib/Core/TileGeometry.js +112 -28
  45. package/lib/Core/TileMesh.js +3 -3
  46. package/lib/Core/View.js +15 -8
  47. package/lib/Layer/C3DTilesLayer.js +20 -16
  48. package/lib/Layer/ColorLayer.js +35 -9
  49. package/lib/Layer/CopcLayer.js +5 -0
  50. package/lib/Layer/ElevationLayer.js +39 -7
  51. package/lib/Layer/EntwinePointTileLayer.js +12 -5
  52. package/lib/Layer/FeatureGeometryLayer.js +20 -6
  53. package/lib/Layer/GeometryLayer.js +42 -11
  54. package/lib/Layer/LabelLayer.js +19 -9
  55. package/lib/Layer/Layer.js +83 -57
  56. package/lib/Layer/OGC3DTilesLayer.js +81 -30
  57. package/lib/Layer/OrientedImageLayer.js +11 -5
  58. package/lib/Layer/PointCloudLayer.js +74 -30
  59. package/lib/Layer/Potree2Layer.js +7 -2
  60. package/lib/Layer/PotreeLayer.js +8 -3
  61. package/lib/Layer/RasterLayer.js +12 -2
  62. package/lib/Layer/TiledGeometryLayer.js +69 -13
  63. package/lib/Main.js +2 -2
  64. package/lib/Parser/GeoJsonParser.js +1 -1
  65. package/lib/Parser/VectorTileParser.js +1 -1
  66. package/lib/Parser/XbilParser.js +14 -2
  67. package/lib/Provider/Fetcher.js +5 -1
  68. package/lib/Provider/URLBuilder.js +22 -11
  69. package/lib/Renderer/Camera.js +1 -1
  70. package/lib/Renderer/OBB.js +11 -13
  71. package/lib/Renderer/PointsMaterial.js +1 -1
  72. package/lib/Renderer/RasterTile.js +1 -2
  73. package/lib/Renderer/SphereHelper.js +0 -6
  74. package/lib/Source/CopcSource.js +13 -2
  75. package/lib/Source/EntwinePointTileSource.js +14 -4
  76. package/lib/Source/FileSource.js +1 -4
  77. package/lib/Source/Source.js +1 -4
  78. package/lib/Source/TMSSource.js +10 -9
  79. package/lib/Source/VectorTilesSource.js +3 -5
  80. package/lib/Source/WFSSource.js +15 -10
  81. package/lib/Source/WMSSource.js +56 -18
  82. package/lib/Source/WMTSSource.js +13 -7
  83. package/lib/Utils/CameraUtils.js +1 -1
  84. package/lib/Utils/gui/C3DTilesStyle.js +2 -3
  85. package/lib/Utils/placeObjectOnGround.js +0 -1
  86. package/package.json +13 -6
  87. package/examples/3dtiles_25d.html +0 -120
  88. package/examples/3dtiles_basic.html +0 -94
  89. package/examples/3dtiles_batch_table.html +0 -86
  90. package/examples/3dtiles_ion.html +0 -126
  91. package/examples/3dtiles_pointcloud.html +0 -95
  92. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
@@ -4,8 +4,18 @@ import textureConverter from "../Converter/textureConverter.js";
4
4
  import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
5
5
  class RasterLayer extends Layer {
6
6
  constructor(id, config) {
7
- config.cacheLifeTime = config.cacheLifeTime ?? CACHE_POLICIES.TEXTURE;
8
- super(id, config);
7
+ const {
8
+ cacheLifeTime = CACHE_POLICIES.TEXTURE,
9
+ minFilter,
10
+ magFilter,
11
+ ...layerConfig
12
+ } = config;
13
+ super(id, {
14
+ ...layerConfig,
15
+ cacheLifeTime
16
+ });
17
+ this.minFilter = minFilter;
18
+ this.magFilter = magFilter;
9
19
  }
10
20
  convert(data, extentDestination) {
11
21
  return textureConverter.convert(data, extentDestination, this);
@@ -16,6 +16,8 @@ const boundingSphereCenter = new THREE.Vector3();
16
16
  * as it is used internally for optimisation.
17
17
  * @property {boolean} hideSkirt (default false) - Used to hide the skirt (tile borders).
18
18
  * Useful when the layer opacity < 1
19
+ *
20
+ * @extends GeometryLayer
19
21
  */
20
22
  class TiledGeometryLayer extends GeometryLayer {
21
23
  /**
@@ -38,12 +40,10 @@ class TiledGeometryLayer extends GeometryLayer {
38
40
  * It corresponds at meters by pixel. If the projection tile exceeds a certain pixel size (on screen)
39
41
  * then it is subdivided into 4 tiles with a zoom greater than 1.
40
42
  *
41
- * @extends GeometryLayer
42
- *
43
43
  * @param {string} id - The id of the layer, that should be unique. It is
44
44
  * not mandatory, but an error will be emitted if this layer is added a
45
45
  * {@link View} that already has a layer going by that id.
46
- * @param {THREE.Object3d} object3d - The object3d used to contain the
46
+ * @param {THREE.Object3D} object3d - The object3d used to contain the
47
47
  * geometry of the TiledGeometryLayer. It is usually a `THREE.Group`, but it
48
48
  * can be anything inheriting from a `THREE.Object3d`.
49
49
  * @param {Array} schemeTile - extents Array of root tiles
@@ -58,16 +58,63 @@ class TiledGeometryLayer extends GeometryLayer {
58
58
  * @throws {Error} `object3d` must be a valid `THREE.Object3d`.
59
59
  */
60
60
  constructor(id, object3d, schemeTile, builder, config) {
61
- // cacheLifeTime = CACHE_POLICIES.INFINITE because the cache is handled by the builder
62
- config.cacheLifeTime = CACHE_POLICIES.INFINITE;
63
- config.source = false;
64
- super(id, object3d, config);
61
+ const {
62
+ sseSubdivisionThreshold = 1.0,
63
+ minSubdivisionLevel,
64
+ maxSubdivisionLevel,
65
+ maxDeltaElevationLevel,
66
+ tileMatrixSets,
67
+ diffuse,
68
+ showOutline = false,
69
+ segments,
70
+ disableSkirt = false,
71
+ materialOptions,
72
+ ...configGeometryLayer
73
+ } = config;
74
+ super(id, object3d, {
75
+ ...configGeometryLayer,
76
+ // cacheLifeTime = CACHE_POLICIES.INFINITE because the cache is handled by the builder
77
+ cacheLifeTime: CACHE_POLICIES.INFINITE,
78
+ source: false
79
+ });
80
+
81
+ /**
82
+ * @type {boolean}
83
+ * @readonly
84
+ */
65
85
  this.isTiledGeometryLayer = true;
86
+ this.protocol = 'tile';
87
+
66
88
  // TODO : this should be add in a preprocess method specific to GeoidLayer.
67
89
  this.object3d.geoidHeight = 0;
68
- this.protocol = 'tile';
90
+
91
+ /**
92
+ * @type {boolean}
93
+ */
94
+ this.disableSkirt = disableSkirt;
69
95
  this._hideSkirt = !!config.hideSkirt;
70
- this.sseSubdivisionThreshold = this.sseSubdivisionThreshold || 1.0;
96
+
97
+ /**
98
+ * @type {number}
99
+ */
100
+ this.sseSubdivisionThreshold = sseSubdivisionThreshold;
101
+
102
+ /**
103
+ * @type {number}
104
+ */
105
+ this.minSubdivisionLevel = minSubdivisionLevel;
106
+
107
+ /**
108
+ * @type {number}
109
+ */
110
+ this.maxSubdivisionLevel = maxSubdivisionLevel;
111
+
112
+ /**
113
+ * @type {number}
114
+ * @deprecated
115
+ */
116
+ this.maxDeltaElevationLevel = maxDeltaElevationLevel;
117
+ this.segments = segments;
71
118
  this.schemeTile = schemeTile;
72
119
  this.builder = builder;
73
120
  this.info = new InfoTiledGeometryLayer(this);
@@ -77,9 +124,19 @@ class TiledGeometryLayer extends GeometryLayer {
77
124
  if (!this.builder) {
78
125
  throw new Error(`Cannot init tiled layer without builder for layer ${this.id}`);
79
126
  }
80
- if (config.maxDeltaElevationLevel) {
81
- console.warn('Config using maxDeltaElevationLevel is deprecated. The parameter maxDeltaElevationLevel is not longer used');
82
- }
127
+ this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
128
+ this.tileMatrixSets = tileMatrixSets;
129
+ this.materialOptions = materialOptions;
130
+
131
+ /*
132
+ * @type {boolean}
133
+ */
134
+ this.showOutline = showOutline;
135
+
136
+ /**
137
+ * @type {THREE.Vector3 | undefined}
138
+ */
139
+ this.diffuse = diffuse;
83
140
  this.level0Nodes = [];
84
141
  const promises = [];
85
142
  for (const root of this.schemeTile) {
@@ -90,7 +147,6 @@ class TiledGeometryLayer extends GeometryLayer {
90
147
  this.object3d.add(...level0s);
91
148
  this.object3d.updateMatrixWorld();
92
149
  }));
93
- this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
94
150
  }
95
151
  get hideSkirt() {
96
152
  return this._hideSkirt;
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";
@@ -53,7 +53,7 @@ export { default as PointCloudLayer } from "./Layer/PointCloudLayer.js";
53
53
  export { default as PotreeLayer } from "./Layer/PotreeLayer.js";
54
54
  export { default as Potree2Layer } from "./Layer/Potree2Layer.js";
55
55
  export { default as C3DTilesLayer, C3DTILES_LAYER_EVENTS } from "./Layer/C3DTilesLayer.js";
56
- export { default as OGC3DTilesLayer, OGC3DTILES_LAYER_EVENTS, enableDracoLoader, enableKtx2Loader } from "./Layer/OGC3DTilesLayer.js";
56
+ export { default as OGC3DTilesLayer, OGC3DTILES_LAYER_EVENTS, enableDracoLoader, enableKtx2Loader, enableMeshoptDecoder } from "./Layer/OGC3DTilesLayer.js";
57
57
  export { default as TiledGeometryLayer } from "./Layer/TiledGeometryLayer.js";
58
58
  export { default as OrientedImageLayer } from "./Layer/OrientedImageLayer.js";
59
59
  export { STRATEGY_MIN_NETWORK_TRAFFIC, STRATEGY_GROUP, STRATEGY_PROGRESSIVE, STRATEGY_DICHOTOMY } from "./Layer/LayerUpdateStrategy.js";
@@ -195,7 +195,7 @@ export default {
195
195
  _in.crs = _in.crs || readCRS(json);
196
196
  if (out.filteringExtent) {
197
197
  if (typeof out.filteringExtent == 'boolean') {
198
- out.filterExtent = options.extent.as(_in.crs);
198
+ out.filterExtent = options.extent.isExtent ? options.extent.as(_in.crs) : options.extent.toExtent(_in.crs);
199
199
  } else if (out.filteringExtent.isExtent) {
200
200
  out.filterExtent = out.filteringExtent;
201
201
  }
@@ -1,7 +1,7 @@
1
1
  import { Vector2, Vector3 } from 'three';
2
2
  import Protobuf from 'pbf';
3
3
  import { VectorTile } from '@mapbox/vector-tile';
4
- import { globalExtentTMS } from "../Core/Geographic/Extent.js";
4
+ import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
5
5
  import { FeatureCollection, FEATURE_TYPES } from "../Core/Feature.js";
6
6
  import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
7
7
  import Coordinates from "../Core/Geographic/Coordinates.js";
@@ -67,10 +67,22 @@ export function computeMinMaxElevation(texture, pitch, options) {
67
67
  }
68
68
  }
69
69
  }
70
- if (options.zmin > min) {
70
+ }
71
+
72
+ // Clamp values to zmin and zmax values configured in ElevationLayer
73
+ if (options.zmin != null) {
74
+ if (min < options.zmin) {
71
75
  min = options.zmin;
72
76
  }
73
- if (options.zmax < max) {
77
+ if (max < options.zmin) {
78
+ max = options.zmin;
79
+ }
80
+ }
81
+ if (options.zmax != null) {
82
+ if (min > options.zmax) {
83
+ min = options.zmax;
84
+ }
85
+ if (max > options.zmax) {
74
86
  max = options.zmax;
75
87
  }
76
88
  }
@@ -102,7 +102,11 @@ export default {
102
102
  res = resolve;
103
103
  rej = reject;
104
104
  });
105
- textureLoader.load(url, res, () => {}, rej);
105
+ textureLoader.load(url, res, () => {}, event => {
106
+ const error = new Error(`Failed to load texture from URL: \`${url}\``);
107
+ error.originalEvent = event;
108
+ rej(error);
109
+ });
106
110
  return promise;
107
111
  },
108
112
  /**
@@ -1,6 +1,9 @@
1
- import Extent from "../Core/Geographic/Extent.js";
2
- const extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
3
1
  let subDomainsCount = 0;
2
+
3
+ /**
4
+ * @param {string} url
5
+ * @returns {string}
6
+ */
4
7
  function subDomains(url) {
5
8
  const subDomainsPtrn = /\$\{u:([\w-_.|]+)\}/.exec(url);
6
9
  if (!subDomainsPtrn) {
@@ -51,8 +54,13 @@ export default {
51
54
  * // The resulting url is:
52
55
  * // http://server.geo/tms/15/2142/3412.jpg;
53
56
  *
54
- * @param {Extent} coords - the coordinates
55
- * @param {Source} source
57
+ * @param {Object} coords - tile coordinates
58
+ * @param {number} coords.row - tile row
59
+ * @param {number} coords.col - tile column
60
+ * @param {number} coords.zoom - tile zoom
61
+ * @param {Object} source
62
+ * @param {string} source.url
63
+ * @param {Function} source.tileMatrixCallback
56
64
  *
57
65
  * @return {string} the formed url
58
66
  */
@@ -79,8 +87,12 @@ export default {
79
87
  * // The resulting url is:
80
88
  * // http://server.geo/wms/BBOX=12,35,14,46&FORMAT=jpg&SERVICE=WMS
81
89
  *
82
- * @param {Extent} bbox - the bounding box
83
- * @param {Object} source
90
+ * @param {Object} bbox - the bounding box
91
+ * @param {number} bbox.west
92
+ * @param {number} bbox.south
93
+ * @param {number} bbox.east
94
+ * @param {number} bbox.north
95
+ * @param {Object} source - the source of data
84
96
  * @param {string} source.crs
85
97
  * @param {number} source.bboxDigits
86
98
  * @param {string} source.url
@@ -93,11 +105,10 @@ export default {
93
105
  if (source.bboxDigits !== undefined) {
94
106
  precision = source.bboxDigits;
95
107
  }
96
- bbox.as(source.crs, extent);
97
- const w = extent.west.toFixed(precision);
98
- const s = extent.south.toFixed(precision);
99
- const e = extent.east.toFixed(precision);
100
- const n = extent.north.toFixed(precision);
108
+ const w = bbox.west.toFixed(precision);
109
+ const s = bbox.south.toFixed(precision);
110
+ const e = bbox.east.toFixed(precision);
111
+ const n = bbox.north.toFixed(precision);
101
112
  let bboxInUnit = source.axisOrder || 'wsen';
102
113
  bboxInUnit = bboxInUnit.replace('w', `${w},`).replace('s', `${s},`).replace('e', `${e},`).replace('n', `${n},`).slice(0, -1);
103
114
  return subDomains(source.url.replace('%bbox', bboxInUnit));
@@ -173,7 +173,7 @@ class Camera {
173
173
  * @return {Coordinates} Coordinates object holding camera's position.
174
174
  */
175
175
  position(crs) {
176
- return new Coordinates(this.crs, this.camera3D.position).as(crs || this.crs);
176
+ return new Coordinates(this.crs).setFromVector3(this.camera3D.position).as(crs || this.crs);
177
177
  }
178
178
 
179
179
  /**
@@ -1,12 +1,11 @@
1
1
  import * as THREE from 'three';
2
- import TileGeometry from "../Core/TileGeometry.js";
3
- import BuilderEllipsoidTile from "../Core/Prefab/Globe/BuilderEllipsoidTile.js";
2
+ import * as CRS from "../Core/Geographic/Crs.js";
3
+ import { TileGeometry } from "../Core/TileGeometry.js";
4
+ import { GlobeTileBuilder } from "../Core/Prefab/Globe/GlobeTileBuilder.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
- const builder = new BuilderEllipsoidTile({
9
- crs: 'EPSG:4978',
8
+ const builder = new GlobeTileBuilder({
10
9
  uvCount: 1
11
10
  });
12
11
  const size = new THREE.Vector3();
@@ -114,18 +113,17 @@ class OBB extends THREE.Object3D {
114
113
  let maxHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : extent.max || 0;
115
114
  if (extent.crs == 'EPSG:4326') {
116
115
  const {
117
- sharableExtent,
116
+ shareableExtent,
118
117
  quaternion,
119
118
  position
120
- } = builder.computeSharableExtent(extent);
119
+ } = builder.computeShareableExtent(extent);
121
120
  // Compute the minimum count of segment to build tile
122
- const segments = Math.max(Math.floor(sharableExtent.planarDimensions(dimension).x / 90 + 1), 2);
123
- const geometry = new TileGeometry({
124
- extent: sharableExtent,
121
+ const segments = Math.max(Math.floor(shareableExtent.planarDimensions(dimension).x / 90 + 1), 2);
122
+ const geometry = new TileGeometry(builder, {
123
+ extent: shareableExtent,
125
124
  level: 0,
126
125
  segments,
127
- disableSkirt: true,
128
- builder
126
+ disableSkirt: true
129
127
  });
130
128
  obb.box3D.copy(geometry.boundingBox);
131
129
  obb.natBox.copy(geometry.boundingBox);
@@ -137,7 +135,7 @@ class OBB extends THREE.Object3D {
137
135
  this.position.copy(position);
138
136
  this.quaternion.copy(quaternion);
139
137
  this.updateMatrixWorld(true);
140
- } else if (!CRS.isTms(extent.crs) && CRS.isMetricUnit(extent.crs)) {
138
+ } else if (CRS.isMetricUnit(extent.crs)) {
141
139
  extent.center(coord).toVector3(this.position);
142
140
  extent.planarDimensions(dimension);
143
141
  size.set(dimension.x, dimension.y, Math.abs(maxHeight - minHeight));
@@ -258,7 +258,7 @@ class PointsMaterial extends THREE.ShaderMaterial {
258
258
  /**
259
259
  * @class PointsMaterial
260
260
  * @param {object} [options={}] The options
261
- * @param {number} [options.size=0] size point
261
+ * @param {number} [options.size=1] point size
262
262
  * @param {number} [options.mode=PNTS_MODE.COLOR] display mode.
263
263
  * @param {number} [options.shape=PNTS_SHAPE.CIRCLE] rendered points shape.
264
264
  * @param {THREE.Vector4} [options.overlayColor=new THREE.Vector4(0, 0, 0, 0)] overlay color.
@@ -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,9 +1,3 @@
1
- /*
2
- * To change this license header, choose License Headers in Project Properties.
3
- * To change this template file, choose Tools | Templates
4
- * and open the template in the editor.
5
- */
6
-
7
1
  import * as THREE from 'three';
8
2
  function SphereHelper(radius) {
9
3
  THREE.Mesh.call(this);
@@ -1,3 +1,4 @@
1
+ import proj4 from 'proj4';
1
2
  import { Binary, Info, Las } from 'copc';
2
3
  import Extent from "../Core/Geographic/Extent.js";
3
4
  import Fetcher from "../Provider/Fetcher.js";
@@ -102,8 +103,18 @@ class CopcSource extends Source {
102
103
  this.header = metadata.header;
103
104
  this.info = metadata.info;
104
105
  this.eb = metadata.eb;
105
- // TODO: use wkt definition in `metadata.wkt` to infer/define crs
106
- this.crs = config.crs || 'EPSG:4326';
106
+ proj4.defs('unknown', metadata.wkt);
107
+ let projCS;
108
+ if (proj4.defs('unknown').type === 'COMPD_CS') {
109
+ console.warn('CopcSource: compound coordinate system is not yet supported.');
110
+ projCS = proj4.defs('unknown').PROJCS;
111
+ } else {
112
+ projCS = proj4.defs('unknown');
113
+ }
114
+ this.crs = projCS.title || projCS.name || 'EPSG:4326';
115
+ if (!(this.crs in proj4.defs)) {
116
+ proj4.defs(this.crs, projCS);
117
+ }
107
118
  const bbox = new THREE.Box3();
108
119
  bbox.min.fromArray(this.info.cube, 0);
109
120
  bbox.max.fromArray(this.info.cube, 3);
@@ -38,10 +38,19 @@ class EntwinePointTileSource extends Source {
38
38
  // Set parser and its configuration from schema
39
39
  this.parse = metadata.dataType === 'laszip' ? LASParser.parse : PotreeBinParser.parse;
40
40
  this.extension = metadata.dataType === 'laszip' ? 'laz' : 'bin';
41
- if (metadata.srs && metadata.srs.authority && metadata.srs.horizontal) {
42
- this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
43
- if (!proj4.defs(this.crs)) {
44
- proj4.defs(this.crs, metadata.srs.wkt);
41
+ if (metadata.srs) {
42
+ if (metadata.srs.authority && metadata.srs.horizontal) {
43
+ this.crs = `${metadata.srs.authority}:${metadata.srs.horizontal}`;
44
+ if (!proj4.defs(this.crs)) {
45
+ proj4.defs(this.crs, metadata.srs.wkt);
46
+ }
47
+ } else if (metadata.srs.wkt) {
48
+ proj4.defs('unknown', metadata.srs.wkt);
49
+ const projCS = proj4.defs('unknown');
50
+ this.crs = projCS.title || projCS.name;
51
+ if (!(this.crs in proj4.defs)) {
52
+ proj4.defs(this.crs, projCS);
53
+ }
45
54
  }
46
55
  if (metadata.srs.vertical && metadata.srs.vertical !== metadata.srs.horizontal) {
47
56
  console.warn('EntwinePointTileSource: Vertical coordinates system code is not yet supported.');
@@ -53,6 +62,7 @@ class EntwinePointTileSource extends Source {
53
62
  // span in ept.json. This needs improvements.
54
63
  this.spacing = (Math.abs(metadata.boundsConforming[3] - metadata.boundsConforming[0]) + Math.abs(metadata.boundsConforming[4] - metadata.boundsConforming[1])) / (2 * metadata.span);
55
64
  this.boundsConforming = metadata.boundsConforming;
65
+ this.bounds = metadata.bounds;
56
66
  this.span = metadata.span;
57
67
  return this;
58
68
  });
@@ -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
@@ -104,12 +103,10 @@ class FileSource extends Source {
104
103
  * presents in `features` under the property `crs`, it is fine.
105
104
  */
106
105
  constructor(source) {
107
- /* istanbul ignore next */
108
106
  if (source.parsedData) {
109
107
  console.warn('FileSource parsedData parameter is deprecated, use features instead of.');
110
108
  source.features = source.features || source.parsedData;
111
109
  }
112
- /* istanbul ignore next */
113
110
  if (source.projection) {
114
111
  console.warn('FileSource projection parameter is deprecated, use crs instead.');
115
112
  source.crs = source.crs || source.projection;
@@ -155,7 +152,7 @@ class FileSource extends Source {
155
152
  if (!features) {
156
153
  options.out.buildExtent = this.crs != 'EPSG:4978';
157
154
  if (options.out.buildExtent) {
158
- options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : CRS.formatToEPSG(this.crs);
155
+ options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : this.crs;
159
156
  }
160
157
  features = this.parser(this.fetchedData, options);
161
158
  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]]);
@@ -30,7 +30,6 @@ const noCache = {
30
30
  */
31
31
  class InformationsData {
32
32
  constructor(options) {
33
- /* istanbul ignore next */
34
33
  if (options.projection) {
35
34
  console.warn('Source projection parameter is deprecated, use crs instead.');
36
35
  options.crs = options.crs || options.projection;
@@ -166,8 +165,6 @@ class Source extends InformationsData {
166
165
  in: this,
167
166
  extent
168
167
  })).catch(err => this.handlingError(err)), key);
169
-
170
- /* istanbul ignore next */
171
168
  if (this.onParsedFile) {
172
169
  features.then(feat => {
173
170
  this.onParsedFile(feat);
@@ -1,8 +1,9 @@
1
1
  import Source from "./Source.js";
2
2
  import URLBuilder from "../Provider/URLBuilder.js";
3
- import Extent, { globalExtentTMS } from "../Core/Geographic/Extent.js";
4
- import CRS from "../Core/Geographic/Crs.js";
5
- const extent = new Extent(CRS.tms_4326, 0, 0, 0);
3
+ import Extent from "../Core/Geographic/Extent.js";
4
+ import Tile from "../Core/Tile/Tile.js";
5
+ import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
6
+ const _tile = new Tile('EPSG:4326', 0, 0, 0);
6
7
 
7
8
  /**
8
9
  * An object defining the source of resources to get from a
@@ -86,7 +87,7 @@ class TMSSource extends Source {
86
87
  }
87
88
  this.zoom = source.zoom;
88
89
  this.isInverted = source.isInverted || false;
89
- this.crs = CRS.formatToTms(source.crs);
90
+ this.crs = source.crs;
90
91
  this.tileMatrixSetLimits = source.tileMatrixSetLimits;
91
92
  this.extentSetlimits = {};
92
93
  this.tileMatrixCallback = source.tileMatrixCallback || (zoomLevel => zoomLevel);
@@ -107,8 +108,8 @@ class TMSSource extends Source {
107
108
  }
108
109
  }
109
110
  }
110
- urlFromExtent(extent) {
111
- return URLBuilder.xyz(extent, this);
111
+ urlFromExtent(tile) {
112
+ return URLBuilder.xyz(tile, this);
112
113
  }
113
114
  onLayerAdded(options) {
114
115
  super.onLayerAdded(options);
@@ -118,17 +119,17 @@ class TMSSource extends Source {
118
119
  const crs = parent ? parent.extent.crs : options.out.crs;
119
120
  if (this.tileMatrixSetLimits && !this.extentSetlimits[crs]) {
120
121
  this.extentSetlimits[crs] = {};
121
- extent.crs = this.crs;
122
+ _tile.crs = this.crs;
122
123
  for (let i = this.zoom.max; i >= this.zoom.min; i--) {
123
124
  const tmsl = this.tileMatrixSetLimits[i];
124
125
  const {
125
126
  west,
126
127
  north
127
- } = extent.set(i, tmsl.minTileRow, tmsl.minTileCol).as(crs);
128
+ } = _tile.set(i, tmsl.minTileRow, tmsl.minTileCol).toExtent(crs);
128
129
  const {
129
130
  east,
130
131
  south
131
- } = extent.set(i, tmsl.maxTileRow, tmsl.maxTileCol).as(crs);
132
+ } = _tile.set(i, tmsl.maxTileRow, tmsl.maxTileCol).toExtent(crs);
132
133
  this.extentSetlimits[crs][i] = new Extent(crs, west, east, south, north);
133
134
  }
134
135
  }
@@ -1,4 +1,4 @@
1
- import { featureFilter } from '@mapbox/mapbox-gl-style-spec';
1
+ import { featureFilter } from '@maplibre/maplibre-gl-style-spec';
2
2
  import Style from "../Core/Style.js";
3
3
  import TMSSource from "./TMSSource.js";
4
4
  import URLBuilder from "../Provider/URLBuilder.js";
@@ -135,8 +135,8 @@ class VectorTilesSource extends TMSSource {
135
135
  this.urls = Array.from(new Set(TMSUrlList));
136
136
  });
137
137
  }
138
- urlFromExtent(extent, url) {
139
- return URLBuilder.xyz(extent, {
138
+ urlFromExtent(tile, url) {
139
+ return URLBuilder.xyz(tile, {
140
140
  tileMatrixCallback: this.tileMatrixCallback,
141
141
  url
142
142
  });
@@ -162,8 +162,6 @@ class VectorTilesSource extends TMSSource {
162
162
  in: this,
163
163
  extent
164
164
  })))).then(collections => mergeCollections(collections)).catch(err => this.handlingError(err)), key);
165
-
166
- /* istanbul ignore next */
167
165
  if (this.onParsedFile) {
168
166
  features.then(feat => {
169
167
  this.onParsedFile(feat);
@@ -1,6 +1,7 @@
1
1
  import Source from "./Source.js";
2
2
  import URLBuilder from "../Provider/URLBuilder.js";
3
- import CRS from "../Core/Geographic/Crs.js";
3
+ import Extent from "../Core/Geographic/Extent.js";
4
+ const _extent = new Extent('EPSG:4326', [0, 0, 0, 0]);
4
5
 
5
6
  /**
6
7
  * An object defining the source of resources to get from a
@@ -118,22 +119,25 @@ class WFSSource extends Source {
118
119
  this.typeName = source.typeName;
119
120
  this.version = source.version || '2.0.2';
120
121
  this.bboxDigits = source.bboxDigits;
121
-
122
- // Add ? at the end of the url if it is not already in the given URL
123
- if (!this.url.endsWith('?')) {
124
- this.url = `${this.url}?`;
125
- }
126
- this.url = `${source.url}SERVICE=WFS&REQUEST=GetFeature&typeName=${this.typeName}&VERSION=${this.version}&SRSNAME=${this.crs}&outputFormat=${this.format}&BBOX=%bbox,${this.crs}`;
127
122
  this.zoom = {
128
123
  min: 0,
129
124
  max: Infinity
130
125
  };
126
+ const urlObj = new URL(source.url);
127
+ urlObj.searchParams.set('SERVICE', 'WFS');
128
+ urlObj.searchParams.set('REQUEST', 'GetFeature');
129
+ urlObj.searchParams.set('typeName', this.typeName);
130
+ urlObj.searchParams.set('VERSION', this.version);
131
+ urlObj.searchParams.set('SRSNAME', this.crs);
132
+ urlObj.searchParams.set('outputFormat', this.format);
133
+ urlObj.searchParams.set('BBOX', `%bbox,${this.crs}`);
131
134
  this.vendorSpecific = source.vendorSpecific;
132
135
  for (const name in this.vendorSpecific) {
133
136
  if (Object.prototype.hasOwnProperty.call(this.vendorSpecific, name)) {
134
- this.url = `${this.url}&${name}=${this.vendorSpecific[name]}`;
137
+ urlObj.searchParams.set(name, this.vendorSpecific[name]);
135
138
  }
136
139
  }
140
+ this.url = decodeURIComponent(urlObj.toString());
137
141
  }
138
142
  handlingError(err) {
139
143
  if (err.response && err.response.status == 400) {
@@ -149,13 +153,14 @@ class WFSSource extends Source {
149
153
  return super.handlingError(err);
150
154
  }
151
155
  requestToKey(extent) {
152
- if (CRS.isTms(extent.crs)) {
156
+ if (extent.isTile) {
153
157
  return super.requestToKey(extent);
154
158
  } else {
155
159
  return [extent.zoom, extent.south, extent.west];
156
160
  }
157
161
  }
158
- urlFromExtent(extent) {
162
+ urlFromExtent(extentOrTile) {
163
+ const extent = extentOrTile.isExtent ? extentOrTile.as(this.crs, _extent) : extentOrTile.toExtent(this.crs, _extent);
159
164
  return URLBuilder.bbox(extent, this);
160
165
  }
161
166
  extentInsideLimit(extent) {