itowns 2.44.3-next.9 → 2.45.1-next.0

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 (214) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +20 -6
  3. package/examples/config.json +1 -0
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/jsm/.eslintrc.cjs +0 -38
  43. package/lib/Controls/FirstPersonControls.js +0 -308
  44. package/lib/Controls/FlyControls.js +0 -175
  45. package/lib/Controls/GlobeControls.js +0 -1162
  46. package/lib/Controls/PlanarControls.js +0 -1025
  47. package/lib/Controls/StateControl.js +0 -429
  48. package/lib/Controls/StreetControls.js +0 -392
  49. package/lib/Converter/Feature2Mesh.js +0 -615
  50. package/lib/Converter/Feature2Texture.js +0 -170
  51. package/lib/Converter/convertToTile.js +0 -75
  52. package/lib/Converter/textureConverter.js +0 -44
  53. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  54. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  55. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  56. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  57. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  58. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  59. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  60. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  61. package/lib/Core/AnimationPlayer.js +0 -142
  62. package/lib/Core/CopcNode.js +0 -174
  63. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  64. package/lib/Core/EntwinePointTileNode.js +0 -126
  65. package/lib/Core/Feature.js +0 -490
  66. package/lib/Core/Geographic/CoordStars.js +0 -80
  67. package/lib/Core/Geographic/Coordinates.js +0 -320
  68. package/lib/Core/Geographic/Crs.js +0 -175
  69. package/lib/Core/Geographic/Extent.js +0 -534
  70. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  71. package/lib/Core/Label.js +0 -222
  72. package/lib/Core/MainLoop.js +0 -211
  73. package/lib/Core/Math/Ellipsoid.js +0 -144
  74. package/lib/Core/Picking.js +0 -255
  75. package/lib/Core/PointCloudNode.js +0 -42
  76. package/lib/Core/Potree2Node.js +0 -206
  77. package/lib/Core/Potree2PointAttributes.js +0 -139
  78. package/lib/Core/PotreeNode.js +0 -101
  79. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  80. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  81. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  82. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  83. package/lib/Core/Prefab/GlobeView.js +0 -161
  84. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  85. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  86. package/lib/Core/Prefab/PlanarView.js +0 -62
  87. package/lib/Core/Prefab/TileBuilder.js +0 -80
  88. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  89. package/lib/Core/Scheduler/Cache.js +0 -256
  90. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  91. package/lib/Core/Scheduler/Scheduler.js +0 -294
  92. package/lib/Core/Style.js +0 -1121
  93. package/lib/Core/System/Capabilities.js +0 -63
  94. package/lib/Core/Tile/Tile.js +0 -219
  95. package/lib/Core/Tile/TileGrid.js +0 -46
  96. package/lib/Core/TileGeometry.js +0 -40
  97. package/lib/Core/TileMesh.js +0 -109
  98. package/lib/Core/View.js +0 -1109
  99. package/lib/Layer/C3DTilesLayer.js +0 -456
  100. package/lib/Layer/ColorLayer.js +0 -128
  101. package/lib/Layer/CopcLayer.js +0 -58
  102. package/lib/Layer/ElevationLayer.js +0 -107
  103. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  104. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  105. package/lib/Layer/GeoidLayer.js +0 -80
  106. package/lib/Layer/GeometryLayer.js +0 -202
  107. package/lib/Layer/InfoLayer.js +0 -64
  108. package/lib/Layer/LabelLayer.js +0 -456
  109. package/lib/Layer/Layer.js +0 -304
  110. package/lib/Layer/LayerUpdateState.js +0 -89
  111. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  112. package/lib/Layer/OGC3DTilesLayer.js +0 -412
  113. package/lib/Layer/OrientedImageLayer.js +0 -222
  114. package/lib/Layer/PointCloudLayer.js +0 -359
  115. package/lib/Layer/Potree2Layer.js +0 -164
  116. package/lib/Layer/PotreeLayer.js +0 -65
  117. package/lib/Layer/RasterLayer.js +0 -27
  118. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  119. package/lib/Layer/TiledGeometryLayer.js +0 -403
  120. package/lib/Loader/LASLoader.js +0 -193
  121. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  122. package/lib/Loader/Potree2Loader.js +0 -207
  123. package/lib/Main.js +0 -115
  124. package/lib/MainBundle.js +0 -4
  125. package/lib/Parser/B3dmParser.js +0 -174
  126. package/lib/Parser/CameraCalibrationParser.js +0 -94
  127. package/lib/Parser/GDFParser.js +0 -72
  128. package/lib/Parser/GTXParser.js +0 -75
  129. package/lib/Parser/GeoJsonParser.js +0 -212
  130. package/lib/Parser/GpxParser.js +0 -25
  131. package/lib/Parser/ISGParser.js +0 -71
  132. package/lib/Parser/KMLParser.js +0 -25
  133. package/lib/Parser/LASParser.js +0 -137
  134. package/lib/Parser/MapBoxUrlParser.js +0 -83
  135. package/lib/Parser/PntsParser.js +0 -131
  136. package/lib/Parser/Potree2BinParser.js +0 -92
  137. package/lib/Parser/PotreeBinParser.js +0 -106
  138. package/lib/Parser/PotreeCinParser.js +0 -29
  139. package/lib/Parser/ShapefileParser.js +0 -78
  140. package/lib/Parser/VectorTileParser.js +0 -202
  141. package/lib/Parser/XbilParser.js +0 -119
  142. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  143. package/lib/Parser/iGLTFLoader.js +0 -168
  144. package/lib/Process/3dTilesProcessing.js +0 -304
  145. package/lib/Process/FeatureProcessing.js +0 -76
  146. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  147. package/lib/Process/ObjectRemovalHelper.js +0 -97
  148. package/lib/Process/handlerNodeError.js +0 -23
  149. package/lib/Provider/3dTilesProvider.js +0 -149
  150. package/lib/Provider/DataSourceProvider.js +0 -8
  151. package/lib/Provider/Fetcher.js +0 -229
  152. package/lib/Provider/PointCloudProvider.js +0 -45
  153. package/lib/Provider/TileProvider.js +0 -16
  154. package/lib/Provider/URLBuilder.js +0 -116
  155. package/lib/Renderer/Camera.js +0 -281
  156. package/lib/Renderer/Color.js +0 -56
  157. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  158. package/lib/Renderer/CommonMaterial.js +0 -31
  159. package/lib/Renderer/Label2DRenderer.js +0 -190
  160. package/lib/Renderer/LayeredMaterial.js +0 -243
  161. package/lib/Renderer/OBB.js +0 -153
  162. package/lib/Renderer/OrientedImageCamera.js +0 -118
  163. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  164. package/lib/Renderer/PointsMaterial.js +0 -485
  165. package/lib/Renderer/RasterTile.js +0 -209
  166. package/lib/Renderer/RenderMode.js +0 -31
  167. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  168. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  169. package/lib/Renderer/SphereHelper.js +0 -23
  170. package/lib/Renderer/WebXR.js +0 -51
  171. package/lib/Renderer/c3DEngine.js +0 -214
  172. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  173. package/lib/Source/C3DTilesIonSource.js +0 -54
  174. package/lib/Source/C3DTilesSource.js +0 -30
  175. package/lib/Source/CopcSource.js +0 -115
  176. package/lib/Source/EntwinePointTileSource.js +0 -62
  177. package/lib/Source/FileSource.js +0 -189
  178. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  179. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  180. package/lib/Source/OGC3DTilesSource.js +0 -21
  181. package/lib/Source/OrientedImageSource.js +0 -59
  182. package/lib/Source/Potree2Source.js +0 -167
  183. package/lib/Source/PotreeSource.js +0 -82
  184. package/lib/Source/Source.js +0 -223
  185. package/lib/Source/TMSSource.js +0 -145
  186. package/lib/Source/VectorTilesSource.js +0 -178
  187. package/lib/Source/WFSSource.js +0 -168
  188. package/lib/Source/WMSSource.js +0 -133
  189. package/lib/Source/WMTSSource.js +0 -86
  190. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  191. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  192. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  193. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  194. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  195. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  196. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  197. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  198. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  199. package/lib/Utils/CameraUtils.js +0 -555
  200. package/lib/Utils/DEMUtils.js +0 -350
  201. package/lib/Utils/FeaturesUtils.js +0 -156
  202. package/lib/Utils/Gradients.js +0 -16
  203. package/lib/Utils/OrientationUtils.js +0 -457
  204. package/lib/Utils/ThreeUtils.js +0 -115
  205. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  206. package/lib/Utils/gui/Main.js +0 -7
  207. package/lib/Utils/gui/Minimap.js +0 -154
  208. package/lib/Utils/gui/Navigation.js +0 -245
  209. package/lib/Utils/gui/Scale.js +0 -107
  210. package/lib/Utils/gui/Searchbar.js +0 -234
  211. package/lib/Utils/gui/Widget.js +0 -80
  212. package/lib/Utils/placeObjectOnGround.js +0 -137
  213. package/lib/Worker/LASLoaderWorker.js +0 -19
  214. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,304 +0,0 @@
1
- import * as THREE from 'three';
2
- import { STRATEGY_MIN_NETWORK_TRAFFIC } from "./LayerUpdateStrategy.js";
3
- import InfoLayer from "./InfoLayer.js";
4
- import Source from "../Source/Source.js";
5
- import Cache from "../Core/Scheduler/Cache.js";
6
- import Style from "../Core/Style.js";
7
-
8
- /**
9
- * @property {boolean} isLayer - Used to checkout whether this layer is a Layer.
10
- * Default is true. You should not change this, as it is used internally for
11
- * optimisation.
12
- * @property {boolean} ready - This property is false when the layer isn't added.
13
- * It's true when the layer is added and all initializations are done.
14
- * @property {Source} source - This source determines the datas to be displayed with the layer.
15
- * The layer determines how this data are displayed.
16
- * By example:
17
- * * For ColorLayer/ElevationLayer, the source datas are rasterised (if it's necessary).
18
- * * For GeometryLayer, the source datas are converted to meshes (not possible for the raster data sources).
19
- * @property {Promise} whenReady - this promise is resolved when the layer is added and all initializations are done.
20
- * This promise is resolved with this layer.
21
- * This promise is returned by [View#addLayer]{@link View}.
22
- * @property {object} [zoom] - This property is used only the layer is attached
23
- * to {@link TiledGeometryLayer}.
24
- * By example,
25
- * The layer checks the tile zoom level to determine if the layer is visible in this tile.
26
- *
27
- * ![tiled geometry](/docs/static/images/wfszoommaxmin.jpeg)
28
- * _In `GlobeView`, **red lines** represents the **WGS84 grid** and **orange lines** the Pseudo-mercator grid_
29
- * _In this example [WFS to 3D objects](http://www.itowns-project.org/itowns/examples/index.html#source_stream_wfs_3d), the building layer zoom min is 14._
30
- * _In the lower part of the picture, the zoom tiles 14 have buildings, while in the upper part of the picture, the level 13 tiles have no buildings._
31
- *
32
- * @property {number} [zoom.max=Infinity] - this is the maximum zoom beyond which it'll be hidden.
33
- * @property {number} [zoom.min=0] - this is the minimum zoom from which it'll be visible.
34
- *
35
- */
36
- class Layer extends THREE.EventDispatcher {
37
- /**
38
- * Don't use directly constructor to instance a new Layer. Instead, use
39
- * another available type of Layer, implement a new one inheriting from this
40
- * one or use [View#addLayer]{@link View}.
41
- *
42
- * @protected
43
- *
44
- * @param {string} id - The id of the layer, that should be unique. It is
45
- * not mandatory, but an error will be emitted if this layer is added a
46
- * {@link View} that already has a layer going by that id.
47
- * @param {Object} config - configuration, all elements in it
48
- * will be merged as is in the layer. For example, if the configuration
49
- * contains three elements `name, extent`, these elements will be
50
- * available using `layer.name` or something else depending on the property
51
- * name.
52
- * @param {Source|boolean} config.source - instantiated Source specifies data source to display.
53
- * if config.source is a boolean, it can only be false. if config.source is false,
54
- * the layer doesn't need Source (like debug Layer or procedural layer).
55
- * @param {StyleOptions} [config.style] - an object that contain any properties
56
- * (order, zoom, fill, stroke, point, text or/and icon)
57
- * and sub properties of a Style (@see {@link StyleOptions}). Or directly a {@link Style} .<br/>
58
- * When entering a StyleOptions the missing style properties will be look for in the data (if any)
59
- * what won't be done when you use a Style.
60
- * @param {number} [config.cacheLifeTime=Infinity] - set life time value in cache.
61
- * This value is used for cache expiration mechanism.
62
- * @param {(boolean|Object)} [config.addLabelLayer] - Used to tell if this layer has
63
- * labels to display from its data. For example, it needs to be set to `true`
64
- * for a layer with vector tiles. If it's `true` a new `LabelLayer` is added and attached to this `Layer`.
65
- * You can also configure it with {@link LabelLayer} options described below such as: `addLabelLayer: { performance: true }`.
66
- * @param {boolean} [config.addLabelLayer.performance=false] - In case label layer adding, so remove labels that have no chance of being visible.
67
- * Indeed, even in the best case, labels will never be displayed. By example, if there's many labels.
68
- * @param {boolean} [config.addLabelLayer.forceClampToTerrain=false] - use elevation layer to clamp label on terrain.
69
- * @param {number} [config.subdivisionThreshold=256] - set the texture size and, if applied to the globe, affects the tile subdivision.
70
- *
71
- * @example
72
- * // Add and create a new Layer
73
- * const newLayer = new Layer('id', options);
74
- * view.addLayer(newLayer);
75
- *
76
- * // Change layer's visibility
77
- * const layerToChange = view.getLayerById('idLayerToChange');
78
- * layerToChange.visible = false;
79
- * view.notifyChange(); // update viewer
80
- *
81
- * // Change layer's opacity
82
- * const layerToChange = view.getLayerById('idLayerToChange');
83
- * layerToChange.opacity = 0.5;
84
- * view.notifyChange(); // update viewer
85
- *
86
- * // Listen properties
87
- * const layerToListen = view.getLayerById('idLayerToListen');
88
- * layerToListen.addEventListener('visible-property-changed', (event) => console.log(event));
89
- * layerToListen.addEventListener('opacity-property-changed', (event) => console.log(event));
90
- */
91
- constructor(id) {
92
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
93
- /* istanbul ignore next */
94
- if (config.projection) {
95
- console.warn('Layer projection parameter is deprecated, use crs instead.');
96
- config.crs = config.crs || config.projection;
97
- }
98
- if (config.source === undefined || config.source === true) {
99
- throw new Error(`Layer ${id} needs Source`);
100
- }
101
- super();
102
- this.isLayer = true;
103
- if (config.style && !(config.style instanceof Style)) {
104
- if (typeof config.style.fill?.pattern === 'string') {
105
- console.warn('Using style.fill.pattern = { source: Img|url } is adviced');
106
- config.style.fill.pattern = {
107
- source: config.style.fill.pattern
108
- };
109
- }
110
- config.style = new Style(config.style);
111
- }
112
- this.style = config.style || new Style();
113
- this.subdivisionThreshold = config.subdivisionThreshold || 256;
114
- this.sizeDiagonalTexture = (2 * (this.subdivisionThreshold * this.subdivisionThreshold)) ** 0.5;
115
- Object.assign(this, config);
116
- Object.defineProperty(this, 'id', {
117
- value: id,
118
- writable: false
119
- });
120
- // Default properties
121
- this.options = config.options || {};
122
- if (!this.updateStrategy) {
123
- this.updateStrategy = {
124
- type: STRATEGY_MIN_NETWORK_TRAFFIC,
125
- options: {}
126
- };
127
- }
128
- this.defineLayerProperty('frozen', false);
129
- if (config.zoom) {
130
- this.zoom = {
131
- max: config.zoom.max,
132
- min: config.zoom.min || 0
133
- };
134
- if (this.zoom.max == undefined) {
135
- this.zoom.max = Infinity;
136
- }
137
- } else {
138
- this.zoom = {
139
- max: Infinity,
140
- min: 0
141
- };
142
- }
143
- this.info = new InfoLayer(this);
144
- this.source = this.source || new Source({
145
- url: 'none'
146
- });
147
- this.ready = false;
148
- this._promises = [];
149
- this.whenReady = new Promise((re, rj) => {
150
- this._resolve = re;
151
- this._reject = rj;
152
- }).then(() => {
153
- this.ready = true;
154
- this.source.onLayerAdded({
155
- out: this
156
- });
157
- return this;
158
- });
159
- this._promises.push(this.source.whenReady);
160
- this.cache = new Cache(config.cacheLifeTime);
161
- this.mergeFeatures = this.mergeFeatures === undefined ? true : config.mergeFeatures;
162
-
163
- // TODO: verify but this.source.filter seems be always undefined.
164
- this.filter = this.filter || this.source.filter;
165
- }
166
- addInitializationStep() {
167
- // Possibility to add rejection handler, if it's necessary.
168
- let resolve;
169
- this._promises.push(new Promise(re => {
170
- resolve = re;
171
- }));
172
- return resolve;
173
- }
174
-
175
- /**
176
- * Defines a property for this layer, with a default value and a callback
177
- * executed when the property changes.
178
- * <br><br>
179
- * When changing the property, it also emits an event, named following this
180
- * convention: `${propertyName}-property-changed`, with `${propertyName}`
181
- * being replaced by the name of the property. For example, if the added
182
- * property name is `frozen`, it will emit a `frozen-property-changed`.
183
- * <br><br>
184
- * @example <caption>The emitted event has some properties assigned to it</caption>
185
- * event = {
186
- * new: {
187
- * ${propertyName}: * // the new value of the property
188
- * },
189
- * previous: {
190
- * ${propertyName}: * // the previous value of the property
191
- * },
192
- * target: Layer // the layer it has been dispatched from
193
- * type: string // the name of the emitted event
194
- * }
195
- *
196
- * @param {string} propertyName - The name of the property, also used in
197
- * the emitted event name.
198
- * @param {*} defaultValue - The default set value.
199
- * @param {function} [onChange] - The function executed when the property is
200
- * changed. Parameters are the layer the property is defined on, and the
201
- * name of the property.
202
- */
203
- defineLayerProperty(propertyName, defaultValue, onChange) {
204
- const existing = Object.getOwnPropertyDescriptor(this, propertyName);
205
- if (!existing || !existing.set) {
206
- let property = this[propertyName] == undefined ? defaultValue : this[propertyName];
207
- Object.defineProperty(this, propertyName, {
208
- get: () => property,
209
- set: newValue => {
210
- if (property !== newValue) {
211
- const event = {
212
- type: `${propertyName}-property-changed`,
213
- previous: {},
214
- new: {}
215
- };
216
- event.previous[propertyName] = property;
217
- event.new[propertyName] = newValue;
218
- property = newValue;
219
- if (onChange) {
220
- onChange(this, propertyName);
221
- }
222
- this.dispatchEvent(event);
223
- }
224
- }
225
- });
226
- }
227
- }
228
-
229
- // Placeholder
230
- // eslint-disable-next-line
231
- convert(data) {
232
- return data;
233
- }
234
- getData(from, to) {
235
- const key = this.source.requestToKey(this.source.isVectorSource ? to : from);
236
- let data = this.cache.getByArray(key);
237
- if (!data) {
238
- data = this.source.loadData(from, this).then(feat => this.convert(feat, to), err => {
239
- throw err;
240
- });
241
- this.cache.setByArray(data, key);
242
- }
243
- return data;
244
- }
245
-
246
- /**
247
- * Determines whether the specified feature is valid data.
248
- *
249
- * @param {Feature} feature The feature
250
- * @returns {Feature} the feature is returned if it's valided
251
- */
252
- // eslint-disable-next-line
253
- isValidData() {}
254
-
255
- /**
256
- * Remove and dispose all objects from layer.
257
- * @param {boolean} [clearCache=false] Whether to clear the layer cache or not
258
- */
259
- // eslint-disable-next-line
260
- delete() {
261
- console.warn('Function delete doesn\'t exist for this layer');
262
- }
263
- }
264
- export default Layer;
265
- export const ImageryLayers = {
266
- // move this to new index
267
- // After the modification :
268
- // * the minimum sequence will always be 0
269
- // * the maximum sequence will always be layers.lenght - 1
270
- // the ordering of all layers (Except that specified) doesn't change
271
- moveLayerToIndex: function (layer, newIndex, imageryLayers) {
272
- newIndex = Math.min(newIndex, imageryLayers.length - 1);
273
- newIndex = Math.max(newIndex, 0);
274
- const oldIndex = layer.sequence;
275
- for (const imagery of imageryLayers) {
276
- if (imagery.id === layer.id) {
277
- // change index of specified layer
278
- imagery.sequence = newIndex;
279
- } else if (imagery.sequence > oldIndex && imagery.sequence <= newIndex) {
280
- // down all layers between the old index and new index (to compensate the deletion of the old index)
281
- imagery.sequence--;
282
- } else if (imagery.sequence >= newIndex && imagery.sequence < oldIndex) {
283
- // up all layers between the new index and old index (to compensate the insertion of the new index)
284
- imagery.sequence++;
285
- }
286
- }
287
- },
288
- moveLayerDown: function (layer, imageryLayers) {
289
- if (layer.sequence > 0) {
290
- this.moveLayerToIndex(layer, layer.sequence - 1, imageryLayers);
291
- }
292
- },
293
- moveLayerUp: function (layer, imageryLayers) {
294
- const m = imageryLayers.length - 1;
295
- if (layer.sequence < m) {
296
- this.moveLayerToIndex(layer, layer.sequence + 1, imageryLayers);
297
- }
298
- },
299
- getColorLayersIdOrderedBySequence: function (imageryLayers) {
300
- const copy = Array.from(imageryLayers);
301
- copy.sort((a, b) => a.sequence - b.sequence);
302
- return copy.map(l => l.id);
303
- }
304
- };
@@ -1,89 +0,0 @@
1
- const UPDATE_STATE = {
2
- IDLE: 0,
3
- PENDING: 1,
4
- ERROR: 2,
5
- DEFINITIVE_ERROR: 3,
6
- FINISHED: 4
7
- };
8
- const PAUSE_BETWEEN_ERRORS = [1.0, 3.0, 7.0, 60.0];
9
-
10
- /**
11
- * LayerUpdateState is the update state of a layer, for a given object (e.g tile).
12
- * It stores information to allow smart update decisions, and especially network
13
- * error handling.
14
- * @constructor
15
- */
16
- class LayerUpdateState {
17
- constructor() {
18
- this.state = UPDATE_STATE.IDLE;
19
- this.lastErrorTimestamp = 0;
20
- this.errorCount = 0;
21
- // lowestLevelError is lowest level with error.
22
- //
23
- // if lowestLevelError is Infinity, so there has been no error.
24
- //
25
- // if lowestLevelError isn't Infinity, so the strategy is to find the
26
- // highest level between the current level and lowestLevelError.
27
- // the dichotomy method is used to find it.
28
- this.failureParams = {
29
- lowestLevelError: Infinity
30
- };
31
- }
32
- hasFinished() {
33
- return UPDATE_STATE.FINISHED == this.state;
34
- }
35
- canTryUpdate() {
36
- let timestamp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Date.now();
37
- switch (this.state) {
38
- case UPDATE_STATE.IDLE:
39
- {
40
- return true;
41
- }
42
- case UPDATE_STATE.DEFINITIVE_ERROR:
43
- case UPDATE_STATE.PENDING:
44
- case UPDATE_STATE.FINISHED:
45
- {
46
- return false;
47
- }
48
- case UPDATE_STATE.ERROR:
49
- default:
50
- {
51
- const errorDuration = this.secondsUntilNextTry() * 1000;
52
- return errorDuration <= timestamp - this.lastErrorTimestamp;
53
- }
54
- }
55
- }
56
- secondsUntilNextTry() {
57
- if (this.state !== UPDATE_STATE.ERROR) {
58
- return 0;
59
- }
60
- const idx = Math.max(0, Math.min(this.errorCount, PAUSE_BETWEEN_ERRORS.length) - 1);
61
- return PAUSE_BETWEEN_ERRORS[idx];
62
- }
63
- newTry() {
64
- this.state = UPDATE_STATE.PENDING;
65
- }
66
- success() {
67
- this.lastErrorTimestamp = 0;
68
- this.state = UPDATE_STATE.IDLE;
69
- }
70
- noMoreUpdatePossible() {
71
- this.state = UPDATE_STATE.FINISHED;
72
- }
73
- noData(failureParams) {
74
- this.state = UPDATE_STATE.IDLE;
75
- this.failureParams.lowestLevelError = Math.min(failureParams.targetLevel, this.failureParams.lowestLevelError);
76
- }
77
- failure(timestamp, definitive, failureParams) {
78
- if (failureParams && failureParams.targetLevel != undefined) {
79
- this.failureParams.lowestLevelError = Math.min(failureParams.targetLevel, this.failureParams.lowestLevelError);
80
- }
81
- this.lastErrorTimestamp = timestamp;
82
- this.state = definitive ? UPDATE_STATE.DEFINITIVE_ERROR : UPDATE_STATE.ERROR;
83
- this.errorCount++;
84
- }
85
- inError() {
86
- return this.state == UPDATE_STATE.DEFINITIVE_ERROR || this.state == UPDATE_STATE.ERROR;
87
- }
88
- }
89
- export default LayerUpdateState;
@@ -1,80 +0,0 @@
1
- import { EMPTY_TEXTURE_ZOOM } from "../Renderer/RasterTile.js";
2
- /**
3
- * This modules implements various layer update strategies.
4
- *
5
- * Default strategy is STRATEGY_MIN_NETWORK_TRAFFIC which aims
6
- * to reduce the amount of network traffic.
7
- */
8
-
9
- export const STRATEGY_MIN_NETWORK_TRAFFIC = 0;
10
- export const STRATEGY_GROUP = 1;
11
- export const STRATEGY_PROGRESSIVE = 2;
12
- export const STRATEGY_DICHOTOMY = 3;
13
- function _minimizeNetworkTraffic(node, nodeLevel, currentLevel, source) {
14
- // TO DO source.isVectorTileSource is a temp fix for pendingSubdivision.
15
- // see issue https://github.com/iTowns/itowns/issues/2214
16
- if (node.pendingSubdivision && !source.isVectorTileSource) {
17
- return currentLevel;
18
- }
19
- return nodeLevel;
20
- }
21
-
22
- // Maps nodeLevel to groups defined in layer's options
23
- // eg with groups = [3, 7, 12]:
24
- // * nodeLevel = 2 -> 3
25
- // * nodeLevel = 4 -> 3
26
- // * nodeLevel = 7 -> 7
27
- // * nodeLevel = 15 -> 12
28
- function _group(nodeLevel, options) {
29
- const f = options.groups.filter(val => val <= nodeLevel);
30
- return f.length ? f[f.length - 1] : options.groups[0];
31
- }
32
- function _progressive(nodeLevel, currentLevel, options) {
33
- return Math.min(nodeLevel, currentLevel + (options.increment || 1));
34
- }
35
-
36
- // Load textures at mid-point between current level and node's level.
37
- // This produces smoother transitions and a single fetch updates multiple
38
- // tiles thanks to caching.
39
- function _dichotomy(nodeLevel, currentLevel) {
40
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
41
- if (currentLevel == EMPTY_TEXTURE_ZOOM) {
42
- return options.zoom ? options.zoom.min : 0;
43
- }
44
- return Math.min(nodeLevel, Math.ceil((currentLevel + nodeLevel) / 2));
45
- }
46
- export function chooseNextLevelToFetch(strategy, node) {
47
- let nodeLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : node.level;
48
- let currentLevel = arguments.length > 3 ? arguments[3] : undefined;
49
- let layer = arguments.length > 4 ? arguments[4] : undefined;
50
- let failureParams = arguments.length > 5 ? arguments[5] : undefined;
51
- let nextLevelToFetch;
52
- const maxZoom = layer.source.zoom ? layer.source.zoom.max : Infinity;
53
- if (failureParams.lowestLevelError != Infinity) {
54
- nextLevelToFetch = _dichotomy(failureParams.lowestLevelError, currentLevel, layer.source);
55
- nextLevelToFetch = failureParams.lowestLevelError == nextLevelToFetch ? nextLevelToFetch - 1 : nextLevelToFetch;
56
- if (strategy == STRATEGY_GROUP) {
57
- nextLevelToFetch = _group(nextLevelToFetch, layer.updateStrategy.options);
58
- }
59
- } else {
60
- switch (strategy) {
61
- case STRATEGY_GROUP:
62
- nextLevelToFetch = _group(nodeLevel, layer.updateStrategy.options);
63
- break;
64
- case STRATEGY_PROGRESSIVE:
65
- {
66
- nextLevelToFetch = _progressive(nodeLevel, currentLevel, layer.updateStrategy.options);
67
- break;
68
- }
69
- case STRATEGY_DICHOTOMY:
70
- nextLevelToFetch = _dichotomy(nodeLevel, currentLevel, layer.source);
71
- break;
72
- // default strategy
73
- case STRATEGY_MIN_NETWORK_TRAFFIC:
74
- default:
75
- nextLevelToFetch = _minimizeNetworkTraffic(node, nodeLevel, currentLevel, layer.source);
76
- }
77
- nextLevelToFetch = Math.min(nextLevelToFetch, maxZoom);
78
- }
79
- return nextLevelToFetch;
80
- }