@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29
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 +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- package/tests/unit/helpers/terrain/terrainData.js +8 -7
|
@@ -129,7 +129,9 @@ class MapCollection extends Collection {
|
|
|
129
129
|
* @type {ClippingObjectManager}
|
|
130
130
|
* @api
|
|
131
131
|
*/
|
|
132
|
-
this.clippingObjectManager = new ClippingObjectManager(
|
|
132
|
+
this.clippingObjectManager = new ClippingObjectManager(
|
|
133
|
+
this._layerCollection,
|
|
134
|
+
);
|
|
133
135
|
|
|
134
136
|
/**
|
|
135
137
|
* @type {Array<Function>}
|
|
@@ -165,7 +167,9 @@ class MapCollection extends Collection {
|
|
|
165
167
|
* @api
|
|
166
168
|
* @readonly
|
|
167
169
|
*/
|
|
168
|
-
get activeMap() {
|
|
170
|
+
get activeMap() {
|
|
171
|
+
return this._activeMap;
|
|
172
|
+
}
|
|
169
173
|
|
|
170
174
|
/**
|
|
171
175
|
* The currently set HTML element in which to render the maps
|
|
@@ -244,8 +248,11 @@ class MapCollection extends Collection {
|
|
|
244
248
|
add(map) {
|
|
245
249
|
const added = super.add(map);
|
|
246
250
|
if (added !== null) {
|
|
247
|
-
this._mapPointerListeners
|
|
248
|
-
|
|
251
|
+
this._mapPointerListeners.push(
|
|
252
|
+
map.pointerInteractionEvent.addEventListener(
|
|
253
|
+
this.eventHandler.handleMapEvent.bind(this.eventHandler),
|
|
254
|
+
),
|
|
255
|
+
);
|
|
249
256
|
map.layerCollection = this._layerCollection;
|
|
250
257
|
map.setTarget(this._target);
|
|
251
258
|
}
|
|
@@ -293,7 +300,8 @@ class MapCollection extends Collection {
|
|
|
293
300
|
setTarget(target) {
|
|
294
301
|
checkMaybe(target, [String, HTMLElement]);
|
|
295
302
|
|
|
296
|
-
this._target =
|
|
303
|
+
this._target =
|
|
304
|
+
typeof target === 'string' ? document.getElementById(target) : target;
|
|
297
305
|
this._array.forEach((map) => {
|
|
298
306
|
map.setTarget(this._target);
|
|
299
307
|
});
|
|
@@ -313,7 +321,9 @@ class MapCollection extends Collection {
|
|
|
313
321
|
if (fMap && fMap !== map) {
|
|
314
322
|
return fMap;
|
|
315
323
|
} else {
|
|
316
|
-
getLogger().warning(
|
|
324
|
+
getLogger().warning(
|
|
325
|
+
`the fallback map with the name: ${fallbackMap} is missconfigured`,
|
|
326
|
+
);
|
|
317
327
|
}
|
|
318
328
|
}
|
|
319
329
|
return null;
|
|
@@ -326,9 +336,7 @@ class MapCollection extends Collection {
|
|
|
326
336
|
*/
|
|
327
337
|
_getFallbackMapOrDefault(map) {
|
|
328
338
|
const fallbackMap = this._getFallbackMap(map);
|
|
329
|
-
return fallbackMap ||
|
|
330
|
-
this.getByType('OpenlayersMap')[0] ||
|
|
331
|
-
this._array[0];
|
|
339
|
+
return fallbackMap || this.getByType('OpenlayersMap')[0] || this._array[0];
|
|
332
340
|
}
|
|
333
341
|
|
|
334
342
|
/**
|
|
@@ -341,7 +349,9 @@ class MapCollection extends Collection {
|
|
|
341
349
|
async setActiveMap(mapName) {
|
|
342
350
|
const map = this.getByKey(mapName);
|
|
343
351
|
if (!map) {
|
|
344
|
-
getLogger('MapCollection').warning(
|
|
352
|
+
getLogger('MapCollection').warning(
|
|
353
|
+
`could not find map with name ${mapName}`,
|
|
354
|
+
);
|
|
345
355
|
return Promise.resolve();
|
|
346
356
|
}
|
|
347
357
|
|
|
@@ -358,7 +368,8 @@ class MapCollection extends Collection {
|
|
|
358
368
|
|
|
359
369
|
try {
|
|
360
370
|
await map.initialize();
|
|
361
|
-
} catch (error) {
|
|
371
|
+
} catch (error) {
|
|
372
|
+
// typically unsupported webGL and cesium map
|
|
362
373
|
getLogger('MapCollection').error(error);
|
|
363
374
|
this.remove(map);
|
|
364
375
|
const fallbackMap = this._getFallbackMapOrDefault(map);
|
|
@@ -379,7 +390,9 @@ class MapCollection extends Collection {
|
|
|
379
390
|
return map.activate();
|
|
380
391
|
}
|
|
381
392
|
|
|
382
|
-
viewpoint = this._activeMap
|
|
393
|
+
viewpoint = this._activeMap
|
|
394
|
+
? await this._activeMap.getViewpoint()
|
|
395
|
+
: this._cachedViewpoint;
|
|
383
396
|
|
|
384
397
|
const canShow = await map.canShowViewpoint(viewpoint);
|
|
385
398
|
if (!canShow) {
|
|
@@ -409,9 +422,11 @@ class MapCollection extends Collection {
|
|
|
409
422
|
|
|
410
423
|
this.clippingObjectManager.mapActivated(map);
|
|
411
424
|
this._postRenderListener();
|
|
412
|
-
this._postRenderListener = this._activeMap.postRender.addEventListener(
|
|
413
|
-
|
|
414
|
-
|
|
425
|
+
this._postRenderListener = this._activeMap.postRender.addEventListener(
|
|
426
|
+
(event) => {
|
|
427
|
+
this.postRender.raiseEvent(event);
|
|
428
|
+
},
|
|
429
|
+
);
|
|
415
430
|
this.mapActivated.raiseEvent(map);
|
|
416
431
|
return Promise.resolve();
|
|
417
432
|
}
|
|
@@ -423,7 +438,7 @@ class MapCollection extends Collection {
|
|
|
423
438
|
* @api
|
|
424
439
|
*/
|
|
425
440
|
getByType(type) {
|
|
426
|
-
return this._array.filter(m => m.className === type);
|
|
441
|
+
return this._array.filter((m) => m.className === type);
|
|
427
442
|
}
|
|
428
443
|
|
|
429
444
|
/**
|
|
@@ -431,7 +446,9 @@ class MapCollection extends Collection {
|
|
|
431
446
|
*/
|
|
432
447
|
destroy() {
|
|
433
448
|
super.destroy();
|
|
434
|
-
[...this._layerCollection].forEach((l) => {
|
|
449
|
+
[...this._layerCollection].forEach((l) => {
|
|
450
|
+
l.destroy();
|
|
451
|
+
});
|
|
435
452
|
this._layerCollection.destroy();
|
|
436
453
|
this.eventHandler.destroy();
|
|
437
454
|
this.mapActivated.destroy();
|
|
@@ -441,7 +458,9 @@ class MapCollection extends Collection {
|
|
|
441
458
|
this.fallbackMapActivated.destroy();
|
|
442
459
|
this.initializeError.destroy();
|
|
443
460
|
|
|
444
|
-
this._mapPointerListeners.forEach((cb) => {
|
|
461
|
+
this._mapPointerListeners.forEach((cb) => {
|
|
462
|
+
cb();
|
|
463
|
+
});
|
|
445
464
|
this._mapPointerListeners = [];
|
|
446
465
|
|
|
447
466
|
this._target = null;
|
package/src/util/math.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Math as CesiumMath,
|
|
3
|
+
Cartesian3,
|
|
4
|
+
Cartographic,
|
|
5
|
+
} from '@vcmap-cesium/engine';
|
|
2
6
|
import Projection from './projection.js';
|
|
3
7
|
|
|
4
8
|
/**
|
|
@@ -13,13 +17,20 @@ export function coordinateAtDistance(coord, d, brng) {
|
|
|
13
17
|
const brngRadians = CesiumMath.toRadians(brng);
|
|
14
18
|
const lat1 = CesiumMath.toRadians(coord[1]);
|
|
15
19
|
const lon1 = CesiumMath.toRadians(coord[0]);
|
|
16
|
-
const lat2 = Math.asin(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Math.sin(brngRadians) * Math.sin(d / R) * Math.cos(lat1),
|
|
20
|
-
Math.cos(d / R) - (Math.sin(lat1) * Math.sin(lat2)),
|
|
20
|
+
const lat2 = Math.asin(
|
|
21
|
+
Math.sin(lat1) * Math.cos(d / R) +
|
|
22
|
+
Math.cos(lat1) * Math.sin(d / R) * Math.cos(brngRadians),
|
|
21
23
|
);
|
|
22
|
-
|
|
24
|
+
const lon2 =
|
|
25
|
+
lon1 +
|
|
26
|
+
Math.atan2(
|
|
27
|
+
Math.sin(brngRadians) * Math.sin(d / R) * Math.cos(lat1),
|
|
28
|
+
Math.cos(d / R) - Math.sin(lat1) * Math.sin(lat2),
|
|
29
|
+
);
|
|
30
|
+
return [
|
|
31
|
+
parseFloat(CesiumMath.toDegrees(lon2).toFixed(5)),
|
|
32
|
+
parseFloat(CesiumMath.toDegrees(lat2).toFixed(5)),
|
|
33
|
+
];
|
|
23
34
|
}
|
|
24
35
|
|
|
25
36
|
/**
|
|
@@ -39,7 +50,9 @@ export function initialBearingBetweenCoords(coords1, coords2) {
|
|
|
39
50
|
const f2 = CesiumMath.toRadians(coords2[1]);
|
|
40
51
|
|
|
41
52
|
const y = Math.sin(l2 - l1) * Math.cos(f2);
|
|
42
|
-
const x =
|
|
53
|
+
const x =
|
|
54
|
+
Math.cos(f1) * Math.sin(f2) -
|
|
55
|
+
Math.sin(f1) * Math.cos(f2) * Math.cos(l2 - l1);
|
|
43
56
|
let brng = CesiumMath.toDegrees(Math.atan2(y, x));
|
|
44
57
|
brng = (brng + 360) % 360;
|
|
45
58
|
return brng;
|
|
@@ -65,7 +78,7 @@ export function getCartesianBearing(p1, p2) {
|
|
|
65
78
|
export function cartesian2DDistance(point0, point1) {
|
|
66
79
|
const distX = point0[0] - point1[0];
|
|
67
80
|
const distY = point0[1] - point1[1];
|
|
68
|
-
return Math.sqrt(
|
|
81
|
+
return Math.sqrt(distX ** 2 + distY ** 2);
|
|
69
82
|
}
|
|
70
83
|
|
|
71
84
|
/**
|
|
@@ -108,7 +121,13 @@ export function cartographicToWgs84(cartographic) {
|
|
|
108
121
|
*/
|
|
109
122
|
export function mercatorToCartesian(mercatorCoordinates, result) {
|
|
110
123
|
const wgs84Coords = Projection.mercatorToWgs84(mercatorCoordinates);
|
|
111
|
-
return Cartesian3.fromDegrees(
|
|
124
|
+
return Cartesian3.fromDegrees(
|
|
125
|
+
wgs84Coords[0],
|
|
126
|
+
wgs84Coords[1],
|
|
127
|
+
wgs84Coords[2],
|
|
128
|
+
null,
|
|
129
|
+
result ?? new Cartesian3(),
|
|
130
|
+
);
|
|
112
131
|
}
|
|
113
132
|
|
|
114
133
|
/**
|
|
@@ -128,16 +147,12 @@ export function cartesianToMercator(cartesian) {
|
|
|
128
147
|
*/
|
|
129
148
|
export function getMidPoint(p1, p2) {
|
|
130
149
|
if (p1.length < 3 && p2.length < 3) {
|
|
131
|
-
return [
|
|
132
|
-
p1[0] + ((p2[0] - p1[0]) / 2),
|
|
133
|
-
p1[1] + ((p2[1] - p1[1]) / 2),
|
|
134
|
-
0,
|
|
135
|
-
];
|
|
150
|
+
return [p1[0] + (p2[0] - p1[0]) / 2, p1[1] + (p2[1] - p1[1]) / 2, 0];
|
|
136
151
|
}
|
|
137
152
|
return [
|
|
138
|
-
p1[0] + (
|
|
139
|
-
p1[1] + (
|
|
140
|
-
p1[2] + (
|
|
153
|
+
p1[0] + (p2[0] - p1[0]) / 2,
|
|
154
|
+
p1[1] + (p2[1] - p1[1]) / 2,
|
|
155
|
+
p1[2] + (p2[2] - p1[2]) / 2,
|
|
141
156
|
];
|
|
142
157
|
}
|
|
143
158
|
|
|
@@ -168,7 +183,8 @@ export function getCartesianPitch(p1, p2) {
|
|
|
168
183
|
|
|
169
184
|
let pitch;
|
|
170
185
|
if (p1[2] > p2[2]) {
|
|
171
|
-
pitch =
|
|
186
|
+
pitch =
|
|
187
|
+
CesiumMath.toDegrees(Math.acos(Cartesian3.dot(scratch2, scratch3))) - 90;
|
|
172
188
|
} else {
|
|
173
189
|
pitch = CesiumMath.toDegrees(Math.acos(Cartesian3.dot(scratch2, scratch3)));
|
|
174
190
|
}
|
|
@@ -57,14 +57,17 @@ function makeOverrideCollection(
|
|
|
57
57
|
|
|
58
58
|
const overrideCollection = /** @type {OverrideCollection<T>} */ (collection);
|
|
59
59
|
if (overrideCollection[isOverrideCollection]) {
|
|
60
|
-
throw new Error(
|
|
60
|
+
throw new Error(
|
|
61
|
+
'Cannot transform collection, collection already is an OverrideCollection',
|
|
62
|
+
);
|
|
61
63
|
}
|
|
62
64
|
overrideCollection[isOverrideCollection] = true;
|
|
63
65
|
|
|
64
|
-
const deserialize = deserializeItem || (i => i);
|
|
66
|
+
const deserialize = deserializeItem || ((i) => i);
|
|
65
67
|
// @ts-ignore
|
|
66
|
-
const serialize = serializeItem || (i => (i.toJSON ? i.toJSON() : i));
|
|
67
|
-
const getShadowIndex =
|
|
68
|
+
const serialize = serializeItem || ((i) => (i.toJSON ? i.toJSON() : i));
|
|
69
|
+
const getShadowIndex =
|
|
70
|
+
determineShadowIndex || ((item, shadow, currentIndex) => currentIndex);
|
|
68
71
|
|
|
69
72
|
/**
|
|
70
73
|
* @type {Map<string, Array<Object>>}
|
|
@@ -117,20 +120,31 @@ function makeOverrideCollection(
|
|
|
117
120
|
* @param {string} moduleId
|
|
118
121
|
* @returns {Promise<void>}
|
|
119
122
|
*/
|
|
120
|
-
overrideCollection.parseItems = async function parseItems(
|
|
123
|
+
overrideCollection.parseItems = async function parseItems(
|
|
124
|
+
configArray,
|
|
125
|
+
moduleId,
|
|
126
|
+
) {
|
|
121
127
|
if (Array.isArray(configArray)) {
|
|
122
|
-
const instanceArray = await Promise.all(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
const instanceArray = await Promise.all(
|
|
129
|
+
configArray.map(async (config) => {
|
|
130
|
+
const item = await deserialize(config);
|
|
131
|
+
if (!item || (ctor && !(item instanceof ctor))) {
|
|
132
|
+
getLogger().warning(
|
|
133
|
+
`Could not load item ${
|
|
134
|
+
config[overrideCollection.uniqueKey]
|
|
135
|
+
} of type ${config.type}`,
|
|
136
|
+
);
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
item[moduleIdSymbol] = moduleId;
|
|
140
|
+
return item;
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
131
143
|
instanceArray
|
|
132
|
-
.filter(i => i)
|
|
133
|
-
.forEach((i) => {
|
|
144
|
+
.filter((i) => i)
|
|
145
|
+
.forEach((i) => {
|
|
146
|
+
overrideCollection.override(i);
|
|
147
|
+
});
|
|
134
148
|
}
|
|
135
149
|
};
|
|
136
150
|
|
|
@@ -154,8 +168,12 @@ function makeOverrideCollection(
|
|
|
154
168
|
if (serializedShadow) {
|
|
155
169
|
const reincarnation = await deserialize(serializedShadow);
|
|
156
170
|
reincarnation[moduleIdSymbol] = serializedShadow[moduleIdSymbol];
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
const index = getShadowIndex(
|
|
172
|
+
reincarnation,
|
|
173
|
+
item,
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
item[overrideCollection.previousIndexSymbol],
|
|
176
|
+
);
|
|
159
177
|
// @ts-ignore
|
|
160
178
|
overrideCollection.add(reincarnation, index);
|
|
161
179
|
}
|
|
@@ -178,7 +196,9 @@ function makeOverrideCollection(
|
|
|
178
196
|
*/
|
|
179
197
|
overrideCollection.removeModule = async function removeModule(moduleId) {
|
|
180
198
|
overrideCollection.shadowMap.forEach((shadowsArray, name) => {
|
|
181
|
-
const newShadowsArray = shadowsArray.filter(
|
|
199
|
+
const newShadowsArray = shadowsArray.filter(
|
|
200
|
+
(c) => c[moduleIdSymbol] !== moduleId,
|
|
201
|
+
);
|
|
182
202
|
if (newShadowsArray.length === 0) {
|
|
183
203
|
overrideCollection.shadowMap.delete(name);
|
|
184
204
|
} else if (newShadowsArray.length !== shadowsArray.length) {
|
|
@@ -186,16 +206,18 @@ function makeOverrideCollection(
|
|
|
186
206
|
}
|
|
187
207
|
});
|
|
188
208
|
|
|
189
|
-
await Promise.all(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (item.destroy) {
|
|
209
|
+
await Promise.all(
|
|
210
|
+
[...overrideCollection]
|
|
211
|
+
.filter((item) => item[moduleIdSymbol] === moduleId)
|
|
212
|
+
.map(async (item) => {
|
|
213
|
+
overrideCollection.remove(item);
|
|
195
214
|
// @ts-ignore
|
|
196
|
-
item.destroy
|
|
197
|
-
|
|
198
|
-
|
|
215
|
+
if (item.destroy) {
|
|
216
|
+
// @ts-ignore
|
|
217
|
+
item.destroy();
|
|
218
|
+
}
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
199
221
|
};
|
|
200
222
|
|
|
201
223
|
/**
|
|
@@ -213,13 +235,16 @@ function makeOverrideCollection(
|
|
|
213
235
|
if (item[moduleIdSymbol] === moduleId) {
|
|
214
236
|
return serialize(item);
|
|
215
237
|
}
|
|
216
|
-
if (
|
|
217
|
-
|
|
218
|
-
|
|
238
|
+
if (
|
|
239
|
+
overrideCollection.shadowMap.has(item[overrideCollection.uniqueKey])
|
|
240
|
+
) {
|
|
241
|
+
return overrideCollection.shadowMap
|
|
242
|
+
.get(item[overrideCollection.uniqueKey])
|
|
243
|
+
.find((i) => i[moduleIdSymbol] === moduleId);
|
|
219
244
|
}
|
|
220
245
|
return null;
|
|
221
246
|
})
|
|
222
|
-
.filter(i => i);
|
|
247
|
+
.filter((i) => i);
|
|
223
248
|
};
|
|
224
249
|
|
|
225
250
|
const originalDestroy = overrideCollection.destroy.bind(overrideCollection);
|
package/src/util/projection.js
CHANGED
|
@@ -16,8 +16,14 @@ import { check } from '@vcsuite/check';
|
|
|
16
16
|
* @typedef {function(Array<number>, Array<number>=, number=): Array<number>} CorrectTransformFunction
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
export const wgs84ToMercatorTransformer =
|
|
20
|
-
|
|
19
|
+
export const wgs84ToMercatorTransformer =
|
|
20
|
+
/** @type {CorrectTransformFunction} */ (
|
|
21
|
+
getTransform('EPSG:4326', 'EPSG:3857')
|
|
22
|
+
);
|
|
23
|
+
export const mercatorToWgs84Transformer =
|
|
24
|
+
/** @type {CorrectTransformFunction} */ (
|
|
25
|
+
getTransform('EPSG:3857', 'EPSG:4326')
|
|
26
|
+
);
|
|
21
27
|
|
|
22
28
|
/**
|
|
23
29
|
* @type {ProjectionOptions}
|
|
@@ -123,7 +129,9 @@ class Projection {
|
|
|
123
129
|
/**
|
|
124
130
|
* @returns {string}
|
|
125
131
|
*/
|
|
126
|
-
static get className() {
|
|
132
|
+
static get className() {
|
|
133
|
+
return 'Projection';
|
|
134
|
+
}
|
|
127
135
|
|
|
128
136
|
/**
|
|
129
137
|
* @param {ProjectionOptions} options
|
|
@@ -293,7 +301,11 @@ class Projection {
|
|
|
293
301
|
* @api
|
|
294
302
|
*/
|
|
295
303
|
static mercatorToWgs84(coords, inPlace) {
|
|
296
|
-
return mercatorToWgs84Transformer(
|
|
304
|
+
return mercatorToWgs84Transformer(
|
|
305
|
+
coords,
|
|
306
|
+
inPlace ? coords : undefined,
|
|
307
|
+
coords.length,
|
|
308
|
+
);
|
|
297
309
|
}
|
|
298
310
|
|
|
299
311
|
/**
|
|
@@ -304,7 +316,11 @@ class Projection {
|
|
|
304
316
|
* @api
|
|
305
317
|
*/
|
|
306
318
|
static wgs84ToMercator(coords, inPlace) {
|
|
307
|
-
return wgs84ToMercatorTransformer(
|
|
319
|
+
return wgs84ToMercatorTransformer(
|
|
320
|
+
coords,
|
|
321
|
+
inPlace ? coords : undefined,
|
|
322
|
+
coords.length,
|
|
323
|
+
);
|
|
308
324
|
}
|
|
309
325
|
|
|
310
326
|
/**
|
package/src/util/urlHelpers.js
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
// eslint-disable-next-line import/prefer-default-export
|
|
6
6
|
export function isSameOrigin(source) {
|
|
7
7
|
const { location } = window;
|
|
8
|
-
const url = new URL(
|
|
8
|
+
const url = new URL(
|
|
9
|
+
source,
|
|
10
|
+
`${location.protocol}//${location.host}${location.pathname}`,
|
|
11
|
+
);
|
|
9
12
|
// for instance data: URIs have no host information and are implicitly same origin
|
|
10
13
|
// see https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#inherited_origins
|
|
11
14
|
if (!url.host) {
|
|
12
15
|
return true;
|
|
13
16
|
}
|
|
14
|
-
return url.protocol === location.protocol &&
|
|
15
|
-
url.host === location.host;
|
|
17
|
+
return url.protocol === location.protocol && url.host === location.host;
|
|
16
18
|
}
|
package/src/util/viewpoint.js
CHANGED
|
@@ -23,11 +23,10 @@ export function propertyEqualsEpsilon(left, right, epsilon) {
|
|
|
23
23
|
* @returns {boolean}
|
|
24
24
|
*/
|
|
25
25
|
export function angleEqualsEpsilon(left, right, epsilon) {
|
|
26
|
-
const diff =
|
|
26
|
+
const diff = left - right - Math.trunc((left - right) / 360) * 360;
|
|
27
27
|
return Math.abs(diff) <= epsilon;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
/**
|
|
32
31
|
* compares two coordinates componentwise
|
|
33
32
|
* @param {import("ol/coordinate").Coordinate} left
|
|
@@ -36,8 +35,11 @@ export function angleEqualsEpsilon(left, right, epsilon) {
|
|
|
36
35
|
* @returns {boolean}
|
|
37
36
|
*/
|
|
38
37
|
export function coordinateEqualsEpsilon(left, right, epsilon) {
|
|
39
|
-
return
|
|
40
|
-
left
|
|
38
|
+
return (
|
|
39
|
+
left !== null &&
|
|
40
|
+
right !== null &&
|
|
41
|
+
left.every((val, idx) => propertyEqualsEpsilon(val, right[idx], epsilon))
|
|
42
|
+
);
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -61,7 +63,9 @@ export function coordinateEqualsEpsilon(left, right, epsilon) {
|
|
|
61
63
|
* @api stable
|
|
62
64
|
*/
|
|
63
65
|
class Viewpoint extends VcsObject {
|
|
64
|
-
static get className() {
|
|
66
|
+
static get className() {
|
|
67
|
+
return 'Viewpoint';
|
|
68
|
+
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
* @param {ViewpointOptions} options
|
|
@@ -76,8 +80,11 @@ class Viewpoint extends VcsObject {
|
|
|
76
80
|
* @api
|
|
77
81
|
*/
|
|
78
82
|
this.cameraPosition = null;
|
|
79
|
-
if (
|
|
80
|
-
|
|
83
|
+
if (
|
|
84
|
+
Array.isArray(options.cameraPosition) &&
|
|
85
|
+
options.cameraPosition.length === 3
|
|
86
|
+
) {
|
|
87
|
+
this.cameraPosition = options.cameraPosition.map((c) => Number(c));
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
/**
|
|
@@ -88,7 +95,7 @@ class Viewpoint extends VcsObject {
|
|
|
88
95
|
*/
|
|
89
96
|
this.groundPosition = null;
|
|
90
97
|
if (Array.isArray(options.groundPosition)) {
|
|
91
|
-
this.groundPosition = options.groundPosition.map(c => Number(c));
|
|
98
|
+
this.groundPosition = options.groundPosition.map((c) => Number(c));
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
/**
|
|
@@ -97,7 +104,10 @@ class Viewpoint extends VcsObject {
|
|
|
97
104
|
* @type {?number}
|
|
98
105
|
* @api
|
|
99
106
|
*/
|
|
100
|
-
this.distance = parseNumber(
|
|
107
|
+
this.distance = parseNumber(
|
|
108
|
+
options.distance,
|
|
109
|
+
this.cameraPosition ? this.cameraPosition[2] : 1000,
|
|
110
|
+
);
|
|
101
111
|
|
|
102
112
|
/**
|
|
103
113
|
* heading, angle between 0 and 360 degree 0° = North, 90° = east ...
|
|
@@ -147,7 +157,9 @@ class Viewpoint extends VcsObject {
|
|
|
147
157
|
* @readonly
|
|
148
158
|
*/
|
|
149
159
|
get easingFunction() {
|
|
150
|
-
return this.easingFunctionName
|
|
160
|
+
return this.easingFunctionName
|
|
161
|
+
? EasingFunction[this.easingFunctionName]
|
|
162
|
+
: null;
|
|
151
163
|
}
|
|
152
164
|
|
|
153
165
|
/**
|
|
@@ -184,7 +196,10 @@ class Viewpoint extends VcsObject {
|
|
|
184
196
|
* @api stable
|
|
185
197
|
*/
|
|
186
198
|
toString() {
|
|
187
|
-
const stringRep =
|
|
199
|
+
const stringRep =
|
|
200
|
+
`Viewpoint: [Ground:${String(
|
|
201
|
+
this.groundPosition ? this.groundPosition : null,
|
|
202
|
+
)}]` +
|
|
188
203
|
`[Camera:${String(this.cameraPosition ? this.cameraPosition : null)}]` +
|
|
189
204
|
`[Distance:${this.distance}]` +
|
|
190
205
|
`[heading:${this.distance}]` +
|
|
@@ -200,9 +215,10 @@ class Viewpoint extends VcsObject {
|
|
|
200
215
|
* @api
|
|
201
216
|
*/
|
|
202
217
|
static createViewpointFromExtent(extent) {
|
|
203
|
-
const extentCoordinates =
|
|
204
|
-
extent
|
|
205
|
-
|
|
218
|
+
const extentCoordinates =
|
|
219
|
+
extent instanceof Extent
|
|
220
|
+
? extent.getCoordinatesInProjection(wgs84Projection)
|
|
221
|
+
: extent;
|
|
206
222
|
|
|
207
223
|
if (extentCoordinates && extentCoordinates.length === 4) {
|
|
208
224
|
const minx = extentCoordinates[0];
|
|
@@ -216,7 +232,7 @@ class Viewpoint extends VcsObject {
|
|
|
216
232
|
if (delta < 0.001) {
|
|
217
233
|
distance = 400;
|
|
218
234
|
} else {
|
|
219
|
-
distance =
|
|
235
|
+
distance = delta * 300000;
|
|
220
236
|
}
|
|
221
237
|
|
|
222
238
|
return new Viewpoint({
|
|
@@ -240,11 +256,11 @@ class Viewpoint extends VcsObject {
|
|
|
240
256
|
static parseURLparameter(urlParameter) {
|
|
241
257
|
let { cameraPosition, groundPosition } = urlParameter;
|
|
242
258
|
if (cameraPosition != null) {
|
|
243
|
-
cameraPosition = cameraPosition.split(',').map(c => Number(c));
|
|
259
|
+
cameraPosition = cameraPosition.split(',').map((c) => Number(c));
|
|
244
260
|
}
|
|
245
261
|
|
|
246
262
|
if (groundPosition != null) {
|
|
247
|
-
groundPosition = groundPosition.split(',').map(c => Number(c));
|
|
263
|
+
groundPosition = groundPosition.split(',').map((c) => Number(c));
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
if (urlParameter.epsg != null) {
|
|
@@ -252,10 +268,18 @@ class Viewpoint extends VcsObject {
|
|
|
252
268
|
const srcProjection = new Projection({ epsg, proj4: proj4String });
|
|
253
269
|
const destProjection = wgs84Projection;
|
|
254
270
|
if (groundPosition) {
|
|
255
|
-
groundPosition = Projection.transform(
|
|
271
|
+
groundPosition = Projection.transform(
|
|
272
|
+
destProjection,
|
|
273
|
+
srcProjection,
|
|
274
|
+
groundPosition,
|
|
275
|
+
);
|
|
256
276
|
}
|
|
257
277
|
if (cameraPosition) {
|
|
258
|
-
cameraPosition = Projection.transform(
|
|
278
|
+
cameraPosition = Projection.transform(
|
|
279
|
+
destProjection,
|
|
280
|
+
srcProjection,
|
|
281
|
+
cameraPosition,
|
|
282
|
+
);
|
|
259
283
|
}
|
|
260
284
|
}
|
|
261
285
|
|
|
@@ -278,15 +302,17 @@ class Viewpoint extends VcsObject {
|
|
|
278
302
|
* @returns {boolean}
|
|
279
303
|
*/
|
|
280
304
|
isValid() {
|
|
281
|
-
const hasCamera =
|
|
305
|
+
const hasCamera =
|
|
306
|
+
this.cameraPosition &&
|
|
282
307
|
Array.isArray(this.cameraPosition) &&
|
|
283
308
|
this.cameraPosition.length === 3 &&
|
|
284
|
-
this.cameraPosition.every(position => Number.isFinite(position));
|
|
285
|
-
const hasGround =
|
|
309
|
+
this.cameraPosition.every((position) => Number.isFinite(position));
|
|
310
|
+
const hasGround =
|
|
311
|
+
this.groundPosition &&
|
|
286
312
|
Array.isArray(this.groundPosition) &&
|
|
287
313
|
this.groundPosition.length > 1 &&
|
|
288
314
|
this.groundPosition.length < 4 &&
|
|
289
|
-
this.groundPosition.every(position => Number.isFinite(position));
|
|
315
|
+
this.groundPosition.every((position) => Number.isFinite(position));
|
|
290
316
|
if (!hasGround && !hasCamera) {
|
|
291
317
|
return false;
|
|
292
318
|
}
|
|
@@ -312,16 +338,23 @@ class Viewpoint extends VcsObject {
|
|
|
312
338
|
* @returns {boolean}
|
|
313
339
|
*/
|
|
314
340
|
equals(other, epsilon = 0) {
|
|
315
|
-
return
|
|
316
|
-
other
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
coordinateEqualsEpsilon(
|
|
323
|
-
|
|
324
|
-
|
|
341
|
+
return (
|
|
342
|
+
other === this ||
|
|
343
|
+
(other !== null &&
|
|
344
|
+
propertyEqualsEpsilon(other.distance, this.distance, epsilon) &&
|
|
345
|
+
angleEqualsEpsilon(other.heading, this.heading, epsilon) &&
|
|
346
|
+
angleEqualsEpsilon(other.pitch, this.pitch, epsilon) &&
|
|
347
|
+
angleEqualsEpsilon(other.roll, this.roll, epsilon) &&
|
|
348
|
+
(coordinateEqualsEpsilon(
|
|
349
|
+
other.cameraPosition,
|
|
350
|
+
this.cameraPosition,
|
|
351
|
+
epsilon,
|
|
352
|
+
) ||
|
|
353
|
+
coordinateEqualsEpsilon(
|
|
354
|
+
other.groundPosition,
|
|
355
|
+
this.groundPosition,
|
|
356
|
+
epsilon,
|
|
357
|
+
)))
|
|
325
358
|
);
|
|
326
359
|
}
|
|
327
360
|
}
|