itowns 2.44.3-next.4 → 2.44.3-next.41

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 (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  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/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. 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,202 +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/Geographic/Extent.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 sourceLayers = Object.keys(vectorTile.layers);
109
- if (sourceLayers.length < 1) {
110
- return;
111
- }
112
-
113
- // x,y,z tile coordinates
114
- const x = options.extent.col;
115
- const z = options.extent.zoom;
116
- // We need to move from TMS to Google/Bing/OSM coordinates
117
- // https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
118
- // Only if the layer.origin is top
119
- const y = options.in.isInverted ? options.extent.row : (1 << z) - options.extent.row - 1;
120
- const collection = new FeatureCollection(options.out);
121
- const vFeature = vectorTile.layers[sourceLayers[0]];
122
- // TODO: verify if size is correct because is computed with only one feature (vFeature).
123
- const size = vFeature.extent * 2 ** z;
124
- const center = -0.5 * size;
125
- collection.scale.set(globalExtent.x / size, -globalExtent.y / size, 1);
126
- collection.position.set(vFeature.extent * x + center, vFeature.extent * y + center, 0).multiply(collection.scale);
127
- collection.updateMatrixWorld();
128
- sourceLayers.forEach(layer_id => {
129
- if (!options.in.layers[layer_id]) {
130
- return;
131
- }
132
- const sourceLayer = vectorTile.layers[layer_id];
133
- for (let i = sourceLayer.length - 1; i >= 0; i--) {
134
- const vtFeature = sourceLayer.feature(i);
135
- vtFeature.tileNumbers = {
136
- x,
137
- y: options.extent.row,
138
- z
139
- };
140
- const layers = options.in.layers[layer_id].filter(l => l.filterExpression.filter({
141
- zoom: z
142
- }, vtFeature) && z >= l.zoom.min && z < l.zoom.max);
143
- let feature;
144
- for (const layer of layers) {
145
- if (!feature) {
146
- feature = collection.requestFeatureById(layer.id, vtFeature.type - 1);
147
- feature.id = layer.id;
148
- feature.order = layer.order;
149
- feature.style = options.in.styles[feature.id];
150
- vtFeatureToFeatureGeometry(vtFeature, feature);
151
- } else if (!collection.features.find(f => f.id === layer.id)) {
152
- feature = collection.newFeatureByReference(feature);
153
- feature.id = layer.id;
154
- feature.order = layer.order;
155
- feature.style = options.in.styles[feature.id];
156
- }
157
- }
158
- }
159
- });
160
- collection.removeEmptyFeature();
161
- // TODO Some vector tiles are already sorted
162
- collection.features.sort((a, b) => a.order - b.order);
163
- // TODO verify if is needed to updateExtent for previous features.
164
- collection.updateExtent();
165
- collection.extent = options.extent;
166
- collection.isInverted = options.in.isInverted;
167
- return Promise.resolve(collection);
168
- }
169
-
170
- /**
171
- * @module VectorTileParser
172
- */
173
- export default {
174
- /**
175
- * Parse a vector tile file and return a [Feature]{@link module:GeoJsonParser.Feature}
176
- * or an array of Features. While multiple formats of vector tile are
177
- * available, the only one supported for the moment is the
178
- * [Mapbox Vector Tile](https://www.mapbox.com/vector-tiles/specification/).
179
- *
180
- * @param {ArrayBuffer} file - The vector tile file to parse.
181
- *
182
- * @param {Object} options - Options controlling the parsing {@link ParsingOptions}.
183
- *
184
- * @param {Object} options.in - Object containing all styles,
185
- * layers and informations data, see {@link InformationsData}.
186
- *
187
- * @param {Object} options.in.styles - Object containing subobject with
188
- * informations on a specific style layer. Styles available is by `layer.id` and by zoom.
189
- *
190
- * @param {Object} options.in.layers - Object containing subobject with
191
- *
192
- * @param {FeatureBuildingOptions} options.out - options indicates how the features should be built,
193
- * see {@link FeatureBuildingOptions}.
194
- *
195
- * @return {Promise} A Promise resolving with a Feature or an array a
196
- * Features.
197
- */
198
- parse(file, options) {
199
- options = deprecatedParsingOptionsToNewOne(options);
200
- return Promise.resolve(readPBF(file, options));
201
- }
202
- };
@@ -1,108 +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
- if (options.zmin > min) {
71
- min = options.zmin;
72
- }
73
- if (options.zmax < max) {
74
- max = options.zmax;
75
- }
76
- }
77
- if (max === -Infinity || min === Infinity) {
78
- // Return null values means the elevation values are incoherent
79
- // They can't be determined.
80
- // Don't return 0, -Infinity or Infinity because the result will be wrong
81
- return {
82
- min: null,
83
- max: null
84
- };
85
- } else {
86
- return {
87
- min,
88
- max
89
- };
90
- }
91
- }
92
-
93
- // We check if the elevation texture has some significant values through corners
94
- export function checkNodeElevationTextureValidity(data, noDataValue) {
95
- const l = data.length;
96
- return data[0] > noDataValue && data[l - 1] > noDataValue && data[Math.sqrt(l) - 1] > noDataValue && data[l - Math.sqrt(l)] > noDataValue;
97
- }
98
-
99
- // This function replaces noDataValue by significant values from parent texture (or 0)
100
- export function insertSignificantValuesFromParent(data) {
101
- let dataParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => 0;
102
- let noDataValue = arguments.length > 2 ? arguments[2] : undefined;
103
- for (let i = 0, l = data.length; i < l; ++i) {
104
- if (data[i] === noDataValue) {
105
- data[i] = dataParent(i);
106
- }
107
- }
108
- }