@vcmap/core 5.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +44 -0
- package/build/postinstall.js +44 -0
- package/index.js +139 -0
- package/package.json +92 -0
- package/src/cesium/cesium3DTileFeature.js +9 -0
- package/src/cesium/cesium3DTilePointFeature.js +9 -0
- package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
- package/src/cesium/wallpaperMaterial.js +64 -0
- package/src/ol/feature.js +47 -0
- package/src/ol/geom/circle.js +24 -0
- package/src/ol/geom/geometryCollection.js +33 -0
- package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
- package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
- package/src/ol/source/VcsCluster.js +37 -0
- package/src/vcs/vcm/classRegistry.js +106 -0
- package/src/vcs/vcm/event/vcsEvent.js +89 -0
- package/src/vcs/vcm/globalCollections.js +11 -0
- package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
- package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
- package/src/vcs/vcm/interaction/eventHandler.js +425 -0
- package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
- package/src/vcs/vcm/interaction/interactionChain.js +124 -0
- package/src/vcs/vcm/interaction/interactionType.js +114 -0
- package/src/vcs/vcm/layer/buildings.js +17 -0
- package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
- package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
- package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
- package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
- package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
- package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
- package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
- package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
- package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
- package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
- package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
- package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
- package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
- package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
- package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
- package/src/vcs/vcm/layer/czml.js +141 -0
- package/src/vcs/vcm/layer/dataSource.js +259 -0
- package/src/vcs/vcm/layer/featureLayer.js +261 -0
- package/src/vcs/vcm/layer/featureStore.js +647 -0
- package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
- package/src/vcs/vcm/layer/featureStoreState.js +19 -0
- package/src/vcs/vcm/layer/featureVisibility.js +435 -0
- package/src/vcs/vcm/layer/geojson.js +185 -0
- package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
- package/src/vcs/vcm/layer/globalHider.js +157 -0
- package/src/vcs/vcm/layer/layer.js +752 -0
- package/src/vcs/vcm/layer/layerImplementation.js +102 -0
- package/src/vcs/vcm/layer/layerState.js +17 -0
- package/src/vcs/vcm/layer/layerSymbols.js +6 -0
- package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
- package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
- package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
- package/src/vcs/vcm/layer/openStreetMap.js +194 -0
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
- package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
- package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
- package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
- package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
- package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
- package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
- package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
- package/src/vcs/vcm/layer/pointCloud.js +162 -0
- package/src/vcs/vcm/layer/rasterLayer.js +294 -0
- package/src/vcs/vcm/layer/singleImage.js +119 -0
- package/src/vcs/vcm/layer/terrain.js +122 -0
- package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
- package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
- package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
- package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
- package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
- package/src/vcs/vcm/layer/tms.js +121 -0
- package/src/vcs/vcm/layer/vector.js +632 -0
- package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
- package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
- package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
- package/src/vcs/vcm/layer/vectorTile.js +480 -0
- package/src/vcs/vcm/layer/wfs.js +165 -0
- package/src/vcs/vcm/layer/wms.js +270 -0
- package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
- package/src/vcs/vcm/layer/wmts.js +235 -0
- package/src/vcs/vcm/maps/baseOLMap.js +257 -0
- package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
- package/src/vcs/vcm/maps/cesium.js +1192 -0
- package/src/vcs/vcm/maps/map.js +511 -0
- package/src/vcs/vcm/maps/mapState.js +17 -0
- package/src/vcs/vcm/maps/oblique.js +536 -0
- package/src/vcs/vcm/maps/openlayers.js +205 -0
- package/src/vcs/vcm/object.js +92 -0
- package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
- package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
- package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
- package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
- package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
- package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
- package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
- package/src/vcs/vcm/oblique/helpers.js +483 -0
- package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
- package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
- package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
- package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
- package/src/vcs/vcm/util/collection.js +193 -0
- package/src/vcs/vcm/util/dateTime.js +60 -0
- package/src/vcs/vcm/util/exclusiveManager.js +135 -0
- package/src/vcs/vcm/util/extent.js +124 -0
- package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
- package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
- package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
- package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
- package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
- package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
- package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
- package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
- package/src/vcs/vcm/util/geometryHelpers.js +172 -0
- package/src/vcs/vcm/util/indexedCollection.js +158 -0
- package/src/vcs/vcm/util/isMobile.js +12 -0
- package/src/vcs/vcm/util/layerCollection.js +216 -0
- package/src/vcs/vcm/util/locale.js +53 -0
- package/src/vcs/vcm/util/mapCollection.js +363 -0
- package/src/vcs/vcm/util/math.js +71 -0
- package/src/vcs/vcm/util/projection.js +348 -0
- package/src/vcs/vcm/util/splitScreen.js +233 -0
- package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
- package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
- package/src/vcs/vcm/util/style/styleFactory.js +48 -0
- package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
- package/src/vcs/vcm/util/style/styleItem.js +226 -0
- package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
- package/src/vcs/vcm/util/style/writeStyle.js +48 -0
- package/src/vcs/vcm/util/urlHelpers.js +16 -0
- package/src/vcs/vcm/util/viewpoint.js +333 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { Cartographic, Cartesian3, Math as CesiumMath, Cesium3DTileFeature, Cesium3DTilePointFeature } from '@vcmap/cesium';
|
|
2
|
+
|
|
3
|
+
import AbstractInteraction from './abstractInteraction.js';
|
|
4
|
+
import Projection from '../util/projection.js';
|
|
5
|
+
import { EventType, ModificationKeyType } from './interactionType.js';
|
|
6
|
+
import { vcsLayerName } from '../layer/layerSymbols.js';
|
|
7
|
+
import { originalFeatureSymbol } from '../layer/vectorSymbols.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @class
|
|
11
|
+
* @extends {AbstractInteraction}
|
|
12
|
+
*/
|
|
13
|
+
class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
/**
|
|
17
|
+
* @type {EventType|number}
|
|
18
|
+
* @private
|
|
19
|
+
*/
|
|
20
|
+
this._pickPosition = EventType.CLICK;
|
|
21
|
+
/**
|
|
22
|
+
* @type {number}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
this._pickPositionMask = -1;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* whether to pick translucent depth or not, defaults to true
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
* @api
|
|
31
|
+
*/
|
|
32
|
+
this.pickTranslucent = true;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* <i>Pulls</i> the picked position towards the camera position by this number
|
|
36
|
+
* @type {number}
|
|
37
|
+
* @default 0
|
|
38
|
+
* @api
|
|
39
|
+
*/
|
|
40
|
+
this.pullPickedPosition = 0;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The number of pixels to take into account for picking features
|
|
44
|
+
* @type {number}
|
|
45
|
+
* @default 10
|
|
46
|
+
* @api
|
|
47
|
+
*/
|
|
48
|
+
this.hitTolerance = 10;
|
|
49
|
+
|
|
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
|
+
/**
|
|
64
|
+
* @type {import("ol").Feature<import("ol/geom/Geometry").default>|Object|null}
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
this._draggingFeature = null;
|
|
68
|
+
this.setActive();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Bitmask of {@link EventType} for which events to pick the position
|
|
73
|
+
* @type {number}
|
|
74
|
+
* @api
|
|
75
|
+
*/
|
|
76
|
+
get pickPosition() { return this._pickPosition; }
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {number} position
|
|
80
|
+
*/
|
|
81
|
+
set pickPosition(position) {
|
|
82
|
+
this._pickPosition = position & this._pickPositionMask;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Bitmask of {@link EventType} for which to never pick positions.
|
|
87
|
+
* @type {number}
|
|
88
|
+
* @api
|
|
89
|
+
*/
|
|
90
|
+
get excludedPickPositionEvents() { return ~this._pickPositionMask; }
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {number} position
|
|
94
|
+
*/
|
|
95
|
+
set excludedPickPositionEvents(position) {
|
|
96
|
+
this._pickPositionMask = ~position;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @inheritDoc
|
|
101
|
+
* @param {InteractionEvent} event
|
|
102
|
+
* @returns {Promise<InteractionEvent>}
|
|
103
|
+
*/
|
|
104
|
+
async pipe(event) {
|
|
105
|
+
if (event.type & EventType.DRAG && !(this._pickPosition & EventType.DRAG)) {
|
|
106
|
+
if (this._draggingFeature) {
|
|
107
|
+
event.feature = this._draggingFeature;
|
|
108
|
+
}
|
|
109
|
+
return event;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (event.type & EventType.DRAGEND) {
|
|
113
|
+
this._draggingFeature = null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (event.map.className === 'vcs.vcm.maps.Openlayers') {
|
|
117
|
+
await this._openlayersHandler(event);
|
|
118
|
+
} else if (event.map.className === 'vcs.vcm.maps.Oblique') {
|
|
119
|
+
await this._obliqueHandler(event);
|
|
120
|
+
} else if (event.map.className === 'vcs.vcm.maps.Cesium') {
|
|
121
|
+
await this._cesiumHandler(event);
|
|
122
|
+
}
|
|
123
|
+
if (event.type & EventType.DRAGSTART && event.feature) {
|
|
124
|
+
this._draggingFeature = event.feature;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (event.type & EventType.DRAG && this._draggingFeature) {
|
|
128
|
+
event.feature = this._draggingFeature;
|
|
129
|
+
}
|
|
130
|
+
return event;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @inheritDoc
|
|
135
|
+
* @param {(boolean|number)=} active
|
|
136
|
+
*/
|
|
137
|
+
setActive(active) {
|
|
138
|
+
if (typeof active === 'undefined') {
|
|
139
|
+
this.pickPosition = EventType.CLICK;
|
|
140
|
+
this.pullPickedPosition = 0;
|
|
141
|
+
}
|
|
142
|
+
super.setActive(active);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @param {InteractionEvent} event
|
|
147
|
+
* @returns {Promise<InteractionEvent>}
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
_openlayersHandler(event) {
|
|
151
|
+
/** @type {null|import("ol").Feature<import("ol/geom/Geometry").default>} */
|
|
152
|
+
let found = null;
|
|
153
|
+
/** @type {null|import("ol/layer/Layer").default} */
|
|
154
|
+
let foundLayer = null;
|
|
155
|
+
/** @type {import("@vcmap/core").Openlayers} */ (event.map).olMap
|
|
156
|
+
.forEachFeatureAtPixel([event.windowPosition.x, event.windowPosition.y], (feat, layer) => {
|
|
157
|
+
if (feat && (feat.get('olcs_allowPicking') == null || feat.get('olcs_allowPicking') === true)) {
|
|
158
|
+
found = /** @type {import("ol").Feature<import("ol/geom/Geometry").default>} */ (feat);
|
|
159
|
+
foundLayer = layer;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}, { hitTolerance: this.hitTolerance });
|
|
163
|
+
if (found && foundLayer) {
|
|
164
|
+
event.feature = found;
|
|
165
|
+
if (found.get('features')) {
|
|
166
|
+
event.feature[vcsLayerName] = foundLayer[vcsLayerName];
|
|
167
|
+
}
|
|
168
|
+
event.exactPosition = true;
|
|
169
|
+
}
|
|
170
|
+
return Promise.resolve(event);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @param {InteractionEvent} event
|
|
175
|
+
* @returns {Promise<InteractionEvent>}
|
|
176
|
+
* @private
|
|
177
|
+
*/
|
|
178
|
+
_obliqueHandler(event) {
|
|
179
|
+
/** @type {null|import("ol").Feature<import("ol/geom/Geometry").default>} */
|
|
180
|
+
let found = null;
|
|
181
|
+
/** @type {null|import("ol/layer/Layer").default} */
|
|
182
|
+
let foundLayer = null;
|
|
183
|
+
/** @type {import("@vcmap/core").Oblique} */ (event.map).olMap
|
|
184
|
+
.forEachFeatureAtPixel([event.windowPosition.x, event.windowPosition.y], (feat, layer) => {
|
|
185
|
+
if (feat) {
|
|
186
|
+
found = feat[originalFeatureSymbol] || feat;
|
|
187
|
+
}
|
|
188
|
+
foundLayer = layer;
|
|
189
|
+
return true;
|
|
190
|
+
}, { hitTolerance: this.hitTolerance });
|
|
191
|
+
|
|
192
|
+
if (found && foundLayer) {
|
|
193
|
+
event.feature = found;
|
|
194
|
+
if (found.get('features')) {
|
|
195
|
+
event.feature[vcsLayerName] = foundLayer[vcsLayerName];
|
|
196
|
+
}
|
|
197
|
+
event.exactPosition = true;
|
|
198
|
+
}
|
|
199
|
+
return Promise.resolve(event);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @param {InteractionEvent} event
|
|
204
|
+
* @returns {Promise<InteractionEvent>}
|
|
205
|
+
* @private
|
|
206
|
+
*/
|
|
207
|
+
_cesiumHandler(event) {
|
|
208
|
+
const cesiumMap = /** @type {import("@vcmap/core").CesiumMap} */ (event.map);
|
|
209
|
+
const scene = cesiumMap.getScene();
|
|
210
|
+
|
|
211
|
+
const object = scene.pick(event.windowPosition, this.hitTolerance, this.hitTolerance);
|
|
212
|
+
|
|
213
|
+
let scratchCartographic = new Cartographic();
|
|
214
|
+
let scratchCartesian = new Cartesian3();
|
|
215
|
+
let scratchPullCartesian = new Cartesian3();
|
|
216
|
+
const { pickTranslucentDepth } = scene;
|
|
217
|
+
|
|
218
|
+
const handlePick = () => {
|
|
219
|
+
if (!scratchCartesian) {
|
|
220
|
+
scratchCartesian = new Cartesian3();
|
|
221
|
+
return Promise.resolve(event);
|
|
222
|
+
}
|
|
223
|
+
if (this.pullPickedPosition && event.ray) {
|
|
224
|
+
scratchPullCartesian = Cartesian3
|
|
225
|
+
.multiplyByScalar(event.ray.direction, this.pullPickedPosition, scratchPullCartesian);
|
|
226
|
+
|
|
227
|
+
scratchCartesian = Cartesian3.subtract(scratchCartesian, scratchPullCartesian, scratchCartesian);
|
|
228
|
+
}
|
|
229
|
+
scratchCartographic = Cartographic
|
|
230
|
+
.fromCartesian(scratchCartesian, scene.globe.ellipsoid, scratchCartographic);
|
|
231
|
+
event.position = Projection.wgs84ToMercator([
|
|
232
|
+
CesiumMath.toDegrees(scratchCartographic.longitude),
|
|
233
|
+
CesiumMath.toDegrees(scratchCartographic.latitude),
|
|
234
|
+
scratchCartographic.height,
|
|
235
|
+
], true);
|
|
236
|
+
event.positionOrPixel = event.position;
|
|
237
|
+
scene.pickTranslucentDepth = pickTranslucentDepth;
|
|
238
|
+
return Promise.resolve(event);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
if (object) {
|
|
242
|
+
if (object.primitive && object.primitive.olFeature) { // vector & vectorCluster
|
|
243
|
+
event.feature = object.primitive.olFeature;
|
|
244
|
+
} else if (
|
|
245
|
+
object.primitive &&
|
|
246
|
+
object.primitive[vcsLayerName] &&
|
|
247
|
+
(object instanceof Cesium3DTileFeature || object instanceof Cesium3DTilePointFeature)
|
|
248
|
+
) { // building
|
|
249
|
+
event.feature = object;
|
|
250
|
+
const symbols = Object.getOwnPropertySymbols(object.primitive);
|
|
251
|
+
const symbolLength = symbols.length;
|
|
252
|
+
for (let i = 0; i < symbolLength; i++) {
|
|
253
|
+
event.feature[symbols[i]] = object.primitive[symbols[i]];
|
|
254
|
+
}
|
|
255
|
+
} else if (object.id && object.id.olFeature) { // cluster size === 1
|
|
256
|
+
event.feature = object.id.olFeature;
|
|
257
|
+
} else if (object.id && object.id[vcsLayerName]) { // entity
|
|
258
|
+
event.feature = object;
|
|
259
|
+
event.feature[vcsLayerName] = object.id[vcsLayerName];
|
|
260
|
+
} else {
|
|
261
|
+
event.feature = object;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (!(event.type & this.pickPosition)) {
|
|
265
|
+
return Promise.resolve(event);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (scene.pickPositionSupported) {
|
|
269
|
+
if (
|
|
270
|
+
object.primitive &&
|
|
271
|
+
this.pickTranslucent &&
|
|
272
|
+
!(object.primitive.pointCloudShading && object.primitive.pointCloudShading.attenuation)
|
|
273
|
+
) { // XXX should this always be on, also for non vector?
|
|
274
|
+
scene.pickTranslucentDepth = true;
|
|
275
|
+
scene.render(cesiumMap.getCesiumWidget().clock.currentTime);
|
|
276
|
+
event.exactPosition = true;
|
|
277
|
+
}
|
|
278
|
+
scratchCartesian = scene.pickPosition(event.windowPosition, scratchCartesian);
|
|
279
|
+
return handlePick();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return Promise.resolve(event);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export default FeatureAtPixelInteraction;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import AbstractInteraction from './abstractInteraction.js';
|
|
2
|
+
import { EventType, ModificationKeyType } from './interactionType.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {AbstractInteraction}
|
|
7
|
+
*/
|
|
8
|
+
class FeatureProviderInteraction extends AbstractInteraction {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
/**
|
|
12
|
+
* @inheritDoc
|
|
13
|
+
* @type {ModificationKeyType|number}
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
this._defaultModificationKey = ModificationKeyType.ALL;
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
* @type {ModificationKeyType|number}
|
|
20
|
+
* @protected
|
|
21
|
+
*/
|
|
22
|
+
this._defaultActive = EventType.CLICK;
|
|
23
|
+
this.setActive();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @inheritDoc
|
|
28
|
+
* @param {InteractionEvent} event
|
|
29
|
+
* @returns {Promise<InteractionEvent>}
|
|
30
|
+
*/
|
|
31
|
+
// eslint-disable-next-line class-methods-use-this
|
|
32
|
+
async pipe(event) {
|
|
33
|
+
if (!event.feature) {
|
|
34
|
+
const layersWithProvider = [...event.map.layerCollection]
|
|
35
|
+
.filter((l) => {
|
|
36
|
+
return l.featureProvider && l.active && l.isSupported(event.map) && l.featureProvider.isSupported(event.map);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (layersWithProvider.length > 0) {
|
|
40
|
+
const resolution = event.map.getCurrentResolution(event.position);
|
|
41
|
+
const features = (await Promise
|
|
42
|
+
.all(layersWithProvider.map(l => l.featureProvider.getFeaturesByCoordinate(event.position, resolution))))
|
|
43
|
+
.flat();
|
|
44
|
+
|
|
45
|
+
if (features.length > 0) {
|
|
46
|
+
event.feature = features[0];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return event;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default FeatureProviderInteraction;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import AbstractInteraction from './abstractInteraction.js';
|
|
2
|
+
import { EventType, ModificationKeyType, PointerKeyType } from './interactionType.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {AbstractInteraction}
|
|
7
|
+
* @export
|
|
8
|
+
*/
|
|
9
|
+
class InteractionChain extends AbstractInteraction {
|
|
10
|
+
/**
|
|
11
|
+
* @param {Array<AbstractInteraction>=} chain
|
|
12
|
+
*/
|
|
13
|
+
constructor(chain) {
|
|
14
|
+
super();
|
|
15
|
+
/**
|
|
16
|
+
* The interactions to handle one after the other
|
|
17
|
+
* @type {Array<AbstractInteraction>}
|
|
18
|
+
* @api
|
|
19
|
+
*/
|
|
20
|
+
this.chain = chain || [];
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
* @type {EventType}
|
|
24
|
+
* @protected
|
|
25
|
+
*/
|
|
26
|
+
this._defaultActive = EventType.ALL;
|
|
27
|
+
/**
|
|
28
|
+
* @inheritDoc
|
|
29
|
+
* @type {ModificationKeyType}
|
|
30
|
+
* @protected
|
|
31
|
+
*/
|
|
32
|
+
this._defaultModificationKey = ModificationKeyType.ALL;
|
|
33
|
+
/**
|
|
34
|
+
* @inheritDoc
|
|
35
|
+
* @type {PointerKeyType}
|
|
36
|
+
* @protected
|
|
37
|
+
*/
|
|
38
|
+
this._defaultPointerKey = PointerKeyType.ALL;
|
|
39
|
+
this.setActive();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Add an interaction to the chain. Optionally passing an index where to add the interaction to.
|
|
44
|
+
* @param {AbstractInteraction} interaction
|
|
45
|
+
* @param {number=} index
|
|
46
|
+
* @api
|
|
47
|
+
*/
|
|
48
|
+
addInteraction(interaction, index) {
|
|
49
|
+
if (index != null) {
|
|
50
|
+
this.chain.splice(index, 0, interaction);
|
|
51
|
+
} else {
|
|
52
|
+
this.chain.push(interaction);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Removes an interaction from the chain, returning the index from which it was removed
|
|
58
|
+
* @param {AbstractInteraction} interaction
|
|
59
|
+
* @returns {number}
|
|
60
|
+
* @api
|
|
61
|
+
*/
|
|
62
|
+
removeInteraction(interaction) {
|
|
63
|
+
const index = this.chain.findIndex(candidate => candidate.id === interaction.id);
|
|
64
|
+
if (index > -1) {
|
|
65
|
+
this.chain.splice(index, 1);
|
|
66
|
+
}
|
|
67
|
+
return index;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @inheritDoc
|
|
72
|
+
* @param {InteractionEvent} event
|
|
73
|
+
* @returns {Promise<InteractionEvent>}
|
|
74
|
+
*/
|
|
75
|
+
pipe(event) {
|
|
76
|
+
let promise = Promise.resolve(event);
|
|
77
|
+
const chainLength = this.chain.length;
|
|
78
|
+
for (let i = 0; i < chainLength; i++) {
|
|
79
|
+
const interaction = this.chain[i];
|
|
80
|
+
if (
|
|
81
|
+
(interaction.active & event.type) &&
|
|
82
|
+
(interaction.modificationKey & event.key) &&
|
|
83
|
+
(interaction.pointerKey & event.pointer)
|
|
84
|
+
) {
|
|
85
|
+
// eslint-disable-next-line
|
|
86
|
+
promise = promise.then(function (pipedEvent) {
|
|
87
|
+
if (pipedEvent.stopPropagation) {
|
|
88
|
+
return Promise.resolve(pipedEvent);
|
|
89
|
+
}
|
|
90
|
+
return this.pipe(pipedEvent);
|
|
91
|
+
}.bind(interaction));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return promise;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* You cannot set the modification of an interaction chain, only of its containing interactions
|
|
99
|
+
* @override
|
|
100
|
+
*/
|
|
101
|
+
setModification() {
|
|
102
|
+
this.modificationKey = this._defaultModificationKey;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* You cannot set the pointer of an interaction chain, only of its containing interactions
|
|
107
|
+
* @override
|
|
108
|
+
*/
|
|
109
|
+
setPointer() {
|
|
110
|
+
this.pointerKey = this._defaultPointerKey;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @inheritDoc
|
|
115
|
+
*/
|
|
116
|
+
destroy() {
|
|
117
|
+
this.chain.forEach((i) => { i.destroy(); });
|
|
118
|
+
this.chain = [];
|
|
119
|
+
super.destroy();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default InteractionChain;
|
|
124
|
+
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
let nextBit = 1;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Provides inforamtion to other interaction plugins for creating bitmasks
|
|
5
|
+
* @class
|
|
6
|
+
* @export
|
|
7
|
+
*/
|
|
8
|
+
export class BitCounter {
|
|
9
|
+
/**
|
|
10
|
+
* @returns {number}
|
|
11
|
+
*/
|
|
12
|
+
static get interactionTypeCounter() { return nextBit; }
|
|
13
|
+
|
|
14
|
+
static getNextBit(counter) {
|
|
15
|
+
return counter << 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Enumeration of modification key types
|
|
21
|
+
* @enum {number}
|
|
22
|
+
* @export
|
|
23
|
+
* @property {number} NONE
|
|
24
|
+
* @property {number} ALT
|
|
25
|
+
* @property {number} CTRL
|
|
26
|
+
* @property {number} SHIFT
|
|
27
|
+
* @property {number} ALL
|
|
28
|
+
* @api
|
|
29
|
+
*/
|
|
30
|
+
export const ModificationKeyType = {
|
|
31
|
+
NONE: nextBit = BitCounter.getNextBit(nextBit),
|
|
32
|
+
ALT: nextBit = BitCounter.getNextBit(nextBit),
|
|
33
|
+
CTRL: nextBit = BitCounter.getNextBit(nextBit),
|
|
34
|
+
SHIFT: nextBit = BitCounter.getNextBit(nextBit),
|
|
35
|
+
ALL: 0,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
ModificationKeyType.ALL = ModificationKeyType.NONE |
|
|
39
|
+
ModificationKeyType.ALT |
|
|
40
|
+
ModificationKeyType.CTRL |
|
|
41
|
+
ModificationKeyType.SHIFT;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Enumeration of pointer event types
|
|
45
|
+
* @enum {number}
|
|
46
|
+
* @property {number} NONE
|
|
47
|
+
* @property {number} CLICK
|
|
48
|
+
* @property {number} DBLCLICK
|
|
49
|
+
* @property {number} DRAG
|
|
50
|
+
* @property {number} DRAGSTART
|
|
51
|
+
* @property {number} DRAGEND
|
|
52
|
+
* @property {number} MOVE
|
|
53
|
+
* @property {number} DRAGEVENTS
|
|
54
|
+
* @property {number} CLICKMOVE
|
|
55
|
+
* @property {number} ALL
|
|
56
|
+
* @export
|
|
57
|
+
* @api
|
|
58
|
+
*/
|
|
59
|
+
export const EventType = {
|
|
60
|
+
NONE: 0,
|
|
61
|
+
CLICK: nextBit = BitCounter.getNextBit(nextBit),
|
|
62
|
+
DBLCLICK: nextBit = BitCounter.getNextBit(nextBit),
|
|
63
|
+
DRAG: nextBit = BitCounter.getNextBit(nextBit),
|
|
64
|
+
DRAGSTART: nextBit = BitCounter.getNextBit(nextBit),
|
|
65
|
+
DRAGEND: nextBit = BitCounter.getNextBit(nextBit),
|
|
66
|
+
MOVE: nextBit = BitCounter.getNextBit(nextBit),
|
|
67
|
+
DRAGEVENTS: 0,
|
|
68
|
+
CLICKMOVE: 0,
|
|
69
|
+
ALL: 0,
|
|
70
|
+
};
|
|
71
|
+
EventType.DRAGEVENTS = EventType.DRAG |
|
|
72
|
+
EventType.DRAGEND |
|
|
73
|
+
EventType.DRAGSTART;
|
|
74
|
+
|
|
75
|
+
EventType.CLICKMOVE = EventType.CLICK |
|
|
76
|
+
EventType.MOVE;
|
|
77
|
+
|
|
78
|
+
EventType.ALL = Object.values(EventType)
|
|
79
|
+
.reduce((val, mask) => val | mask, 0);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Enumeration of pointer keys.
|
|
83
|
+
* @enum {number}
|
|
84
|
+
* @property {number} LEFT
|
|
85
|
+
* @property {number} RIGHT
|
|
86
|
+
* @property {number} MIDDLE
|
|
87
|
+
* @property {number} ALL
|
|
88
|
+
* @export
|
|
89
|
+
* @api
|
|
90
|
+
*/
|
|
91
|
+
export const PointerKeyType = {
|
|
92
|
+
LEFT: nextBit = BitCounter.getNextBit(nextBit),
|
|
93
|
+
RIGHT: nextBit = BitCounter.getNextBit(nextBit),
|
|
94
|
+
MIDDLE: nextBit = BitCounter.getNextBit(nextBit),
|
|
95
|
+
ALL: 0,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
PointerKeyType.ALL = PointerKeyType.LEFT |
|
|
99
|
+
PointerKeyType.RIGHT |
|
|
100
|
+
PointerKeyType.MIDDLE;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Enumeration of pointer key events.
|
|
104
|
+
* @enum {number}
|
|
105
|
+
* @property {number} DOWN
|
|
106
|
+
* @property {number} UP
|
|
107
|
+
* @property {number} MOVE
|
|
108
|
+
*/
|
|
109
|
+
export const PointerEventType = {
|
|
110
|
+
DOWN: 1,
|
|
111
|
+
UP: 2,
|
|
112
|
+
MOVE: 3,
|
|
113
|
+
};
|
|
114
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { VcsClassRegistry } from '../classRegistry.js';
|
|
2
|
+
import CesiumTileset from './cesiumTileset.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* represents a specific Building layer for cesium.
|
|
6
|
+
* @class
|
|
7
|
+
* @export
|
|
8
|
+
* @extends {CesiumTileset}
|
|
9
|
+
* @api stable
|
|
10
|
+
*/
|
|
11
|
+
class Buildings extends CesiumTileset {
|
|
12
|
+
/** @type {string} */
|
|
13
|
+
static get className() { return 'vcs.vcm.layer.Buildings'; }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
VcsClassRegistry.registerClass(Buildings.className, Buildings);
|
|
17
|
+
export default Buildings;
|