itowns 2.36.2 → 2.38.1
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/CONTRIBUTING.md +30 -17
- package/README.md +12 -1
- package/changelog.md +138 -0
- package/dist/debug.js +1 -1
- package/dist/debug.js.LICENSE.txt +2 -2
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.LICENSE.txt +2 -2
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +2 -0
- package/dist/itowns_widgets.js.map +1 -0
- package/examples/config.json +28 -6
- package/examples/css/example.css +21 -1
- package/examples/css/widgets.css +360 -0
- package/examples/geoid_geoidLayer.html +102 -0
- package/examples/images/code-logo.svg +43 -0
- package/examples/index.html +5 -5
- package/examples/itowns-potree.html +252 -0
- package/examples/js/GUI/GuiTools.js +17 -0
- package/examples/mars.html +0 -1
- package/examples/misc_orthographic_camera.html +7 -19
- package/examples/source_file_from_fetched_data.html +90 -0
- package/examples/source_file_from_format.html +85 -0
- package/examples/source_file_from_methods.html +87 -0
- package/examples/source_file_from_parsed_data.html +104 -0
- package/examples/source_file_geojson_raster.html +21 -45
- package/examples/source_file_gpx_raster.html +28 -36
- package/examples/source_file_kml_raster.html +1 -4
- package/examples/source_file_shapefile.html +39 -34
- package/examples/source_stream_wfs_25d.html +21 -13
- package/examples/source_stream_wfs_3d.html +21 -12
- package/examples/source_stream_wfs_raster.html +20 -20
- package/examples/vector_tile_3d_mesh.html +155 -0
- package/examples/vector_tile_raster_3d.html +0 -5
- package/examples/view_25d_map.html +6 -19
- package/examples/view_2d_map.html +6 -19
- package/examples/view_3d_map.html +106 -81
- package/examples/view_immersive.html +13 -14
- package/examples/widgets_minimap.html +124 -0
- package/examples/widgets_navigation.html +124 -0
- package/examples/widgets_scale.html +96 -0
- package/examples/widgets_searchbar.html +124 -0
- package/lib/Controls/GlobeControls.js +13 -0
- package/lib/Controls/PlanarControls.js +11 -43
- package/lib/Converter/Feature2Mesh.js +203 -45
- package/lib/Converter/convertToTile.js +13 -4
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +4 -1
- package/lib/Core/Deprecated/Undeprecator.js +1 -1
- package/lib/Core/Feature.js +60 -34
- package/lib/Core/Geographic/Extent.js +1 -1
- package/lib/Core/Geographic/GeoidGrid.js +143 -0
- package/lib/Core/MainLoop.js +137 -63
- package/lib/Core/Math/Ellipsoid.js +1 -1
- package/lib/Core/Prefab/Globe/SkyShader.js +3 -1
- package/lib/Core/Prefab/Planar/PlanarLayer.js +3 -1
- package/lib/Core/Style.js +1 -1
- package/lib/Core/TileGeometry.js +3 -1
- package/lib/Core/TileMesh.js +32 -22
- package/lib/Core/View.js +81 -15
- package/lib/Layer/ElevationLayer.js +6 -2
- package/lib/Layer/FeatureGeometryLayer.js +36 -7
- package/lib/Layer/GeoidLayer.js +142 -0
- package/lib/Layer/GeometryLayer.js +6 -54
- package/lib/Layer/InfoLayer.js +1 -1
- package/lib/Layer/Layer.js +1 -1
- package/lib/Layer/LayerUpdateStrategy.js +1 -1
- package/lib/Layer/OrientedImageLayer.js +1 -0
- package/lib/Layer/PotreeLayer.js +3 -1
- package/lib/Layer/RasterLayer.js +3 -1
- package/lib/Layer/ReferencingLayerProperties.js +50 -0
- package/lib/Layer/TiledGeometryLayer.js +3 -1
- package/lib/Main.js +214 -174
- package/lib/MainBundle.js +1 -1
- package/lib/Parser/B3dmParser.js +5 -3
- package/lib/Parser/GDFParser.js +118 -0
- package/lib/Parser/GTXParser.js +92 -0
- package/lib/Parser/GeoJsonParser.js +29 -7
- package/lib/Parser/ISGParser.js +121 -0
- package/lib/Parser/LASParser.js +3 -1
- package/lib/Parser/VectorTileParser.js +4 -3
- package/lib/Parser/XbilParser.js +1 -1
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +1 -1
- package/lib/Process/3dTilesProcessing.js +2 -2
- package/lib/Process/FeatureProcessing.js +38 -86
- package/lib/Process/LayeredMaterialNodeProcessing.js +16 -7
- package/lib/Process/ObjectRemovalHelper.js +4 -0
- package/lib/Provider/3dTilesProvider.js +2 -7
- package/lib/Provider/Fetcher.js +4 -1
- package/lib/Provider/TileProvider.js +18 -2
- package/lib/Provider/URLBuilder.js +1 -1
- package/lib/Renderer/Camera.js +33 -12
- package/lib/Renderer/ColorLayersOrdering.js +3 -1
- package/lib/Renderer/LayeredMaterial.js +34 -9
- package/lib/Renderer/OBB.js +22 -25
- package/lib/Renderer/OrientedImageMaterial.js +8 -5
- package/lib/Renderer/PointsMaterial.js +6 -6
- package/lib/Renderer/RasterTile.js +1 -1
- package/lib/Renderer/RenderMode.js +3 -1
- package/lib/Renderer/Shader/ShaderChunk.js +5 -1
- package/lib/Renderer/Shader/ShaderUtils.js +4 -2
- package/lib/Renderer/c3DEngine.js +9 -6
- package/lib/Source/C3DTilesSource.js +3 -1
- package/lib/Source/EntwinePointTileSource.js +3 -1
- package/lib/Source/FileSource.js +8 -1
- package/lib/Source/PotreeSource.js +3 -1
- package/lib/Source/Source.js +15 -10
- package/lib/Source/VectorTilesSource.js +5 -0
- package/lib/Source/WFSSource.js +9 -3
- package/lib/Source/WMTSSource.js +3 -1
- package/lib/ThreeExtended/{WebGL.js → capabilities/WebGL.js} +8 -7
- package/lib/ThreeExtended/loaders/GLTFLoader.js +88 -39
- package/lib/Utils/CameraUtils.js +11 -1
- package/lib/Utils/DEMUtils.js +4 -2
- package/lib/Utils/FeaturesUtils.js +8 -4
- package/lib/Utils/gui/Main.js +39 -0
- package/lib/Utils/gui/Minimap.js +197 -0
- package/lib/Utils/gui/Navigation.js +322 -0
- package/lib/Utils/gui/Scale.js +154 -0
- package/lib/Utils/gui/Searchbar.js +299 -0
- package/lib/Utils/gui/Widget.js +119 -0
- package/package.json +32 -27
- package/examples/js/Scale.js +0 -40
package/lib/Core/Feature.js
CHANGED
|
@@ -7,7 +7,9 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports
|
|
10
|
+
exports["default"] = exports.FeatureGeometry = exports.FeatureCollection = exports.FeatureBuildingOptions = exports.FEATURE_TYPES = void 0;
|
|
11
|
+
|
|
12
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
13
|
|
|
12
14
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
15
|
|
|
@@ -17,6 +19,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
17
19
|
|
|
18
20
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
21
|
|
|
22
|
+
var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet"));
|
|
23
|
+
|
|
24
|
+
var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet"));
|
|
25
|
+
|
|
20
26
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
21
27
|
|
|
22
28
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
@@ -45,6 +51,10 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
45
51
|
|
|
46
52
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
47
53
|
|
|
54
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
55
|
+
|
|
56
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
57
|
+
|
|
48
58
|
function defaultExtent(crs) {
|
|
49
59
|
return new _Extent["default"](crs, Infinity, -Infinity, Infinity, -Infinity);
|
|
50
60
|
}
|
|
@@ -71,7 +81,6 @@ function _setGeometryValues(geom, feature, _long, lat, alt, normal) {
|
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
var coordOut = new _Coordinates["default"]('EPSG:4326', 0, 0, 0);
|
|
74
|
-
var defaultNormal = new THREE.Vector3(0, 0, 1);
|
|
75
84
|
var FEATURE_TYPES = {
|
|
76
85
|
POINT: 0,
|
|
77
86
|
LINE: 1,
|
|
@@ -98,9 +107,9 @@ var typeToStyleProperty = ['point', 'stroke', 'fill'];
|
|
|
98
107
|
*
|
|
99
108
|
*/
|
|
100
109
|
|
|
101
|
-
var FeatureBuildingOptions = function FeatureBuildingOptions() {
|
|
110
|
+
var FeatureBuildingOptions = /*#__PURE__*/(0, _createClass2["default"])(function FeatureBuildingOptions() {
|
|
102
111
|
(0, _classCallCheck2["default"])(this, FeatureBuildingOptions);
|
|
103
|
-
};
|
|
112
|
+
});
|
|
104
113
|
/**
|
|
105
114
|
* @property {Extent} extent - The 2D extent containing all the points
|
|
106
115
|
* composing the geometry.
|
|
@@ -112,22 +121,29 @@ var FeatureBuildingOptions = function FeatureBuildingOptions() {
|
|
|
112
121
|
* anything specified in the GeoJSON under the `properties` property.
|
|
113
122
|
*/
|
|
114
123
|
|
|
115
|
-
|
|
116
124
|
exports.FeatureBuildingOptions = FeatureBuildingOptions;
|
|
117
125
|
|
|
126
|
+
var _currentExtent = /*#__PURE__*/new WeakMap();
|
|
127
|
+
|
|
118
128
|
var FeatureGeometry = /*#__PURE__*/function () {
|
|
119
129
|
/**
|
|
120
130
|
* @param {Feature} feature geometry
|
|
121
131
|
*/
|
|
122
132
|
function FeatureGeometry(feature) {
|
|
123
133
|
(0, _classCallCheck2["default"])(this, FeatureGeometry);
|
|
134
|
+
|
|
135
|
+
_classPrivateFieldInitSpec(this, _currentExtent, {
|
|
136
|
+
writable: true,
|
|
137
|
+
value: void 0
|
|
138
|
+
});
|
|
139
|
+
|
|
124
140
|
this.indices = [];
|
|
125
141
|
this.properties = {};
|
|
126
142
|
this.size = feature.size;
|
|
127
143
|
|
|
128
144
|
if (feature.extent) {
|
|
129
145
|
this.extent = defaultExtent(feature.extent.crs);
|
|
130
|
-
this
|
|
146
|
+
(0, _classPrivateFieldSet2["default"])(this, _currentExtent, defaultExtent(feature.extent.crs));
|
|
131
147
|
}
|
|
132
148
|
|
|
133
149
|
this.altitude = {
|
|
@@ -155,7 +171,7 @@ var FeatureGeometry = /*#__PURE__*/function () {
|
|
|
155
171
|
count: count,
|
|
156
172
|
extent: extent
|
|
157
173
|
});
|
|
158
|
-
this
|
|
174
|
+
(0, _classPrivateFieldSet2["default"])(this, _currentExtent, extent);
|
|
159
175
|
|
|
160
176
|
_extendBuffer(feature, count);
|
|
161
177
|
}
|
|
@@ -175,12 +191,12 @@ var FeatureGeometry = /*#__PURE__*/function () {
|
|
|
175
191
|
this.indices.push({
|
|
176
192
|
offset: offset,
|
|
177
193
|
count: count,
|
|
178
|
-
extent: this
|
|
194
|
+
extent: (0, _classPrivateFieldGet2["default"])(this, _currentExtent)
|
|
179
195
|
});
|
|
180
196
|
|
|
181
197
|
if (this.extent) {
|
|
182
|
-
this.extent.union(this
|
|
183
|
-
this
|
|
198
|
+
this.extent.union((0, _classPrivateFieldGet2["default"])(this, _currentExtent));
|
|
199
|
+
(0, _classPrivateFieldSet2["default"])(this, _currentExtent, defaultExtent(this.extent.crs));
|
|
184
200
|
}
|
|
185
201
|
}
|
|
186
202
|
}, {
|
|
@@ -211,8 +227,8 @@ var FeatureGeometry = /*#__PURE__*/function () {
|
|
|
211
227
|
_setGeometryValues(this, feature, coordOut.x, coordOut.y, coordOut.z, coordOut.geodesicNormal); // expand extent if present
|
|
212
228
|
|
|
213
229
|
|
|
214
|
-
if (this
|
|
215
|
-
this
|
|
230
|
+
if ((0, _classPrivateFieldGet2["default"])(this, _currentExtent)) {
|
|
231
|
+
(0, _classPrivateFieldGet2["default"])(this, _currentExtent).expandByCoordinates(feature.useCrsOut ? coordOut : coordIn);
|
|
216
232
|
}
|
|
217
233
|
}
|
|
218
234
|
/**
|
|
@@ -223,20 +239,19 @@ var FeatureGeometry = /*#__PURE__*/function () {
|
|
|
223
239
|
* @param {Feature} feature - the feature containing the geometry
|
|
224
240
|
* @param {number} long The longitude coordinate.
|
|
225
241
|
* @param {number} lat The latitude coordinate.
|
|
226
|
-
* @param {THREE.Vector3} [normal
|
|
242
|
+
* @param {THREE.Vector3} [normal] the normal on coordinates (only for `EPSG:4978` projection).
|
|
227
243
|
*/
|
|
228
244
|
|
|
229
245
|
}, {
|
|
230
246
|
key: "pushCoordinatesValues",
|
|
231
|
-
value: function pushCoordinatesValues(feature, _long2, lat) {
|
|
232
|
-
var normal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : defaultNormal;
|
|
247
|
+
value: function pushCoordinatesValues(feature, _long2, lat, normal) {
|
|
233
248
|
var altitude = this.baseAltitude(feature);
|
|
234
249
|
|
|
235
250
|
_setGeometryValues(this, feature, _long2, lat, altitude, normal); // expand extent if present
|
|
236
251
|
|
|
237
252
|
|
|
238
|
-
if (this
|
|
239
|
-
this
|
|
253
|
+
if ((0, _classPrivateFieldGet2["default"])(this, _currentExtent)) {
|
|
254
|
+
(0, _classPrivateFieldGet2["default"])(this, _currentExtent).expandByValuesCoordinates(_long2, lat);
|
|
240
255
|
}
|
|
241
256
|
}
|
|
242
257
|
/**
|
|
@@ -325,7 +340,7 @@ var Feature = /*#__PURE__*/function () {
|
|
|
325
340
|
this.vertices = [];
|
|
326
341
|
this.crs = collection.crs;
|
|
327
342
|
this.size = collection.size;
|
|
328
|
-
this.normals = collection.
|
|
343
|
+
this.normals = collection.crs == 'EPSG:4978' ? [] : undefined;
|
|
329
344
|
this.transformToLocalSystem = collection.transformToLocalSystem.bind(collection);
|
|
330
345
|
|
|
331
346
|
if (collection.extent) {
|
|
@@ -448,6 +463,10 @@ var alignYtoEast = new THREE.Quaternion();
|
|
|
448
463
|
*
|
|
449
464
|
*/
|
|
450
465
|
|
|
466
|
+
var _transformToLocalSystem = /*#__PURE__*/new WeakMap();
|
|
467
|
+
|
|
468
|
+
var _setLocalSystem = /*#__PURE__*/new WeakMap();
|
|
469
|
+
|
|
451
470
|
var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
|
|
452
471
|
(0, _inherits2["default"])(FeatureCollection, _THREE$Object3D);
|
|
453
472
|
|
|
@@ -457,12 +476,25 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
457
476
|
* @param {FeatureBuildingOptions|Layer} options The building options .
|
|
458
477
|
*/
|
|
459
478
|
function FeatureCollection(options) {
|
|
479
|
+
var _options$source;
|
|
480
|
+
|
|
460
481
|
var _this;
|
|
461
482
|
|
|
462
483
|
(0, _classCallCheck2["default"])(this, FeatureCollection);
|
|
463
484
|
_this = _super.call(this);
|
|
485
|
+
|
|
486
|
+
_classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _transformToLocalSystem, {
|
|
487
|
+
writable: true,
|
|
488
|
+
value: transformToLocalSystem2D
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
_classPrivateFieldInitSpec((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, {
|
|
492
|
+
writable: true,
|
|
493
|
+
value: doNothing
|
|
494
|
+
});
|
|
495
|
+
|
|
464
496
|
_this.isFeatureCollection = true;
|
|
465
|
-
_this.crs = _Crs["default"].formatToEPSG(options.crs);
|
|
497
|
+
_this.crs = _Crs["default"].formatToEPSG(options.accurate || !((_options$source = options.source) !== null && _options$source !== void 0 && _options$source.crs) ? options.crs : options.source.crs);
|
|
466
498
|
_this.features = [];
|
|
467
499
|
_this.mergeFeatures = options.mergeFeatures === undefined ? true : options.mergeFeatures;
|
|
468
500
|
_this.size = options.structure == '3d' ? 3 : 2;
|
|
@@ -474,8 +506,7 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
474
506
|
|
|
475
507
|
if (_this.size == 2) {
|
|
476
508
|
_this.extent = options.buildExtent === false ? undefined : defaultExtent(options.forcedExtentCrs || _this.crs);
|
|
477
|
-
|
|
478
|
-
_this._setLocalSystem = function (center) {
|
|
509
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, function (center) {
|
|
479
510
|
// set local system center
|
|
480
511
|
center.as('EPSG:4326', _this.center); // set position to local system center
|
|
481
512
|
|
|
@@ -483,14 +514,11 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
483
514
|
|
|
484
515
|
_this.updateMatrixWorld();
|
|
485
516
|
|
|
486
|
-
_this
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
_this._transformToLocalSystem = transformToLocalSystem2D;
|
|
517
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, doNothing);
|
|
518
|
+
});
|
|
490
519
|
} else {
|
|
491
520
|
_this.extent = options.buildExtent ? defaultExtent(options.forcedExtentCrs || _this.crs) : undefined;
|
|
492
|
-
|
|
493
|
-
_this._setLocalSystem = function (center) {
|
|
521
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, function (center) {
|
|
494
522
|
// set local system center
|
|
495
523
|
center.as('EPSG:4326', _this.center);
|
|
496
524
|
|
|
@@ -512,10 +540,9 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
512
540
|
_this.normalMatrix.getNormalMatrix(_this.matrix);
|
|
513
541
|
|
|
514
542
|
_this.normalMatrixInverse = new THREE.Matrix3().copy(_this.normalMatrix).invert();
|
|
515
|
-
_this
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
_this._transformToLocalSystem = transformToLocalSystem3D;
|
|
543
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _setLocalSystem, doNothing);
|
|
544
|
+
});
|
|
545
|
+
(0, _classPrivateFieldSet2["default"])((0, _assertThisInitialized2["default"])(_this), _transformToLocalSystem, transformToLocalSystem3D);
|
|
519
546
|
}
|
|
520
547
|
|
|
521
548
|
_this.altitude = {
|
|
@@ -537,9 +564,8 @@ var FeatureCollection = /*#__PURE__*/function (_THREE$Object3D) {
|
|
|
537
564
|
(0, _createClass2["default"])(FeatureCollection, [{
|
|
538
565
|
key: "transformToLocalSystem",
|
|
539
566
|
value: function transformToLocalSystem(coordinates) {
|
|
540
|
-
this.
|
|
541
|
-
|
|
542
|
-
return this._transformToLocalSystem(coordinates, this);
|
|
567
|
+
(0, _classPrivateFieldGet2["default"])(this, _setLocalSystem).call(this, coordinates);
|
|
568
|
+
return (0, _classPrivateFieldGet2["default"])(this, _transformToLocalSystem).call(this, coordinates, this);
|
|
543
569
|
}
|
|
544
570
|
/**
|
|
545
571
|
* Update FeatureCollection extent with `extent` or all features extent if
|
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports
|
|
10
|
+
exports.schemeTiles = exports.globalExtentTMS = exports["default"] = void 0;
|
|
11
11
|
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var THREE = _interopRequireWildcard(require("three"));
|
|
17
|
+
|
|
18
|
+
var _Coordinates = _interopRequireDefault(require("./Coordinates"));
|
|
19
|
+
|
|
20
|
+
var _Crs = _interopRequireDefault(require("./Crs"));
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
var coord = new _Coordinates["default"]('EPSG:4326');
|
|
27
|
+
var indexes = new THREE.Vector2();
|
|
28
|
+
|
|
29
|
+
function biLinearInterpolation(indexes, getData) {
|
|
30
|
+
var j = Math.floor(indexes.x);
|
|
31
|
+
var i = Math.floor(indexes.y);
|
|
32
|
+
var u = indexes.x - j;
|
|
33
|
+
var v = indexes.y - i;
|
|
34
|
+
return (1 - u) * ((1 - v) * getData(i, j) + v * getData(i + 1, j)) + u * ((1 - v) * getData(i, j + 1) + v * getData(i + 1, j + 1));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* An instance of `GeoidGrid` allows accessing some geoid height grid data from geographic instances (like some
|
|
38
|
+
* `{@link Coordinates}`). The geoid height grid data must contain geoid height values for a set of geographic points
|
|
39
|
+
* regularly dispatched on a planar surface.
|
|
40
|
+
*
|
|
41
|
+
* @property {Extent} extent The geographic extent of the geoid height grid data.
|
|
42
|
+
* @property {THREE.Vector2} step The distance between two consecutive points of the geoid height grid. The
|
|
43
|
+
* `x` value stands for the distance along the West-East direction, and the
|
|
44
|
+
* `y` value stands for the distance along the South-North direction.
|
|
45
|
+
* @property {THREE.Vector2} dimensions The planar dimensions of the geoid height grid data extent.
|
|
46
|
+
* @property {THREE.Vector2} dataSize The number of values in the gridded data along the West-East direction (`x`
|
|
47
|
+
* axis) and the South-North direction (`y` axis).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Create a set of gridded data.
|
|
51
|
+
* const data = [
|
|
52
|
+
* [1, 2, 3],
|
|
53
|
+
* [2, 3, 4],
|
|
54
|
+
* [3, 4, 5],
|
|
55
|
+
* ];
|
|
56
|
+
* // This set of data presents the following spatial distribution of geoid heights values :
|
|
57
|
+
* //
|
|
58
|
+
* // Latitudes ^
|
|
59
|
+
* // |
|
|
60
|
+
* // 41.0 | 3 4 5
|
|
61
|
+
* // 40.5 | 2 3 4
|
|
62
|
+
* // 40.0 | 1 2 3
|
|
63
|
+
* // |------------->
|
|
64
|
+
* // 1 2 3 Longitudes
|
|
65
|
+
*
|
|
66
|
+
* // Create a GeoidGrid allowing to access the gridded data.
|
|
67
|
+
* const geoidGrid = new GeoidGrid(
|
|
68
|
+
* new Extent('EPSG:4326', 1, 3, 40, 41),
|
|
69
|
+
* new THREE.Vector2(1, 0.5),
|
|
70
|
+
* (verticalIndex, horizontalIndex) => data[verticalIndex][horizontalIndex],
|
|
71
|
+
* );
|
|
72
|
+
*
|
|
73
|
+
* // Access a value of geoid height at some geographic coordinates.
|
|
74
|
+
* // The value is interpolated from the gridded data.
|
|
75
|
+
* const value = geoidGrid.getHeightAtCoordinates(
|
|
76
|
+
* new Coordinates('EPSG:4326', 1.5, 40.25)
|
|
77
|
+
* );
|
|
78
|
+
* // This should return 2.0, which is the result from the bi-linear
|
|
79
|
+
* // interpolation at the center of the `[[1, 2], [2, 3]]` subsection
|
|
80
|
+
* // of the grid data.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
var GeoidGrid = /*#__PURE__*/function () {
|
|
85
|
+
/**
|
|
86
|
+
* @param {Extent} extent The geographic extent of the geoid height grid data.
|
|
87
|
+
* @param {THREE.Vector2} step The distance between two consecutive points of the geoid height grid. The
|
|
88
|
+
* `x` value stands for the distance along the West-East direction, and the
|
|
89
|
+
* `y` value stands for the distance along the South-North direction.
|
|
90
|
+
* @param {function} getData A method that allows reading a value in the geoid height grid from its
|
|
91
|
+
* vertical and horizontal indexes. The lower an index, the lower the
|
|
92
|
+
* coordinate on the corresponding axis - 0 being the index of the minimal
|
|
93
|
+
* coordinate of the gridded data on a given axis. In other words :
|
|
94
|
+
* - `getData(0, 0)` must return the geoid height value at the SOUTH-WEST
|
|
95
|
+
* corner of your data extent.
|
|
96
|
+
* - `getData(0, j)` must return a geoid height on the southern limit of your
|
|
97
|
+
* data extent.
|
|
98
|
+
* - `getData(i, 0)` must return a geoid height on the western limit of your
|
|
99
|
+
* data extent.
|
|
100
|
+
* - if your gridded data has dimensions (rowNumber, colNumber),
|
|
101
|
+
* `getData(rowNumber - 1, colNumber - 1)` must return the geoid height at
|
|
102
|
+
* the NORTH-EAST corner of your data extent.
|
|
103
|
+
*/
|
|
104
|
+
function GeoidGrid(extent, step, getData) {
|
|
105
|
+
(0, _classCallCheck2["default"])(this, GeoidGrid);
|
|
106
|
+
|
|
107
|
+
_Crs["default"].isGeographic(extent.crs);
|
|
108
|
+
|
|
109
|
+
this.extent = extent;
|
|
110
|
+
this.step = new THREE.Vector2(step.x, step.y || step.x);
|
|
111
|
+
this.dimensions = this.extent.planarDimensions();
|
|
112
|
+
this.dataSize = new THREE.Vector2().addVectors(this.step, this.dimensions).divide(this.step).round();
|
|
113
|
+
this.getData = getData;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the value of the geoid height at given geographic `{@link Coordinates}`. The geoid height value is
|
|
117
|
+
* bi-linearly interpolated from the gridded data accessed by the `GeoidGrid` instance.
|
|
118
|
+
*
|
|
119
|
+
* @param {Coordinates} coordinates Geographic coordinates to get the geoid height value at.
|
|
120
|
+
*
|
|
121
|
+
* @returns {number} The geoid height value at the given `{@link Coordinates}`, bi-interpolated from the gridded
|
|
122
|
+
* data accessed by the `GeoidGrid` instance.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
(0, _createClass2["default"])(GeoidGrid, [{
|
|
127
|
+
key: "getHeightAtCoordinates",
|
|
128
|
+
value: function getHeightAtCoordinates(coordinates) {
|
|
129
|
+
coordinates.as(this.extent.crs, coord);
|
|
130
|
+
indexes.set((this.dataSize.x - 1) * (coord.x - this.extent.west) / this.dimensions.x, (this.dataSize.y - 1) * (coord.y - this.extent.south) / this.dimensions.y); // TODO : add management for global GeoidGrid.
|
|
131
|
+
|
|
132
|
+
if (indexes.x < 0 || indexes.x >= this.dataSize.x - 1 || indexes.y < 0 || indexes.y >= this.dataSize.y - 1) {
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return biLinearInterpolation(indexes, this.getData);
|
|
137
|
+
}
|
|
138
|
+
}]);
|
|
139
|
+
return GeoidGrid;
|
|
140
|
+
}();
|
|
141
|
+
|
|
142
|
+
var _default = GeoidGrid;
|
|
143
|
+
exports["default"] = _default;
|