@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,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { Cartesian2 } from '@vcmap/
|
|
2
|
+
import { Cartesian2 } from '@vcmap-cesium/engine';
|
|
3
3
|
|
|
4
4
|
import { check, checkMaybe } from '@vcsuite/check';
|
|
5
5
|
import { getLogger as getLoggerByName } from '@vcsuite/logger';
|
|
@@ -7,9 +7,13 @@ import AbstractInteraction from './abstractInteraction.js';
|
|
|
7
7
|
import InteractionChain from './interactionChain.js';
|
|
8
8
|
import CoordinateAtPixel from './coordinateAtPixel.js';
|
|
9
9
|
import FeatureAtPixelInteraction from './featureAtPixelInteraction.js';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
EventType,
|
|
12
|
+
ModificationKeyType,
|
|
13
|
+
PointerEventType,
|
|
14
|
+
} from './interactionType.js';
|
|
11
15
|
import FeatureProviderInteraction from './featureProviderInteraction.js';
|
|
12
|
-
import VcsEvent from '../
|
|
16
|
+
import VcsEvent from '../vcsEvent.js';
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* @namespace interaction
|
|
@@ -27,18 +31,18 @@ import VcsEvent from '../event/vcsEvent.js';
|
|
|
27
31
|
* @typedef {Object} MapEvent
|
|
28
32
|
* @property {PointerEventType} pointerEvent
|
|
29
33
|
* @property {import("@vcmap/core").VcsMap} map
|
|
30
|
-
* @property {import("@vcmap/
|
|
34
|
+
* @property {import("@vcmap-cesium/engine").Cartesian2} windowPosition
|
|
31
35
|
* @property {import("@vcmap/core").ModificationKeyType} key
|
|
32
36
|
* @property {import("@vcmap/core").PointerKeyType} pointer
|
|
33
37
|
* @property {import("ol/coordinate").Coordinate|undefined} position - position in web mercator coordinates
|
|
34
|
-
* @property {import("ol/coordinate").Coordinate|undefined} positionOrPixel - position in web mercator coordinates or image coordinates in
|
|
38
|
+
* @property {import("ol/coordinate").Coordinate|undefined} positionOrPixel - position in web mercator coordinates or image coordinates in ObliqueMap Map Mode
|
|
35
39
|
* @property {boolean|undefined} multipleTouch - vcs:undocumented
|
|
36
40
|
* @property {number|null|undefined} time - vcs:undocumented
|
|
37
41
|
*/
|
|
38
42
|
|
|
39
43
|
/**
|
|
40
44
|
* @typedef {Object} LastClick
|
|
41
|
-
* @property {import("@vcmap/
|
|
45
|
+
* @property {import("@vcmap-cesium/engine").Cartesian2} windowPosition - vcs:undocumented
|
|
42
46
|
* @property {number|null} time - vcs:undocumented
|
|
43
47
|
* @api
|
|
44
48
|
*/
|
|
@@ -47,7 +51,7 @@ import VcsEvent from '../event/vcsEvent.js';
|
|
|
47
51
|
* @returns {import("@vcsuite/logger").Logger}
|
|
48
52
|
*/
|
|
49
53
|
function getLogger() {
|
|
50
|
-
return getLoggerByName('
|
|
54
|
+
return getLoggerByName('EventHandler');
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
/**
|
|
@@ -105,6 +109,20 @@ class EventHandler {
|
|
|
105
109
|
windowPosition: new Cartesian2(),
|
|
106
110
|
};
|
|
107
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @type {Map<ModificationKeyType, boolean>}
|
|
114
|
+
* @private
|
|
115
|
+
*/
|
|
116
|
+
this._lastKeyEventModifiers = new Map();
|
|
117
|
+
this._lastKeyEventModifiers.set(ModificationKeyType.SHIFT, false);
|
|
118
|
+
this._lastKeyEventModifiers.set(ModificationKeyType.ALT, false);
|
|
119
|
+
this._lastKeyEventModifiers.set(ModificationKeyType.CTRL, false);
|
|
120
|
+
/**
|
|
121
|
+
* @type {ModificationKeyType}
|
|
122
|
+
* @private
|
|
123
|
+
*/
|
|
124
|
+
this._lastDispatchedModifier = ModificationKeyType.NONE;
|
|
125
|
+
|
|
108
126
|
/**
|
|
109
127
|
* @type {null|MapEvent}
|
|
110
128
|
* @private
|
|
@@ -146,6 +164,19 @@ class EventHandler {
|
|
|
146
164
|
* @api
|
|
147
165
|
*/
|
|
148
166
|
this.exclusiveAdded = new VcsEvent();
|
|
167
|
+
/**
|
|
168
|
+
* @type {function(KeyboardEvent):void}
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
this._boundKeyListener = this._keyListener.bind(this);
|
|
172
|
+
window.addEventListener('keydown', this._boundKeyListener);
|
|
173
|
+
window.addEventListener('keyup', this._boundKeyListener);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @type {VcsEvent<ModificationKeyType>}
|
|
177
|
+
* @private
|
|
178
|
+
*/
|
|
179
|
+
this._modifierChanged = new VcsEvent();
|
|
149
180
|
}
|
|
150
181
|
|
|
151
182
|
/**
|
|
@@ -153,21 +184,27 @@ class EventHandler {
|
|
|
153
184
|
* @readonly
|
|
154
185
|
* @api
|
|
155
186
|
*/
|
|
156
|
-
get positionInteraction() {
|
|
187
|
+
get positionInteraction() {
|
|
188
|
+
return this._positionInteraction;
|
|
189
|
+
}
|
|
157
190
|
|
|
158
191
|
/**
|
|
159
192
|
* @type {FeatureAtPixelInteraction}
|
|
160
193
|
* @readonly
|
|
161
194
|
* @api
|
|
162
195
|
*/
|
|
163
|
-
get featureInteraction() {
|
|
196
|
+
get featureInteraction() {
|
|
197
|
+
return this._featureInteraction;
|
|
198
|
+
}
|
|
164
199
|
|
|
165
200
|
/**
|
|
166
201
|
* @api
|
|
167
202
|
* @readonly
|
|
168
203
|
* @type {FeatureProviderInteraction}
|
|
169
204
|
*/
|
|
170
|
-
get featureProviderInteraction() {
|
|
205
|
+
get featureProviderInteraction() {
|
|
206
|
+
return this._featureProviderInteraction;
|
|
207
|
+
}
|
|
171
208
|
|
|
172
209
|
/**
|
|
173
210
|
* A copy of all the EventHandler interactions
|
|
@@ -175,24 +212,35 @@ class EventHandler {
|
|
|
175
212
|
* @type {AbstractInteraction[]}
|
|
176
213
|
* @api
|
|
177
214
|
*/
|
|
178
|
-
get interactions() {
|
|
215
|
+
get interactions() {
|
|
216
|
+
return this._interactionChain.chain.slice();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* An event called, when the modifier changes. Order of precedence, if more then one key is pressed: SHIFT, ALT, CTRL
|
|
221
|
+
* @type {VcsEvent<ModificationKeyType>}
|
|
222
|
+
* @readonly
|
|
223
|
+
*/
|
|
224
|
+
get modifierChanged() {
|
|
225
|
+
return this._modifierChanged;
|
|
226
|
+
}
|
|
179
227
|
|
|
180
228
|
/**
|
|
181
229
|
* Add a dynamic interaction to the interaction chain. This is the default methodology for
|
|
182
230
|
* user map interactions, such as drawing or measuring. If another exclusive interaction is added,
|
|
183
231
|
* this interaction is removed and a provided callback is called. Use the id parameter to add multiple interactions
|
|
184
|
-
* from the same source (if you don't wish to provide an {@link InteractionChain}
|
|
232
|
+
* from the same source (if you don't wish to provide an {@link InteractionChain})
|
|
185
233
|
* @param {AbstractInteraction} interaction
|
|
186
234
|
* @param {Function} removed - the callback for when the interaction is forcefully removed.
|
|
187
|
-
* @param {number=}
|
|
235
|
+
* @param {number=} index - the position at which to push the interaction. If no index is provided, the interaction is pushed at the end and therefore is executed last.
|
|
188
236
|
* @param {string=} id - an id to allow for multiple interactions to belong to the same exclusive registerer
|
|
189
237
|
* @returns {Function} function to remove the interaction with. returns number of removed interactions (0|1)
|
|
190
238
|
* @api
|
|
191
239
|
*/
|
|
192
|
-
addExclusiveInteraction(interaction, removed, index
|
|
240
|
+
addExclusiveInteraction(interaction, removed, index, id) {
|
|
193
241
|
check(interaction, AbstractInteraction);
|
|
194
242
|
check(removed, Function);
|
|
195
|
-
|
|
243
|
+
checkMaybe(index, Number);
|
|
196
244
|
checkMaybe(id, String);
|
|
197
245
|
|
|
198
246
|
if (this._exclusiveInteraction && this._exclusiveInteraction.id !== id) {
|
|
@@ -210,7 +258,11 @@ class EventHandler {
|
|
|
210
258
|
};
|
|
211
259
|
}
|
|
212
260
|
this.exclusiveAdded.raiseEvent();
|
|
213
|
-
return this._exclusiveUnListen.bind(
|
|
261
|
+
return this._exclusiveUnListen.bind(
|
|
262
|
+
this,
|
|
263
|
+
interaction,
|
|
264
|
+
this._exclusiveInteraction.id,
|
|
265
|
+
);
|
|
214
266
|
}
|
|
215
267
|
|
|
216
268
|
/**
|
|
@@ -220,12 +272,12 @@ class EventHandler {
|
|
|
220
272
|
removeExclusive() {
|
|
221
273
|
if (this._exclusiveInteraction) {
|
|
222
274
|
this._exclusiveInteraction.interactions
|
|
223
|
-
.filter(i => i)
|
|
275
|
+
.filter((i) => i)
|
|
224
276
|
.forEach((i) => {
|
|
225
277
|
this._interactionChain.removeInteraction(i);
|
|
226
278
|
});
|
|
227
279
|
this._exclusiveInteraction.cb
|
|
228
|
-
.filter(cb => cb)
|
|
280
|
+
.filter((cb) => cb)
|
|
229
281
|
.forEach((cb) => {
|
|
230
282
|
cb();
|
|
231
283
|
});
|
|
@@ -242,17 +294,21 @@ class EventHandler {
|
|
|
242
294
|
* @private
|
|
243
295
|
*/
|
|
244
296
|
_exclusiveUnListen(interaction, id) {
|
|
245
|
-
if (
|
|
297
|
+
if (
|
|
298
|
+
!this._exclusiveInteraction ||
|
|
299
|
+
(this._exclusiveInteraction && this._exclusiveInteraction.id !== id)
|
|
300
|
+
) {
|
|
246
301
|
return 0;
|
|
247
302
|
}
|
|
248
303
|
const removed = this._interactionChain.removeInteraction(interaction);
|
|
249
|
-
const index = this._exclusiveInteraction.interactions
|
|
250
|
-
|
|
304
|
+
const index = this._exclusiveInteraction.interactions.findIndex(
|
|
305
|
+
(candidate) => candidate && candidate.id === interaction.id,
|
|
306
|
+
);
|
|
251
307
|
if (index > -1) {
|
|
252
308
|
this._exclusiveInteraction.interactions.splice(index, 1, undefined);
|
|
253
309
|
this._exclusiveInteraction.cb.splice(index, 1, undefined);
|
|
254
310
|
}
|
|
255
|
-
if (this._exclusiveInteraction.interactions.every(i => i === undefined)) {
|
|
311
|
+
if (this._exclusiveInteraction.interactions.every((i) => i === undefined)) {
|
|
256
312
|
this._exclusiveInteraction = null;
|
|
257
313
|
}
|
|
258
314
|
if (removed > -1) {
|
|
@@ -274,7 +330,8 @@ class EventHandler {
|
|
|
274
330
|
check(index, Number);
|
|
275
331
|
|
|
276
332
|
this._interactionChain.addInteraction(interaction, index);
|
|
277
|
-
return () =>
|
|
333
|
+
return () =>
|
|
334
|
+
this._interactionChain.removeInteraction(interaction) !== -1 ? 1 : 0;
|
|
278
335
|
}
|
|
279
336
|
|
|
280
337
|
/**
|
|
@@ -334,13 +391,19 @@ class EventHandler {
|
|
|
334
391
|
if (
|
|
335
392
|
this._lastClick.time &&
|
|
336
393
|
Date.now() - this._lastClick.time < this.clickDuration &&
|
|
337
|
-
Cartesian2.distanceSquared(
|
|
394
|
+
Cartesian2.distanceSquared(
|
|
395
|
+
this._lastClick.windowPosition,
|
|
396
|
+
actualEvent.windowPosition,
|
|
397
|
+
) < 12
|
|
338
398
|
) {
|
|
339
399
|
this._lastClick.time = null;
|
|
340
400
|
actualEvent.type = EventType.DBLCLICK;
|
|
341
401
|
} else {
|
|
342
402
|
this._lastClick.time = Date.now();
|
|
343
|
-
Cartesian2.clone(
|
|
403
|
+
Cartesian2.clone(
|
|
404
|
+
actualEvent.windowPosition,
|
|
405
|
+
this._lastClick.windowPosition,
|
|
406
|
+
);
|
|
344
407
|
actualEvent.type = EventType.CLICK;
|
|
345
408
|
}
|
|
346
409
|
this._startChain(actualEvent);
|
|
@@ -361,7 +424,10 @@ class EventHandler {
|
|
|
361
424
|
actualEvent.key = this._dragging.key;
|
|
362
425
|
actualEvent.pointer = this._dragging.pointer;
|
|
363
426
|
this._startChain(actualEvent, true);
|
|
364
|
-
} else if (
|
|
427
|
+
} else if (
|
|
428
|
+
!this._dragging &&
|
|
429
|
+
Date.now() - this._lastDown.time > this.dragDuration
|
|
430
|
+
) {
|
|
365
431
|
actualEvent = { type: EventType.DRAGSTART, ...this._lastDown };
|
|
366
432
|
this._dragging = actualEvent;
|
|
367
433
|
this._startChain(actualEvent, true);
|
|
@@ -372,6 +438,43 @@ class EventHandler {
|
|
|
372
438
|
}
|
|
373
439
|
}
|
|
374
440
|
|
|
441
|
+
/**
|
|
442
|
+
* @param {KeyboardEvent} event
|
|
443
|
+
* @private
|
|
444
|
+
*/
|
|
445
|
+
_keyListener(event) {
|
|
446
|
+
if (event.key === 'Shift' || event.key === 'Alt') {
|
|
447
|
+
event.preventDefault();
|
|
448
|
+
event.stopPropagation();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (
|
|
452
|
+
this._lastKeyEventModifiers.get(ModificationKeyType.SHIFT) !==
|
|
453
|
+
event.shiftKey ||
|
|
454
|
+
this._lastKeyEventModifiers.get(ModificationKeyType.ALT) !==
|
|
455
|
+
event.altKey ||
|
|
456
|
+
this._lastKeyEventModifiers.get(ModificationKeyType.CTRL) !==
|
|
457
|
+
event.ctrlKey
|
|
458
|
+
) {
|
|
459
|
+
this._lastKeyEventModifiers.set(
|
|
460
|
+
ModificationKeyType.SHIFT,
|
|
461
|
+
event.shiftKey,
|
|
462
|
+
);
|
|
463
|
+
this._lastKeyEventModifiers.set(ModificationKeyType.ALT, event.altKey);
|
|
464
|
+
this._lastKeyEventModifiers.set(ModificationKeyType.CTRL, event.ctrlKey);
|
|
465
|
+
const modifier =
|
|
466
|
+
[...this._lastKeyEventModifiers.keys()].find((k) =>
|
|
467
|
+
this._lastKeyEventModifiers.get(k),
|
|
468
|
+
) || ModificationKeyType.NONE;
|
|
469
|
+
|
|
470
|
+
if (modifier !== this._lastDispatchedModifier) {
|
|
471
|
+
this._interactionChain.modifierChanged(modifier);
|
|
472
|
+
this._lastDispatchedModifier = modifier;
|
|
473
|
+
this._modifierChanged.raiseEvent(modifier);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
375
478
|
/**
|
|
376
479
|
* @param {InteractionEvent} event
|
|
377
480
|
* @param {boolean=} discardOnRunning if true the event will discarded if an eventHandler is already Running
|
|
@@ -419,6 +522,8 @@ class EventHandler {
|
|
|
419
522
|
this._featureInteraction.destroy();
|
|
420
523
|
this._featureInteraction = null;
|
|
421
524
|
this._eventQueue = [];
|
|
525
|
+
window.removeEventListener('keydown', this._boundKeyListener);
|
|
526
|
+
window.removeEventListener('keyup', this._boundKeyListener);
|
|
422
527
|
}
|
|
423
528
|
}
|
|
424
529
|
|
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Cartographic,
|
|
3
|
+
Cartesian3,
|
|
4
|
+
Math as CesiumMath,
|
|
5
|
+
Cesium3DTileFeature,
|
|
6
|
+
Cesium3DTilePointFeature,
|
|
7
|
+
Entity,
|
|
8
|
+
} from '@vcmap-cesium/engine';
|
|
2
9
|
|
|
3
10
|
import AbstractInteraction from './abstractInteraction.js';
|
|
4
11
|
import Projection from '../util/projection.js';
|
|
5
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
EventType,
|
|
14
|
+
ModificationKeyType,
|
|
15
|
+
PointerKeyType,
|
|
16
|
+
} from './interactionType.js';
|
|
6
17
|
import { vcsLayerName } from '../layer/layerSymbols.js';
|
|
7
18
|
import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
|
|
8
19
|
|
|
@@ -12,7 +23,11 @@ import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
|
|
|
12
23
|
*/
|
|
13
24
|
class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
14
25
|
constructor() {
|
|
15
|
-
super(
|
|
26
|
+
super(
|
|
27
|
+
EventType.ALL ^ EventType.MOVE,
|
|
28
|
+
ModificationKeyType.ALL,
|
|
29
|
+
PointerKeyType.ALL,
|
|
30
|
+
);
|
|
16
31
|
/**
|
|
17
32
|
* @type {EventType|number}
|
|
18
33
|
* @private
|
|
@@ -47,19 +62,6 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
47
62
|
*/
|
|
48
63
|
this.hitTolerance = 10;
|
|
49
64
|
|
|
50
|
-
/**
|
|
51
|
-
* @inheritDoc
|
|
52
|
-
* @type {ModificationKeyType|number}
|
|
53
|
-
* @protected
|
|
54
|
-
*/
|
|
55
|
-
this._defaultModificationKey = ModificationKeyType.ALL;
|
|
56
|
-
/**
|
|
57
|
-
* @inheritDoc
|
|
58
|
-
* @type {ModificationKeyType|number}
|
|
59
|
-
* @protected
|
|
60
|
-
*/
|
|
61
|
-
this._defaultActive = EventType.ALL ^ EventType.MOVE;
|
|
62
|
-
|
|
63
65
|
/**
|
|
64
66
|
* @type {import("ol").Feature<import("ol/geom/Geometry").default>|Object|null}
|
|
65
67
|
* @private
|
|
@@ -73,7 +75,9 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
73
75
|
* @type {number}
|
|
74
76
|
* @api
|
|
75
77
|
*/
|
|
76
|
-
get pickPosition() {
|
|
78
|
+
get pickPosition() {
|
|
79
|
+
return this._pickPosition;
|
|
80
|
+
}
|
|
77
81
|
|
|
78
82
|
/**
|
|
79
83
|
* @param {number} position
|
|
@@ -87,7 +91,9 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
87
91
|
* @type {number}
|
|
88
92
|
* @api
|
|
89
93
|
*/
|
|
90
|
-
get excludedPickPositionEvents() {
|
|
94
|
+
get excludedPickPositionEvents() {
|
|
95
|
+
return ~this._pickPositionMask;
|
|
96
|
+
}
|
|
91
97
|
|
|
92
98
|
/**
|
|
93
99
|
* @param {number} position
|
|
@@ -113,11 +119,11 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
113
119
|
this._draggingFeature = null;
|
|
114
120
|
}
|
|
115
121
|
|
|
116
|
-
if (event.map.className === '
|
|
122
|
+
if (event.map.className === 'OpenlayersMap') {
|
|
117
123
|
await this._openlayersHandler(event);
|
|
118
|
-
} else if (event.map.className === '
|
|
124
|
+
} else if (event.map.className === 'ObliqueMap') {
|
|
119
125
|
await this._obliqueHandler(event);
|
|
120
|
-
} else if (event.map.className === '
|
|
126
|
+
} else if (event.map.className === 'CesiumMap') {
|
|
121
127
|
await this._cesiumHandler(event);
|
|
122
128
|
}
|
|
123
129
|
if (event.type & EventType.DRAGSTART && event.feature) {
|
|
@@ -152,14 +158,26 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
152
158
|
let found = null;
|
|
153
159
|
/** @type {null|import("ol/layer/Layer").default} */
|
|
154
160
|
let foundLayer = null;
|
|
155
|
-
/** @type {import("@vcmap/core").
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
161
|
+
/** @type {import("@vcmap/core").OpenlayersMap} */ (
|
|
162
|
+
event.map
|
|
163
|
+
).olMap.forEachFeatureAtPixel(
|
|
164
|
+
[event.windowPosition.x, event.windowPosition.y],
|
|
165
|
+
(feat, layer) => {
|
|
166
|
+
if (
|
|
167
|
+
feat &&
|
|
168
|
+
(feat.get('olcs_allowPicking') == null ||
|
|
169
|
+
feat.get('olcs_allowPicking') === true)
|
|
170
|
+
) {
|
|
171
|
+
found =
|
|
172
|
+
/** @type {import("ol").Feature<import("ol/geom/Geometry").default>} */ (
|
|
173
|
+
feat
|
|
174
|
+
);
|
|
159
175
|
foundLayer = layer;
|
|
160
176
|
}
|
|
161
177
|
return true;
|
|
162
|
-
},
|
|
178
|
+
},
|
|
179
|
+
{ hitTolerance: this.hitTolerance },
|
|
180
|
+
);
|
|
163
181
|
if (found && foundLayer) {
|
|
164
182
|
event.feature = found;
|
|
165
183
|
if (found.get('features')) {
|
|
@@ -180,14 +198,19 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
180
198
|
let found = null;
|
|
181
199
|
/** @type {null|import("ol/layer/Layer").default} */
|
|
182
200
|
let foundLayer = null;
|
|
183
|
-
/** @type {import("@vcmap/core").
|
|
184
|
-
|
|
201
|
+
/** @type {import("@vcmap/core").ObliqueMap} */ (
|
|
202
|
+
event.map
|
|
203
|
+
).olMap.forEachFeatureAtPixel(
|
|
204
|
+
[event.windowPosition.x, event.windowPosition.y],
|
|
205
|
+
(feat, layer) => {
|
|
185
206
|
if (feat) {
|
|
186
207
|
found = feat[originalFeatureSymbol] || feat;
|
|
187
208
|
}
|
|
188
209
|
foundLayer = layer;
|
|
189
210
|
return true;
|
|
190
|
-
},
|
|
211
|
+
},
|
|
212
|
+
{ hitTolerance: this.hitTolerance },
|
|
213
|
+
);
|
|
191
214
|
|
|
192
215
|
if (found && foundLayer) {
|
|
193
216
|
event.feature = found;
|
|
@@ -205,10 +228,16 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
205
228
|
* @private
|
|
206
229
|
*/
|
|
207
230
|
_cesiumHandler(event) {
|
|
208
|
-
const cesiumMap = /** @type {import("@vcmap/core").CesiumMap} */ (
|
|
231
|
+
const cesiumMap = /** @type {import("@vcmap/core").CesiumMap} */ (
|
|
232
|
+
event.map
|
|
233
|
+
);
|
|
209
234
|
const scene = cesiumMap.getScene();
|
|
210
235
|
|
|
211
|
-
const object = scene.pick(
|
|
236
|
+
const object = scene.pick(
|
|
237
|
+
event.windowPosition,
|
|
238
|
+
this.hitTolerance,
|
|
239
|
+
this.hitTolerance,
|
|
240
|
+
);
|
|
212
241
|
|
|
213
242
|
let scratchCartographic = new Cartographic();
|
|
214
243
|
let scratchCartesian = new Cartesian3();
|
|
@@ -221,44 +250,63 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
221
250
|
return Promise.resolve(event);
|
|
222
251
|
}
|
|
223
252
|
if (this.pullPickedPosition && event.ray) {
|
|
224
|
-
scratchPullCartesian = Cartesian3
|
|
225
|
-
|
|
253
|
+
scratchPullCartesian = Cartesian3.multiplyByScalar(
|
|
254
|
+
event.ray.direction,
|
|
255
|
+
this.pullPickedPosition,
|
|
256
|
+
scratchPullCartesian,
|
|
257
|
+
);
|
|
226
258
|
|
|
227
|
-
scratchCartesian = Cartesian3.subtract(
|
|
259
|
+
scratchCartesian = Cartesian3.subtract(
|
|
260
|
+
scratchCartesian,
|
|
261
|
+
scratchPullCartesian,
|
|
262
|
+
scratchCartesian,
|
|
263
|
+
);
|
|
228
264
|
}
|
|
229
|
-
scratchCartographic = Cartographic
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
265
|
+
scratchCartographic = Cartographic.fromCartesian(
|
|
266
|
+
scratchCartesian,
|
|
267
|
+
scene.globe.ellipsoid,
|
|
268
|
+
scratchCartographic,
|
|
269
|
+
);
|
|
270
|
+
event.position = Projection.wgs84ToMercator(
|
|
271
|
+
[
|
|
272
|
+
CesiumMath.toDegrees(scratchCartographic.longitude),
|
|
273
|
+
CesiumMath.toDegrees(scratchCartographic.latitude),
|
|
274
|
+
scratchCartographic.height,
|
|
275
|
+
],
|
|
276
|
+
true,
|
|
277
|
+
);
|
|
236
278
|
event.positionOrPixel = event.position;
|
|
237
279
|
scene.pickTranslucentDepth = pickTranslucentDepth;
|
|
238
280
|
return Promise.resolve(event);
|
|
239
281
|
};
|
|
240
282
|
|
|
241
283
|
if (object) {
|
|
242
|
-
if (object.primitive && object.primitive.olFeature) {
|
|
284
|
+
if (object.primitive && object.primitive.olFeature) {
|
|
285
|
+
// vector & vectorCluster
|
|
243
286
|
event.feature = object.primitive.olFeature;
|
|
244
287
|
} else if (
|
|
245
288
|
object.primitive &&
|
|
246
289
|
object.primitive[vcsLayerName] &&
|
|
247
|
-
(object instanceof Cesium3DTileFeature ||
|
|
248
|
-
|
|
290
|
+
(object instanceof Cesium3DTileFeature ||
|
|
291
|
+
object instanceof Cesium3DTilePointFeature)
|
|
292
|
+
) {
|
|
293
|
+
// building
|
|
249
294
|
event.feature = object;
|
|
250
295
|
const symbols = Object.getOwnPropertySymbols(object.primitive);
|
|
251
296
|
const symbolLength = symbols.length;
|
|
252
297
|
for (let i = 0; i < symbolLength; i++) {
|
|
253
298
|
event.feature[symbols[i]] = object.primitive[symbols[i]];
|
|
254
299
|
}
|
|
255
|
-
} else if (object.id && object.id.olFeature) {
|
|
300
|
+
} else if (object.id && object.id.olFeature) {
|
|
301
|
+
// cluster size === 1
|
|
256
302
|
event.feature = object.id.olFeature;
|
|
257
|
-
} else if (
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
303
|
+
} else if (
|
|
304
|
+
object.id &&
|
|
305
|
+
object.id[vcsLayerName] &&
|
|
306
|
+
object.id instanceof Entity
|
|
307
|
+
) {
|
|
308
|
+
// entity
|
|
309
|
+
event.feature = object.id;
|
|
262
310
|
}
|
|
263
311
|
|
|
264
312
|
if (!(event.type & this.pickPosition)) {
|
|
@@ -269,13 +317,20 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
269
317
|
if (
|
|
270
318
|
object.primitive &&
|
|
271
319
|
this.pickTranslucent &&
|
|
272
|
-
!(
|
|
273
|
-
|
|
320
|
+
!(
|
|
321
|
+
object.primitive.pointCloudShading &&
|
|
322
|
+
object.primitive.pointCloudShading.attenuation
|
|
323
|
+
)
|
|
324
|
+
) {
|
|
325
|
+
// XXX should this always be on, also for non vector?
|
|
274
326
|
scene.pickTranslucentDepth = true;
|
|
275
327
|
scene.render(cesiumMap.getCesiumWidget().clock.currentTime);
|
|
276
328
|
event.exactPosition = true;
|
|
277
329
|
}
|
|
278
|
-
scratchCartesian = scene.pickPosition(
|
|
330
|
+
scratchCartesian = scene.pickPosition(
|
|
331
|
+
event.windowPosition,
|
|
332
|
+
scratchCartesian,
|
|
333
|
+
);
|
|
279
334
|
return handlePick();
|
|
280
335
|
}
|
|
281
336
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import AbstractInteraction from './abstractInteraction.js';
|
|
2
|
+
import {
|
|
3
|
+
EventType,
|
|
4
|
+
ModificationKeyType,
|
|
5
|
+
PointerKeyType,
|
|
6
|
+
} from './interactionType.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @class
|
|
10
|
+
* @extends {AbstractInteraction}
|
|
11
|
+
*/
|
|
12
|
+
class FeatureProviderInteraction extends AbstractInteraction {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(EventType.CLICK, ModificationKeyType.ALL, PointerKeyType.ALL);
|
|
15
|
+
|
|
16
|
+
this.setActive();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
* @param {InteractionEvent} event
|
|
22
|
+
* @returns {Promise<InteractionEvent>}
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line class-methods-use-this
|
|
25
|
+
async pipe(event) {
|
|
26
|
+
if (!event.feature) {
|
|
27
|
+
const layersWithProvider = [...event.map.layerCollection].filter((l) => {
|
|
28
|
+
return (
|
|
29
|
+
l.featureProvider &&
|
|
30
|
+
l.active &&
|
|
31
|
+
l.isSupported(event.map) &&
|
|
32
|
+
l.featureProvider.isSupported(event.map)
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (layersWithProvider.length > 0) {
|
|
37
|
+
const resolution = event.map.getCurrentResolution(event.position);
|
|
38
|
+
const features = (
|
|
39
|
+
await Promise.all(
|
|
40
|
+
layersWithProvider.map((l) =>
|
|
41
|
+
l.featureProvider.getFeaturesByCoordinate(
|
|
42
|
+
event.position,
|
|
43
|
+
resolution,
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
).flat();
|
|
48
|
+
|
|
49
|
+
if (features.length > 0) {
|
|
50
|
+
event.feature = features[0];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return event;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default FeatureProviderInteraction;
|