itowns 2.44.3-next.8 → 2.45.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.
- package/README.md +3 -129
- package/examples/3dtiles_loader.html +123 -48
- package/examples/config.json +3 -10
- package/examples/copc_simple_loader.html +15 -5
- package/examples/effects_stereo.html +2 -2
- package/examples/entwine_3d_loader.html +3 -1
- package/examples/entwine_simple_loader.html +1 -1
- package/examples/images/itowns_logo.svg +123 -0
- package/examples/js/plugins/COGParser.js +1 -1
- package/examples/jsm/OGC3DTilesHelper.js +6 -1
- package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
- package/examples/misc_collada.html +2 -2
- package/examples/source_file_geojson_3d.html +0 -1
- package/examples/source_file_kml_raster_usgs.html +0 -1
- package/examples/source_stream_wfs_raster.html +0 -7
- package/examples/vector_tile_mapbox_raster.html +91 -0
- package/examples/view_3d_map_webxr.html +3 -1
- package/examples/view_multi_25d.html +2 -2
- package/package.json +21 -75
- package/CODING.md +0 -120
- package/CONTRIBUTING.md +0 -150
- package/CONTRIBUTORS.md +0 -55
- package/LICENSE.md +0 -44
- package/changelog.md +0 -1361
- package/dist/455.js +0 -2
- package/dist/455.js.map +0 -1
- package/dist/debug.js +0 -3
- package/dist/debug.js.LICENSE.txt +0 -13
- package/dist/debug.js.map +0 -1
- package/dist/itowns.js +0 -3
- package/dist/itowns.js.LICENSE.txt +0 -7
- package/dist/itowns.js.map +0 -1
- package/dist/itowns_lasparser.js +0 -2
- package/dist/itowns_lasparser.js.map +0 -1
- package/dist/itowns_lasworker.js +0 -2
- package/dist/itowns_lasworker.js.map +0 -1
- package/dist/itowns_potree2worker.js +0 -2
- package/dist/itowns_potree2worker.js.map +0 -1
- package/dist/itowns_widgets.js +0 -2
- package/dist/itowns_widgets.js.map +0 -1
- package/examples/.eslintrc.cjs +0 -35
- package/examples/3dtiles_25d.html +0 -120
- package/examples/3dtiles_basic.html +0 -94
- package/examples/3dtiles_batch_table.html +0 -86
- package/examples/3dtiles_ion.html +0 -126
- package/examples/3dtiles_pointcloud.html +0 -95
- package/examples/jsm/.eslintrc.cjs +0 -38
- package/lib/Controls/FirstPersonControls.js +0 -308
- package/lib/Controls/FlyControls.js +0 -175
- package/lib/Controls/GlobeControls.js +0 -1162
- package/lib/Controls/PlanarControls.js +0 -1025
- package/lib/Controls/StateControl.js +0 -429
- package/lib/Controls/StreetControls.js +0 -392
- package/lib/Converter/Feature2Mesh.js +0 -615
- package/lib/Converter/Feature2Texture.js +0 -170
- package/lib/Converter/convertToTile.js +0 -75
- package/lib/Converter/textureConverter.js +0 -44
- package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
- package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
- package/lib/Core/3DTiles/C3DTFeature.js +0 -110
- package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
- package/lib/Core/3DTiles/C3DTileset.js +0 -99
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
- package/lib/Core/AnimationPlayer.js +0 -142
- package/lib/Core/CopcNode.js +0 -174
- package/lib/Core/Deprecated/Undeprecator.js +0 -75
- package/lib/Core/EntwinePointTileNode.js +0 -126
- package/lib/Core/Feature.js +0 -490
- package/lib/Core/Geographic/CoordStars.js +0 -80
- package/lib/Core/Geographic/Coordinates.js +0 -320
- package/lib/Core/Geographic/Crs.js +0 -175
- package/lib/Core/Geographic/Extent.js +0 -534
- package/lib/Core/Geographic/GeoidGrid.js +0 -109
- package/lib/Core/Label.js +0 -222
- package/lib/Core/MainLoop.js +0 -211
- package/lib/Core/Math/Ellipsoid.js +0 -144
- package/lib/Core/Picking.js +0 -255
- package/lib/Core/PointCloudNode.js +0 -42
- package/lib/Core/Potree2Node.js +0 -206
- package/lib/Core/Potree2PointAttributes.js +0 -139
- package/lib/Core/PotreeNode.js +0 -101
- package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
- package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
- package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
- package/lib/Core/Prefab/GlobeView.js +0 -161
- package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
- package/lib/Core/Prefab/PlanarView.js +0 -62
- package/lib/Core/Prefab/TileBuilder.js +0 -80
- package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
- package/lib/Core/Scheduler/Cache.js +0 -256
- package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
- package/lib/Core/Scheduler/Scheduler.js +0 -294
- package/lib/Core/Style.js +0 -1121
- package/lib/Core/System/Capabilities.js +0 -63
- package/lib/Core/Tile/Tile.js +0 -219
- package/lib/Core/Tile/TileGrid.js +0 -46
- package/lib/Core/TileGeometry.js +0 -40
- package/lib/Core/TileMesh.js +0 -109
- package/lib/Core/View.js +0 -1109
- package/lib/Layer/C3DTilesLayer.js +0 -455
- package/lib/Layer/ColorLayer.js +0 -128
- package/lib/Layer/CopcLayer.js +0 -58
- package/lib/Layer/ElevationLayer.js +0 -107
- package/lib/Layer/EntwinePointTileLayer.js +0 -64
- package/lib/Layer/FeatureGeometryLayer.js +0 -63
- package/lib/Layer/GeoidLayer.js +0 -80
- package/lib/Layer/GeometryLayer.js +0 -202
- package/lib/Layer/InfoLayer.js +0 -64
- package/lib/Layer/LabelLayer.js +0 -456
- package/lib/Layer/Layer.js +0 -304
- package/lib/Layer/LayerUpdateState.js +0 -89
- package/lib/Layer/LayerUpdateStrategy.js +0 -80
- package/lib/Layer/OGC3DTilesLayer.js +0 -387
- package/lib/Layer/OrientedImageLayer.js +0 -222
- package/lib/Layer/PointCloudLayer.js +0 -359
- package/lib/Layer/Potree2Layer.js +0 -164
- package/lib/Layer/PotreeLayer.js +0 -65
- package/lib/Layer/RasterLayer.js +0 -27
- package/lib/Layer/ReferencingLayerProperties.js +0 -62
- package/lib/Layer/TiledGeometryLayer.js +0 -403
- package/lib/Loader/LASLoader.js +0 -193
- package/lib/Loader/Potree2BrotliLoader.js +0 -261
- package/lib/Loader/Potree2Loader.js +0 -207
- package/lib/Main.js +0 -115
- package/lib/MainBundle.js +0 -4
- package/lib/Parser/B3dmParser.js +0 -174
- package/lib/Parser/CameraCalibrationParser.js +0 -94
- package/lib/Parser/GDFParser.js +0 -72
- package/lib/Parser/GTXParser.js +0 -75
- package/lib/Parser/GeoJsonParser.js +0 -212
- package/lib/Parser/GpxParser.js +0 -25
- package/lib/Parser/ISGParser.js +0 -71
- package/lib/Parser/KMLParser.js +0 -25
- package/lib/Parser/LASParser.js +0 -137
- package/lib/Parser/MapBoxUrlParser.js +0 -83
- package/lib/Parser/PntsParser.js +0 -131
- package/lib/Parser/Potree2BinParser.js +0 -92
- package/lib/Parser/PotreeBinParser.js +0 -106
- package/lib/Parser/PotreeCinParser.js +0 -29
- package/lib/Parser/ShapefileParser.js +0 -78
- package/lib/Parser/VectorTileParser.js +0 -202
- package/lib/Parser/XbilParser.js +0 -119
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
- package/lib/Parser/iGLTFLoader.js +0 -168
- package/lib/Process/3dTilesProcessing.js +0 -304
- package/lib/Process/FeatureProcessing.js +0 -76
- package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
- package/lib/Process/ObjectRemovalHelper.js +0 -97
- package/lib/Process/handlerNodeError.js +0 -23
- package/lib/Provider/3dTilesProvider.js +0 -149
- package/lib/Provider/DataSourceProvider.js +0 -8
- package/lib/Provider/Fetcher.js +0 -229
- package/lib/Provider/PointCloudProvider.js +0 -45
- package/lib/Provider/TileProvider.js +0 -16
- package/lib/Provider/URLBuilder.js +0 -116
- package/lib/Renderer/Camera.js +0 -281
- package/lib/Renderer/Color.js +0 -56
- package/lib/Renderer/ColorLayersOrdering.js +0 -115
- package/lib/Renderer/CommonMaterial.js +0 -31
- package/lib/Renderer/Label2DRenderer.js +0 -190
- package/lib/Renderer/LayeredMaterial.js +0 -243
- package/lib/Renderer/OBB.js +0 -153
- package/lib/Renderer/OrientedImageCamera.js +0 -118
- package/lib/Renderer/OrientedImageMaterial.js +0 -167
- package/lib/Renderer/PointsMaterial.js +0 -485
- package/lib/Renderer/RasterTile.js +0 -209
- package/lib/Renderer/RenderMode.js +0 -31
- package/lib/Renderer/Shader/ShaderChunk.js +0 -160
- package/lib/Renderer/Shader/ShaderUtils.js +0 -47
- package/lib/Renderer/SphereHelper.js +0 -23
- package/lib/Renderer/WebXR.js +0 -51
- package/lib/Renderer/c3DEngine.js +0 -214
- package/lib/Source/C3DTilesGoogleSource.js +0 -74
- package/lib/Source/C3DTilesIonSource.js +0 -54
- package/lib/Source/C3DTilesSource.js +0 -30
- package/lib/Source/CopcSource.js +0 -115
- package/lib/Source/EntwinePointTileSource.js +0 -62
- package/lib/Source/FileSource.js +0 -189
- package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
- package/lib/Source/OGC3DTilesIonSource.js +0 -34
- package/lib/Source/OGC3DTilesSource.js +0 -21
- package/lib/Source/OrientedImageSource.js +0 -59
- package/lib/Source/Potree2Source.js +0 -167
- package/lib/Source/PotreeSource.js +0 -82
- package/lib/Source/Source.js +0 -223
- package/lib/Source/TMSSource.js +0 -145
- package/lib/Source/VectorTilesSource.js +0 -178
- package/lib/Source/WFSSource.js +0 -168
- package/lib/Source/WMSSource.js +0 -133
- package/lib/Source/WMTSSource.js +0 -86
- package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
- package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
- package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
- package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
- package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
- package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
- package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
- package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
- package/lib/Utils/CameraUtils.js +0 -555
- package/lib/Utils/DEMUtils.js +0 -350
- package/lib/Utils/FeaturesUtils.js +0 -156
- package/lib/Utils/Gradients.js +0 -16
- package/lib/Utils/OrientationUtils.js +0 -457
- package/lib/Utils/ThreeUtils.js +0 -115
- package/lib/Utils/gui/C3DTilesStyle.js +0 -215
- package/lib/Utils/gui/Main.js +0 -7
- package/lib/Utils/gui/Minimap.js +0 -154
- package/lib/Utils/gui/Navigation.js +0 -245
- package/lib/Utils/gui/Scale.js +0 -107
- package/lib/Utils/gui/Searchbar.js +0 -234
- package/lib/Utils/gui/Widget.js +0 -80
- package/lib/Utils/placeObjectOnGround.js +0 -137
- package/lib/Worker/LASLoaderWorker.js +0 -19
- 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/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 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
|
-
};
|
package/lib/Parser/XbilParser.js
DELETED
|
@@ -1,119 +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
|
-
// Clamp values to zmin and zmax values configured in ElevationLayer
|
|
71
|
-
if (options.zmin != null) {
|
|
72
|
-
if (min < options.zmin) {
|
|
73
|
-
min = options.zmin;
|
|
74
|
-
}
|
|
75
|
-
if (max < options.zmin) {
|
|
76
|
-
max = options.zmin;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (options.zmax != null) {
|
|
80
|
-
if (min > options.zmax) {
|
|
81
|
-
min = options.zmax;
|
|
82
|
-
}
|
|
83
|
-
if (max > options.zmax) {
|
|
84
|
-
max = options.zmax;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (max === -Infinity || min === Infinity) {
|
|
89
|
-
// Return null values means the elevation values are incoherent
|
|
90
|
-
// They can't be determined.
|
|
91
|
-
// Don't return 0, -Infinity or Infinity because the result will be wrong
|
|
92
|
-
return {
|
|
93
|
-
min: null,
|
|
94
|
-
max: null
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
return {
|
|
98
|
-
min,
|
|
99
|
-
max
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// We check if the elevation texture has some significant values through corners
|
|
105
|
-
export function checkNodeElevationTextureValidity(data, noDataValue) {
|
|
106
|
-
const l = data.length;
|
|
107
|
-
return data[0] > noDataValue && data[l - 1] > noDataValue && data[Math.sqrt(l) - 1] > noDataValue && data[l - Math.sqrt(l)] > noDataValue;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// This function replaces noDataValue by significant values from parent texture (or 0)
|
|
111
|
-
export function insertSignificantValuesFromParent(data) {
|
|
112
|
-
let dataParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => 0;
|
|
113
|
-
let noDataValue = arguments.length > 2 ? arguments[2] : undefined;
|
|
114
|
-
for (let i = 0, l = data.length; i < l; ++i) {
|
|
115
|
-
if (data[i] === noDataValue) {
|
|
116
|
-
data[i] = dataParent(i);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|