@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.30
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/LICENSE.md +1 -1
- package/README.md +12 -5
- package/build/postinstall.js +14 -3
- package/index.d.ts +3477 -2007
- package/index.js +169 -131
- package/package.json +25 -27
- package/src/category/category.js +483 -0
- package/src/category/categoryCollection.js +153 -0
- package/src/cesium/cesium3DTileFeature.js +2 -2
- package/src/cesium/cesium3DTilePointFeature.js +1 -1
- package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
- package/src/cesium/entity.js +29 -0
- package/src/cesium/wallpaperMaterial.js +5 -3
- package/src/classRegistry.js +169 -0
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
- package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
- package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
- package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
- package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
- package/src/interaction/featureProviderInteraction.js +58 -0
- package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
- package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
- package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +67 -55
- package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
- package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
- package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
- package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
- package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
- package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +6 -6
- package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
- package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
- package/src/layer/cesium/vectorContext.js +363 -0
- package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
- package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
- package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
- package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
- package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
- package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -108
- package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
- package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
- package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
- package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
- package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
- package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
- package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
- package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
- package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
- package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
- package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
- package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
- package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
- package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
- package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
- package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
- package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
- package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
- package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
- package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
- package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
- package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
- package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
- package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
- package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
- package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
- package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
- package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
- package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
- package/src/layer/terrainHelpers.js +98 -0
- package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +26 -18
- package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
- package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
- package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
- package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
- package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
- package/src/layer/vectorHelpers.js +129 -0
- package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
- package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
- package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
- package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
- package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
- package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
- package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
- package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
- package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
- package/src/{vcs/vcm/maps → map}/cameraLimiter.js +75 -32
- package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +429 -276
- package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
- package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
- package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
- package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
- package/src/oblique/defaultObliqueCollection.js +62 -0
- package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
- package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +145 -54
- package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +62 -32
- package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
- package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
- package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
- package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
- package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
- package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
- package/src/ol/feature.js +34 -1
- package/src/ol/geom/circle.js +14 -5
- package/src/ol/geom/geometryCollection.js +14 -8
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
- package/src/overrideClassRegistry.js +214 -0
- package/src/style/arcStyle.js +453 -0
- package/src/style/arrowStyle.js +304 -0
- package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
- package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
- package/src/style/styleFactory.js +32 -0
- package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
- package/src/style/styleItem.js +174 -0
- package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
- package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
- package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +84 -52
- package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
- package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
- package/src/{vcs/vcm/util → util}/collection.js +28 -10
- package/src/util/editor/createFeatureSession.js +195 -0
- package/src/util/editor/editFeaturesSession.js +325 -0
- package/src/util/editor/editGeometrySession.js +452 -0
- package/src/util/editor/editorHelpers.js +300 -0
- package/src/util/editor/editorSessionHelpers.js +132 -0
- package/src/util/editor/editorSymbols.js +21 -0
- package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
- package/src/util/editor/interactions/createCircleInteraction.js +119 -0
- package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
- package/src/util/editor/interactions/createPointInteraction.js +73 -0
- package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
- package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
- package/src/util/editor/interactions/mapInteractionController.js +119 -0
- package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
- package/src/util/editor/selectFeaturesSession.js +303 -0
- package/src/util/editor/transformation/create2DHandlers.js +339 -0
- package/src/util/editor/transformation/create3DHandlers.js +678 -0
- package/src/util/editor/transformation/extrudeInteraction.js +106 -0
- package/src/util/editor/transformation/rotateInteraction.js +201 -0
- package/src/util/editor/transformation/scaleInteraction.js +201 -0
- package/src/util/editor/transformation/transformationHandler.js +178 -0
- package/src/util/editor/transformation/transformationTypes.js +88 -0
- package/src/util/editor/transformation/translateInteraction.js +263 -0
- package/src/util/editor/validateGeoemetry.js +24 -0
- package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
- package/src/{vcs/vcm/util → util}/extent.js +26 -20
- package/src/util/featureconverter/arcToCesium.js +121 -0
- package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
- package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
- package/src/util/featureconverter/extent3D.js +284 -0
- package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
- package/src/util/featureconverter/lineStringToCesium.js +343 -0
- package/src/util/featureconverter/pointHelpers.js +413 -0
- package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
- package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
- package/src/util/fetch.js +34 -0
- package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
- package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
- package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
- package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
- package/src/util/locale.js +12 -0
- package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
- package/src/util/math.js +193 -0
- package/src/util/overrideCollection.js +261 -0
- package/src/{vcs/vcm/util → util}/projection.js +23 -31
- package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
- package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
- package/src/vcsApp.js +657 -0
- package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
- package/src/vcsModule.js +130 -0
- package/src/vcsModuleHelpers.js +136 -0
- package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
- package/tests/data/dynamicPointCzml.json +53 -0
- package/tests/data/oblique/imageData/imagev34.json +136 -0
- package/tests/data/oblique/imageData/imagev35.json +307 -0
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
- package/tests/data/oblique/tiledImageData/image.json +70 -0
- package/tests/data/terrain/13/8800/6485.terrain +0 -0
- package/tests/data/terrain/13/8800/6486.terrain +0 -0
- package/tests/data/terrain/13/8801/6485.terrain +0 -0
- package/tests/data/terrain/13/8801/6486.terrain +0 -0
- package/tests/data/terrain/layer.json +127 -0
- package/tests/data/testGeoJSON.json +149 -0
- package/tests/data/tile.pbf +0 -0
- package/tests/unit/helpers/cesiumHelpers.js +326 -0
- package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
- package/tests/unit/helpers/helpers.js +32 -0
- package/tests/unit/helpers/imageHelpers.js +24 -0
- package/tests/unit/helpers/importJSON.js +15 -0
- package/tests/unit/helpers/obliqueData.js +102 -0
- package/tests/unit/helpers/obliqueHelpers.js +115 -0
- package/tests/unit/helpers/openlayersHelpers.js +25 -0
- package/tests/unit/helpers/terrain/terrainData.js +47 -0
- package/src/vcs/vcm/classRegistry.js +0 -106
- package/src/vcs/vcm/globalCollections.js +0 -11
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
- package/src/vcs/vcm/layer/buildings.js +0 -17
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
- package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
- package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
- package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
- package/src/vcs/vcm/util/dateTime.js +0 -60
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
- package/src/vcs/vcm/util/locale.js +0 -53
- package/src/vcs/vcm/util/math.js +0 -71
- package/src/vcs/vcm/util/splitScreen.js +0 -233
- package/src/vcs/vcm/util/style/styleFactory.js +0 -48
- package/src/vcs/vcm/util/style/styleItem.js +0 -243
- /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import VectorStyleItem from './vectorStyleItem.js';
|
|
2
2
|
import DeclarativeStyleItem from './declarativeStyleItem.js';
|
|
3
|
-
import { referenceableStyleSymbol } from './styleItem.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @param {VectorStyleItemOptions} obj
|
|
@@ -8,11 +7,7 @@ import { referenceableStyleSymbol } from './styleItem.js';
|
|
|
8
7
|
* @returns {VectorStyleItemOptions}
|
|
9
8
|
*/
|
|
10
9
|
export function embedIconsInStyle(obj, embeddedIcons) {
|
|
11
|
-
if (
|
|
12
|
-
obj.image &&
|
|
13
|
-
obj.image.src &&
|
|
14
|
-
/^data:/.test(obj.image.src)
|
|
15
|
-
) {
|
|
10
|
+
if (obj.image && obj.image.src && /^data:/.test(obj.image.src)) {
|
|
16
11
|
if (embeddedIcons) {
|
|
17
12
|
let index = embeddedIcons.indexOf(obj.image.src);
|
|
18
13
|
if (index === -1) {
|
|
@@ -21,7 +16,8 @@ export function embedIconsInStyle(obj, embeddedIcons) {
|
|
|
21
16
|
}
|
|
22
17
|
obj.image.src = `:${index}`;
|
|
23
18
|
} else {
|
|
24
|
-
obj.image = {
|
|
19
|
+
obj.image = {
|
|
20
|
+
// XXX is this the correct fallback?
|
|
25
21
|
radius: 5,
|
|
26
22
|
};
|
|
27
23
|
}
|
|
@@ -35,12 +31,11 @@ export function embedIconsInStyle(obj, embeddedIcons) {
|
|
|
35
31
|
* @returns {VcsMeta}
|
|
36
32
|
*/
|
|
37
33
|
function writeStyle(style, vcsMeta = {}) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
vcsMeta.style = embedIconsInStyle(style.getOptions(), vcsMeta.embeddedIcons);
|
|
34
|
+
// XXX this entire function is not what is to be expected. feature store expects styles as refs to be possible
|
|
35
|
+
if (style instanceof VectorStyleItem) {
|
|
36
|
+
vcsMeta.style = embedIconsInStyle(style.toJSON(), vcsMeta.embeddedIcons);
|
|
42
37
|
} else if (style instanceof DeclarativeStyleItem) {
|
|
43
|
-
vcsMeta.style = style.
|
|
38
|
+
vcsMeta.style = style.toJSON();
|
|
44
39
|
}
|
|
45
40
|
return vcsMeta;
|
|
46
41
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { Cesium3DTileset } from '@vcmap/
|
|
2
|
+
import { Cesium3DTileset } from '@vcmap-cesium/engine';
|
|
3
3
|
|
|
4
4
|
import { check } from '@vcsuite/check';
|
|
5
5
|
import { parseBoolean } from '@vcsuite/parsers';
|
|
6
6
|
import { getLogger as getLoggerByName } from '@vcsuite/logger';
|
|
7
|
-
import CesiumMap from '../../
|
|
8
|
-
import VcsEvent from '../../
|
|
7
|
+
import CesiumMap from '../../map/cesiumMap.js';
|
|
8
|
+
import VcsEvent from '../../vcsEvent.js';
|
|
9
9
|
import LayerCollection from '../layerCollection.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @namespace clipping
|
|
13
|
-
* @export
|
|
14
13
|
* @api
|
|
15
14
|
*/
|
|
16
15
|
|
|
@@ -26,7 +25,7 @@ import LayerCollection from '../layerCollection.js';
|
|
|
26
25
|
* @typedef {Object} ClippingObjectOptions
|
|
27
26
|
* @property {Array<string>|undefined} layerNames
|
|
28
27
|
* @property {Array<ClippingObjectEntityOption>|undefined} entities
|
|
29
|
-
* @property {import("@vcmap/
|
|
28
|
+
* @property {import("@vcmap-cesium/engine").ClippingPlaneCollection|undefined} clippingPlaneCollection
|
|
30
29
|
* @property {boolean} [terrain=false]
|
|
31
30
|
* @property {boolean} [local=false] - if not local, coordinates are expected in ECEF
|
|
32
31
|
* @api
|
|
@@ -36,21 +35,20 @@ import LayerCollection from '../layerCollection.js';
|
|
|
36
35
|
* @returns {import("@vcsuite/logger").Logger}
|
|
37
36
|
*/
|
|
38
37
|
function getLogger() {
|
|
39
|
-
return getLoggerByName('
|
|
38
|
+
return getLoggerByName('ClippingObject');
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
const globeSymbol = Symbol('ClippingObjectGlobe');
|
|
43
42
|
|
|
44
43
|
/**
|
|
45
44
|
* The ClippingObject is a container for a Cesium.ClippingPlaneCollection. The container holds information on the
|
|
46
|
-
* targeted Cesium objects, based on layerNames (for [
|
|
47
|
-
* layerName and entity id for Cesium.
|
|
45
|
+
* targeted Cesium objects, based on layerNames (for [CesiumTilesetLayer]{@link CesiumTilesetLayer}) or
|
|
46
|
+
* layerName and entity id for Cesium.DataSourceLayer which are part of an [DataSourceLayer]{@link DataSource} layer.
|
|
48
47
|
* Adding a ClippingObject to the [ClippingObjectManager]{@link ClippingObjectManager} applies the
|
|
49
48
|
* objects Cesium.ClippingPlaneCollection where applicable. Once added, changes to the targets of the object are tracked.
|
|
50
49
|
* To update the Cesium.ClippingPlaneCollection or its definitions, you must trigger an update by setting the clippingPlaneCollection
|
|
51
50
|
* property to the new definition.
|
|
52
51
|
* @class
|
|
53
|
-
* @export
|
|
54
52
|
* @api stable
|
|
55
53
|
*/
|
|
56
54
|
class ClippingObject {
|
|
@@ -80,12 +78,12 @@ class ClippingObject {
|
|
|
80
78
|
/**
|
|
81
79
|
* Key is a semantic identifier, eg. layerName or layerName-entitiyId, depending on the target. Targets
|
|
82
80
|
* represent Cesium Object which support the clippingPlanes API
|
|
83
|
-
* @type {Map<(string|symbol), import("@vcmap/
|
|
81
|
+
* @type {Map<(string|symbol), import("@vcmap-cesium/engine").Entity|import("@vcmap-cesium/engine").Cesium3DTileset|import("@vcmap-cesium/engine").Globe>}
|
|
84
82
|
*/
|
|
85
83
|
this.targets = new Map();
|
|
86
84
|
|
|
87
85
|
/**
|
|
88
|
-
* @type {import("@vcmap/
|
|
86
|
+
* @type {import("@vcmap-cesium/engine").ClippingPlaneCollection|null}
|
|
89
87
|
* @private
|
|
90
88
|
*/
|
|
91
89
|
this._clippingPlaneCollection = options.clippingPlaneCollection || null;
|
|
@@ -115,7 +113,7 @@ class ClippingObject {
|
|
|
115
113
|
this.clippingPlaneUpdated = new VcsEvent();
|
|
116
114
|
|
|
117
115
|
/**
|
|
118
|
-
* @type {Set<import("@vcmap/core").
|
|
116
|
+
* @type {Set<import("@vcmap/core").FeatureStoreLayer>}
|
|
119
117
|
* @private
|
|
120
118
|
*/
|
|
121
119
|
this._cachedFeatureStoreLayers = new Set();
|
|
@@ -126,12 +124,14 @@ class ClippingObject {
|
|
|
126
124
|
/**
|
|
127
125
|
* The current Cesium.ClippingPlaneCollection. To update the collection, set this property to the new definition.
|
|
128
126
|
* @api
|
|
129
|
-
* @type {import("@vcmap/
|
|
127
|
+
* @type {import("@vcmap-cesium/engine").ClippingPlaneCollection|null}
|
|
130
128
|
*/
|
|
131
|
-
get clippingPlaneCollection() {
|
|
129
|
+
get clippingPlaneCollection() {
|
|
130
|
+
return this._clippingPlaneCollection;
|
|
131
|
+
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
|
-
* @param {import("@vcmap/
|
|
134
|
+
* @param {import("@vcmap-cesium/engine").ClippingPlaneCollection} clippingPlaneCollection
|
|
135
135
|
*/
|
|
136
136
|
set clippingPlaneCollection(clippingPlaneCollection) {
|
|
137
137
|
this._clippingPlaneCollection = clippingPlaneCollection;
|
|
@@ -143,7 +143,9 @@ class ClippingObject {
|
|
|
143
143
|
* @api
|
|
144
144
|
* @type {boolean}
|
|
145
145
|
*/
|
|
146
|
-
get terrain() {
|
|
146
|
+
get terrain() {
|
|
147
|
+
return this._terrain;
|
|
148
|
+
}
|
|
147
149
|
|
|
148
150
|
/**
|
|
149
151
|
* @param {boolean} terrain
|
|
@@ -164,7 +166,9 @@ class ClippingObject {
|
|
|
164
166
|
* @api
|
|
165
167
|
* @type {boolean}
|
|
166
168
|
*/
|
|
167
|
-
get local() {
|
|
169
|
+
get local() {
|
|
170
|
+
return this._local;
|
|
171
|
+
}
|
|
168
172
|
|
|
169
173
|
/**
|
|
170
174
|
* @param {boolean} local
|
|
@@ -202,56 +206,65 @@ class ClippingObject {
|
|
|
202
206
|
if (this.layerNames.includes(layer.name)) {
|
|
203
207
|
if (layer.active) {
|
|
204
208
|
const visualisations = map.getVisualizationsForLayer(layer);
|
|
205
|
-
const tilesets = visualisations
|
|
206
|
-
[...visualisations]
|
|
207
|
-
|
|
208
|
-
[];
|
|
209
|
+
const tilesets = visualisations
|
|
210
|
+
? [...visualisations].filter((v) => v instanceof Cesium3DTileset)
|
|
211
|
+
: [];
|
|
209
212
|
|
|
210
213
|
if (tilesets.length > 0) {
|
|
211
|
-
tilesets.forEach(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
214
|
+
tilesets.forEach(
|
|
215
|
+
/** @param {import("@vcmap-cesium/engine").Cesium3DTileset} tileset */ (
|
|
216
|
+
tileset,
|
|
217
|
+
) => {
|
|
218
|
+
tileset.readyPromise.then((cesium3DTileset) => {
|
|
219
|
+
if (this.layerNames.includes(layer.name) && layer.active) {
|
|
220
|
+
this.targets.set(layer.name, cesium3DTileset);
|
|
221
|
+
this.targetsUpdated.raiseEvent();
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
);
|
|
219
226
|
} else {
|
|
220
227
|
const index = this.layerNames.indexOf(layer.name);
|
|
221
|
-
getLogger().warning(
|
|
228
|
+
getLogger().warning(
|
|
229
|
+
`layer ${layer.name} cannot have a ClippingObject applied`,
|
|
230
|
+
);
|
|
222
231
|
this.layerNames.splice(index, 1);
|
|
223
232
|
}
|
|
224
233
|
} else if (this.targets.has(layer.name)) {
|
|
225
234
|
this.targets.delete(layer.name);
|
|
226
235
|
this.targetsUpdated.raiseEvent();
|
|
227
236
|
}
|
|
228
|
-
} else if (this.entities.find(eo => eo.layerName === layer.name)) {
|
|
237
|
+
} else if (this.entities.find((eo) => eo.layerName === layer.name)) {
|
|
229
238
|
let raise = false;
|
|
230
239
|
const visualisations = map.getVisualizationsForLayer(layer);
|
|
231
|
-
const dataSource = visualisations ?
|
|
232
|
-
[...visualisations][0] :
|
|
233
|
-
null;
|
|
240
|
+
const dataSource = visualisations ? [...visualisations][0] : null;
|
|
234
241
|
|
|
235
242
|
if (!dataSource) {
|
|
236
243
|
const index = this.layerNames.indexOf(layer.name);
|
|
237
|
-
getLogger().warning(
|
|
244
|
+
getLogger().warning(
|
|
245
|
+
`layer ${layer.name} cannot have a ClippingObject applied`,
|
|
246
|
+
);
|
|
238
247
|
this.layerNames.splice(index, 1);
|
|
239
248
|
return;
|
|
240
249
|
}
|
|
241
250
|
|
|
242
251
|
this.entities
|
|
243
|
-
.filter(eo => eo.layerName === layer.name)
|
|
252
|
+
.filter((eo) => eo.layerName === layer.name)
|
|
244
253
|
.forEach((eo) => {
|
|
245
254
|
const key = `${eo.layerName}-${eo.entityId}`;
|
|
246
255
|
if (layer.active) {
|
|
247
|
-
const entity =
|
|
248
|
-
.
|
|
256
|
+
const entity =
|
|
257
|
+
/** @type {import("@vcmap-cesium/engine").CustomDataSource} */ (
|
|
258
|
+
dataSource
|
|
259
|
+
).entities.getById(eo.entityId);
|
|
249
260
|
if (entity) {
|
|
250
261
|
this.targets.set(key, entity);
|
|
251
262
|
raise = true;
|
|
252
263
|
} else {
|
|
253
264
|
const index = this.entities.indexOf(eo);
|
|
254
|
-
getLogger().warning(
|
|
265
|
+
getLogger().warning(
|
|
266
|
+
`could not find entity with id ${eo.entityId} in layer ${eo.layerName}`,
|
|
267
|
+
);
|
|
255
268
|
this.entities.splice(index, 1);
|
|
256
269
|
}
|
|
257
270
|
} else if (this.targets.has(key)) {
|
|
@@ -264,11 +277,22 @@ class ClippingObject {
|
|
|
264
277
|
this.targetsUpdated.raiseEvent();
|
|
265
278
|
}
|
|
266
279
|
}
|
|
267
|
-
} else if (
|
|
280
|
+
} else if (
|
|
281
|
+
this.layerNames.includes(layer.name) &&
|
|
282
|
+
layer.className === 'FeatureStoreLayer'
|
|
283
|
+
) {
|
|
268
284
|
if (layer.active) {
|
|
269
|
-
this._cachedFeatureStoreLayers.add(
|
|
270
|
-
|
|
271
|
-
|
|
285
|
+
this._cachedFeatureStoreLayers.add(
|
|
286
|
+
/** @type {import("@vcmap/core").FeatureStoreLayer} */ (layer),
|
|
287
|
+
);
|
|
288
|
+
} else if (
|
|
289
|
+
this._cachedFeatureStoreLayers.has(
|
|
290
|
+
/** @type {import("@vcmap/core").FeatureStoreLayer} */ (layer),
|
|
291
|
+
)
|
|
292
|
+
) {
|
|
293
|
+
this._cachedFeatureStoreLayers.delete(
|
|
294
|
+
/** @type {import("@vcmap/core").FeatureStoreLayer} */ (layer),
|
|
295
|
+
);
|
|
272
296
|
}
|
|
273
297
|
}
|
|
274
298
|
}
|
|
@@ -293,7 +317,9 @@ class ClippingObject {
|
|
|
293
317
|
}
|
|
294
318
|
|
|
295
319
|
if (this._cachedFeatureStoreLayers.size > 0) {
|
|
296
|
-
this._cachedFeatureStoreLayers.forEach((layer) => {
|
|
320
|
+
this._cachedFeatureStoreLayers.forEach((layer) => {
|
|
321
|
+
this.handleLayerChanged(layer);
|
|
322
|
+
});
|
|
297
323
|
this._cachedFeatureStoreLayers.clear();
|
|
298
324
|
}
|
|
299
325
|
}
|
|
@@ -310,9 +336,9 @@ class ClippingObject {
|
|
|
310
336
|
|
|
311
337
|
if (!this.layerNames.includes(layerName)) {
|
|
312
338
|
this.layerNames.push(layerName);
|
|
313
|
-
const layer = this._layerCollection
|
|
314
|
-
this._layerCollection.getByKey(layerName)
|
|
315
|
-
null;
|
|
339
|
+
const layer = this._layerCollection
|
|
340
|
+
? this._layerCollection.getByKey(layerName)
|
|
341
|
+
: null;
|
|
316
342
|
// XXX active state is not part of this yet
|
|
317
343
|
if (layer && layer.active) {
|
|
318
344
|
this.handleLayerChanged(layer);
|
|
@@ -349,11 +375,15 @@ class ClippingObject {
|
|
|
349
375
|
check(layerName, String);
|
|
350
376
|
check(entityId, String);
|
|
351
377
|
|
|
352
|
-
if (
|
|
378
|
+
if (
|
|
379
|
+
!this.entities.find(
|
|
380
|
+
(eo) => eo.layerName === layerName && eo.entityId === entityId,
|
|
381
|
+
)
|
|
382
|
+
) {
|
|
353
383
|
this.entities.push({ layerName, entityId });
|
|
354
|
-
const layer = this._layerCollection
|
|
355
|
-
this._layerCollection.getByKey(layerName)
|
|
356
|
-
null;
|
|
384
|
+
const layer = this._layerCollection
|
|
385
|
+
? this._layerCollection.getByKey(layerName)
|
|
386
|
+
: null;
|
|
357
387
|
if (layer && layer.active) {
|
|
358
388
|
this.handleLayerChanged(layer);
|
|
359
389
|
}
|
|
@@ -370,7 +400,9 @@ class ClippingObject {
|
|
|
370
400
|
check(layerName, String);
|
|
371
401
|
check(entityId, String);
|
|
372
402
|
|
|
373
|
-
const index = this.entities.findIndex(
|
|
403
|
+
const index = this.entities.findIndex(
|
|
404
|
+
(c) => c.layerName === layerName && c.entityId === entityId,
|
|
405
|
+
);
|
|
374
406
|
if (index > -1) {
|
|
375
407
|
this.entities.splice(index, 1);
|
|
376
408
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { check } from '@vcsuite/check';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
clearClippingPlanes,
|
|
4
|
+
setClippingPlanes,
|
|
5
|
+
} from './clippingPlaneHelper.js';
|
|
3
6
|
import ClippingObject from './clippingObject.js';
|
|
4
|
-
import CesiumMap from '../../
|
|
7
|
+
import CesiumMap from '../../map/cesiumMap.js';
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* ClippingObjectManager, a singleton Class for managing [ClippingObjects]{@link ClippingObject}. The manager takes care to only apply a
|
|
@@ -12,12 +15,11 @@ import CesiumMap from '../../maps/cesium.js';
|
|
|
12
15
|
* overwritten in the order they where added to the manager. Exclusive [ClippingObjects]{@link ClippingObject} are always applied last, even
|
|
13
16
|
* if a default [ClippingObject]{@link ClippingObject} is added after.
|
|
14
17
|
* @class
|
|
15
|
-
* @export
|
|
16
18
|
* @api stable
|
|
17
19
|
*/
|
|
18
20
|
class ClippingObjectManager {
|
|
19
21
|
static get className() {
|
|
20
|
-
return '
|
|
22
|
+
return 'ClippingObjectManager';
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
constructor(layerCollection) {
|
|
@@ -32,7 +34,7 @@ class ClippingObjectManager {
|
|
|
32
34
|
*/
|
|
33
35
|
this._exclusiveClippingObjects = null;
|
|
34
36
|
/**
|
|
35
|
-
* @type {Map<(import("@vcmap/
|
|
37
|
+
* @type {Map<(import("@vcmap-cesium/engine").Globe|import("@vcmap-cesium/engine").Entity|import("@vcmap-cesium/engine").Cesium3DTileset), ClippingObject>}
|
|
36
38
|
* @private
|
|
37
39
|
*/
|
|
38
40
|
this._targetsMap = new Map();
|
|
@@ -68,9 +70,10 @@ class ClippingObjectManager {
|
|
|
68
70
|
* @type {Function}
|
|
69
71
|
* @private
|
|
70
72
|
*/
|
|
71
|
-
this._layerChangedListener =
|
|
72
|
-
this.
|
|
73
|
-
|
|
73
|
+
this._layerChangedListener =
|
|
74
|
+
this._layerCollection.stateChanged.addEventListener((layer) => {
|
|
75
|
+
this._layerChanged(layer);
|
|
76
|
+
});
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
/**
|
|
@@ -101,9 +104,13 @@ class ClippingObjectManager {
|
|
|
101
104
|
*/
|
|
102
105
|
_layerChanged(layer) {
|
|
103
106
|
this.suspendUpdate = true;
|
|
104
|
-
this._defaultClippingObjects.forEach((co) => {
|
|
107
|
+
this._defaultClippingObjects.forEach((co) => {
|
|
108
|
+
co.handleLayerChanged(layer);
|
|
109
|
+
});
|
|
105
110
|
if (this._exclusiveClippingObjects) {
|
|
106
|
-
this._exclusiveClippingObjects.forEach((co) => {
|
|
111
|
+
this._exclusiveClippingObjects.forEach((co) => {
|
|
112
|
+
co.handleLayerChanged(layer);
|
|
113
|
+
});
|
|
107
114
|
}
|
|
108
115
|
this.suspendUpdate = false;
|
|
109
116
|
}
|
|
@@ -113,9 +120,13 @@ class ClippingObjectManager {
|
|
|
113
120
|
*/
|
|
114
121
|
mapActivated(map) {
|
|
115
122
|
this.suspendUpdate = true;
|
|
116
|
-
this._defaultClippingObjects.forEach((co) => {
|
|
123
|
+
this._defaultClippingObjects.forEach((co) => {
|
|
124
|
+
co.handleMapChanged(map);
|
|
125
|
+
});
|
|
117
126
|
if (this._exclusiveClippingObjects) {
|
|
118
|
-
this._exclusiveClippingObjects.forEach((co) => {
|
|
127
|
+
this._exclusiveClippingObjects.forEach((co) => {
|
|
128
|
+
co.handleMapChanged(map);
|
|
129
|
+
});
|
|
119
130
|
}
|
|
120
131
|
this.suspendUpdate = false;
|
|
121
132
|
this._activeMap = map;
|
|
@@ -145,7 +156,9 @@ class ClippingObjectManager {
|
|
|
145
156
|
|
|
146
157
|
this._listenersMap.set(clippingObject, [
|
|
147
158
|
clippingObject.targetsUpdated.addEventListener(this._update.bind(this)),
|
|
148
|
-
clippingObject.clippingPlaneUpdated.addEventListener(
|
|
159
|
+
clippingObject.clippingPlaneUpdated.addEventListener(
|
|
160
|
+
this._clippingPlaneUpdated.bind(this, clippingObject),
|
|
161
|
+
),
|
|
149
162
|
]);
|
|
150
163
|
this._update();
|
|
151
164
|
}
|
|
@@ -160,7 +173,9 @@ class ClippingObjectManager {
|
|
|
160
173
|
|
|
161
174
|
if (this._defaultClippingObjects.has(clippingObject)) {
|
|
162
175
|
this._defaultClippingObjects.delete(clippingObject);
|
|
163
|
-
this._listenersMap.get(clippingObject).forEach((cb) => {
|
|
176
|
+
this._listenersMap.get(clippingObject).forEach((cb) => {
|
|
177
|
+
cb();
|
|
178
|
+
});
|
|
164
179
|
this._listenersMap.delete(clippingObject);
|
|
165
180
|
this._update();
|
|
166
181
|
}
|
|
@@ -175,8 +190,13 @@ class ClippingObjectManager {
|
|
|
175
190
|
hasClippingObject(clippingObject) {
|
|
176
191
|
check(clippingObject, ClippingObject);
|
|
177
192
|
|
|
178
|
-
return
|
|
179
|
-
|
|
193
|
+
return (
|
|
194
|
+
this._defaultClippingObjects.has(clippingObject) ||
|
|
195
|
+
!!(
|
|
196
|
+
this._exclusiveClippingObjects &&
|
|
197
|
+
this._exclusiveClippingObjects.includes(clippingObject)
|
|
198
|
+
)
|
|
199
|
+
);
|
|
180
200
|
}
|
|
181
201
|
|
|
182
202
|
/**
|
|
@@ -194,8 +214,10 @@ class ClippingObjectManager {
|
|
|
194
214
|
check(clippingObjects, [ClippingObject]);
|
|
195
215
|
check(removedCb, Function);
|
|
196
216
|
|
|
197
|
-
if (clippingObjects.find(co => this._defaultClippingObjects.has(co))) {
|
|
198
|
-
throw new Error(
|
|
217
|
+
if (clippingObjects.find((co) => this._defaultClippingObjects.has(co))) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
'Some ClippingObjects are already managed, remove them first',
|
|
220
|
+
);
|
|
199
221
|
}
|
|
200
222
|
|
|
201
223
|
this._clearExclusiveClippingObjects();
|
|
@@ -209,7 +231,9 @@ class ClippingObjectManager {
|
|
|
209
231
|
}
|
|
210
232
|
this._listenersMap.set(clippingObject, [
|
|
211
233
|
clippingObject.targetsUpdated.addEventListener(this._update.bind(this)),
|
|
212
|
-
clippingObject.clippingPlaneUpdated.addEventListener(
|
|
234
|
+
clippingObject.clippingPlaneUpdated.addEventListener(
|
|
235
|
+
this._clippingPlaneUpdated.bind(this, clippingObject),
|
|
236
|
+
),
|
|
213
237
|
]);
|
|
214
238
|
});
|
|
215
239
|
this._update();
|
|
@@ -222,7 +246,9 @@ class ClippingObjectManager {
|
|
|
222
246
|
_clearExclusiveClippingObjects(silent) {
|
|
223
247
|
if (this._exclusiveClippingObjects) {
|
|
224
248
|
this._exclusiveClippingObjects.forEach((cp) => {
|
|
225
|
-
this._listenersMap.get(cp).forEach((cb) => {
|
|
249
|
+
this._listenersMap.get(cp).forEach((cb) => {
|
|
250
|
+
cb();
|
|
251
|
+
});
|
|
226
252
|
this._listenersMap.delete(cp);
|
|
227
253
|
});
|
|
228
254
|
this._exclusiveClippingObjects = null;
|
|
@@ -270,7 +296,9 @@ class ClippingObjectManager {
|
|
|
270
296
|
this._exclusiveClippingObjects.forEach(setTargets);
|
|
271
297
|
}
|
|
272
298
|
|
|
273
|
-
currentTargets.forEach((t) => {
|
|
299
|
+
currentTargets.forEach((t) => {
|
|
300
|
+
clearClippingPlanes(t);
|
|
301
|
+
});
|
|
274
302
|
this._targetsMap.forEach((clippingObject, target) => {
|
|
275
303
|
if (clippingObject.clippingPlaneCollection) {
|
|
276
304
|
setClippingPlanes(
|
|
@@ -288,7 +316,10 @@ class ClippingObjectManager {
|
|
|
288
316
|
*/
|
|
289
317
|
_clippingPlaneUpdated(clippingObject) {
|
|
290
318
|
this._targetsMap.forEach((setClippingObject, target) => {
|
|
291
|
-
if (
|
|
319
|
+
if (
|
|
320
|
+
setClippingObject === clippingObject &&
|
|
321
|
+
clippingObject.clippingPlaneCollection
|
|
322
|
+
) {
|
|
292
323
|
setClippingPlanes(target, clippingObject.clippingPlaneCollection);
|
|
293
324
|
}
|
|
294
325
|
});
|
|
@@ -299,7 +330,9 @@ class ClippingObjectManager {
|
|
|
299
330
|
*/
|
|
300
331
|
destroy() {
|
|
301
332
|
this._listenersMap.forEach((listeners) => {
|
|
302
|
-
listeners.forEach((cb) => {
|
|
333
|
+
listeners.forEach((cb) => {
|
|
334
|
+
cb();
|
|
335
|
+
});
|
|
303
336
|
});
|
|
304
337
|
this._layerChangedListener();
|
|
305
338
|
this._listenersMap.clear();
|