@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
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import AbstractInteraction from '../../../interaction/abstractInteraction.js';
|
|
2
|
+
import { EventType } from '../../../interaction/interactionType.js';
|
|
3
|
+
import { handlerSymbol } from '../editorSymbols.js';
|
|
4
|
+
import {
|
|
5
|
+
createCameraVerticalPlane,
|
|
6
|
+
getCartographicFromPlane,
|
|
7
|
+
} from '../editorHelpers.js';
|
|
8
|
+
import VcsEvent from '../../../vcsEvent.js';
|
|
9
|
+
import { AXIS_AND_PLANES } from './transformationTypes.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class to handle events on a {@see TransformationHandler}. Should be used with {@see TransformationHandler} created for mode TransformationMode.EXTRUDE.
|
|
13
|
+
* If the Z handler is dragged, the extruded event will be raised with a delta in Z direction. This
|
|
14
|
+
* interaction only works if a {@see CesiumMap} is the active map.
|
|
15
|
+
* @class
|
|
16
|
+
* @extends {AbstractInteraction}
|
|
17
|
+
*/
|
|
18
|
+
class ExtrudeInteraction extends AbstractInteraction {
|
|
19
|
+
/**
|
|
20
|
+
* @param {TransformationHandler} transformationHandler
|
|
21
|
+
*/
|
|
22
|
+
constructor(transformationHandler) {
|
|
23
|
+
super(EventType.DRAGEVENTS);
|
|
24
|
+
/**
|
|
25
|
+
* @type {TransformationHandler}
|
|
26
|
+
* @private
|
|
27
|
+
*/
|
|
28
|
+
this._transformationHandler = transformationHandler;
|
|
29
|
+
/**
|
|
30
|
+
* @type {VcsEvent<number>}
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
this._extruded = new VcsEvent();
|
|
34
|
+
/**
|
|
35
|
+
* @type {null|function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):number}
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
this._getExtrudeEvent = null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Event raised with the extrusion delta to the last event fired.
|
|
43
|
+
* @type {VcsEvent<number>}
|
|
44
|
+
* @readonly
|
|
45
|
+
*/
|
|
46
|
+
get extruded() {
|
|
47
|
+
return this._extruded;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {InteractionEvent} event
|
|
52
|
+
* @returns {Promise<InteractionEvent>}
|
|
53
|
+
*/
|
|
54
|
+
async pipe(event) {
|
|
55
|
+
if (this._getExtrudeEvent) {
|
|
56
|
+
this._extruded.raiseEvent(
|
|
57
|
+
this._getExtrudeEvent(event.positionOrPixel, event.windowPosition),
|
|
58
|
+
);
|
|
59
|
+
if (event.type === EventType.DRAGEND) {
|
|
60
|
+
this._getExtrudeEvent = null;
|
|
61
|
+
this._transformationHandler.showAxis = AXIS_AND_PLANES.NONE;
|
|
62
|
+
}
|
|
63
|
+
} else if (
|
|
64
|
+
event.type === EventType.DRAGSTART &&
|
|
65
|
+
event?.feature?.[handlerSymbol]
|
|
66
|
+
) {
|
|
67
|
+
const axis = event.feature[handlerSymbol];
|
|
68
|
+
if (axis === AXIS_AND_PLANES.Z) {
|
|
69
|
+
const scene = /** @type {import("@vcmap/core").CesiumMap} */ (
|
|
70
|
+
event.map
|
|
71
|
+
).getScene();
|
|
72
|
+
this._transformationHandler.showAxis = axis;
|
|
73
|
+
const plane = createCameraVerticalPlane(
|
|
74
|
+
this._transformationHandler.center.slice(),
|
|
75
|
+
scene,
|
|
76
|
+
);
|
|
77
|
+
let currentHeight = getCartographicFromPlane(
|
|
78
|
+
plane,
|
|
79
|
+
scene.camera,
|
|
80
|
+
event.windowPosition,
|
|
81
|
+
).height;
|
|
82
|
+
this._getExtrudeEvent = (c, windowPosition) => {
|
|
83
|
+
const newHeight = getCartographicFromPlane(
|
|
84
|
+
plane,
|
|
85
|
+
scene.camera,
|
|
86
|
+
windowPosition,
|
|
87
|
+
).height;
|
|
88
|
+
const extrude = newHeight - currentHeight;
|
|
89
|
+
currentHeight = newHeight;
|
|
90
|
+
return extrude;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return event;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @inheritDoc
|
|
99
|
+
*/
|
|
100
|
+
destroy() {
|
|
101
|
+
this._transformationHandler = null;
|
|
102
|
+
this._extruded.destroy();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default ExtrudeInteraction;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Cartesian2, Plane, Transforms } from '@vcmap-cesium/engine';
|
|
2
|
+
import AbstractInteraction from '../../../interaction/abstractInteraction.js';
|
|
3
|
+
import { EventType } from '../../../interaction/interactionType.js';
|
|
4
|
+
import { handlerSymbol } from '../editorSymbols.js';
|
|
5
|
+
import { getCartographicFromPlane } from '../editorHelpers.js';
|
|
6
|
+
import VcsEvent from '../../../vcsEvent.js';
|
|
7
|
+
import Projection from '../../projection.js';
|
|
8
|
+
import { cartographicToWgs84, mercatorToCartesian } from '../../math.js';
|
|
9
|
+
import { AXIS_AND_PLANES } from './transformationTypes.js';
|
|
10
|
+
import CesiumMap from '../../../map/cesiumMap.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {Object} RotationEvent
|
|
14
|
+
* @property {number} angle - in radians
|
|
15
|
+
* @property {AXIS_AND_PLANES} axis - the axis of rotation
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {import("@vcmap-cesium/engine").Cartesian2} start
|
|
20
|
+
* @param {import("@vcmap-cesium/engine").Cartesian2} end
|
|
21
|
+
* @param {number} angle
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
function determineOrientation(start, end, angle) {
|
|
25
|
+
const orientation = start.x * end.y - start.y * end.x;
|
|
26
|
+
return orientation > 0 ? angle : angle * -1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("@vcmap-cesium/engine").Cartesian2} getPosition
|
|
31
|
+
* @param {InteractionEvent} event
|
|
32
|
+
* @param {AXIS_AND_PLANES} axis
|
|
33
|
+
* @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):RotationEvent}
|
|
34
|
+
*/
|
|
35
|
+
function createGetRotationEvent(getPosition, event, axis) {
|
|
36
|
+
let currentPosition = getPosition(
|
|
37
|
+
event.positionOrPixel,
|
|
38
|
+
event.windowPosition,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return (coordinate, windowPosition) => {
|
|
42
|
+
const newPosition = getPosition(coordinate, windowPosition);
|
|
43
|
+
const angle = determineOrientation(
|
|
44
|
+
currentPosition,
|
|
45
|
+
newPosition,
|
|
46
|
+
Cartesian2.angleBetween(currentPosition, newPosition),
|
|
47
|
+
);
|
|
48
|
+
currentPosition = newPosition;
|
|
49
|
+
return { angle, axis };
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A class to handle events on a {@see TransformationHandler}. Should be used with {@see TransformationHandler} created for mode TransformationMode.ROTATE.
|
|
55
|
+
* If the rings are dragged, the rotated event will be raised.
|
|
56
|
+
* @class
|
|
57
|
+
* @extends {AbstractInteraction}
|
|
58
|
+
*/
|
|
59
|
+
class RotateInteraction extends AbstractInteraction {
|
|
60
|
+
/**
|
|
61
|
+
* @param {TransformationHandler} transformationHandler
|
|
62
|
+
*/
|
|
63
|
+
constructor(transformationHandler) {
|
|
64
|
+
super(EventType.DRAGEVENTS);
|
|
65
|
+
/**
|
|
66
|
+
* @type {TransformationHandler}
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
this._transformationHandler = transformationHandler;
|
|
70
|
+
/**
|
|
71
|
+
* @type {VcsEvent<RotationEvent>}
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
this._rotated = new VcsEvent();
|
|
75
|
+
/**
|
|
76
|
+
* @type {null|function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):{angle: number, axis: AXIS_AND_PLANES}}
|
|
77
|
+
* @private
|
|
78
|
+
*/
|
|
79
|
+
this._getRotationEvent = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The event raised, if the rings are dragged. Event is raised with the angle delta to the last event in radians.
|
|
84
|
+
* @type {VcsEvent<RotationEvent>}
|
|
85
|
+
* @readonly
|
|
86
|
+
*/
|
|
87
|
+
get rotated() {
|
|
88
|
+
return this._rotated;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {InteractionEvent} event
|
|
93
|
+
* @returns {Promise<InteractionEvent>}
|
|
94
|
+
*/
|
|
95
|
+
async pipe(event) {
|
|
96
|
+
if (this._getRotationEvent) {
|
|
97
|
+
this._rotated.raiseEvent(
|
|
98
|
+
this._getRotationEvent(event.positionOrPixel, event.windowPosition),
|
|
99
|
+
);
|
|
100
|
+
if (event.type === EventType.DRAGEND) {
|
|
101
|
+
this._getRotationEvent = null;
|
|
102
|
+
}
|
|
103
|
+
} else if (
|
|
104
|
+
event.type === EventType.DRAGSTART &&
|
|
105
|
+
event?.feature?.[handlerSymbol]
|
|
106
|
+
) {
|
|
107
|
+
const axis = event.feature[handlerSymbol];
|
|
108
|
+
if (axis !== AXIS_AND_PLANES.NONE) {
|
|
109
|
+
if (event.map instanceof CesiumMap) {
|
|
110
|
+
this._getRotationEvent = this._dragAlongPlane3D(axis, event);
|
|
111
|
+
} else {
|
|
112
|
+
this._getRotationEvent = this._dragAlongPlane2D(axis, event);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return event;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @param {AXIS_AND_PLANES} axis
|
|
121
|
+
* @param {InteractionEvent} event
|
|
122
|
+
* @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):{angle: number, axis: AXIS_AND_PLANES}}
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
_dragAlongPlane3D(axis, event) {
|
|
126
|
+
const scene = /** @type {import("@vcmap/core").CesiumMap} */ (
|
|
127
|
+
event.map
|
|
128
|
+
).getScene();
|
|
129
|
+
const center = mercatorToCartesian(this._transformationHandler.center);
|
|
130
|
+
let plane;
|
|
131
|
+
if (axis === AXIS_AND_PLANES.X) {
|
|
132
|
+
plane = Plane.clone(Plane.ORIGIN_YZ_PLANE);
|
|
133
|
+
} else if (axis === AXIS_AND_PLANES.Y) {
|
|
134
|
+
plane = Plane.clone(Plane.ORIGIN_ZX_PLANE);
|
|
135
|
+
} else {
|
|
136
|
+
plane = Plane.clone(Plane.ORIGIN_XY_PLANE);
|
|
137
|
+
}
|
|
138
|
+
plane = Plane.transform(
|
|
139
|
+
plane,
|
|
140
|
+
Transforms.eastNorthUpToFixedFrame(center),
|
|
141
|
+
plane,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return createGetRotationEvent(
|
|
145
|
+
(c, windowPosition) => {
|
|
146
|
+
const cartographic = getCartographicFromPlane(
|
|
147
|
+
plane,
|
|
148
|
+
scene.camera,
|
|
149
|
+
windowPosition,
|
|
150
|
+
);
|
|
151
|
+
const centeredCoordinates = Projection.wgs84ToMercator(
|
|
152
|
+
cartographicToWgs84(cartographic),
|
|
153
|
+
);
|
|
154
|
+
const { center: currentCenter } = this._transformationHandler;
|
|
155
|
+
centeredCoordinates[0] = currentCenter[0] - centeredCoordinates[0];
|
|
156
|
+
centeredCoordinates[1] = currentCenter[1] - centeredCoordinates[1];
|
|
157
|
+
centeredCoordinates[2] = currentCenter[2] - centeredCoordinates[2];
|
|
158
|
+
if (axis === AXIS_AND_PLANES.Z) {
|
|
159
|
+
return Cartesian2.fromArray(centeredCoordinates);
|
|
160
|
+
}
|
|
161
|
+
if (axis === AXIS_AND_PLANES.X) {
|
|
162
|
+
return new Cartesian2(centeredCoordinates[1], centeredCoordinates[2]);
|
|
163
|
+
}
|
|
164
|
+
return new Cartesian2(centeredCoordinates[0], centeredCoordinates[2]);
|
|
165
|
+
},
|
|
166
|
+
event,
|
|
167
|
+
axis,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {AXIS_AND_PLANES} axis
|
|
173
|
+
* @param {InteractionEvent} event
|
|
174
|
+
* @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):{angle: number, axis: AXIS_AND_PLANES}}
|
|
175
|
+
* @private
|
|
176
|
+
*/
|
|
177
|
+
_dragAlongPlane2D(axis, event) {
|
|
178
|
+
return createGetRotationEvent(
|
|
179
|
+
(c) => {
|
|
180
|
+
const centeredCoordinates = c.slice();
|
|
181
|
+
const { center } = this._transformationHandler;
|
|
182
|
+
centeredCoordinates[0] = center[0] - centeredCoordinates[0];
|
|
183
|
+
centeredCoordinates[1] = center[1] - centeredCoordinates[1];
|
|
184
|
+
centeredCoordinates[2] = center[2] - centeredCoordinates[2];
|
|
185
|
+
return Cartesian2.fromArray(centeredCoordinates);
|
|
186
|
+
},
|
|
187
|
+
event,
|
|
188
|
+
axis,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @inheritDoc
|
|
194
|
+
*/
|
|
195
|
+
destroy() {
|
|
196
|
+
this._transformationHandler = null;
|
|
197
|
+
this._rotated.destroy();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export default RotateInteraction;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Plane, Transforms } from '@vcmap-cesium/engine';
|
|
2
|
+
import AbstractInteraction from '../../../interaction/abstractInteraction.js';
|
|
3
|
+
import { EventType } from '../../../interaction/interactionType.js';
|
|
4
|
+
import { handlerSymbol } from '../editorSymbols.js';
|
|
5
|
+
import { getCartographicFromPlane } from '../editorHelpers.js';
|
|
6
|
+
import VcsEvent from '../../../vcsEvent.js';
|
|
7
|
+
import Projection from '../../projection.js';
|
|
8
|
+
import {
|
|
9
|
+
cartesian2DDistance,
|
|
10
|
+
cartographicToWgs84,
|
|
11
|
+
mercatorToCartesian,
|
|
12
|
+
} from '../../math.js';
|
|
13
|
+
import { AXIS_AND_PLANES } from './transformationTypes.js';
|
|
14
|
+
import CesiumMap from '../../../map/cesiumMap.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):import("ol/coordinate").Coordinate} getPosition
|
|
18
|
+
* @param {InteractionEvent} event
|
|
19
|
+
* @param {TransformationHandler} transformationHandler
|
|
20
|
+
* @param {AXIS_AND_PLANES} axis
|
|
21
|
+
* @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):Array<number>}
|
|
22
|
+
*/
|
|
23
|
+
function createGetScaledEvent(getPosition, event, transformationHandler, axis) {
|
|
24
|
+
const { center } = transformationHandler;
|
|
25
|
+
let flippedX = false;
|
|
26
|
+
let flippedY = false;
|
|
27
|
+
|
|
28
|
+
const getDistance = (coordinate, windowPosition) => {
|
|
29
|
+
const position = getPosition(coordinate, windowPosition);
|
|
30
|
+
const dx = position[0] - center[0];
|
|
31
|
+
const dy = position[1] - center[1];
|
|
32
|
+
let distance;
|
|
33
|
+
if (axis === AXIS_AND_PLANES.X) {
|
|
34
|
+
distance = Math.abs(dx);
|
|
35
|
+
} else if (axis === AXIS_AND_PLANES.Y) {
|
|
36
|
+
distance = Math.abs(dy);
|
|
37
|
+
} else {
|
|
38
|
+
distance = cartesian2DDistance(center, position);
|
|
39
|
+
}
|
|
40
|
+
return { distance, dx, dy };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const { distance: initialDistance } = getDistance(
|
|
44
|
+
event.positionOrPixel,
|
|
45
|
+
event.windowPosition,
|
|
46
|
+
);
|
|
47
|
+
let currentDistance = initialDistance;
|
|
48
|
+
return (coordinate, windowPosition) => {
|
|
49
|
+
const { distance, dx, dy } = getDistance(coordinate, windowPosition);
|
|
50
|
+
|
|
51
|
+
const distanceDelta = distance / currentDistance;
|
|
52
|
+
const currentFlippedX = dx < 0;
|
|
53
|
+
const currentFlippedY = dy < 0;
|
|
54
|
+
let sx = distanceDelta;
|
|
55
|
+
let sy = distanceDelta;
|
|
56
|
+
if (currentFlippedX !== flippedX) {
|
|
57
|
+
flippedX = currentFlippedX;
|
|
58
|
+
sx *= -1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (currentFlippedY !== flippedY) {
|
|
62
|
+
flippedY = currentFlippedY;
|
|
63
|
+
sy *= -1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
currentDistance = distance;
|
|
67
|
+
if (axis === AXIS_AND_PLANES.X) {
|
|
68
|
+
return [sx, 1, 1];
|
|
69
|
+
} else if (axis === AXIS_AND_PLANES.Y) {
|
|
70
|
+
return [1, sy, 1];
|
|
71
|
+
} else {
|
|
72
|
+
return [sx, sy, 1];
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A class to handle events on a {@see TransformationHandler}. Should be used with {@see TransformationHandler} created for mode TransformationMode.SCALE..
|
|
79
|
+
* If the handlers are dragged, the scaled event will be raised.
|
|
80
|
+
* @class
|
|
81
|
+
* @extends {AbstractInteraction}
|
|
82
|
+
*/
|
|
83
|
+
class ScaleInteraction extends AbstractInteraction {
|
|
84
|
+
/**
|
|
85
|
+
* @param {TransformationHandler} transformationHandler
|
|
86
|
+
*/
|
|
87
|
+
constructor(transformationHandler) {
|
|
88
|
+
super(EventType.DRAGEVENTS);
|
|
89
|
+
/**
|
|
90
|
+
* @type {TransformationHandler}
|
|
91
|
+
*/
|
|
92
|
+
this._transformationHandler = transformationHandler;
|
|
93
|
+
/**
|
|
94
|
+
* @type {VcsEvent<Array<number>>}
|
|
95
|
+
*/
|
|
96
|
+
this._scaled = new VcsEvent();
|
|
97
|
+
/**
|
|
98
|
+
* @type {null|function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):Array<number>}
|
|
99
|
+
* @private
|
|
100
|
+
*/
|
|
101
|
+
this._getScaleEvent = null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Event raised if the handlers are dragged. The resulting array is of type [sx, sy, sz] where all numbers
|
|
106
|
+
* are considered to be deltas to the previous event (where 1 means no scaling).
|
|
107
|
+
* @type {VcsEvent<Array<number>>}
|
|
108
|
+
* @readonly
|
|
109
|
+
*/
|
|
110
|
+
get scaled() {
|
|
111
|
+
return this._scaled;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {InteractionEvent} event
|
|
116
|
+
* @returns {Promise<InteractionEvent>}
|
|
117
|
+
*/
|
|
118
|
+
async pipe(event) {
|
|
119
|
+
if (this._getScaleEvent) {
|
|
120
|
+
this._scaled.raiseEvent(
|
|
121
|
+
this._getScaleEvent(event.positionOrPixel, event.windowPosition),
|
|
122
|
+
);
|
|
123
|
+
if (event.type === EventType.DRAGEND) {
|
|
124
|
+
this._getScaleEvent = null;
|
|
125
|
+
this._transformationHandler.showAxis = AXIS_AND_PLANES.NONE;
|
|
126
|
+
}
|
|
127
|
+
} else if (
|
|
128
|
+
event.type === EventType.DRAGSTART &&
|
|
129
|
+
event?.feature?.[handlerSymbol]
|
|
130
|
+
) {
|
|
131
|
+
const axis = event.feature[handlerSymbol];
|
|
132
|
+
if (axis !== AXIS_AND_PLANES.NONE) {
|
|
133
|
+
this._transformationHandler.showAxis = axis;
|
|
134
|
+
if (event.map instanceof CesiumMap) {
|
|
135
|
+
this._getScaleEvent = this._dragAlongPlane3D(axis, event);
|
|
136
|
+
} else {
|
|
137
|
+
this._getScaleEvent = this._dragAlongPlane2D(axis, event);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return event;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param {AXIS_AND_PLANES} axis
|
|
146
|
+
* @param {InteractionEvent} event
|
|
147
|
+
* @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):Array<number>}
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
_dragAlongPlane3D(axis, event) {
|
|
151
|
+
const scene = /** @type {import("@vcmap/core").CesiumMap} */ (
|
|
152
|
+
event.map
|
|
153
|
+
).getScene();
|
|
154
|
+
const center = mercatorToCartesian(this._transformationHandler.center);
|
|
155
|
+
let plane = Plane.clone(Plane.ORIGIN_XY_PLANE);
|
|
156
|
+
plane = Plane.transform(
|
|
157
|
+
plane,
|
|
158
|
+
Transforms.eastNorthUpToFixedFrame(center),
|
|
159
|
+
plane,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return createGetScaledEvent(
|
|
163
|
+
(c, windowPosition) => {
|
|
164
|
+
const cartographic = getCartographicFromPlane(
|
|
165
|
+
plane,
|
|
166
|
+
scene.camera,
|
|
167
|
+
windowPosition,
|
|
168
|
+
);
|
|
169
|
+
return Projection.wgs84ToMercator(cartographicToWgs84(cartographic));
|
|
170
|
+
},
|
|
171
|
+
event,
|
|
172
|
+
this._transformationHandler,
|
|
173
|
+
axis,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {AXIS_AND_PLANES} axis
|
|
179
|
+
* @param {InteractionEvent} event
|
|
180
|
+
* @returns {function(import("ol/coordinate").Coordinate, import("@vcmap-cesium/engine").Cartesian2):Array<number>}
|
|
181
|
+
* @private
|
|
182
|
+
*/
|
|
183
|
+
_dragAlongPlane2D(axis, event) {
|
|
184
|
+
return createGetScaledEvent(
|
|
185
|
+
(c) => c.slice(),
|
|
186
|
+
event,
|
|
187
|
+
this._transformationHandler,
|
|
188
|
+
axis,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @inheritDoc
|
|
194
|
+
*/
|
|
195
|
+
destroy() {
|
|
196
|
+
this._transformationHandler = null;
|
|
197
|
+
this._scaled.destroy();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export default ScaleInteraction;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { HeightReference } from '@vcmap-cesium/engine';
|
|
2
|
+
import {
|
|
3
|
+
createEmpty as createEmptyExtent,
|
|
4
|
+
extend as extendExtent,
|
|
5
|
+
getCenter as getExtentCenter,
|
|
6
|
+
} from 'ol/extent.js';
|
|
7
|
+
import Extent3D from '../../featureconverter/extent3D.js';
|
|
8
|
+
import CesiumMap from '../../../map/cesiumMap.js';
|
|
9
|
+
import BaseOLMap from '../../../map/baseOLMap.js';
|
|
10
|
+
import create3DHandlers from './create3DHandlers.js';
|
|
11
|
+
import create2DHandlers from './create2DHandlers.js';
|
|
12
|
+
import { obliqueGeometry } from '../../../layer/vectorSymbols.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} FeatureCenterInfo
|
|
16
|
+
* @property {import("ol/coordinate").Coordinate} center
|
|
17
|
+
* @property {boolean} someClamped
|
|
18
|
+
* @property {boolean} someNoTerrain
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {import("@vcmap/core").VectorLayer} layer
|
|
24
|
+
* @param {Array<import("ol").Feature>} features
|
|
25
|
+
* @returns {FeatureCenterInfo}
|
|
26
|
+
*/
|
|
27
|
+
function getCenterFromFeatures3D(layer, features) {
|
|
28
|
+
const extent3D = new Extent3D();
|
|
29
|
+
let someClamped = false;
|
|
30
|
+
let someNoTerrain = false;
|
|
31
|
+
const layerIsClamped =
|
|
32
|
+
layer.vectorProperties.altitudeMode === HeightReference.CLAMP_TO_GROUND;
|
|
33
|
+
|
|
34
|
+
features.forEach((f) => {
|
|
35
|
+
const geometry = f.getGeometry();
|
|
36
|
+
extent3D.extendWithGeometry(geometry);
|
|
37
|
+
if (!someNoTerrain) {
|
|
38
|
+
const firstCoordinates = /** @type {import("ol/geom").SimpleGeometry} */ (
|
|
39
|
+
geometry
|
|
40
|
+
).getFirstCoordinate();
|
|
41
|
+
if (!firstCoordinates[2]) {
|
|
42
|
+
someNoTerrain = true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!someClamped) {
|
|
47
|
+
const altitudeMode = f.get('olcs_altitudeMode');
|
|
48
|
+
someClamped =
|
|
49
|
+
altitudeMode === 'clampToGround' || (!altitudeMode && layerIsClamped);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const center = extent3D.getCenter();
|
|
53
|
+
return {
|
|
54
|
+
center,
|
|
55
|
+
someClamped,
|
|
56
|
+
someNoTerrain,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param {Array<import("ol").Feature>} features
|
|
62
|
+
* @returns {FeatureCenterInfo}
|
|
63
|
+
*/
|
|
64
|
+
function getCenterFromFeatures2D(features) {
|
|
65
|
+
const extent = createEmptyExtent();
|
|
66
|
+
|
|
67
|
+
features.forEach((f) => {
|
|
68
|
+
const geometry = f[obliqueGeometry] ?? f.getGeometry();
|
|
69
|
+
extendExtent(extent, geometry.getExtent());
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
center: [...getExtentCenter(extent), 0],
|
|
74
|
+
someClamped: false,
|
|
75
|
+
someNoTerrain: false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The transformation handler is a set of handlers used for transformation interactions. these handlers are centered at the
|
|
81
|
+
* origin of the currently selected features and are rendered depending on a) the current mode and b) the current selections
|
|
82
|
+
* sets capabilities. if one or more selected features are clamp to ground, no Z manipulations will be available and
|
|
83
|
+
* they will be greyed out. updates to the selection set are handled by the handler. updates to the features (for instance
|
|
84
|
+
* setting the olcs_altitudeMode on a currently selected feature) is currently not handled.
|
|
85
|
+
* transformation handlers are only valid for the currently active map (and oblique image).
|
|
86
|
+
* it is up to the creator to re-create them as needed (map change, image change, external geometry or property change to a selected feature).
|
|
87
|
+
* In most scenarios, this function must not be called directly and the startEditFeatureSession used instead.
|
|
88
|
+
* @param {import("@vcmap/core").VcsMap} map
|
|
89
|
+
* @param {import("@vcmap/core").VectorLayer} layer
|
|
90
|
+
* @param {import("@vcmap/core").VectorLayer} scratchLayer
|
|
91
|
+
* @param {import("@vcmap/core").TransformationMode} mode
|
|
92
|
+
* @returns {TransformationHandler}
|
|
93
|
+
*/
|
|
94
|
+
export default function createTransformationHandler(
|
|
95
|
+
map,
|
|
96
|
+
layer,
|
|
97
|
+
scratchLayer,
|
|
98
|
+
mode,
|
|
99
|
+
) {
|
|
100
|
+
/** @type {Handlers} */
|
|
101
|
+
let handlerFeatures;
|
|
102
|
+
/** @type {import("ol/coordinate").Coordinate} */
|
|
103
|
+
let center = [0, 0, 0];
|
|
104
|
+
|
|
105
|
+
/** @type {function(Array<import("ol").Feature>):FeatureCenterInfo} */
|
|
106
|
+
let getCenterFromFeatures;
|
|
107
|
+
/** @type {import("@vcmap/core").CesiumMap|null} */
|
|
108
|
+
let cesiumMap = null;
|
|
109
|
+
|
|
110
|
+
let cancelAsyncSetting = () => {};
|
|
111
|
+
const setFeatures = async (features) => {
|
|
112
|
+
cancelAsyncSetting();
|
|
113
|
+
const show = features.length > 0;
|
|
114
|
+
if (show) {
|
|
115
|
+
const {
|
|
116
|
+
center: newCenter,
|
|
117
|
+
someClamped,
|
|
118
|
+
someNoTerrain,
|
|
119
|
+
} = getCenterFromFeatures(features);
|
|
120
|
+
center = newCenter;
|
|
121
|
+
if (!cesiumMap || !someNoTerrain) {
|
|
122
|
+
// only set center sync, if updating will not change it too drastically (to avoid jumps)
|
|
123
|
+
handlerFeatures.show = true;
|
|
124
|
+
handlerFeatures.setCenter(center);
|
|
125
|
+
}
|
|
126
|
+
handlerFeatures.greyOutZ = someClamped;
|
|
127
|
+
if (cesiumMap && (someClamped || someNoTerrain)) {
|
|
128
|
+
let cancel = false;
|
|
129
|
+
cancelAsyncSetting = () => {
|
|
130
|
+
cancel = true;
|
|
131
|
+
};
|
|
132
|
+
await cesiumMap.getHeightFromTerrain([center]);
|
|
133
|
+
if (!cancel) {
|
|
134
|
+
handlerFeatures.show = true;
|
|
135
|
+
handlerFeatures.setCenter(center);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
handlerFeatures.show = false;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
if (map instanceof CesiumMap) {
|
|
144
|
+
handlerFeatures = create3DHandlers(map, mode);
|
|
145
|
+
getCenterFromFeatures = getCenterFromFeatures3D.bind(null, layer);
|
|
146
|
+
cesiumMap = map;
|
|
147
|
+
} else if (map instanceof BaseOLMap) {
|
|
148
|
+
handlerFeatures = create2DHandlers(map, scratchLayer, mode);
|
|
149
|
+
getCenterFromFeatures = getCenterFromFeatures2D;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
get showing() {
|
|
154
|
+
return handlerFeatures.show;
|
|
155
|
+
},
|
|
156
|
+
get center() {
|
|
157
|
+
return center.slice();
|
|
158
|
+
},
|
|
159
|
+
get showAxis() {
|
|
160
|
+
return handlerFeatures.showAxis;
|
|
161
|
+
},
|
|
162
|
+
set showAxis(axis) {
|
|
163
|
+
handlerFeatures.showAxis = axis;
|
|
164
|
+
},
|
|
165
|
+
translate(dx, dy, dz) {
|
|
166
|
+
center[0] += dx;
|
|
167
|
+
center[1] += dy;
|
|
168
|
+
center[2] += dz;
|
|
169
|
+
handlerFeatures.setCenter(center);
|
|
170
|
+
},
|
|
171
|
+
setFeatures,
|
|
172
|
+
destroy() {
|
|
173
|
+
cancelAsyncSetting();
|
|
174
|
+
handlerFeatures.destroy();
|
|
175
|
+
scratchLayer.removeAllFeatures();
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|