@vcmap/core 6.0.0-rc.4 → 6.0.0-rc.6
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/dist/cesium.d.ts +11 -0
- package/dist/index.d.ts +23 -16
- package/dist/index.js +21 -14
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +15 -2
- package/dist/src/layer/cesium/clusterContext.d.ts +8 -14
- package/dist/src/layer/cesium/clusterContext.js +62 -41
- package/dist/src/layer/cesium/clusterContext.js.map +1 -1
- package/dist/src/layer/cesium/vectorCesiumImpl.d.ts +2 -3
- package/dist/src/layer/cesium/vectorCesiumImpl.js +16 -10
- package/dist/src/layer/cesium/vectorCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorContext.d.ts +10 -53
- package/dist/src/layer/cesium/vectorContext.js +88 -172
- package/dist/src/layer/cesium/vectorContext.js.map +1 -1
- package/dist/src/layer/geojsonHelpers.d.ts +1 -1
- package/dist/src/layer/geojsonHelpers.js +5 -10
- package/dist/src/layer/geojsonHelpers.js.map +1 -1
- package/dist/src/layer/oblique/obliqueHelpers.js +6 -6
- package/dist/src/layer/oblique/obliqueHelpers.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +0 -37
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.d.ts +8 -3
- package/dist/src/layer/vectorProperties.js +30 -5
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/map/baseOLMap.js +1 -1
- package/dist/src/map/baseOLMap.js.map +1 -1
- package/dist/src/map/obliqueMap.d.ts +3 -0
- package/dist/src/map/obliqueMap.js +27 -6
- package/dist/src/map/obliqueMap.js.map +1 -1
- package/dist/src/map/vcsMap.d.ts +8 -0
- package/dist/src/map/vcsMap.js +11 -0
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/oblique/helpers.js +5 -5
- package/dist/src/oblique/helpers.js.map +1 -1
- package/dist/src/oblique/obliqueDataSet.js +4 -4
- package/dist/src/oblique/obliqueDataSet.js.map +1 -1
- package/dist/src/ol/geom/geometryCollection.js +19 -2
- package/dist/src/ol/geom/geometryCollection.js.map +1 -1
- package/dist/src/style/arcStyle.js +1 -0
- package/dist/src/style/arcStyle.js.map +1 -1
- package/dist/src/util/editor/createFeatureSession.d.ts +5 -1
- package/dist/src/util/editor/createFeatureSession.js +48 -4
- package/dist/src/util/editor/createFeatureSession.js.map +1 -1
- package/dist/src/util/editor/editFeaturesSession.d.ts +10 -4
- package/dist/src/util/editor/editFeaturesSession.js +74 -37
- package/dist/src/util/editor/editFeaturesSession.js.map +1 -1
- package/dist/src/util/editor/editGeometrySession.d.ts +5 -1
- package/dist/src/util/editor/editGeometrySession.js +77 -55
- package/dist/src/util/editor/editGeometrySession.js.map +1 -1
- package/dist/src/util/editor/editorHelpers.d.ts +12 -6
- package/dist/src/util/editor/editorHelpers.js +47 -20
- package/dist/src/util/editor/editorHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSessionHelpers.d.ts +5 -0
- package/dist/src/util/editor/editorSessionHelpers.js +1 -0
- package/dist/src/util/editor/editorSessionHelpers.js.map +1 -1
- package/dist/src/util/editor/editorSymbols.d.ts +1 -1
- package/dist/src/util/editor/editorSymbols.js +1 -1
- package/dist/src/util/editor/editorSymbols.js.map +1 -1
- package/dist/src/util/editor/interactions/createBBoxInteraction.d.ts +1 -0
- package/dist/src/util/editor/interactions/createBBoxInteraction.js +20 -16
- package/dist/src/util/editor/interactions/createBBoxInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createCircleInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createLineStringInteraction.js +3 -3
- package/dist/src/util/editor/interactions/createLineStringInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js +1 -1
- package/dist/src/util/editor/interactions/createPointInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/createPolygonInteraction.d.ts +4 -0
- package/dist/src/util/editor/interactions/createPolygonInteraction.js +9 -3
- package/dist/src/util/editor/interactions/createPolygonInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/creationSnapping.d.ts +26 -0
- package/dist/src/util/editor/interactions/creationSnapping.js +139 -0
- package/dist/src/util/editor/interactions/creationSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js +3 -2
- package/dist/src/util/editor/interactions/editGeometryMouseOverInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.d.ts +3 -1
- package/dist/src/util/editor/interactions/insertVertexInteraction.js +14 -6
- package/dist/src/util/editor/interactions/insertVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/layerSnapping.d.ts +19 -0
- package/dist/src/util/editor/interactions/layerSnapping.js +87 -0
- package/dist/src/util/editor/interactions/layerSnapping.js.map +1 -0
- package/dist/src/util/editor/interactions/translateVertexInteraction.js +2 -2
- package/dist/src/util/editor/interactions/translateVertexInteraction.js.map +1 -1
- package/dist/src/util/editor/interactions/translationSnapping.d.ts +25 -0
- package/dist/src/util/editor/interactions/translationSnapping.js +179 -0
- package/dist/src/util/editor/interactions/translationSnapping.js.map +1 -0
- package/dist/src/util/editor/snappingHelpers.d.ts +44 -0
- package/dist/src/util/editor/snappingHelpers.js +329 -0
- package/dist/src/util/editor/snappingHelpers.js.map +1 -0
- package/dist/src/util/editor/transformation/create2DHandlers.js +26 -26
- package/dist/src/util/editor/transformation/create2DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/create3DHandlers.js +65 -14
- package/dist/src/util/editor/transformation/create3DHandlers.js.map +1 -1
- package/dist/src/util/editor/transformation/scaleInteraction.js +27 -5
- package/dist/src/util/editor/transformation/scaleInteraction.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationHandler.js +56 -38
- package/dist/src/util/editor/transformation/transformationHandler.js.map +1 -1
- package/dist/src/util/editor/transformation/transformationTypes.d.ts +2 -0
- package/dist/src/util/editor/transformation/transformationTypes.js +4 -0
- package/dist/src/util/editor/transformation/transformationTypes.js.map +1 -1
- package/dist/src/util/featureconverter/arcToCesium.d.ts +5 -19
- package/dist/src/util/featureconverter/arcToCesium.js +15 -42
- package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/circleToCesium.d.ts +2 -27
- package/dist/src/util/featureconverter/circleToCesium.js +84 -63
- package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/clampedPrimitive.d.ts +2 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js +29 -0
- package/dist/src/util/featureconverter/clampedPrimitive.js.map +1 -0
- package/dist/src/util/featureconverter/convert.d.ts +26 -7
- package/dist/src/util/featureconverter/convert.js +221 -44
- package/dist/src/util/featureconverter/convert.js.map +1 -1
- package/dist/src/util/featureconverter/extent3D.d.ts +4 -3
- package/dist/src/util/featureconverter/extent3D.js +4 -3
- package/dist/src/util/featureconverter/extent3D.js.map +1 -1
- package/dist/src/util/featureconverter/lineStringToCesium.d.ts +12 -27
- package/dist/src/util/featureconverter/lineStringToCesium.js +85 -107
- package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/pointHelpers.d.ts +8 -11
- package/dist/src/util/featureconverter/pointHelpers.js +134 -120
- package/dist/src/util/featureconverter/pointHelpers.js.map +1 -1
- package/dist/src/util/featureconverter/pointToCesium.d.ts +14 -17
- package/dist/src/util/featureconverter/pointToCesium.js +47 -96
- package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/polygonToCesium.d.ts +2 -26
- package/dist/src/util/featureconverter/polygonToCesium.js +62 -72
- package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/storeyHelpers.d.ts +17 -0
- package/dist/src/util/featureconverter/storeyHelpers.js +78 -0
- package/dist/src/util/featureconverter/storeyHelpers.js.map +1 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.d.ts +54 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js +278 -0
- package/dist/src/util/featureconverter/vectorGeometryFactory.js.map +1 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.d.ts +86 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js +242 -0
- package/dist/src/util/featureconverter/vectorHeightInfo.js.map +1 -0
- package/dist/src/util/geometryHelpers.d.ts +22 -1
- package/dist/src/util/geometryHelpers.js +65 -2
- package/dist/src/util/geometryHelpers.js.map +1 -1
- package/dist/src/util/mapCollection.js +8 -0
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/math.d.ts +6 -2
- package/dist/src/util/math.js +34 -12
- package/dist/src/util/math.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js +3 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/helpers.d.ts +2 -9
- package/dist/tests/unit/helpers/helpers.js +2 -8
- package/dist/tests/unit/helpers/helpers.js.map +1 -1
- package/index.ts +74 -35
- package/package.json +3 -3
- package/src/cesium/cesium.d.ts +11 -0
- package/src/layer/cesium/clusterContext.ts +82 -91
- package/src/layer/cesium/vectorCesiumImpl.ts +17 -11
- package/src/layer/cesium/vectorContext.ts +120 -348
- package/src/layer/geojsonHelpers.ts +9 -12
- package/src/layer/oblique/obliqueHelpers.ts +6 -6
- package/src/layer/vectorLayer.ts +0 -71
- package/src/layer/vectorProperties.ts +46 -9
- package/src/map/baseOLMap.ts +1 -1
- package/src/map/obliqueMap.ts +46 -6
- package/src/map/vcsMap.ts +20 -2
- package/src/oblique/helpers.ts +11 -5
- package/src/oblique/obliqueDataSet.ts +4 -4
- package/src/ol/geom/geometryCollection.js +21 -2
- package/src/ol/ol.d.ts +15 -2
- package/src/style/arcStyle.ts +1 -0
- package/src/util/editor/createFeatureSession.ts +64 -6
- package/src/util/editor/editFeaturesSession.ts +105 -39
- package/src/util/editor/editGeometrySession.ts +118 -75
- package/src/util/editor/editorHelpers.ts +78 -30
- package/src/util/editor/editorSessionHelpers.ts +7 -0
- package/src/util/editor/editorSymbols.ts +1 -1
- package/src/util/editor/interactions/createBBoxInteraction.ts +25 -16
- package/src/util/editor/interactions/createCircleInteraction.ts +1 -1
- package/src/util/editor/interactions/createLineStringInteraction.ts +9 -3
- package/src/util/editor/interactions/createPointInteraction.ts +1 -1
- package/src/util/editor/interactions/createPolygonInteraction.ts +16 -3
- package/src/util/editor/interactions/creationSnapping.ts +226 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.ts +3 -2
- package/src/util/editor/interactions/insertVertexInteraction.ts +27 -7
- package/src/util/editor/interactions/layerSnapping.ts +136 -0
- package/src/util/editor/interactions/translateVertexInteraction.ts +8 -2
- package/src/util/editor/interactions/translationSnapping.ts +302 -0
- package/src/util/editor/snappingHelpers.ts +490 -0
- package/src/util/editor/transformation/create2DHandlers.ts +38 -26
- package/src/util/editor/transformation/create3DHandlers.ts +84 -22
- package/src/util/editor/transformation/scaleInteraction.ts +28 -5
- package/src/util/editor/transformation/transformationHandler.ts +72 -41
- package/src/util/editor/transformation/transformationTypes.ts +5 -0
- package/src/util/featureconverter/arcToCesium.ts +25 -95
- package/src/util/featureconverter/circleToCesium.ts +127 -113
- package/src/util/featureconverter/clampedPrimitive.ts +70 -0
- package/src/util/featureconverter/convert.ts +446 -114
- package/src/util/featureconverter/extent3D.ts +13 -6
- package/src/util/featureconverter/lineStringToCesium.ts +132 -179
- package/src/util/featureconverter/pointHelpers.ts +271 -214
- package/src/util/featureconverter/pointToCesium.ts +111 -175
- package/src/util/featureconverter/polygonToCesium.ts +98 -117
- package/src/util/featureconverter/storeyHelpers.ts +104 -0
- package/src/util/featureconverter/vectorGeometryFactory.ts +601 -0
- package/src/util/featureconverter/vectorHeightInfo.ts +393 -0
- package/src/util/geometryHelpers.ts +79 -5
- package/src/util/mapCollection.ts +8 -0
- package/src/util/math.ts +59 -12
- package/dist/src/util/featureconverter/featureconverterHelper.d.ts +0 -35
- package/dist/src/util/featureconverter/featureconverterHelper.js +0 -404
- package/dist/src/util/featureconverter/featureconverterHelper.js.map +0 -1
- package/src/util/featureconverter/featureconverterHelper.ts +0 -672
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { check, ofEnum } from '@vcsuite/check';
|
|
2
2
|
import { Feature } from 'ol';
|
|
3
|
-
import type { Geometry } from 'ol/geom.js';
|
|
3
|
+
import type { Geometry, LineString, Polygon } from 'ol/geom.js';
|
|
4
4
|
import { unByKey } from 'ol/Observable.js';
|
|
5
5
|
import VcsEvent from '../../vcsEvent.js';
|
|
6
6
|
import {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
GeometryType,
|
|
11
11
|
SessionType,
|
|
12
12
|
setupInteractionChain,
|
|
13
|
+
setupScratchLayer,
|
|
13
14
|
} from './editorSessionHelpers.js';
|
|
14
15
|
import CreateLineStringInteraction from './interactions/createLineStringInteraction.js';
|
|
15
16
|
import CreateCircleInteraction from './interactions/createCircleInteraction.js';
|
|
@@ -23,6 +24,10 @@ import geometryIsValid from './validateGeoemetry.js';
|
|
|
23
24
|
import ObliqueMap from '../../map/obliqueMap.js';
|
|
24
25
|
import { cursorMap } from './interactions/editGeometryMouseOverInteraction.js';
|
|
25
26
|
import { AltitudeModeType } from '../../layer/vectorProperties.js';
|
|
27
|
+
import CreationSnapping from './interactions/creationSnapping.js';
|
|
28
|
+
import { syncScratchLayerVectorProperties } from './editorHelpers.js';
|
|
29
|
+
import LayerSnapping from './interactions/layerSnapping.js';
|
|
30
|
+
import { SnapType, snapTypes } from './snappingHelpers.js';
|
|
26
31
|
|
|
27
32
|
export type CreateFeatureSession<T extends GeometryType> =
|
|
28
33
|
EditorSession<SessionType.CREATE> & {
|
|
@@ -30,6 +35,7 @@ export type CreateFeatureSession<T extends GeometryType> =
|
|
|
30
35
|
featureAltitudeMode: AltitudeModeType | undefined;
|
|
31
36
|
featureCreated: VcsEvent<Feature<GeometryToType<T>>>;
|
|
32
37
|
creationFinished: VcsEvent<Feature<GeometryToType<T>> | null>;
|
|
38
|
+
snapToLayers: VectorLayer[];
|
|
33
39
|
finish(): void;
|
|
34
40
|
};
|
|
35
41
|
|
|
@@ -91,6 +97,8 @@ export interface CreateInteraction<T extends Geometry> {
|
|
|
91
97
|
* @param layer
|
|
92
98
|
* @param geometryType
|
|
93
99
|
* @param initialAltitudeMode - whether to use the layers altitude mode or set this on the feature
|
|
100
|
+
* @param [initialSnapToLayers=[layer]] - the layers to initially snap to. defaults to the provided layer
|
|
101
|
+
* @param [snapTo] - what to snap to, by default all snaps are active
|
|
94
102
|
* @group Editor
|
|
95
103
|
*/
|
|
96
104
|
function startCreateFeatureSession<T extends GeometryType>(
|
|
@@ -98,6 +106,8 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
98
106
|
layer: VectorLayer,
|
|
99
107
|
geometryType: T,
|
|
100
108
|
initialAltitudeMode?: AltitudeModeType,
|
|
109
|
+
initialSnapToLayers: VectorLayer[] = [layer],
|
|
110
|
+
snapTo: SnapType[] = [...snapTypes],
|
|
101
111
|
): CreateFeatureSession<T> {
|
|
102
112
|
check(app, VcsApp);
|
|
103
113
|
check(layer, VectorLayer);
|
|
@@ -108,6 +118,7 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
108
118
|
removed: interactionRemoved,
|
|
109
119
|
destroy: destroyInteractionChain,
|
|
110
120
|
} = setupInteractionChain(app.maps.eventHandler);
|
|
121
|
+
const scratchLayer = setupScratchLayer(app.layers);
|
|
111
122
|
|
|
112
123
|
const featureCreated = new VcsEvent<Feature<GeometryToType<T>>>();
|
|
113
124
|
const creationFinished = new VcsEvent<Feature<GeometryToType<T>> | null>();
|
|
@@ -116,6 +127,9 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
116
127
|
|
|
117
128
|
let currentInteraction: InteractionOfGeometryType<T> | null = null;
|
|
118
129
|
let currentFeature: Feature<GeometryToType<T>> | null = null;
|
|
130
|
+
let snappingInteraction: CreationSnapping | null = null;
|
|
131
|
+
let layerSnappingInteraction: LayerSnapping | null = null;
|
|
132
|
+
let snapToLayers: VectorLayer[] = initialSnapToLayers?.slice() ?? [];
|
|
119
133
|
|
|
120
134
|
/**
|
|
121
135
|
* Ture if the currently active map is an ObliqueMap. set in setupActiveMap
|
|
@@ -131,16 +145,19 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
131
145
|
const altitudeModeInUse =
|
|
132
146
|
layer.vectorProperties.getAltitudeMode(altitudeModeFeature);
|
|
133
147
|
|
|
148
|
+
scratchLayer.vectorProperties.altitudeMode = altitudeModeInUse;
|
|
134
149
|
pickingBehavior.setForAltitudeMode(altitudeModeInUse);
|
|
135
150
|
};
|
|
136
151
|
|
|
137
|
-
const vectorPropertiesListener =
|
|
138
|
-
|
|
139
|
-
|
|
152
|
+
const vectorPropertiesListener = syncScratchLayerVectorProperties(
|
|
153
|
+
scratchLayer,
|
|
154
|
+
layer,
|
|
155
|
+
() => {
|
|
156
|
+
if (!featureAltitudeMode) {
|
|
140
157
|
altitudeModeChanged();
|
|
141
158
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
159
|
+
},
|
|
160
|
+
);
|
|
144
161
|
altitudeModeChanged();
|
|
145
162
|
|
|
146
163
|
let currentFeatureListener = (): void => {};
|
|
@@ -152,6 +169,16 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
152
169
|
currentInteraction.destroy();
|
|
153
170
|
currentInteraction = null;
|
|
154
171
|
}
|
|
172
|
+
if (snappingInteraction) {
|
|
173
|
+
interactionChain.removeInteraction(snappingInteraction);
|
|
174
|
+
snappingInteraction.destroy();
|
|
175
|
+
snappingInteraction = null;
|
|
176
|
+
}
|
|
177
|
+
if (layerSnappingInteraction) {
|
|
178
|
+
interactionChain.removeInteraction(layerSnappingInteraction);
|
|
179
|
+
layerSnappingInteraction.destroy();
|
|
180
|
+
layerSnappingInteraction = null;
|
|
181
|
+
}
|
|
155
182
|
interactionListeners.forEach((cb) => {
|
|
156
183
|
cb();
|
|
157
184
|
});
|
|
@@ -161,6 +188,18 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
161
188
|
const createInteraction = (): void => {
|
|
162
189
|
destroyCurrentInteraction();
|
|
163
190
|
currentInteraction = createInteractionForGeometryType(geometryType);
|
|
191
|
+
layerSnappingInteraction = new LayerSnapping(
|
|
192
|
+
snapToLayers,
|
|
193
|
+
scratchLayer,
|
|
194
|
+
(f) => currentFeature !== f,
|
|
195
|
+
snapTo,
|
|
196
|
+
);
|
|
197
|
+
if (
|
|
198
|
+
geometryType === GeometryType.Polygon ||
|
|
199
|
+
geometryType === GeometryType.LineString
|
|
200
|
+
) {
|
|
201
|
+
snappingInteraction = new CreationSnapping(scratchLayer, snapTo);
|
|
202
|
+
}
|
|
164
203
|
|
|
165
204
|
interactionListeners = [
|
|
166
205
|
currentInteraction.created.addEventListener((geometry) => {
|
|
@@ -187,6 +226,9 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
187
226
|
};
|
|
188
227
|
layer.addFeatures([currentFeature]);
|
|
189
228
|
featureCreated.raiseEvent(currentFeature);
|
|
229
|
+
if (snappingInteraction) {
|
|
230
|
+
snappingInteraction.setGeometry(geometry as LineString | Polygon);
|
|
231
|
+
}
|
|
190
232
|
}),
|
|
191
233
|
currentInteraction.finished.addEventListener((geometry) => {
|
|
192
234
|
if (isOblique) {
|
|
@@ -214,6 +256,10 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
214
256
|
}
|
|
215
257
|
}),
|
|
216
258
|
];
|
|
259
|
+
interactionChain.addInteraction(layerSnappingInteraction);
|
|
260
|
+
if (snappingInteraction) {
|
|
261
|
+
interactionChain.addInteraction(snappingInteraction);
|
|
262
|
+
}
|
|
217
263
|
interactionChain.addInteraction(currentInteraction);
|
|
218
264
|
};
|
|
219
265
|
createInteraction();
|
|
@@ -252,6 +298,9 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
252
298
|
|
|
253
299
|
const stop = (): void => {
|
|
254
300
|
isStopped = true; // setting stopped true immediately, to prevent the recreation of the interaction chain on finished
|
|
301
|
+
app.layers.remove(scratchLayer);
|
|
302
|
+
scratchLayer.destroy();
|
|
303
|
+
|
|
255
304
|
if (app.maps.target) {
|
|
256
305
|
app.maps.target.style.cursor = cursorMap.auto;
|
|
257
306
|
}
|
|
@@ -292,6 +341,15 @@ function startCreateFeatureSession<T extends GeometryType>(
|
|
|
292
341
|
}
|
|
293
342
|
}
|
|
294
343
|
},
|
|
344
|
+
get snapToLayers(): VectorLayer[] {
|
|
345
|
+
return snapToLayers.slice();
|
|
346
|
+
},
|
|
347
|
+
set snapToLayers(layers: VectorLayer[]) {
|
|
348
|
+
snapToLayers = layers.slice();
|
|
349
|
+
if (layerSnappingInteraction) {
|
|
350
|
+
layerSnappingInteraction.layers = snapToLayers;
|
|
351
|
+
}
|
|
352
|
+
},
|
|
295
353
|
featureCreated,
|
|
296
354
|
creationFinished,
|
|
297
355
|
stopped,
|
|
@@ -8,6 +8,7 @@ import type { Feature } from 'ol/index.js';
|
|
|
8
8
|
import type { EventsKey } from 'ol/events.js';
|
|
9
9
|
import { unByKey } from 'ol/Observable.js';
|
|
10
10
|
import { getLogger } from '@vcsuite/logger';
|
|
11
|
+
import { Math as CesiumMath } from '@vcmap-cesium/engine';
|
|
11
12
|
|
|
12
13
|
import VcsEvent from '../../vcsEvent.js';
|
|
13
14
|
import {
|
|
@@ -18,6 +19,7 @@ import {
|
|
|
18
19
|
} from './editorSessionHelpers.js';
|
|
19
20
|
import createTransformationHandler from './transformation/transformationHandler.js';
|
|
20
21
|
import {
|
|
22
|
+
AxisAndPlanes,
|
|
21
23
|
TransformationHandler,
|
|
22
24
|
TransformationMode,
|
|
23
25
|
} from './transformation/transformationTypes.js';
|
|
@@ -28,7 +30,7 @@ import ScaleInteraction from './transformation/scaleInteraction.js';
|
|
|
28
30
|
import { createSync, obliqueGeometry } from '../../layer/vectorSymbols.js';
|
|
29
31
|
import ExtrudeInteraction from './transformation/extrudeInteraction.js';
|
|
30
32
|
import ObliqueMap from '../../map/obliqueMap.js';
|
|
31
|
-
import {
|
|
33
|
+
import { geometryChangeKeys } from './editorHelpers.js';
|
|
32
34
|
import CesiumMap from '../../map/cesiumMap.js';
|
|
33
35
|
import EnsureHandlerSelectionInteraction from './interactions/ensureHandlerSelectionInteraction.js';
|
|
34
36
|
import EditFeaturesMouseOverInteraction from './interactions/editFeaturesMouseOverInteraction.js';
|
|
@@ -112,12 +114,18 @@ function clearCreateSync(
|
|
|
112
114
|
export type EditFeaturesSession = EditorSession<SessionType.EDIT_FEATURES> & {
|
|
113
115
|
readonly mode: TransformationMode;
|
|
114
116
|
/**
|
|
115
|
-
* Function for rotating features. Takes angle in radians as parameter.
|
|
117
|
+
* Function for rotating features. Takes angle in radians as parameter. you can provide an axis to rotate around for features & primitives
|
|
116
118
|
* @param angle - in radians
|
|
119
|
+
* @param axis - optional axis. only has effect when rotating a single model or primitive
|
|
117
120
|
*/
|
|
118
|
-
rotate(angle: number): void;
|
|
121
|
+
rotate(angle: number, axis?: AxisAndPlanes): void;
|
|
119
122
|
translate(dx: number, dy: number, dz: number): void;
|
|
120
|
-
|
|
123
|
+
/**
|
|
124
|
+
* @param sx
|
|
125
|
+
* @param sy
|
|
126
|
+
* @param sz - optional sz. only has effect when rotating a single model or primitive
|
|
127
|
+
*/
|
|
128
|
+
scale(sx: number, sy: number, sz?: number): void;
|
|
121
129
|
setMode(mode: TransformationMode): void;
|
|
122
130
|
modeChanged: VcsEvent<TransformationMode>;
|
|
123
131
|
setFeatures(features: Feature[]): void;
|
|
@@ -204,16 +212,22 @@ function startEditFeaturesSession(
|
|
|
204
212
|
let destroyTransformation = (): void => {};
|
|
205
213
|
let transformationHandler: TransformationHandler | undefined;
|
|
206
214
|
const translate = (dx: number, dy: number, dz: number): void => {
|
|
207
|
-
transformationHandler?.translate?.(dx, dy, dz);
|
|
215
|
+
transformationHandler?.translate?.(dx, dy, dz); // XXX should we changes this in 2D to change the layout to XY?
|
|
208
216
|
currentFeatures.forEach((f) => {
|
|
209
217
|
const geometry = f[obliqueGeometry] ?? f.getGeometry(); // XXX wont work in oblqiue
|
|
210
218
|
geometry!.applyTransform(
|
|
211
|
-
(
|
|
219
|
+
(
|
|
220
|
+
input: number[],
|
|
221
|
+
output: number[] | undefined,
|
|
222
|
+
stride = 2,
|
|
223
|
+
): number[] => {
|
|
212
224
|
const inputLength = input.length;
|
|
213
|
-
for (let i = 0; i < inputLength; i +=
|
|
225
|
+
for (let i = 0; i < inputLength; i += stride) {
|
|
214
226
|
output![i] = input[i] + dx;
|
|
215
227
|
output![i + 1] = input[i + 1] + dy;
|
|
216
|
-
|
|
228
|
+
if (stride > 2) {
|
|
229
|
+
output![i + 2] = input[i + 2] + dz;
|
|
230
|
+
}
|
|
217
231
|
}
|
|
218
232
|
return output!;
|
|
219
233
|
},
|
|
@@ -221,39 +235,92 @@ function startEditFeaturesSession(
|
|
|
221
235
|
});
|
|
222
236
|
};
|
|
223
237
|
|
|
224
|
-
const rotate = (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
238
|
+
const rotate = (
|
|
239
|
+
angle: number,
|
|
240
|
+
axis: AxisAndPlanes = AxisAndPlanes.Z,
|
|
241
|
+
): void => {
|
|
242
|
+
if (
|
|
243
|
+
currentFeatures.length === 1 &&
|
|
244
|
+
currentFeatures[0].getGeometry()?.getType() === 'Point' &&
|
|
245
|
+
layer.vectorProperties.renderAs(currentFeatures[0]) !== 'geometry'
|
|
246
|
+
) {
|
|
247
|
+
if (axis === AxisAndPlanes.Z) {
|
|
248
|
+
const currentRotation = layer.vectorProperties.getModelHeading(
|
|
249
|
+
currentFeatures[0],
|
|
250
|
+
);
|
|
251
|
+
currentFeatures[0].set(
|
|
252
|
+
'olcs_modelHeading',
|
|
253
|
+
currentRotation - CesiumMath.toDegrees(angle),
|
|
254
|
+
);
|
|
255
|
+
} else if (axis === AxisAndPlanes.X) {
|
|
256
|
+
const currentRotation = layer.vectorProperties.getModelPitch(
|
|
257
|
+
currentFeatures[0],
|
|
258
|
+
);
|
|
259
|
+
currentFeatures[0].set(
|
|
260
|
+
'olcs_modelPitch',
|
|
261
|
+
currentRotation - CesiumMath.toDegrees(angle),
|
|
262
|
+
);
|
|
263
|
+
} else if (axis === AxisAndPlanes.Y) {
|
|
264
|
+
const currentRotation = layer.vectorProperties.getModelRoll(
|
|
265
|
+
currentFeatures[0],
|
|
266
|
+
);
|
|
267
|
+
currentFeatures[0].set(
|
|
268
|
+
'olcs_modelRoll',
|
|
269
|
+
currentRotation - CesiumMath.toDegrees(angle),
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
let center = transformationHandler?.center;
|
|
274
|
+
if (!center) {
|
|
275
|
+
const extent = createEmptyExtent();
|
|
276
|
+
currentFeatures.forEach((f) => {
|
|
277
|
+
extendExtent(extent, f.getGeometry()!.getExtent()); // XXX wont work in oblqiue
|
|
278
|
+
});
|
|
279
|
+
if (!isEmpty(extent)) {
|
|
280
|
+
center = getCenter(extent);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
228
283
|
currentFeatures.forEach((f) => {
|
|
229
|
-
|
|
284
|
+
const geometry = f[obliqueGeometry] ?? f.getGeometry(); // XXX wont work in oblqiue
|
|
285
|
+
geometry!.rotate(angle, center!);
|
|
230
286
|
});
|
|
231
|
-
if (!isEmpty(extent)) {
|
|
232
|
-
center = getCenter(extent);
|
|
233
|
-
}
|
|
234
287
|
}
|
|
235
|
-
currentFeatures.forEach((f) => {
|
|
236
|
-
const geometry = f[obliqueGeometry] ?? f.getGeometry(); // XXX wont work in oblqiue
|
|
237
|
-
geometry!.rotate(angle, center!);
|
|
238
|
-
});
|
|
239
288
|
};
|
|
240
289
|
|
|
241
|
-
const scale = (sx: number, sy: number): void => {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
290
|
+
const scale = (sx: number, sy: number, sz?: number): void => {
|
|
291
|
+
if (
|
|
292
|
+
currentFeatures.length === 1 &&
|
|
293
|
+
currentFeatures[0].getGeometry()?.getType() === 'Point' &&
|
|
294
|
+
layer.vectorProperties.renderAs(currentFeatures[0]) !== 'geometry'
|
|
295
|
+
) {
|
|
296
|
+
const feature = currentFeatures[0];
|
|
297
|
+
const scaleX = layer.vectorProperties.getModelScaleX(feature);
|
|
298
|
+
const scaleY = layer.vectorProperties.getModelScaleY(feature);
|
|
299
|
+
const scaleZ = layer.vectorProperties.getModelScaleZ(feature);
|
|
300
|
+
currentFeatures[0].set('olcs_modelScaleX', scaleX * sx);
|
|
301
|
+
currentFeatures[0].set('olcs_modelScaleY', scaleY * sy);
|
|
302
|
+
let usedSz = sz;
|
|
303
|
+
if (usedSz == null) {
|
|
304
|
+
usedSz = sx === sy ? sx : 1;
|
|
305
|
+
}
|
|
306
|
+
currentFeatures[0].set('olcs_modelScaleZ', scaleZ * usedSz);
|
|
307
|
+
} else {
|
|
308
|
+
let center = transformationHandler?.center;
|
|
309
|
+
if (!center) {
|
|
310
|
+
// XXX copy paste
|
|
311
|
+
const extent = createEmptyExtent();
|
|
312
|
+
currentFeatures.forEach((f) => {
|
|
313
|
+
extendExtent(extent, f.getGeometry()!.getExtent());
|
|
314
|
+
});
|
|
315
|
+
if (!isEmpty(extent)) {
|
|
316
|
+
center = getCenter(extent);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
246
319
|
currentFeatures.forEach((f) => {
|
|
247
|
-
|
|
320
|
+
const geometry = f[obliqueGeometry] ?? f.getGeometry();
|
|
321
|
+
geometry!.scale(sx, sy, center);
|
|
248
322
|
});
|
|
249
|
-
if (!isEmpty(extent)) {
|
|
250
|
-
center = getCenter(extent);
|
|
251
|
-
}
|
|
252
323
|
}
|
|
253
|
-
currentFeatures.forEach((f) => {
|
|
254
|
-
const geometry = f[obliqueGeometry] ?? f.getGeometry();
|
|
255
|
-
geometry!.scale(sx, sy, center);
|
|
256
|
-
});
|
|
257
324
|
};
|
|
258
325
|
|
|
259
326
|
const createTransformations = (): void => {
|
|
@@ -281,8 +348,6 @@ function startEditFeaturesSession(
|
|
|
281
348
|
interaction = new ExtrudeInteraction(transformationHandler);
|
|
282
349
|
interaction.extruded.addEventListener((dz) => {
|
|
283
350
|
currentFeatures.forEach((f) => {
|
|
284
|
-
// eslint-disable-next-line no-void
|
|
285
|
-
void ensureFeatureAbsolute(f, layer, app.maps.activeMap as CesiumMap);
|
|
286
351
|
let extrudedHeight =
|
|
287
352
|
(f.get('olcs_extrudedHeight') as number | undefined) ?? 0;
|
|
288
353
|
extrudedHeight += dz;
|
|
@@ -291,13 +356,13 @@ function startEditFeaturesSession(
|
|
|
291
356
|
});
|
|
292
357
|
} else if (mode === TransformationMode.ROTATE) {
|
|
293
358
|
interaction = new RotateInteraction(transformationHandler);
|
|
294
|
-
interaction.rotated.addEventListener(({ angle }) => {
|
|
295
|
-
rotate(angle);
|
|
359
|
+
interaction.rotated.addEventListener(({ angle, axis }) => {
|
|
360
|
+
rotate(angle, axis);
|
|
296
361
|
});
|
|
297
362
|
} else if (mode === TransformationMode.SCALE) {
|
|
298
363
|
interaction = new ScaleInteraction(transformationHandler);
|
|
299
|
-
interaction.scaled.addEventListener(([sx, sy]) => {
|
|
300
|
-
scale(sx, sy);
|
|
364
|
+
interaction.scaled.addEventListener(([sx, sy, sz]) => {
|
|
365
|
+
scale(sx, sy, sz);
|
|
301
366
|
});
|
|
302
367
|
} else {
|
|
303
368
|
throw new Error(`Unknown transformation mode ${String(mode)}`);
|
|
@@ -378,6 +443,7 @@ function startEditFeaturesSession(
|
|
|
378
443
|
});
|
|
379
444
|
allowPickingMap.clear();
|
|
380
445
|
app.layers.remove(scratchLayer);
|
|
446
|
+
scratchLayer.destroy();
|
|
381
447
|
modeChanged.destroy();
|
|
382
448
|
removeRightClickStart();
|
|
383
449
|
rightClickStart.destroy();
|