itowns 2.42.1-next.9 → 2.43.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.
- package/changelog.md +90 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/examples/effects_stereo.html +2 -2
- package/examples/misc_collada.html +2 -2
- package/examples/source_stream_wfs_25d.html +11 -11
- package/examples/source_stream_wfs_3d.html +1 -1
- package/examples/view_25d_map.html +2 -2
- package/examples/view_3d_map.html +2 -2
- package/examples/view_3d_map_webxr.html +1 -1
- package/examples/view_3d_mns_map.html +2 -2
- package/examples/view_immersive.html +1 -1
- package/examples/view_multi_25d.html +2 -2
- package/examples/widgets_searchbar.html +2 -2
- package/lib/Controls/FirstPersonControls.js +5 -12
- package/lib/Controls/FlyControls.js +4 -13
- package/lib/Controls/GlobeControls.js +33 -43
- package/lib/Controls/PlanarControls.js +9 -20
- package/lib/Controls/StateControl.js +2 -11
- package/lib/Controls/StreetControls.js +14 -24
- package/lib/Converter/Feature2Mesh.js +28 -38
- package/lib/Converter/Feature2Texture.js +15 -25
- package/lib/Converter/convertToTile.js +16 -26
- package/lib/Converter/textureConverter.js +9 -19
- package/lib/Core/3DTiles/C3DTBatchTable.js +5 -13
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +1 -8
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +17 -27
- package/lib/Core/3DTiles/C3DTExtensions.js +1 -8
- package/lib/Core/3DTiles/C3DTFeature.js +3 -10
- package/lib/Core/3DTiles/C3DTilesEnums.js +3 -11
- package/lib/Core/3DTiles/C3DTileset.js +7 -16
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +5 -11
- package/lib/Core/AnimationPlayer.js +2 -11
- package/lib/Core/Deprecated/Undeprecator.js +9 -20
- package/lib/Core/EntwinePointTileNode.js +6 -16
- package/lib/Core/Feature.js +16 -30
- package/lib/Core/Geographic/CoordStars.js +3 -12
- package/lib/Core/Geographic/Coordinates.js +12 -22
- package/lib/Core/Geographic/Crs.js +7 -15
- package/lib/Core/Geographic/Extent.js +36 -47
- package/lib/Core/Geographic/GeoidGrid.js +6 -16
- package/lib/Core/Label.js +7 -17
- package/lib/Core/MainLoop.js +7 -16
- package/lib/Core/Math/Ellipsoid.js +6 -17
- package/lib/Core/Picking.js +10 -20
- package/lib/Core/PointCloudNode.js +2 -11
- package/lib/Core/PotreeNode.js +4 -13
- package/lib/Core/Prefab/Globe/Atmosphere.js +17 -26
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +6 -16
- package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -28
- package/lib/Core/Prefab/Globe/SkyShader.js +2 -11
- package/lib/Core/Prefab/GlobeView.js +27 -45
- package/lib/Core/Prefab/Planar/PlanarLayer.js +11 -20
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +6 -16
- package/lib/Core/Prefab/PlanarView.js +10 -25
- package/lib/Core/Prefab/TileBuilder.js +13 -22
- package/lib/Core/Prefab/computeBufferTileGeometry.js +12 -16
- package/lib/Core/Scheduler/Cache.js +2 -10
- package/lib/Core/Scheduler/CancelledCommandException.js +1 -8
- package/lib/Core/Scheduler/Scheduler.js +15 -23
- package/lib/Core/Style.js +24 -38
- package/lib/Core/System/Capabilities.js +2 -13
- package/lib/Core/TileGeometry.js +13 -15
- package/lib/Core/TileMesh.js +6 -15
- package/lib/Core/View.js +43 -58
- package/lib/Layer/C3DTilesLayer.js +29 -41
- package/lib/Layer/ColorLayer.js +10 -16
- package/lib/Layer/ElevationLayer.js +7 -14
- package/lib/Layer/EntwinePointTileLayer.js +9 -18
- package/lib/Layer/FeatureGeometryLayer.js +9 -16
- package/lib/Layer/GeoidLayer.js +6 -15
- package/lib/Layer/GeometryLayer.js +11 -17
- package/lib/Layer/InfoLayer.js +5 -14
- package/lib/Layer/LabelLayer.js +22 -32
- package/lib/Layer/Layer.js +16 -26
- package/lib/Layer/LayerUpdateState.js +1 -8
- package/lib/Layer/LayerUpdateStrategy.js +7 -18
- package/lib/Layer/OrientedImageLayer.js +15 -25
- package/lib/Layer/PointCloudLayer.js +9 -19
- package/lib/Layer/PotreeLayer.js +8 -18
- package/lib/Layer/RasterLayer.js +9 -17
- package/lib/Layer/ReferencingLayerProperties.js +1 -8
- package/lib/Layer/TiledGeometryLayer.js +37 -33
- package/lib/Main.js +87 -708
- package/lib/MainBundle.js +4 -34
- package/lib/Parser/B3dmParser.js +80 -131
- package/lib/Parser/CameraCalibrationParser.js +5 -14
- package/lib/Parser/GDFParser.js +11 -22
- package/lib/Parser/GLTFParser.js +88 -0
- package/lib/Parser/GTXParser.js +9 -21
- package/lib/Parser/GeoJsonParser.js +14 -22
- package/lib/Parser/GpxParser.js +7 -14
- package/lib/Parser/ISGParser.js +19 -28
- package/lib/Parser/KMLParser.js +7 -14
- package/lib/Parser/LASLoader.js +20 -21
- package/lib/Parser/LASParser.js +6 -15
- package/lib/Parser/MapBoxUrlParser.js +2 -9
- package/lib/Parser/PntsParser.js +4 -14
- package/lib/Parser/PotreeBinParser.js +8 -16
- package/lib/Parser/PotreeCinParser.js +3 -12
- package/lib/Parser/ShapefileParser.js +11 -18
- package/lib/Parser/VectorTileParser.js +23 -31
- package/lib/Parser/XbilParser.js +5 -13
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +2 -12
- package/lib/Process/3dTilesProcessing.js +14 -27
- package/lib/Process/FeatureProcessing.js +14 -22
- package/lib/Process/LayeredMaterialNodeProcessing.js +14 -26
- package/lib/Process/ObjectRemovalHelper.js +2 -9
- package/lib/Process/handlerNodeError.js +1 -7
- package/lib/Provider/3dTilesProvider.js +32 -29
- package/lib/Provider/DataSourceProvider.js +2 -9
- package/lib/Provider/Fetcher.js +40 -22
- package/lib/Provider/PointCloudProvider.js +7 -19
- package/lib/Provider/TileProvider.js +4 -12
- package/lib/Provider/URLBuilder.js +4 -12
- package/lib/Renderer/Camera.js +7 -17
- package/lib/Renderer/Color.js +3 -11
- package/lib/Renderer/ColorLayersOrdering.js +14 -22
- package/lib/Renderer/CommonMaterial.js +3 -12
- package/lib/Renderer/Label2DRenderer.js +5 -16
- package/lib/Renderer/LayeredMaterial.js +33 -53
- package/lib/Renderer/OBB.js +12 -21
- package/lib/Renderer/OrientedImageCamera.js +2 -11
- package/lib/Renderer/OrientedImageMaterial.js +17 -35
- package/lib/Renderer/PointsMaterial.js +37 -60
- package/lib/Renderer/RasterTile.js +16 -29
- package/lib/Renderer/RenderMode.js +2 -9
- package/lib/Renderer/Shader/ShaderChunk.js +5 -23
- package/lib/Renderer/Shader/ShaderUtils.js +2 -9
- package/lib/Renderer/SphereHelper.js +2 -11
- package/lib/Renderer/WebXR.js +2 -11
- package/lib/Renderer/c3DEngine.js +20 -53
- package/lib/Source/C3DTilesGoogleSource.js +76 -0
- package/lib/Source/C3DTilesIonSource.js +6 -13
- package/lib/Source/C3DTilesSource.js +5 -12
- package/lib/Source/EntwinePointTileSource.js +12 -19
- package/lib/Source/FileSource.js +7 -14
- package/lib/Source/OrientedImageSource.js +6 -14
- package/lib/Source/PotreeSource.js +9 -16
- package/lib/Source/Source.js +26 -39
- package/lib/Source/TMSSource.js +11 -22
- package/lib/Source/VectorTilesSource.js +75 -34
- package/lib/Source/WFSSource.js +7 -14
- package/lib/Source/WMSSource.js +5 -12
- package/lib/Source/WMTSSource.js +3 -10
- package/lib/ThreeExtended/capabilities/WebGL.js +1 -8
- package/lib/ThreeExtended/libs/ktx-parse.module.js +2 -256
- package/lib/ThreeExtended/libs/zstddec.module.js +2 -8
- package/lib/ThreeExtended/loaders/DDSLoader.js +10 -16
- package/lib/ThreeExtended/loaders/DRACOLoader.js +14 -19
- package/lib/ThreeExtended/loaders/GLTFLoader.js +124 -129
- package/lib/ThreeExtended/loaders/KTX2Loader.js +73 -78
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +40 -59
- package/lib/ThreeExtended/utils/WorkerPool.js +2 -9
- package/lib/Utils/CameraUtils.js +32 -44
- package/lib/Utils/DEMUtils.js +8 -19
- package/lib/Utils/FeaturesUtils.js +8 -16
- package/lib/Utils/Gradients.js +3 -12
- package/lib/Utils/OrientationUtils.js +8 -18
- package/lib/Utils/ThreeUtils.js +2 -9
- package/lib/Utils/gui/C3DTilesStyle.js +7 -15
- package/lib/Utils/gui/Main.js +7 -48
- package/lib/Utils/gui/Minimap.js +12 -20
- package/lib/Utils/gui/Navigation.js +6 -14
- package/lib/Utils/gui/Scale.js +11 -19
- package/lib/Utils/gui/Searchbar.js +5 -13
- package/lib/Utils/gui/Widget.js +1 -8
- package/lib/Utils/placeObjectOnGround.js +13 -23
- package/package.json +13 -8
package/lib/Parser/GpxParser.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { gpx } from '@tmcw/togeojson';
|
|
2
|
+
import GeoJsonParser from "./GeoJsonParser.js";
|
|
3
|
+
import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
|
|
2
4
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _togeojson = require("@tmcw/togeojson");
|
|
9
|
-
var _GeoJsonParser = _interopRequireDefault(require("./GeoJsonParser"));
|
|
10
|
-
var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
11
5
|
/**
|
|
12
6
|
* The GpxParser module provides a [parse]{@link module:GpxParser.parse}
|
|
13
7
|
* method that takes a GPX in and gives an object formatted for iTowns
|
|
@@ -15,7 +9,7 @@ var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
|
15
9
|
*
|
|
16
10
|
* @module GpxParser
|
|
17
11
|
*/
|
|
18
|
-
|
|
12
|
+
export default {
|
|
19
13
|
/**
|
|
20
14
|
* Parse a GPX file content and return a [FeatureCollection]{@link
|
|
21
15
|
* module:GeoJsonParser~FeatureCollection}.
|
|
@@ -27,8 +21,7 @@ var _default = {
|
|
|
27
21
|
* module:GeoJsonParser~FeatureCollection}.
|
|
28
22
|
*/
|
|
29
23
|
parse(gpxFile, options) {
|
|
30
|
-
options =
|
|
31
|
-
return
|
|
24
|
+
options = deprecatedParsingOptionsToNewOne(options);
|
|
25
|
+
return GeoJsonParser.parse(gpx(gpxFile), options);
|
|
32
26
|
}
|
|
33
|
-
};
|
|
34
|
-
exports.default = _default;
|
|
27
|
+
};
|
package/lib/Parser/ISGParser.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import GeoidGrid from "../Core/Geographic/GeoidGrid.js";
|
|
3
|
+
import Extent from "../Core/Geographic/Extent.js";
|
|
4
|
+
import { getHeaderAttribute } from "./GDFParser.js";
|
|
5
|
+
import { BYTES_PER_DOUBLE } from "./GTXParser.js";
|
|
2
6
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _GeoidGrid = _interopRequireDefault(require("../Core/Geographic/GeoidGrid"));
|
|
10
|
-
var _Extent = _interopRequireDefault(require("../Core/Geographic/Extent"));
|
|
11
|
-
var _GDFParser = require("./GDFParser");
|
|
12
|
-
var _GTXParser = require("./GTXParser");
|
|
13
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
7
|
/**
|
|
16
8
|
* The `ISGParser` module provides a `[parse]{@link module:ISGParser.parse}` method. This method takes the content of a
|
|
17
9
|
* ISG file in, and returns a `{@link GeoidGrid}`. the `{@link GeoidGrid}` contains all the necessary attributes and
|
|
@@ -19,7 +11,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
19
11
|
*
|
|
20
12
|
* @module ISGParser
|
|
21
13
|
*/
|
|
22
|
-
|
|
14
|
+
export default {
|
|
23
15
|
/**
|
|
24
16
|
* Parses an ISG file content and returns a corresponding `{@link GeoidGrid}`.
|
|
25
17
|
*
|
|
@@ -45,19 +37,19 @@ var _default = {
|
|
|
45
37
|
// ---------- GET METADATA FROM THE FILE : ----------
|
|
46
38
|
|
|
47
39
|
const metadata = {
|
|
48
|
-
minX:
|
|
49
|
-
maxX:
|
|
50
|
-
minY:
|
|
51
|
-
maxY:
|
|
52
|
-
stepX:
|
|
53
|
-
stepY:
|
|
54
|
-
nRows:
|
|
55
|
-
nColumns:
|
|
40
|
+
minX: getHeaderAttribute(rawHeaderData, 'lon min'),
|
|
41
|
+
maxX: getHeaderAttribute(rawHeaderData, 'lon max'),
|
|
42
|
+
minY: getHeaderAttribute(rawHeaderData, 'lat min'),
|
|
43
|
+
maxY: getHeaderAttribute(rawHeaderData, 'lat max'),
|
|
44
|
+
stepX: getHeaderAttribute(rawHeaderData, 'delta lon'),
|
|
45
|
+
stepY: getHeaderAttribute(rawHeaderData, 'delta lat'),
|
|
46
|
+
nRows: getHeaderAttribute(rawHeaderData, 'nrows'),
|
|
47
|
+
nColumns: getHeaderAttribute(rawHeaderData, 'ncols')
|
|
56
48
|
};
|
|
57
49
|
|
|
58
50
|
// ---------- BUILD A DATA VIEWER FROM THE TEXT DATA : ----------
|
|
59
51
|
|
|
60
|
-
const data = new DataView(new ArrayBuffer(
|
|
52
|
+
const data = new DataView(new ArrayBuffer(BYTES_PER_DOUBLE * metadata.nRows * metadata.nColumns));
|
|
61
53
|
let index = 0;
|
|
62
54
|
for (let row of rows.slice(firstMeasureLine, rows.length)) {
|
|
63
55
|
row = row.split(' ').filter(value => value !== '');
|
|
@@ -65,16 +57,15 @@ var _default = {
|
|
|
65
57
|
continue;
|
|
66
58
|
}
|
|
67
59
|
for (const value of row) {
|
|
68
|
-
data.setFloat64(index *
|
|
60
|
+
data.setFloat64(index * BYTES_PER_DOUBLE, parseFloat(value));
|
|
69
61
|
index++;
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
64
|
|
|
73
65
|
// ---------- CREATE A GeoidGrid FOR THE GIVEN FILE DATA : ----------
|
|
74
66
|
|
|
75
|
-
const dataExtent = new
|
|
67
|
+
const dataExtent = new Extent(options.in.crs || 'EPSG:4326', metadata.minX + metadata.stepX / 2, metadata.maxX - metadata.stepX / 2, metadata.minY + metadata.stepY / 2, metadata.maxY - metadata.stepY / 2);
|
|
76
68
|
const dataStep = new THREE.Vector2(metadata.stepX, metadata.stepY);
|
|
77
|
-
return Promise.resolve(new
|
|
69
|
+
return Promise.resolve(new GeoidGrid(dataExtent, dataStep, (verticalIndex, horizontalIndex) => data.getFloat64((metadata.nColumns * verticalIndex + horizontalIndex) * BYTES_PER_DOUBLE)));
|
|
78
70
|
}
|
|
79
|
-
};
|
|
80
|
-
exports.default = _default;
|
|
71
|
+
};
|
package/lib/Parser/KMLParser.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { kml } from '@tmcw/togeojson';
|
|
2
|
+
import GeoJsonParser from "./GeoJsonParser.js";
|
|
3
|
+
import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
|
|
2
4
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _togeojson = require("@tmcw/togeojson");
|
|
9
|
-
var _GeoJsonParser = _interopRequireDefault(require("./GeoJsonParser"));
|
|
10
|
-
var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
11
5
|
/**
|
|
12
6
|
* The KMLParser module provides a [parse]{@link module:KMLParser.parse}
|
|
13
7
|
* method that takes a KML in and gives an object formatted for iTowns
|
|
@@ -15,7 +9,7 @@ var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
|
15
9
|
*
|
|
16
10
|
* @module KMLParser
|
|
17
11
|
*/
|
|
18
|
-
|
|
12
|
+
export default {
|
|
19
13
|
/**
|
|
20
14
|
* Parse a KML file content and return a [FeatureCollection]{@link
|
|
21
15
|
* module:GeoJsonParser~FeatureCollection}.
|
|
@@ -27,8 +21,7 @@ var _default = {
|
|
|
27
21
|
* module:GeoJsonParser~FeatureCollection}.
|
|
28
22
|
*/
|
|
29
23
|
parse(kmlFile, options) {
|
|
30
|
-
options =
|
|
31
|
-
return
|
|
24
|
+
options = deprecatedParsingOptionsToNewOne(options);
|
|
25
|
+
return GeoJsonParser.parse(kml(kmlFile), options);
|
|
32
26
|
}
|
|
33
|
-
};
|
|
34
|
-
exports.default = _default;
|
|
27
|
+
};
|
package/lib/Parser/LASLoader.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { LazPerf } from 'laz-perf';
|
|
2
|
+
import { Las } from 'copc';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _lazPerf = require("laz-perf");
|
|
8
|
-
var _copc = require("copc");
|
|
9
4
|
/**
|
|
10
5
|
* @typedef {Object} Header - Partial LAS header.
|
|
11
6
|
* @property {number} header.pointDataRecordFormat - Type of point data
|
|
@@ -19,6 +14,7 @@ var _copc = require("copc");
|
|
|
19
14
|
* @property {number[]} header.offset - Offsets (an array `[xOffset,
|
|
20
15
|
* xOffset, zOffset]`) added to the scaled X, Y, Z point record values.
|
|
21
16
|
*/
|
|
17
|
+
|
|
22
18
|
/**
|
|
23
19
|
* @classdesc
|
|
24
20
|
* Loader for LAS and LAZ (LASZip) point clouds. It uses the copc.js library and
|
|
@@ -30,14 +26,14 @@ var _copc = require("copc");
|
|
|
30
26
|
*/
|
|
31
27
|
class LASLoader {
|
|
32
28
|
constructor() {
|
|
33
|
-
this._wasmPath = 'https://
|
|
29
|
+
this._wasmPath = 'https://cdn.jsdelivr.net/npm/laz-perf@0.0.6/lib/';
|
|
34
30
|
this._wasmPromise = null;
|
|
35
31
|
}
|
|
36
32
|
_initDecoder() {
|
|
37
33
|
if (this._wasmPromise) {
|
|
38
34
|
return this._wasmPromise;
|
|
39
35
|
}
|
|
40
|
-
this._wasmPromise =
|
|
36
|
+
this._wasmPromise = LazPerf.create({
|
|
41
37
|
locateFile: file => `${this._wasmPath}/${file}`
|
|
42
38
|
});
|
|
43
39
|
return this._wasmPromise;
|
|
@@ -67,13 +63,16 @@ class LASLoader {
|
|
|
67
63
|
The copc.js library does the degree convertion and stores it as a `Float32`.
|
|
68
64
|
*/
|
|
69
65
|
const scanAngles = new Float32Array(view.pointCount);
|
|
66
|
+
|
|
67
|
+
// For precision we take the first point that will be use as origin for a local referentiel.
|
|
68
|
+
const origin = getPosition.map(f => f(0)).map(val => Math.floor(val));
|
|
70
69
|
for (let i = 0; i < view.pointCount; i++) {
|
|
71
70
|
// `getPosition` apply scale and offset transform to the X, Y, Z
|
|
72
71
|
// values. See https://github.com/connormanning/copc.js/blob/master/src/las/extractor.ts.
|
|
73
72
|
const [x, y, z] = getPosition.map(f => f(i));
|
|
74
|
-
positions[i * 3] = x;
|
|
75
|
-
positions[i * 3 + 1] = y;
|
|
76
|
-
positions[i * 3 + 2] = z;
|
|
73
|
+
positions[i * 3] = x - origin[0];
|
|
74
|
+
positions[i * 3 + 1] = y - origin[1];
|
|
75
|
+
positions[i * 3 + 2] = z - origin[2];
|
|
77
76
|
intensities[i] = getIntensity(i);
|
|
78
77
|
returnNumbers[i] = getReturnNumber(i);
|
|
79
78
|
numberOfReturns[i] = getNumberOfReturns(i);
|
|
@@ -104,7 +103,8 @@ class LASLoader {
|
|
|
104
103
|
classification: classifications,
|
|
105
104
|
pointSourceID: pointSourceIDs,
|
|
106
105
|
color: colors,
|
|
107
|
-
scanAngle: scanAngles
|
|
106
|
+
scanAngle: scanAngles,
|
|
107
|
+
origin
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -129,14 +129,14 @@ class LASLoader {
|
|
|
129
129
|
async parseFile(data) {
|
|
130
130
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
131
131
|
const bytes = new Uint8Array(data);
|
|
132
|
-
const pointData = await
|
|
133
|
-
const header =
|
|
132
|
+
const pointData = await Las.PointData.decompressFile(bytes, this._initDecoder());
|
|
133
|
+
const header = Las.Header.parse(bytes);
|
|
134
134
|
const colorDepth = options.colorDepth ?? (header.majorVersion === 1 && header.minorVersion <= 2 ? 8 : 16);
|
|
135
135
|
const getter = async (begin, end) => bytes.slice(begin, end);
|
|
136
|
-
const vlrs = await
|
|
137
|
-
const ebVlr =
|
|
138
|
-
const eb = ebVlr &&
|
|
139
|
-
const view =
|
|
136
|
+
const vlrs = await Las.Vlr.walk(getter, header);
|
|
137
|
+
const ebVlr = Las.Vlr.find(vlrs, 'LASF_Spec', 4);
|
|
138
|
+
const eb = ebVlr && Las.ExtraBytes.parse(await Las.Vlr.fetch(getter, ebVlr));
|
|
139
|
+
const view = Las.View.create(pointData, header, eb);
|
|
140
140
|
const attributes = this._parseView(view, {
|
|
141
141
|
colorDepth
|
|
142
142
|
});
|
|
@@ -146,5 +146,4 @@ class LASLoader {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
exports.default = _default;
|
|
149
|
+
export default LASLoader;
|
package/lib/Parser/LASParser.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _LASLoader = _interopRequireDefault(require("./LASLoader"));
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
|
-
const lasLoader = new _LASLoader.default();
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import LASLoader from "./LASLoader.js";
|
|
3
|
+
const lasLoader = new LASLoader();
|
|
13
4
|
|
|
14
5
|
/** The LASParser module provides a [parse]{@link
|
|
15
6
|
* module:LASParser.parse} method that takes a LAS or LAZ (LASZip) file in, and
|
|
@@ -19,7 +10,7 @@ const lasLoader = new _LASLoader.default();
|
|
|
19
10
|
*
|
|
20
11
|
* @module LASParser
|
|
21
12
|
*/
|
|
22
|
-
|
|
13
|
+
export default {
|
|
23
14
|
/*
|
|
24
15
|
* Set the laz-perf decoder path.
|
|
25
16
|
* @param {string} path - path to `laz-perf.wasm` folder.
|
|
@@ -75,8 +66,8 @@ var _default = {
|
|
|
75
66
|
const scanAngle = new THREE.BufferAttribute(attributes.scanAngle, 1);
|
|
76
67
|
geometry.setAttribute('scanAngle', scanAngle);
|
|
77
68
|
geometry.computeBoundingBox();
|
|
69
|
+
geometry.userData.origin = new THREE.Vector3().fromArray(attributes.origin);
|
|
78
70
|
return geometry;
|
|
79
71
|
});
|
|
80
72
|
}
|
|
81
|
-
};
|
|
82
|
-
exports.default = _default;
|
|
73
|
+
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
const urlRe = /^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;
|
|
8
2
|
const config = {
|
|
9
3
|
API_URL: 'https://api.mapbox.com',
|
|
@@ -82,9 +76,8 @@ function normalizeStyleURL(url, accessToken) {
|
|
|
82
76
|
urlObject.path = `/styles/v1${urlObject.path}`;
|
|
83
77
|
return makeAPIURL(urlObject, accessToken);
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
export default {
|
|
86
80
|
normalizeStyleURL,
|
|
87
81
|
normalizeSourceURL,
|
|
88
82
|
normalizeSpriteURL
|
|
89
|
-
};
|
|
90
|
-
exports.default = _default;
|
|
83
|
+
};
|
package/lib/Parser/PntsParser.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
9
|
-
var _C3DTBatchTable = _interopRequireDefault(require("../Core/3DTiles/C3DTBatchTable"));
|
|
10
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import C3DTBatchTable from "../Core/3DTiles/C3DTBatchTable.js";
|
|
12
3
|
const utf8Decoder = new TextDecoder();
|
|
13
|
-
|
|
4
|
+
export default {
|
|
14
5
|
/** @module PntsParser */
|
|
15
6
|
/** Parse pnts buffer and extract THREE.Points and batch table
|
|
16
7
|
* @function parse
|
|
@@ -69,7 +60,7 @@ var _default = {
|
|
|
69
60
|
const BTBuffer = buffer.slice(sizeBegin, pntsHeader.BTJSONLength + pntsHeader.BTBinaryLength + sizeBegin);
|
|
70
61
|
|
|
71
62
|
// If the BATCH_ID semantic is not defined, then the Batch Table stores per-point metadata, and the length of the Batch Table arrays will equal POINTS_LENGTH.
|
|
72
|
-
batchTable = new
|
|
63
|
+
batchTable = new C3DTBatchTable(BTBuffer, pntsHeader.BTJSONLength, pntsHeader.BTBinaryLength, FTJSON.BATCH_ID && FTJSON.BATCH_LENGTH ? FTJSON.BATCH_LENGTH : FTJSON.POINTS_LENGTH, registeredExtensions);
|
|
73
64
|
point = setClassification(point, batchTable);
|
|
74
65
|
}
|
|
75
66
|
const pnts = {
|
|
@@ -82,7 +73,6 @@ var _default = {
|
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
75
|
};
|
|
85
|
-
exports.default = _default;
|
|
86
76
|
function parseFeatureBinary(array, byteOffset, FTJSONLength) {
|
|
87
77
|
// Init geometry
|
|
88
78
|
const geometry = new THREE.BufferGeometry();
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import * as THREE from 'three';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
3
|
// See the different constants holding ordinal, name, numElements, byteSize in PointAttributes.cpp in PotreeConverter
|
|
11
4
|
// elementByteSize is byteSize / numElements
|
|
12
|
-
const
|
|
5
|
+
const POINT_ATTRIBUTES = {
|
|
13
6
|
POSITION_CARTESIAN: {
|
|
14
7
|
numElements: 3,
|
|
15
8
|
arrayType: Float32Array,
|
|
@@ -55,8 +48,8 @@ const POINT_ATTTRIBUTES = {
|
|
|
55
48
|
attributeName: 'normal'
|
|
56
49
|
}
|
|
57
50
|
};
|
|
58
|
-
for (const potreeName of Object.keys(
|
|
59
|
-
const attr =
|
|
51
|
+
for (const potreeName of Object.keys(POINT_ATTRIBUTES)) {
|
|
52
|
+
const attr = POINT_ATTRIBUTES[potreeName];
|
|
60
53
|
attr.potreeName = potreeName;
|
|
61
54
|
attr.numByte = attr.numByte || attr.arrayType.BYTES_PER_ELEMENT;
|
|
62
55
|
attr.byteSize = attr.numElements * attr.numByte;
|
|
@@ -69,7 +62,7 @@ for (const potreeName of Object.keys(POINT_ATTTRIBUTES)) {
|
|
|
69
62
|
return view[fnName](offset, true);
|
|
70
63
|
};
|
|
71
64
|
}
|
|
72
|
-
|
|
65
|
+
export default {
|
|
73
66
|
/** @module PotreeBinParser */
|
|
74
67
|
/** Parse .bin PotreeConverter format and convert to a THREE.BufferGeometry
|
|
75
68
|
* @function parse
|
|
@@ -87,14 +80,14 @@ var _default = {
|
|
|
87
80
|
// Format: X1,Y1,Z1,R1,G1,B1,A1,[...],XN,YN,ZN,RN,GN,BN,AN
|
|
88
81
|
let pointByteSize = 0;
|
|
89
82
|
for (const potreeName of options.in.pointAttributes) {
|
|
90
|
-
pointByteSize +=
|
|
83
|
+
pointByteSize += POINT_ATTRIBUTES[potreeName].byteSize;
|
|
91
84
|
}
|
|
92
85
|
const numPoints = Math.floor(buffer.byteLength / pointByteSize);
|
|
93
86
|
const geometry = new THREE.BufferGeometry();
|
|
94
87
|
let elemOffset = 0;
|
|
95
88
|
let attrOffset = 0;
|
|
96
89
|
for (const potreeName of options.in.pointAttributes) {
|
|
97
|
-
const attr =
|
|
90
|
+
const attr = POINT_ATTRIBUTES[potreeName];
|
|
98
91
|
const arrayLength = attr.numElements * numPoints;
|
|
99
92
|
const array = new attr.arrayType(arrayLength);
|
|
100
93
|
for (let arrayOffset = 0; arrayOffset < arrayLength; arrayOffset += attr.numElements) {
|
|
@@ -110,5 +103,4 @@ var _default = {
|
|
|
110
103
|
geometry.computeBoundingBox();
|
|
111
104
|
return Promise.resolve(geometry);
|
|
112
105
|
}
|
|
113
|
-
};
|
|
114
|
-
exports.default = _default;
|
|
106
|
+
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var THREE = _interopRequireWildcard(require("three"));
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
var _default = {
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export default {
|
|
11
3
|
/** @module PotreeCinParser */
|
|
12
4
|
/** Parse .cin PotreeConverter format (see {@link https://github.com/peppsac/PotreeConverter/tree/custom_bin}) and convert to a THREE.BufferGeometry
|
|
13
5
|
* @function parse
|
|
@@ -34,5 +26,4 @@ var _default = {
|
|
|
34
26
|
geometry.boundingBox = box;
|
|
35
27
|
return Promise.resolve(geometry);
|
|
36
28
|
}
|
|
37
|
-
};
|
|
38
|
-
exports.default = _default;
|
|
29
|
+
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import proj4 from 'proj4';
|
|
2
|
+
import shp from 'shpjs';
|
|
3
|
+
import GeoJsonParser from "./GeoJsonParser.js";
|
|
4
|
+
import { deprecatedParsingOptionsToNewOne } from "../Core/Deprecated/Undeprecator.js";
|
|
2
5
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _proj = _interopRequireDefault(require("proj4"));
|
|
9
|
-
var _shpjs = _interopRequireDefault(require("shpjs"));
|
|
10
|
-
var _GeoJsonParser = _interopRequireDefault(require("./GeoJsonParser"));
|
|
11
|
-
var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
12
6
|
/**
|
|
13
7
|
* The ShapefileParser module provides a [parse]{@link
|
|
14
8
|
* module:ShapefileParser.parse} method that takes a bunch of files constituing
|
|
@@ -49,7 +43,7 @@ var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
|
49
43
|
*
|
|
50
44
|
* @module ShapefileParser
|
|
51
45
|
*/
|
|
52
|
-
|
|
46
|
+
export default {
|
|
53
47
|
/**
|
|
54
48
|
* Parse a bunch of Shapefile files and return a [FeatureCollection]{@link
|
|
55
49
|
* module:GeoJsonParser~FeatureCollection}.
|
|
@@ -69,18 +63,17 @@ var _default = {
|
|
|
69
63
|
*/
|
|
70
64
|
parse(data) {
|
|
71
65
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
72
|
-
options =
|
|
66
|
+
options = deprecatedParsingOptionsToNewOne(options);
|
|
73
67
|
let result;
|
|
74
68
|
|
|
75
69
|
// If a zip is present, don't read anything else
|
|
76
70
|
if (data.zip) {
|
|
77
|
-
result =
|
|
71
|
+
result = shp.parseZip(data.zip);
|
|
78
72
|
} else if (data.shp && data.shx && data.dbf) {
|
|
79
|
-
result = Promise.all([
|
|
73
|
+
result = Promise.all([shp.parseShp(data.shp, data.prj), shp.parseDbf(data.dbf)]).then(shp.combine);
|
|
80
74
|
}
|
|
81
75
|
options.in = options.in || {};
|
|
82
|
-
options.in.crs = data.prj ? (
|
|
83
|
-
return Promise.resolve(result).then(res =>
|
|
76
|
+
options.in.crs = data.prj ? proj4(data.prj).oProj.datumName : options.in.crs;
|
|
77
|
+
return Promise.resolve(result).then(res => GeoJsonParser.parse(res, options));
|
|
84
78
|
}
|
|
85
|
-
};
|
|
86
|
-
exports.default = _default;
|
|
79
|
+
};
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _Feature = require("../Core/Feature");
|
|
13
|
-
var _Undeprecator = require("../Core/Deprecated/Undeprecator");
|
|
14
|
-
var _Coordinates = _interopRequireDefault(require("../Core/Geographic/Coordinates"));
|
|
15
|
-
const worldDimension3857 = _Extent.globalExtentTMS.get('EPSG:3857').planarDimensions();
|
|
16
|
-
const globalExtent = new _three.Vector3(worldDimension3857.x, worldDimension3857.y, 1);
|
|
17
|
-
const lastPoint = new _three.Vector2();
|
|
18
|
-
const firstPoint = new _three.Vector2();
|
|
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();
|
|
19
12
|
|
|
20
13
|
// Calculate the projected coordinates in EPSG:4326 of a given point in the VT local system
|
|
21
14
|
// adapted from @mapbox/vector-tile
|
|
@@ -23,7 +16,7 @@ function project(x, y, tileNumbers, tileExtent) {
|
|
|
23
16
|
const size = tileExtent * 2 ** tileNumbers.z;
|
|
24
17
|
const x0 = tileExtent * tileNumbers.x;
|
|
25
18
|
const y0 = tileExtent * tileNumbers.y;
|
|
26
|
-
return new
|
|
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);
|
|
27
20
|
}
|
|
28
21
|
|
|
29
22
|
// Classify option, it allows to classify a full polygon and its holes.
|
|
@@ -34,7 +27,7 @@ function project(x, y, tileNumbers, tileExtent) {
|
|
|
34
27
|
function vtFeatureToFeatureGeometry(vtFeature, feature) {
|
|
35
28
|
let classify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
36
29
|
let geometry = feature.bindNewGeometry();
|
|
37
|
-
const isPolygon = feature.type ===
|
|
30
|
+
const isPolygon = feature.type === FEATURE_TYPES.POLYGON;
|
|
38
31
|
classify = classify && isPolygon;
|
|
39
32
|
geometry.properties = vtFeature.properties;
|
|
40
33
|
const pbf = vtFeature._pbf;
|
|
@@ -111,20 +104,20 @@ function vtFeatureToFeatureGeometry(vtFeature, feature) {
|
|
|
111
104
|
}
|
|
112
105
|
function readPBF(file, options) {
|
|
113
106
|
options.out = options.out || {};
|
|
114
|
-
const vectorTile = new
|
|
107
|
+
const vectorTile = new VectorTile(new Protobuf(file));
|
|
115
108
|
const sourceLayers = Object.keys(vectorTile.layers);
|
|
116
109
|
if (sourceLayers.length < 1) {
|
|
117
110
|
return;
|
|
118
111
|
}
|
|
119
112
|
|
|
120
113
|
// x,y,z tile coordinates
|
|
121
|
-
const x =
|
|
122
|
-
const z =
|
|
114
|
+
const x = options.extent.col;
|
|
115
|
+
const z = options.extent.zoom;
|
|
123
116
|
// We need to move from TMS to Google/Bing/OSM coordinates
|
|
124
117
|
// https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
|
|
125
118
|
// Only if the layer.origin is top
|
|
126
|
-
const y = options.in.isInverted ?
|
|
127
|
-
const collection = new
|
|
119
|
+
const y = options.in.isInverted ? options.extent.row : (1 << z) - options.extent.row - 1;
|
|
120
|
+
const collection = new FeatureCollection(options.out);
|
|
128
121
|
const vFeature = vectorTile.layers[sourceLayers[0]];
|
|
129
122
|
// TODO: verify if size is correct because is computed with only one feature (vFeature).
|
|
130
123
|
const size = vFeature.extent * 2 ** z;
|
|
@@ -141,7 +134,7 @@ function readPBF(file, options) {
|
|
|
141
134
|
const vtFeature = sourceLayer.feature(i);
|
|
142
135
|
vtFeature.tileNumbers = {
|
|
143
136
|
x,
|
|
144
|
-
y:
|
|
137
|
+
y: options.extent.row,
|
|
145
138
|
z
|
|
146
139
|
};
|
|
147
140
|
const layers = options.in.layers[layer_id].filter(l => l.filterExpression.filter({
|
|
@@ -169,7 +162,7 @@ function readPBF(file, options) {
|
|
|
169
162
|
collection.features.sort((a, b) => a.order - b.order);
|
|
170
163
|
// TODO verify if is needed to updateExtent for previous features.
|
|
171
164
|
collection.updateExtent();
|
|
172
|
-
collection.extent =
|
|
165
|
+
collection.extent = options.extent;
|
|
173
166
|
collection.isInverted = options.in.isInverted;
|
|
174
167
|
return Promise.resolve(collection);
|
|
175
168
|
}
|
|
@@ -177,7 +170,7 @@ function readPBF(file, options) {
|
|
|
177
170
|
/**
|
|
178
171
|
* @module VectorTileParser
|
|
179
172
|
*/
|
|
180
|
-
|
|
173
|
+
export default {
|
|
181
174
|
/**
|
|
182
175
|
* Parse a vector tile file and return a [Feature]{@link module:GeoJsonParser.Feature}
|
|
183
176
|
* or an array of Features. While multiple formats of vector tile are
|
|
@@ -203,8 +196,7 @@ var _default = {
|
|
|
203
196
|
* Features.
|
|
204
197
|
*/
|
|
205
198
|
parse(file, options) {
|
|
206
|
-
options =
|
|
199
|
+
options = deprecatedParsingOptionsToNewOne(options);
|
|
207
200
|
return Promise.resolve(readPBF(file, options));
|
|
208
201
|
}
|
|
209
|
-
};
|
|
210
|
-
exports.default = _default;
|
|
202
|
+
};
|
package/lib/Parser/XbilParser.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.checkNodeElevationTextureValidity = checkNodeElevationTextureValidity;
|
|
7
|
-
exports.computeMinMaxElevation = computeMinMaxElevation;
|
|
8
|
-
exports.insertSignificantValuesFromParent = insertSignificantValuesFromParent;
|
|
9
|
-
var _DEMUtils = require("../Utils/DEMUtils");
|
|
1
|
+
import { readTextureValueWithBilinearFiltering } from "../Utils/DEMUtils.js";
|
|
10
2
|
function minMax4Corners(texture, pitch, options) {
|
|
11
3
|
const u = pitch.x;
|
|
12
4
|
const v = pitch.y;
|
|
13
5
|
const w = pitch.z;
|
|
14
|
-
const 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);
|
|
15
7
|
if (z.length) {
|
|
16
8
|
return {
|
|
17
9
|
min: Math.min(...z),
|
|
@@ -36,7 +28,7 @@ function minMax4Corners(texture, pitch, options) {
|
|
|
36
28
|
* @param {number} [options.zmax] The maximum elevation value after which it will be clamped
|
|
37
29
|
* @return {Object} The minimum and maximum elevation.
|
|
38
30
|
*/
|
|
39
|
-
function computeMinMaxElevation(texture, pitch, options) {
|
|
31
|
+
export function computeMinMaxElevation(texture, pitch, options) {
|
|
40
32
|
const {
|
|
41
33
|
width,
|
|
42
34
|
height,
|
|
@@ -99,13 +91,13 @@ function computeMinMaxElevation(texture, pitch, options) {
|
|
|
99
91
|
}
|
|
100
92
|
|
|
101
93
|
// We check if the elevation texture has some significant values through corners
|
|
102
|
-
function checkNodeElevationTextureValidity(data, noDataValue) {
|
|
94
|
+
export function checkNodeElevationTextureValidity(data, noDataValue) {
|
|
103
95
|
const l = data.length;
|
|
104
96
|
return data[0] > noDataValue && data[l - 1] > noDataValue && data[Math.sqrt(l) - 1] > noDataValue && data[l - Math.sqrt(l)] > noDataValue;
|
|
105
97
|
}
|
|
106
98
|
|
|
107
99
|
// This function replaces noDataValue by significant values from parent texture (or 0)
|
|
108
|
-
function insertSignificantValuesFromParent(data) {
|
|
100
|
+
export function insertSignificantValuesFromParent(data) {
|
|
109
101
|
let dataParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : () => 0;
|
|
110
102
|
let noDataValue = arguments.length > 2 ? arguments[2] : undefined;
|
|
111
103
|
for (let i = 0, l = data.length; i < l; ++i) {
|