itowns 2.44.3-next.40 → 2.44.3-next.42

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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,78 +0,0 @@
1
- import proj4 from 'proj4';
2
- import shp from 'shpjs';
3
- import GeoJsonParser from "./GeoJsonParser.js";
4
- import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
5
-
6
- /**
7
- * The ShapefileParser module provides a [parse]{@link
8
- * module:ShapefileParser.parse} method that takes a bunch of files constituing
9
- * a shapefile in and gives an object formateted for iTowns, containing all
10
- * necessary informations to display this shapefile.
11
- *
12
- * It uses the [shpjs](https://www.npmjs.com/package/shpjs) library to
13
- * parse all the files.
14
- *
15
- * @example
16
- * // Load all the necessary files for a shapefile, parse them and
17
- * // display them using a FileSource.
18
- * Promise.all([
19
- * Fetcher.arrayBuffer('shapefile.shp'),
20
- * Fetcher.arrayBuffer('shapefile.dbf'),
21
- * Fetcher.arrayBuffer('shapefile.shx'),
22
- * Fetcher.text('shapefile.prj'),
23
- * ]).then(function _(res) {
24
- * return ShapefileParser.parse({
25
- * shp: res[0],
26
- * dbf: res[1],
27
- * shx: res[2],
28
- * prj: res[3],
29
- * }, {
30
- * in: {
31
- * crs: 'EPSG:4326',
32
- * },
33
- * out: {
34
- * crs: view.tileLayer.extent.crs,
35
- * }
36
- * });
37
- * }).then(function _(geojson) {
38
- * var source = new FileSource({ features: geojson });
39
- * var layer = new ColorLayer('velib', { source });
40
- * view.addLayer(layer);
41
- * });
42
- *
43
- *
44
- * @module ShapefileParser
45
- */
46
- export default {
47
- /**
48
- * Parse a bunch of Shapefile files and return a {@link FeatureCollection}.
49
- *
50
- * @param {Object} data - All the data that can be specified in a shapefile.
51
- * @param {ArrayBuffer} data.shp - Data from the shapefile itself,
52
- * containing the feature geometry itself.
53
- * @param {ArrayBuffer} data.shx - A positional index of the feature
54
- * geometry.
55
- * @param {ArrayBuffer} data.dbf - Columnar attributes for each shape, in
56
- * [dBase](https://en.wikipedia.org/wiki/DBase) IV format.
57
- * @param {string} [data.prj] - The coordinate system and crs projection
58
- * information.
59
- * @param {ParsingOptions} [options]
60
- *
61
- * @return {Promise} A promise resolving with a {@link FeatureCollection}.
62
- */
63
- parse(data) {
64
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
65
- options = deprecatedParsingOptionsToNewOne(options);
66
- let result;
67
-
68
- // If a zip is present, don't read anything else
69
- if (data.zip) {
70
- result = shp(data.zip);
71
- } else if (data.shp && data.shx && data.dbf) {
72
- result = shp(data);
73
- }
74
- options.in = options.in || {};
75
- options.in.crs = data.prj ? proj4(data.prj).oProj.datumName : options.in.crs;
76
- return Promise.resolve(result).then(res => GeoJsonParser.parse(res, options));
77
- }
78
- };
@@ -1,215 +0,0 @@
1
- import { Vector2, Vector3 } from 'three';
2
- import Protobuf from 'pbf';
3
- import { VectorTile } from '@mapbox/vector-tile';
4
- import { globalExtentTMS } from "../Core/Tile/TileGrid.js";
5
- import { FeatureCollection, FEATURE_TYPES } from "../Core/Feature.js";
6
- import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
7
- import Coordinates from "../Core/Geographic/Coordinates.js";
8
- const worldDimension3857 = globalExtentTMS.get('EPSG:3857').planarDimensions();
9
- const globalExtent = new Vector3(worldDimension3857.x, worldDimension3857.y, 1);
10
- const lastPoint = new Vector2();
11
- const firstPoint = new Vector2();
12
-
13
- // Calculate the projected coordinates in EPSG:4326 of a given point in the VT local system
14
- // adapted from @mapbox/vector-tile
15
- function project(x, y, tileNumbers, tileExtent) {
16
- const size = tileExtent * 2 ** tileNumbers.z;
17
- const x0 = tileExtent * tileNumbers.x;
18
- const y0 = tileExtent * tileNumbers.y;
19
- return new Coordinates('EPSG:4326', (x + x0) * 360 / size - 180, 360 / Math.PI * Math.atan(Math.exp((180 - (y + y0) * 360 / size) * Math.PI / 180)) - 90);
20
- }
21
-
22
- // Classify option, it allows to classify a full polygon and its holes.
23
- // Each polygon with its holes are in one FeatureGeometry.
24
- // A polygon is determined by its clockwise direction and the holes are in the opposite direction.
25
- // Clockwise direction is determined by Shoelace formula https://en.wikipedia.org/wiki/Shoelace_formula
26
- // Draw polygon with canvas doesn't need to classify however it is necessary for meshs.
27
- function vtFeatureToFeatureGeometry(vtFeature, feature) {
28
- let classify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
29
- let geometry = feature.bindNewGeometry();
30
- const isPolygon = feature.type === FEATURE_TYPES.POLYGON;
31
- classify = classify && isPolygon;
32
- geometry.properties = vtFeature.properties;
33
- const pbf = vtFeature._pbf;
34
- pbf.pos = vtFeature._geometry;
35
- const end = pbf.readVarint() + pbf.pos;
36
- let cmd = 1;
37
- let length = 0;
38
- let x = 0;
39
- let y = 0;
40
- let count = 0;
41
- let sum = 0;
42
- while (pbf.pos < end) {
43
- if (length <= 0) {
44
- const cmdLen = pbf.readVarint();
45
- cmd = cmdLen & 0x7;
46
- length = cmdLen >> 3;
47
- }
48
- length--;
49
- if (cmd === 1 || cmd === 2) {
50
- x += pbf.readSVarint();
51
- y += pbf.readSVarint();
52
- if (cmd === 1) {
53
- if (count) {
54
- if (classify && sum > 0 && geometry.indices.length > 0) {
55
- feature.updateExtent(geometry);
56
- geometry = feature.bindNewGeometry();
57
- geometry.properties = vtFeature.properties;
58
- }
59
- geometry.closeSubGeometry(count, feature);
60
- geometry.getLastSubGeometry().ccw = sum < 0;
61
- }
62
- count = 0;
63
- sum = 0;
64
- }
65
- count++;
66
- const coordProj = project(x, y, vtFeature.tileNumbers, vtFeature.extent);
67
- geometry.pushCoordinatesValues(feature, {
68
- x,
69
- y
70
- }, coordProj);
71
- if (count == 1) {
72
- firstPoint.set(x, y);
73
- firstPoint.coordProj = coordProj;
74
- lastPoint.set(x, y);
75
- } else if (isPolygon && count > 1) {
76
- sum += (lastPoint.x - x) * (lastPoint.y + y);
77
- lastPoint.set(x, y);
78
- }
79
- } else if (cmd === 7) {
80
- if (count) {
81
- count++;
82
- geometry.pushCoordinatesValues(feature, {
83
- x: firstPoint.x,
84
- y: firstPoint.y
85
- }, firstPoint.coordProj);
86
- if (isPolygon) {
87
- sum += (lastPoint.x - firstPoint.x) * (lastPoint.y + firstPoint.y);
88
- }
89
- }
90
- } else {
91
- throw new Error(`unknown command ${cmd}`);
92
- }
93
- }
94
- if (count) {
95
- if (classify && sum > 0 && geometry.indices.length > 0) {
96
- feature.updateExtent(geometry);
97
- geometry = feature.bindNewGeometry();
98
- geometry.properties = vtFeature.properties;
99
- }
100
- geometry.closeSubGeometry(count, feature);
101
- geometry.getLastSubGeometry().ccw = sum < 0;
102
- }
103
- feature.updateExtent(geometry);
104
- }
105
- function readPBF(file, options) {
106
- options.out = options.out || {};
107
- const vectorTile = new VectorTile(new Protobuf(file));
108
- const vtLayerNames = Object.keys(vectorTile.layers);
109
- const collection = new FeatureCollection(options.out);
110
- if (vtLayerNames.length < 1) {
111
- return Promise.resolve(collection);
112
- }
113
-
114
- // x,y,z tile coordinates
115
- const x = options.extent.col;
116
- const z = options.extent.zoom;
117
- // We need to move from TMS to Google/Bing/OSM coordinates
118
- // https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
119
- // Only if the layer.origin is top
120
- const y = options.in.isInverted ? options.extent.row : (1 << z) - options.extent.row - 1;
121
- const vFeature0 = vectorTile.layers[vtLayerNames[0]];
122
- // TODO: verify if size is correct because is computed with only one feature (vFeature0).
123
- const size = vFeature0.extent * 2 ** z;
124
- const center = -0.5 * size;
125
- collection.scale.set(globalExtent.x / size, -globalExtent.y / size, 1);
126
- collection.position.set(vFeature0.extent * x + center, vFeature0.extent * y + center, 0).multiply(collection.scale);
127
- collection.updateMatrixWorld();
128
- vtLayerNames.forEach(vtLayerName => {
129
- if (!options.in.layers[vtLayerName]) {
130
- return Promise.resolve(collection);
131
- }
132
- const vectorTileLayer = vectorTile.layers[vtLayerName];
133
- for (let i = vectorTileLayer.length - 1; i >= 0; i--) {
134
- const vtFeature = vectorTileLayer.feature(i);
135
- vtFeature.tileNumbers = {
136
- x,
137
- y: options.extent.row,
138
- z
139
- };
140
- // Find layers where this vtFeature is used
141
- const layers = options.in.layers[vtLayerName].filter(l => l.filterExpression.filter({
142
- zoom: z
143
- }, vtFeature));
144
- for (const layer of layers) {
145
- const feature = collection.requestFeatureById(layer.id, vtFeature.type - 1);
146
- feature.id = layer.id;
147
- feature.order = layer.order;
148
- feature.style = options.in.styles[feature.id];
149
- vtFeatureToFeatureGeometry(vtFeature, feature);
150
- }
151
-
152
- /*
153
- // This optimization is not fully working and need to be reassessed
154
- // (see https://github.com/iTowns/itowns/pull/2469/files#r1861802136)
155
- let feature;
156
- for (const layer of layers) {
157
- if (!feature) {
158
- feature = collection.requestFeatureById(layer.id, vtFeature.type - 1);
159
- feature.id = layer.id;
160
- feature.order = layer.order;
161
- feature.style = options.in.styles[feature.id];
162
- vtFeatureToFeatureGeometry(vtFeature, feature);
163
- } else if (!collection.features.find(f => f.id === layer.id)) {
164
- feature = collection.newFeatureByReference(feature);
165
- feature.id = layer.id;
166
- feature.order = layer.order;
167
- feature.style = options.in.styles[feature.id];
168
- }
169
- }
170
- */
171
- }
172
- });
173
- collection.removeEmptyFeature();
174
- // TODO Some vector tiles are already sorted
175
- collection.features.sort((a, b) => a.order - b.order);
176
- // TODO verify if is needed to updateExtent for previous features.
177
- collection.updateExtent();
178
- collection.extent = options.extent;
179
- collection.isInverted = options.in.isInverted;
180
- return Promise.resolve(collection);
181
- }
182
-
183
- /**
184
- * @module VectorTileParser
185
- */
186
- export default {
187
- /**
188
- * Parse a vector tile file and return a [Feature]{@link module:GeoJsonParser.Feature}
189
- * or an array of Features. While multiple formats of vector tile are
190
- * available, the only one supported for the moment is the
191
- * [Mapbox Vector Tile](https://www.mapbox.com/vector-tiles/specification/).
192
- *
193
- * @param {ArrayBuffer} file - The vector tile file to parse.
194
- *
195
- * @param {Object} options - Options controlling the parsing {@link ParsingOptions}.
196
- *
197
- * @param {Object} options.in - Object containing all styles,
198
- * layers and informations data, see {@link InformationsData}.
199
- *
200
- * @param {Object} options.in.styles - Object containing subobject with
201
- * informations on a specific style layer. Styles available is by `layer.id` and by zoom.
202
- *
203
- * @param {Object} options.in.layers - Object containing subobject with
204
- *
205
- * @param {FeatureBuildingOptions} options.out - options indicates how the features should be built,
206
- * see {@link FeatureBuildingOptions}.
207
- *
208
- * @return {Promise} A Promise resolving with a Feature or an array a
209
- * Features.
210
- */
211
- parse(file, options) {
212
- options = deprecatedParsingOptionsToNewOne(options);
213
- return Promise.resolve(readPBF(file, options));
214
- }
215
- };
@@ -1,120 +0,0 @@
1
- import { readTextureValueWithBilinearFiltering } from "../Utils/DEMUtils.js";
2
- function minMax4Corners(texture, pitch, options) {
3
- const u = pitch.x;
4
- const v = pitch.y;
5
- const w = pitch.z;
6
- const z = [readTextureValueWithBilinearFiltering(options, texture, u, v), readTextureValueWithBilinearFiltering(options, texture, u + w, v), readTextureValueWithBilinearFiltering(options, texture, u + w, v + w), readTextureValueWithBilinearFiltering(options, texture, u, v + w)].filter(val => val != undefined);
7
- if (z.length) {
8
- return {
9
- min: Math.min(...z),
10
- max: Math.max(...z)
11
- };
12
- } else {
13
- return {
14
- min: Infinity,
15
- max: -Infinity
16
- };
17
- }
18
- }
19
-
20
- /**
21
- * Calculates the minimum maximum texture elevation with xbil data
22
- *
23
- * @param {THREE.Texture} texture The texture to parse
24
- * @param {THREE.Vector4} pitch The pitch, restrict zone to parse
25
- * @param {Object} options No data value and clamp values
26
- * @param {number} options.noDataValue No data value
27
- * @param {number} [options.zmin] The minimum elevation value after which it will be clamped
28
- * @param {number} [options.zmax] The maximum elevation value after which it will be clamped
29
- * @return {Object} The minimum and maximum elevation.
30
- */
31
- export function computeMinMaxElevation(texture, pitch, options) {
32
- const {
33
- width,
34
- height,
35
- data
36
- } = texture.image;
37
- if (!data) {
38
- // Return null values means there's no elevation values.
39
- // They can't be determined.
40
- // Don't return 0 because the result will be wrong
41
- return {
42
- min: null,
43
- max: null
44
- };
45
- }
46
-
47
- // compute the minimum and maximum elevation on the 4 corners texture.
48
- let {
49
- min,
50
- max
51
- } = minMax4Corners(texture, pitch, options);
52
- const sizeX = Math.floor(pitch.z * width);
53
- if (sizeX > 2) {
54
- const sizeY = Math.floor(pitch.z * height);
55
- const xs = Math.floor(pitch.x * width);
56
- const ys = Math.floor(pitch.y * height);
57
- const inc = Math.max(Math.floor(sizeX / 32), 2);
58
- for (let y = ys; y < ys + sizeY; y += inc) {
59
- const pit = y * (width || 0);
60
- let x = pit + xs;
61
- const limX = x + sizeX;
62
- for (x; x < limX; x += inc) {
63
- const val = data[x];
64
- if (val !== options.noDataValue) {
65
- max = Math.max(max, val);
66
- min = Math.min(min, val);
67
- }
68
- }
69
- }
70
- }
71
-
72
- // Clamp values to zmin and zmax values configured in ElevationLayer
73
- if (options.zmin != null) {
74
- if (min < options.zmin) {
75
- min = options.zmin;
76
- }
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) {
86
- max = options.zmax;
87
- }
88
- }
89
- if (max === -Infinity || min === Infinity) {
90
- // Return null values means the elevation values are incoherent
91
- // They can't be determined.
92
- // Don't return 0, -Infinity or Infinity because the result will be wrong
93
- return {
94
- min: null,
95
- max: null
96
- };
97
- } else {
98
- return {
99
- min,
100
- max
101
- };
102
- }
103
- }
104
-
105
- // We check if the elevation texture has some significant values through corners
106
- export function checkNodeElevationTextureValidity(data, noDataValue) {
107
- const l = data.length;
108
- return data[0] > noDataValue && data[l - 1] > noDataValue && data[Math.sqrt(l) - 1] > noDataValue && data[l - Math.sqrt(l)] > noDataValue;
109
- }
110
-
111
- // This function replaces noDataValue by significant values from parent texture (or 0)
112
- export function insertSignificantValuesFromParent(data) {
113
- let dataParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => 0;
114
- let noDataValue = arguments.length > 2 ? arguments[2] : undefined;
115
- for (let i = 0, l = data.length; i < l; ++i) {
116
- if (data[i] === noDataValue) {
117
- data[i] = dataParent(i);
118
- }
119
- }
120
- }