itowns 2.42.1-next.2 → 2.42.1-next.21

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 (180) hide show
  1. package/dist/debug.js +1 -1
  2. package/dist/debug.js.map +1 -1
  3. package/dist/itowns.js +1 -1
  4. package/dist/itowns.js.map +1 -1
  5. package/dist/itowns_widgets.js +1 -1
  6. package/dist/itowns_widgets.js.map +1 -1
  7. package/examples/{.eslintrc.js → .eslintrc.cjs} +1 -1
  8. package/examples/effects_stereo.html +2 -2
  9. package/examples/entwine_simple_loader.html +24 -8
  10. package/examples/misc_collada.html +2 -2
  11. package/examples/misc_instancing.html +1 -1
  12. package/examples/source_file_gpx_3d.html +2 -2
  13. package/examples/source_stream_wfs_25d.html +11 -11
  14. package/examples/source_stream_wfs_3d.html +1 -1
  15. package/examples/vector_tile_3d_mesh.html +2 -2
  16. package/examples/vector_tile_raster_2d.html +1 -1
  17. package/examples/vector_tile_raster_3d.html +1 -1
  18. package/examples/view_25d_map.html +2 -2
  19. package/examples/view_3d_map.html +3 -3
  20. package/examples/view_3d_map_webxr.html +1 -1
  21. package/examples/view_3d_mns_map.html +3 -3
  22. package/examples/view_immersive.html +1 -1
  23. package/examples/view_multi_25d.html +2 -2
  24. package/examples/widgets_minimap.html +1 -1
  25. package/examples/widgets_searchbar.html +2 -2
  26. package/lib/Controls/FirstPersonControls.js +5 -12
  27. package/lib/Controls/FlyControls.js +4 -13
  28. package/lib/Controls/GlobeControls.js +33 -43
  29. package/lib/Controls/PlanarControls.js +9 -20
  30. package/lib/Controls/StateControl.js +2 -11
  31. package/lib/Controls/StreetControls.js +14 -24
  32. package/lib/Converter/Feature2Mesh.js +77 -70
  33. package/lib/Converter/Feature2Texture.js +15 -25
  34. package/lib/Converter/convertToTile.js +16 -26
  35. package/lib/Converter/textureConverter.js +9 -19
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +5 -13
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +1 -8
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +17 -27
  39. package/lib/Core/3DTiles/C3DTExtensions.js +1 -8
  40. package/lib/Core/3DTiles/C3DTFeature.js +3 -10
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +3 -11
  42. package/lib/Core/3DTiles/C3DTileset.js +7 -16
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +5 -11
  44. package/lib/Core/AnimationPlayer.js +2 -11
  45. package/lib/Core/Deprecated/Undeprecator.js +9 -20
  46. package/lib/Core/EntwinePointTileNode.js +6 -16
  47. package/lib/Core/Feature.js +16 -30
  48. package/lib/Core/Geographic/CoordStars.js +3 -12
  49. package/lib/Core/Geographic/Coordinates.js +12 -22
  50. package/lib/Core/Geographic/Crs.js +7 -15
  51. package/lib/Core/Geographic/Extent.js +36 -47
  52. package/lib/Core/Geographic/GeoidGrid.js +6 -16
  53. package/lib/Core/Label.js +7 -17
  54. package/lib/Core/MainLoop.js +7 -16
  55. package/lib/Core/Math/Ellipsoid.js +6 -17
  56. package/lib/Core/Picking.js +10 -20
  57. package/lib/Core/PointCloudNode.js +2 -11
  58. package/lib/Core/PotreeNode.js +4 -13
  59. package/lib/Core/Prefab/Globe/Atmosphere.js +17 -26
  60. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +6 -16
  61. package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -28
  62. package/lib/Core/Prefab/Globe/SkyShader.js +2 -11
  63. package/lib/Core/Prefab/GlobeView.js +27 -45
  64. package/lib/Core/Prefab/Planar/PlanarLayer.js +11 -20
  65. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +6 -16
  66. package/lib/Core/Prefab/PlanarView.js +10 -25
  67. package/lib/Core/Prefab/TileBuilder.js +13 -22
  68. package/lib/Core/Prefab/computeBufferTileGeometry.js +12 -16
  69. package/lib/Core/Scheduler/Cache.js +2 -10
  70. package/lib/Core/Scheduler/CancelledCommandException.js +1 -8
  71. package/lib/Core/Scheduler/Scheduler.js +15 -23
  72. package/lib/Core/Style.js +26 -40
  73. package/lib/Core/System/Capabilities.js +2 -13
  74. package/lib/Core/TileGeometry.js +13 -15
  75. package/lib/Core/TileMesh.js +6 -15
  76. package/lib/Core/View.js +43 -58
  77. package/lib/Layer/C3DTilesLayer.js +29 -41
  78. package/lib/Layer/ColorLayer.js +10 -16
  79. package/lib/Layer/ElevationLayer.js +7 -14
  80. package/lib/Layer/EntwinePointTileLayer.js +11 -18
  81. package/lib/Layer/FeatureGeometryLayer.js +9 -16
  82. package/lib/Layer/GeoidLayer.js +6 -15
  83. package/lib/Layer/GeometryLayer.js +11 -17
  84. package/lib/Layer/InfoLayer.js +5 -14
  85. package/lib/Layer/LabelLayer.js +22 -32
  86. package/lib/Layer/Layer.js +16 -26
  87. package/lib/Layer/LayerUpdateState.js +1 -8
  88. package/lib/Layer/LayerUpdateStrategy.js +7 -18
  89. package/lib/Layer/OrientedImageLayer.js +15 -25
  90. package/lib/Layer/PointCloudLayer.js +27 -24
  91. package/lib/Layer/PotreeLayer.js +8 -18
  92. package/lib/Layer/RasterLayer.js +9 -17
  93. package/lib/Layer/ReferencingLayerProperties.js +1 -8
  94. package/lib/Layer/TiledGeometryLayer.js +37 -33
  95. package/lib/Main.js +86 -707
  96. package/lib/MainBundle.js +4 -34
  97. package/lib/Parser/B3dmParser.js +80 -131
  98. package/lib/Parser/CameraCalibrationParser.js +5 -14
  99. package/lib/Parser/GDFParser.js +11 -22
  100. package/lib/Parser/GLTFParser.js +88 -0
  101. package/lib/Parser/GTXParser.js +9 -21
  102. package/lib/Parser/GeoJsonParser.js +14 -22
  103. package/lib/Parser/GpxParser.js +7 -14
  104. package/lib/Parser/ISGParser.js +19 -28
  105. package/lib/Parser/KMLParser.js +7 -14
  106. package/lib/Parser/LASLoader.js +31 -21
  107. package/lib/Parser/LASParser.js +10 -17
  108. package/lib/Parser/MapBoxUrlParser.js +2 -9
  109. package/lib/Parser/PntsParser.js +4 -14
  110. package/lib/Parser/PotreeBinParser.js +8 -16
  111. package/lib/Parser/PotreeCinParser.js +3 -12
  112. package/lib/Parser/ShapefileParser.js +11 -18
  113. package/lib/Parser/VectorTileParser.js +23 -31
  114. package/lib/Parser/XbilParser.js +5 -13
  115. package/lib/Parser/deprecated/LegacyGLTFLoader.js +2 -12
  116. package/lib/Process/3dTilesProcessing.js +14 -27
  117. package/lib/Process/FeatureProcessing.js +14 -22
  118. package/lib/Process/LayeredMaterialNodeProcessing.js +19 -28
  119. package/lib/Process/ObjectRemovalHelper.js +2 -9
  120. package/lib/Process/handlerNodeError.js +1 -7
  121. package/lib/Provider/3dTilesProvider.js +32 -29
  122. package/lib/Provider/DataSourceProvider.js +2 -9
  123. package/lib/Provider/Fetcher.js +40 -22
  124. package/lib/Provider/PointCloudProvider.js +7 -19
  125. package/lib/Provider/TileProvider.js +4 -12
  126. package/lib/Provider/URLBuilder.js +4 -12
  127. package/lib/Renderer/Camera.js +7 -17
  128. package/lib/Renderer/Color.js +3 -11
  129. package/lib/Renderer/ColorLayersOrdering.js +14 -22
  130. package/lib/Renderer/CommonMaterial.js +3 -12
  131. package/lib/Renderer/Label2DRenderer.js +5 -16
  132. package/lib/Renderer/LayeredMaterial.js +33 -53
  133. package/lib/Renderer/OBB.js +12 -21
  134. package/lib/Renderer/OrientedImageCamera.js +2 -11
  135. package/lib/Renderer/OrientedImageMaterial.js +17 -35
  136. package/lib/Renderer/PointsMaterial.js +224 -94
  137. package/lib/Renderer/RasterTile.js +18 -30
  138. package/lib/Renderer/RenderMode.js +2 -9
  139. package/lib/Renderer/Shader/ShaderChunk.js +5 -23
  140. package/lib/Renderer/Shader/ShaderUtils.js +2 -9
  141. package/lib/Renderer/SphereHelper.js +2 -11
  142. package/lib/Renderer/WebXR.js +2 -11
  143. package/lib/Renderer/c3DEngine.js +20 -53
  144. package/lib/Source/C3DTilesGoogleSource.js +76 -0
  145. package/lib/Source/C3DTilesIonSource.js +6 -13
  146. package/lib/Source/C3DTilesSource.js +5 -12
  147. package/lib/Source/EntwinePointTileSource.js +12 -19
  148. package/lib/Source/FileSource.js +7 -14
  149. package/lib/Source/OrientedImageSource.js +6 -14
  150. package/lib/Source/PotreeSource.js +9 -16
  151. package/lib/Source/Source.js +26 -39
  152. package/lib/Source/TMSSource.js +11 -22
  153. package/lib/Source/VectorTilesSource.js +75 -34
  154. package/lib/Source/WFSSource.js +7 -14
  155. package/lib/Source/WMSSource.js +5 -12
  156. package/lib/Source/WMTSSource.js +3 -10
  157. package/lib/ThreeExtended/capabilities/WebGL.js +1 -8
  158. package/lib/ThreeExtended/libs/ktx-parse.module.js +2 -256
  159. package/lib/ThreeExtended/libs/zstddec.module.js +2 -8
  160. package/lib/ThreeExtended/loaders/DDSLoader.js +10 -16
  161. package/lib/ThreeExtended/loaders/DRACOLoader.js +14 -19
  162. package/lib/ThreeExtended/loaders/GLTFLoader.js +124 -129
  163. package/lib/ThreeExtended/loaders/KTX2Loader.js +73 -78
  164. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +40 -59
  165. package/lib/ThreeExtended/utils/WorkerPool.js +2 -9
  166. package/lib/Utils/CameraUtils.js +32 -44
  167. package/lib/Utils/DEMUtils.js +8 -19
  168. package/lib/Utils/FeaturesUtils.js +8 -16
  169. package/lib/Utils/Gradients.js +16 -0
  170. package/lib/Utils/OrientationUtils.js +8 -18
  171. package/lib/Utils/ThreeUtils.js +2 -9
  172. package/lib/Utils/gui/C3DTilesStyle.js +7 -15
  173. package/lib/Utils/gui/Main.js +7 -48
  174. package/lib/Utils/gui/Minimap.js +12 -20
  175. package/lib/Utils/gui/Navigation.js +6 -14
  176. package/lib/Utils/gui/Scale.js +11 -19
  177. package/lib/Utils/gui/Searchbar.js +5 -13
  178. package/lib/Utils/gui/Widget.js +1 -8
  179. package/lib/Utils/placeObjectOnGround.js +13 -23
  180. package/package.json +13 -8
@@ -1,13 +1,7 @@
1
- "use strict";
1
+ import Source from "./Source.js";
2
+ import Cache from "../Core/Scheduler/Cache.js";
3
+ import CRS from "../Core/Geographic/Crs.js";
2
4
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Source = _interopRequireDefault(require("./Source"));
9
- var _Cache = _interopRequireDefault(require("../Core/Scheduler/Cache"));
10
- var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
11
5
  /**
12
6
  * @classdesc
13
7
  * An object defining the source of a single resource to get from a direct
@@ -104,7 +98,7 @@ var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
104
98
  * return view.addLayer(ariegeLayer);
105
99
  * });
106
100
  */
107
- class FileSource extends _Source.default {
101
+ class FileSource extends Source {
108
102
  /**
109
103
  * @param {Object} source - An object that can contain all properties of a
110
104
  * FileSource and {@link Source}. Only `crs` is mandatory, but if it
@@ -145,7 +139,7 @@ class FileSource extends _Source.default {
145
139
  this.fetchedData = f;
146
140
  });
147
141
  } else if (source.features) {
148
- this._featuresCaches[source.features.crs] = new _Cache.default();
142
+ this._featuresCaches[source.features.crs] = new Cache();
149
143
  this._featuresCaches[source.features.crs].setByArray(Promise.resolve(source.features), [0]);
150
144
  }
151
145
  this.whenReady.then(() => this.fetchedData);
@@ -164,7 +158,7 @@ class FileSource extends _Source.default {
164
158
  if (!features) {
165
159
  options.out.buildExtent = this.crs != 'EPSG:4978';
166
160
  if (options.out.buildExtent) {
167
- options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : _Crs.default.formatToEPSG(this.crs);
161
+ options.out.forcedExtentCrs = options.out.crs != 'EPSG:4978' ? options.out.crs : CRS.formatToEPSG(this.crs);
168
162
  }
169
163
  features = this.parser(this.fetchedData, options);
170
164
  this._featuresCaches[options.out.crs].setByArray(features, [0]);
@@ -195,5 +189,4 @@ class FileSource extends _Source.default {
195
189
  return this.extent.intersectsExtent(extent);
196
190
  }
197
191
  }
198
- var _default = FileSource;
199
- exports.default = _default;
192
+ export default FileSource;
@@ -1,17 +1,11 @@
1
- "use strict";
1
+ import Source from "./Source.js";
2
+ import Fetcher from "../Provider/Fetcher.js";
2
3
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Source = _interopRequireDefault(require("./Source"));
9
- var _Fetcher = _interopRequireDefault(require("../Provider/Fetcher"));
10
4
  /**
11
5
  * @classdesc OrientedImageSource is a specific source used to load oriented images.
12
6
  * @extends Source
13
7
  */
14
- class OrientedImageSource extends _Source.default {
8
+ class OrientedImageSource extends Source {
15
9
  /**
16
10
  * @constructor
17
11
  * @param { Object } source - Configuration object
@@ -23,14 +17,13 @@ class OrientedImageSource extends _Source.default {
23
17
  * to find the good texture for each camera for each panoramic.
24
18
  */
25
19
  constructor(source) {
26
- source.format = source.format || 'json';
27
20
  super(source);
28
21
  this.isOrientedImageSource = true;
29
22
 
30
23
  // Fetch the two files
31
24
  const promises = [];
32
- promises.push(source.orientationsUrl ? _Fetcher.default.json(source.orientationsUrl, this.networkOptions) : Promise.resolve());
33
- promises.push(source.calibrationUrl ? _Fetcher.default.json(source.calibrationUrl, this.networkOptions) : Promise.resolve());
25
+ promises.push(source.orientationsUrl ? Fetcher.json(source.orientationsUrl, this.networkOptions) : Promise.resolve());
26
+ promises.push(source.calibrationUrl ? Fetcher.json(source.calibrationUrl, this.networkOptions) : Promise.resolve());
34
27
  this.whenReady = Promise.all(promises).then(data => ({
35
28
  orientation: data[0],
36
29
  calibration: data[1]
@@ -63,5 +56,4 @@ class OrientedImageSource extends _Source.default {
63
56
  return this.url.replace('{cameraId}', cameraId).replace('{panoId}', panoId);
64
57
  }
65
58
  }
66
- var _default = OrientedImageSource;
67
- exports.default = _default;
59
+ export default OrientedImageSource;
@@ -1,14 +1,8 @@
1
- "use strict";
1
+ import Source from "./Source.js";
2
+ import Fetcher from "../Provider/Fetcher.js";
3
+ import PotreeBinParser from "../Parser/PotreeBinParser.js";
4
+ import PotreeCinParser from "../Parser/PotreeCinParser.js";
2
5
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Source = _interopRequireDefault(require("./Source"));
9
- var _Fetcher = _interopRequireDefault(require("../Provider/Fetcher"));
10
- var _PotreeBinParser = _interopRequireDefault(require("../Parser/PotreeBinParser"));
11
- var _PotreeCinParser = _interopRequireDefault(require("../Parser/PotreeCinParser"));
12
6
  /**
13
7
  * @classdesc
14
8
  * PotreeSource are object containing informations on how to fetch points cloud resources.
@@ -16,7 +10,7 @@ var _PotreeCinParser = _interopRequireDefault(require("../Parser/PotreeCinParser
16
10
  *
17
11
  */
18
12
 
19
- class PotreeSource extends _Source.default {
13
+ class PotreeSource extends Source {
20
14
  /**
21
15
  * @param {Object} source - An object that can contain all properties of a
22
16
  * PotreeSource
@@ -76,19 +70,18 @@ class PotreeSource extends _Source.default {
76
70
  }
77
71
  super(source);
78
72
  this.file = source.file;
79
- this.fetcher = _Fetcher.default.arrayBuffer;
73
+ this.fetcher = Fetcher.arrayBuffer;
80
74
  this.extensionOctree = 'hrc';
81
75
 
82
76
  // For cloud specification visit:
83
77
  // https://github.com/PropellerAero/potree-propeller-private/blob/master/docs/file_format.md#cloudjs
84
- this.whenReady = (source.cloud ? Promise.resolve(source.cloud) : _Fetcher.default.json(`${this.url}/${this.file}`, this.networkOptions)).then(cloud => {
78
+ this.whenReady = (source.cloud ? Promise.resolve(source.cloud) : Fetcher.json(`${this.url}/${this.file}`, this.networkOptions)).then(cloud => {
85
79
  this.pointAttributes = cloud.pointAttributes;
86
80
  this.baseurl = `${this.url}/${cloud.octreeDir}/r`;
87
81
  this.extension = cloud.pointAttributes === 'CIN' ? 'cin' : 'bin';
88
- this.parse = this.extension === 'cin' ? _PotreeCinParser.default.parse : _PotreeBinParser.default.parse;
82
+ this.parse = this.extension === 'cin' ? PotreeCinParser.parse : PotreeBinParser.parse;
89
83
  return cloud;
90
84
  });
91
85
  }
92
86
  }
93
- var _default = PotreeSource;
94
- exports.default = _default;
87
+ export default PotreeSource;
@@ -1,25 +1,15 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.supportedParsers = exports.supportedFetchers = exports.default = void 0;
8
- var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
9
- var _GeoJsonParser = _interopRequireDefault(require("../Parser/GeoJsonParser"));
10
- var _KMLParser = _interopRequireDefault(require("../Parser/KMLParser"));
11
- var _GDFParser = _interopRequireDefault(require("../Parser/GDFParser"));
12
- var _GpxParser = _interopRequireDefault(require("../Parser/GpxParser"));
13
- var _GTXParser = _interopRequireDefault(require("../Parser/GTXParser"));
14
- var _ISGParser = _interopRequireDefault(require("../Parser/ISGParser"));
15
- var _VectorTileParser = _interopRequireDefault(require("../Parser/VectorTileParser"));
16
- var _Fetcher = _interopRequireDefault(require("../Provider/Fetcher"));
17
- var _Cache = _interopRequireDefault(require("../Core/Scheduler/Cache"));
18
- var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
19
- const supportedFetchers = new Map([['image/x-bil;bits=32', _Fetcher.default.textureFloat], ['geojson', _Fetcher.default.json], ['application/json', _Fetcher.default.json], ['application/kml', _Fetcher.default.xml], ['application/gpx', _Fetcher.default.xml], ['application/x-protobuf;type=mapbox-vector', _Fetcher.default.arrayBuffer], ['application/gtx', _Fetcher.default.arrayBuffer], ['application/isg', _Fetcher.default.text], ['application/gdf', _Fetcher.default.text]]);
20
- exports.supportedFetchers = supportedFetchers;
21
- const supportedParsers = new Map([['geojson', _GeoJsonParser.default.parse], ['application/json', _GeoJsonParser.default.parse], ['application/kml', _KMLParser.default.parse], ['application/gpx', _GpxParser.default.parse], ['application/x-protobuf;type=mapbox-vector', _VectorTileParser.default.parse], ['application/gtx', _GTXParser.default.parse], ['application/isg', _ISGParser.default.parse], ['application/gdf', _GDFParser.default.parse]]);
22
- exports.supportedParsers = supportedParsers;
1
+ import Extent from "../Core/Geographic/Extent.js";
2
+ import GeoJsonParser from "../Parser/GeoJsonParser.js";
3
+ import KMLParser from "../Parser/KMLParser.js";
4
+ import GDFParser from "../Parser/GDFParser.js";
5
+ import GpxParser from "../Parser/GpxParser.js";
6
+ import GTXParser from "../Parser/GTXParser.js";
7
+ import ISGParser from "../Parser/ISGParser.js";
8
+ import VectorTileParser from "../Parser/VectorTileParser.js";
9
+ import Fetcher from "../Provider/Fetcher.js";
10
+ import Cache from "../Core/Scheduler/Cache.js";
11
+ import CRS from "../Core/Geographic/Crs.js";
12
+ 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]]);
23
13
  const noCache = {
24
14
  getByArray: () => {},
25
15
  setByArray: a => a,
@@ -44,7 +34,7 @@ class InformationsData {
44
34
  options.crs = options.crs || options.projection;
45
35
  }
46
36
  if (options.crs) {
47
- _Crs.default.isValid(options.crs);
37
+ CRS.isValid(options.crs);
48
38
  }
49
39
  this.crs = options.crs;
50
40
  }
@@ -56,13 +46,6 @@ class InformationsData {
56
46
  */
57
47
  // eslint-disable-next-line
58
48
  class /* istanbul ignore next */ParsingOptions {}
59
- function fetchSourceData(source, extent) {
60
- const url = source.urlFromExtent(extent);
61
- return source.fetcher(url, source.networkOptions).then(f => {
62
- f.extent = extent;
63
- return f;
64
- }, err => source.handlingError(err));
65
- }
66
49
  let uid = 0;
67
50
 
68
51
  /**
@@ -125,8 +108,11 @@ class Source extends InformationsData {
125
108
  this.uid = uid++;
126
109
  this.url = source.url;
127
110
  this.format = source.format;
128
- this.fetcher = source.fetcher || supportedFetchers.get(source.format) || _Fetcher.default.texture;
129
- this.parser = source.parser || supportedParsers.get(source.format) || (d => d);
111
+ this.fetcher = source.fetcher || Fetcher.get(source.format);
112
+ this.parser = source.parser || supportedParsers.get(source.format) || ((d, opt) => {
113
+ d.extent = opt.extent;
114
+ return d;
115
+ });
130
116
  this.isVectorSource = (source.parser || supportedParsers.get(source.format)) != undefined;
131
117
  this.networkOptions = source.networkOptions || {
132
118
  crossOrigin: 'anonymous'
@@ -135,7 +121,7 @@ class Source extends InformationsData {
135
121
  this.whenReady = Promise.resolve();
136
122
  this._featuresCaches = {};
137
123
  if (source.extent && !source.extent.isExtent) {
138
- this.extent = new _Extent.default(this.crs, source.extent);
124
+ this.extent = new Extent(this.crs, source.extent);
139
125
  } else {
140
126
  this.extent = source.extent;
141
127
  }
@@ -174,10 +160,12 @@ class Source extends InformationsData {
174
160
  let features = cache.getByArray(key);
175
161
  if (!features) {
176
162
  // otherwise fetch/parse the data
177
- features = cache.setByArray(fetchSourceData(this, extent).then(file => this.parser(file, {
163
+ features = cache.setByArray(this.fetcher(this.urlFromExtent(extent), this.networkOptions).then(file => this.parser(file, {
178
164
  out,
179
- in: this
180
- }), err => this.handlingError(err)), key);
165
+ in: this,
166
+ extent
167
+ })).catch(err => this.handlingError(err)), key);
168
+
181
169
  /* istanbul ignore next */
182
170
  if (this.onParsedFile) {
183
171
  features.then(feat => {
@@ -201,7 +189,7 @@ class Source extends InformationsData {
201
189
  // Cache feature only if it's vector data, the feature are cached in source.
202
190
  // It's not necessary to cache raster in Source,
203
191
  // because it's already cached on layer.
204
- this._featuresCaches[options.out.crs] = this.isVectorSource ? new _Cache.default() : noCache;
192
+ this._featuresCaches[options.out.crs] = this.isVectorSource ? new Cache() : noCache;
205
193
  }
206
194
  }
207
195
 
@@ -231,5 +219,4 @@ class Source extends InformationsData {
231
219
  throw new Error('In extented Source, you have to implement the method extentInsideLimit!');
232
220
  }
233
221
  }
234
- var _default = Source;
235
- exports.default = _default;
222
+ export default Source;
@@ -1,17 +1,8 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Source = _interopRequireDefault(require("./Source"));
9
- var _URLBuilder = _interopRequireDefault(require("../Provider/URLBuilder"));
10
- var _Extent = _interopRequireWildcard(require("../Core/Geographic/Extent"));
11
- var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
12
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
- const extent = new _Extent.default(_Crs.default.tms_4326, 0, 0, 0);
1
+ import Source from "./Source.js";
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);
15
6
 
16
7
  /**
17
8
  * @classdesc
@@ -78,7 +69,7 @@ const extent = new _Extent.default(_Crs.default.tms_4326, 0, 0, 0);
78
69
  * // Add the layer to the view
79
70
  * view.addLayer(imageryLayer);
80
71
  */
81
- class TMSSource extends _Source.default {
72
+ class TMSSource extends Source {
82
73
  /**
83
74
  * @param {Object} source - An object that can contain all properties of a
84
75
  * TMSSource and {@link Source}. Only `url` is mandatory.
@@ -94,12 +85,11 @@ class TMSSource extends _Source.default {
94
85
  this.isTMSSource = true;
95
86
  if (!source.extent) {
96
87
  // default to the global extent
97
- this.extent = _Extent.globalExtentTMS.get(source.crs);
88
+ this.extent = globalExtentTMS.get(source.crs);
98
89
  }
99
90
  this.zoom = source.zoom;
100
91
  this.isInverted = source.isInverted || false;
101
- this.url = source.url;
102
- this.crs = _Crs.default.formatToTms(source.crs);
92
+ this.crs = CRS.formatToTms(source.crs);
103
93
  this.tileMatrixSetLimits = source.tileMatrixSetLimits;
104
94
  this.extentSetlimits = {};
105
95
  this.tileMatrixCallback = source.tileMatrixCallback || (zoomLevel => zoomLevel);
@@ -121,7 +111,7 @@ class TMSSource extends _Source.default {
121
111
  }
122
112
  }
123
113
  urlFromExtent(extent) {
124
- return _URLBuilder.default.xyz(extent, this);
114
+ return URLBuilder.xyz(extent, this);
125
115
  }
126
116
  onLayerAdded(options) {
127
117
  super.onLayerAdded(options);
@@ -142,7 +132,7 @@ class TMSSource extends _Source.default {
142
132
  east,
143
133
  south
144
134
  } = extent.set(i, tmsl.maxTileRow, tmsl.maxTileCol).as(crs);
145
- this.extentSetlimits[crs][i] = new _Extent.default(crs, west, east, south, north);
135
+ this.extentSetlimits[crs][i] = new Extent(crs, west, east, south, north);
146
136
  }
147
137
  }
148
138
  }
@@ -153,5 +143,4 @@ class TMSSource extends _Source.default {
153
143
  return zoom >= this.zoom.min && zoom <= this.zoom.max && (this.extentSetlimits[extent.crs] == undefined || this.extentSetlimits[extent.crs][zoom].intersectsExtent(extent));
154
144
  }
155
145
  }
156
- var _default = TMSSource;
157
- exports.default = _default;
146
+ export default TMSSource;
@@ -1,18 +1,24 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _mapboxGlStyleSpec = require("@mapbox/mapbox-gl-style-spec");
9
- var _Style = _interopRequireDefault(require("../Core/Style"));
10
- var _TMSSource = _interopRequireDefault(require("./TMSSource"));
11
- var _Fetcher = _interopRequireDefault(require("../Provider/Fetcher"));
12
- var _MapBoxUrlParser = _interopRequireDefault(require("../Parser/MapBoxUrlParser"));
1
+ import { featureFilter } from '@mapbox/mapbox-gl-style-spec';
2
+ import Style from "../Core/Style.js";
3
+ import TMSSource from "./TMSSource.js";
4
+ import URLBuilder from "../Provider/URLBuilder.js";
5
+ import Fetcher from "../Provider/Fetcher.js";
6
+ import urlParser from "../Parser/MapBoxUrlParser.js";
13
7
  function toTMSUrl(url) {
14
8
  return url.replace(/\{/g, '${');
15
9
  }
10
+ function mergeCollections(collections) {
11
+ const collection = collections[0];
12
+ collections.forEach((col, index) => {
13
+ if (index === 0) {
14
+ return;
15
+ }
16
+ col.features.forEach(feature => {
17
+ collection.features.push(feature);
18
+ });
19
+ });
20
+ return collection;
21
+ }
16
22
 
17
23
  /**
18
24
  * @classdesc
@@ -24,7 +30,7 @@ function toTMSUrl(url) {
24
30
  * @property {boolean} [symbolToCircle=false] - If true, all symbols from a tile
25
31
  * will be considered as circle, and render as circles.
26
32
  */
27
- class VectorTilesSource extends _TMSSource.default {
33
+ class VectorTilesSource extends TMSSource {
28
34
  /**
29
35
  * @param {Object} source - An object that can contain all properties of a
30
36
  * VectorTilesSource and {@link Source}.
@@ -59,6 +65,7 @@ class VectorTilesSource extends _TMSSource.default {
59
65
  source.url = source.url || '.';
60
66
  super(source);
61
67
  const ffilter = source.filter || (() => true);
68
+ this.urls = [];
62
69
  this.layers = {};
63
70
  this.styles = {};
64
71
  let promise;
@@ -66,8 +73,8 @@ class VectorTilesSource extends _TMSSource.default {
66
73
  this.accessToken = source.accessToken;
67
74
  if (source.style) {
68
75
  if (typeof source.style == 'string') {
69
- const styleUrl = _MapBoxUrlParser.default.normalizeStyleURL(source.style, this.accessToken);
70
- promise = _Fetcher.default.json(styleUrl, this.networkOptions);
76
+ const styleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken);
77
+ promise = Fetcher.json(styleUrl, this.networkOptions);
71
78
  } else {
72
79
  promise = Promise.resolve(source.style);
73
80
  }
@@ -78,24 +85,22 @@ class VectorTilesSource extends _TMSSource.default {
78
85
  this.jsonStyle = style;
79
86
  const baseurl = source.sprite || style.sprite;
80
87
  if (baseurl) {
81
- const spriteUrl = _MapBoxUrlParser.default.normalizeSpriteURL(baseurl, '', '.json', this.accessToken);
82
- return _Fetcher.default.json(spriteUrl, this.networkOptions).then(sprites => {
88
+ const spriteUrl = urlParser.normalizeSpriteURL(baseurl, '', '.json', this.accessToken);
89
+ return Fetcher.json(spriteUrl, this.networkOptions).then(sprites => {
83
90
  this.sprites = sprites;
84
- const imgUrl = _MapBoxUrlParser.default.normalizeSpriteURL(baseurl, '', '.png', this.accessToken);
91
+ const imgUrl = urlParser.normalizeSpriteURL(baseurl, '', '.png', this.accessToken);
85
92
  this.sprites.source = imgUrl;
86
93
  return style;
87
94
  });
88
95
  }
89
96
  return style;
90
97
  }).then(style => {
91
- const s = Object.keys(style.sources)[0];
92
- const os = style.sources[s];
93
98
  style.layers.forEach((layer, order) => {
94
99
  layer.sourceUid = this.uid;
95
100
  if (layer.type === 'background') {
96
101
  this.backgroundLayer = layer;
97
102
  } else if (ffilter(layer)) {
98
- const style = _Style.default.setFromVectorTileLayer(layer, this.sprites, order, this.symbolToCircle);
103
+ const style = Style.setFromVectorTileLayer(layer, this.sprites, order, this.symbolToCircle);
99
104
  this.styles[layer.id] = style;
100
105
  if (!this.layers[layer['source-layer']]) {
101
106
  this.layers[layer['source-layer']] = [];
@@ -103,7 +108,7 @@ class VectorTilesSource extends _TMSSource.default {
103
108
  this.layers[layer['source-layer']].push({
104
109
  id: layer.id,
105
110
  order,
106
- filterExpression: (0, _mapboxGlStyleSpec.featureFilter)(layer.filter),
111
+ filterExpression: featureFilter(layer.filter),
107
112
  zoom: {
108
113
  min: layer.minzoom || 0,
109
114
  max: layer.maxzoom || 24
@@ -112,17 +117,30 @@ class VectorTilesSource extends _TMSSource.default {
112
117
  }
113
118
  });
114
119
  if (this.url == '.') {
115
- if (os.url) {
116
- const urlSource = _MapBoxUrlParser.default.normalizeSourceURL(os.url, this.accessToken);
117
- return _Fetcher.default.json(urlSource, this.networkOptions).then(tileJSON => {
118
- if (tileJSON.tiles[0]) {
119
- this.url = toTMSUrl(tileJSON.tiles[0]);
120
- }
121
- });
122
- } else if (os.tiles[0]) {
123
- this.url = toTMSUrl(os.tiles[0]);
124
- }
120
+ const TMSUrlList = Object.values(style.sources).map(sourceVT => {
121
+ if (sourceVT.url) {
122
+ const urlSource = urlParser.normalizeSourceURL(sourceVT.url, this.accessToken);
123
+ return Fetcher.json(urlSource, this.networkOptions).then(tileJSON => {
124
+ if (tileJSON.tiles[0]) {
125
+ return toTMSUrl(tileJSON.tiles[0]);
126
+ }
127
+ });
128
+ } else if (sourceVT.tiles) {
129
+ return Promise.resolve(toTMSUrl(sourceVT.tiles[0]));
130
+ }
131
+ return Promise.reject();
132
+ });
133
+ return Promise.all(TMSUrlList);
125
134
  }
135
+ return Promise.resolve([this.url]);
136
+ }).then(TMSUrlList => {
137
+ this.urls = Array.from(new Set(TMSUrlList));
138
+ });
139
+ }
140
+ urlFromExtent(extent, url) {
141
+ return URLBuilder.xyz(extent, {
142
+ tileMatrixCallback: this.tileMatrixCallback,
143
+ url
126
144
  });
127
145
  }
128
146
  onLayerAdded(options) {
@@ -134,6 +152,29 @@ class VectorTilesSource extends _TMSSource.default {
134
152
  }
135
153
  }
136
154
  }
155
+ loadData(extent, out) {
156
+ const cache = this._featuresCaches[out.crs];
157
+ const key = this.requestToKey(extent);
158
+ // try to get parsed data from cache
159
+ let features = cache.getByArray(key);
160
+ if (!features) {
161
+ // otherwise fetch/parse the data
162
+ features = cache.setByArray(Promise.all(this.urls.map(url => this.fetcher(this.urlFromExtent(extent, url), this.networkOptions).then(file => this.parser(file, {
163
+ out,
164
+ in: this,
165
+ extent
166
+ })))).then(collections => mergeCollections(collections)).catch(err => this.handlingError(err)), key);
167
+
168
+ /* istanbul ignore next */
169
+ if (this.onParsedFile) {
170
+ features.then(feat => {
171
+ this.onParsedFile(feat);
172
+ console.warn('Source.onParsedFile was deprecated');
173
+ return feat;
174
+ });
175
+ }
176
+ }
177
+ return features;
178
+ }
137
179
  }
138
- var _default = VectorTilesSource;
139
- exports.default = _default;
180
+ export default VectorTilesSource;
@@ -1,13 +1,7 @@
1
- "use strict";
1
+ import Source from "./Source.js";
2
+ import URLBuilder from "../Provider/URLBuilder.js";
3
+ import CRS from "../Core/Geographic/Crs.js";
2
4
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Source = _interopRequireDefault(require("./Source"));
9
- var _URLBuilder = _interopRequireDefault(require("../Provider/URLBuilder"));
10
- var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
11
5
  /**
12
6
  * @classdesc
13
7
  * An object defining the source of resources to get from a
@@ -102,7 +96,7 @@ var _Crs = _interopRequireDefault(require("../Core/Geographic/Crs"));
102
96
  * // Add the layer
103
97
  * view.addLayer(geometryLayer);
104
98
  */
105
- class WFSSource extends _Source.default {
99
+ class WFSSource extends Source {
106
100
  /**
107
101
  * @param {Object} source - An object that can contain all properties of a
108
102
  * WFSSource and {@link Source}. `url`, `typeName` and `crs` are
@@ -158,18 +152,17 @@ class WFSSource extends _Source.default {
158
152
  return super.handlingError(err);
159
153
  }
160
154
  requestToKey(extent) {
161
- if (_Crs.default.isTms(extent.crs)) {
155
+ if (CRS.isTms(extent.crs)) {
162
156
  return super.requestToKey(extent);
163
157
  } else {
164
158
  return [extent.zoom, extent.south, extent.west];
165
159
  }
166
160
  }
167
161
  urlFromExtent(extent) {
168
- return _URLBuilder.default.bbox(extent, this);
162
+ return URLBuilder.bbox(extent, this);
169
163
  }
170
164
  extentInsideLimit(extent) {
171
165
  return this.extent.intersectsExtent(extent);
172
166
  }
173
167
  }
174
- var _default = WFSSource;
175
- exports.default = _default;
168
+ export default WFSSource;
@@ -1,12 +1,6 @@
1
- "use strict";
1
+ import Source from "./Source.js";
2
+ import URLBuilder from "../Provider/URLBuilder.js";
2
3
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _Source = _interopRequireDefault(require("./Source"));
9
- var _URLBuilder = _interopRequireDefault(require("../Provider/URLBuilder"));
10
4
  /**
11
5
  * @classdesc
12
6
  * An object defining the source of images to get from a
@@ -72,7 +66,7 @@ var _URLBuilder = _interopRequireDefault(require("../Provider/URLBuilder"));
72
66
  * // Add the layer
73
67
  * view.addLayer(colorlayer);
74
68
  */
75
- class WMSSource extends _Source.default {
69
+ class WMSSource extends Source {
76
70
  /**
77
71
  * @param {Object} source - An object that can contain all properties of
78
72
  * WMSSource and {@link Source}. `url`, `name`, `extent` and `crs`
@@ -130,11 +124,10 @@ class WMSSource extends _Source.default {
130
124
  }
131
125
  }
132
126
  urlFromExtent(extent) {
133
- return _URLBuilder.default.bbox(extent, this);
127
+ return URLBuilder.bbox(extent, this);
134
128
  }
135
129
  extentInsideLimit(extent) {
136
130
  return this.extent.intersectsExtent(extent);
137
131
  }
138
132
  }
139
- var _default = WMSSource;
140
- exports.default = _default;
133
+ export default WMSSource;
@@ -1,11 +1,5 @@
1
- "use strict";
1
+ import TMSSource from "./TMSSource.js";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _TMSSource = _interopRequireDefault(require("./TMSSource"));
9
3
  /**
10
4
  * @classdesc
11
5
  * An object defining the source of resources to get from a
@@ -65,7 +59,7 @@ var _TMSSource = _interopRequireDefault(require("./TMSSource"));
65
59
  * // Add the layer
66
60
  * view.addLayer(colorLayer);
67
61
  */
68
- class WMTSSource extends _TMSSource.default {
62
+ class WMTSSource extends TMSSource {
69
63
  /**
70
64
  * @param {Object} source - An object that can contain all properties of a
71
65
  * WMTSSource and {@link Source}. Only `url`, `name` and `crs` are mandatory.
@@ -92,5 +86,4 @@ class WMTSSource extends _TMSSource.default {
92
86
  }
93
87
  }
94
88
  }
95
- var _default = WMTSSource;
96
- exports.default = _default;
89
+ export default WMTSSource;
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
1
  class WebGL {
8
2
  static isWebGLAvailable() {
9
3
  try {
@@ -67,5 +61,4 @@ class WebGL {
67
61
  return element;
68
62
  }
69
63
  }
70
- var _default = WebGL;
71
- exports.default = _default;
64
+ export default WebGL;