@deck.gl-community/editable-layers 9.0.0-alpha.1 → 9.0.2
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 +19 -0
- package/README.md +2 -81
- package/dist/constants.js +4 -1
- package/dist/edit-modes/composite-mode.d.ts +1 -1
- package/dist/edit-modes/composite-mode.js +4 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.js +29 -24
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.js +7 -4
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.js +7 -4
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +1 -1
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +3 -0
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +1 -1
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +3 -0
- package/dist/edit-modes/draw-line-string-mode.d.ts +1 -1
- package/dist/edit-modes/draw-line-string-mode.js +19 -16
- package/dist/edit-modes/draw-point-mode.d.ts +1 -1
- package/dist/edit-modes/draw-point-mode.js +7 -4
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +1 -1
- package/dist/edit-modes/draw-polygon-by-dragging-mode.js +10 -5
- package/dist/edit-modes/draw-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/draw-polygon-mode.js +20 -16
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.js +3 -0
- package/dist/edit-modes/draw-rectangle-mode.d.ts +1 -1
- package/dist/edit-modes/draw-rectangle-mode.js +3 -0
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +1 -1
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.js +8 -5
- package/dist/edit-modes/draw-square-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-square-from-center-mode.js +3 -0
- package/dist/edit-modes/draw-square-mode.d.ts +1 -1
- package/dist/edit-modes/draw-square-mode.js +3 -0
- package/dist/edit-modes/duplicate-mode.d.ts +1 -1
- package/dist/edit-modes/duplicate-mode.js +3 -0
- package/dist/edit-modes/edit-mode.js +3 -1
- package/dist/edit-modes/elevation-mode.d.ts +2 -2
- package/dist/edit-modes/elevation-mode.js +8 -5
- package/dist/edit-modes/extend-line-string-mode.d.ts +1 -1
- package/dist/edit-modes/extend-line-string-mode.js +9 -6
- package/dist/edit-modes/extrude-mode.d.ts +1 -1
- package/dist/edit-modes/extrude-mode.js +10 -7
- package/dist/edit-modes/geojson-edit-mode.d.ts +1 -1
- package/dist/edit-modes/geojson-edit-mode.js +18 -15
- package/dist/edit-modes/immutable-feature-collection.d.ts +2 -1
- package/dist/edit-modes/immutable-feature-collection.js +25 -20
- package/dist/edit-modes/measure-angle-mode.d.ts +1 -1
- package/dist/edit-modes/measure-angle-mode.js +8 -8
- package/dist/edit-modes/measure-area-mode.d.ts +1 -1
- package/dist/edit-modes/measure-area-mode.js +7 -5
- package/dist/edit-modes/measure-distance-mode.d.ts +1 -1
- package/dist/edit-modes/measure-distance-mode.js +17 -14
- package/dist/edit-modes/modify-mode.d.ts +1 -1
- package/dist/edit-modes/modify-mode.js +17 -14
- package/dist/edit-modes/resize-circle-mode.d.ts +2 -2
- package/dist/edit-modes/resize-circle-mode.js +3 -1
- package/dist/edit-modes/rotate-mode.d.ts +1 -1
- package/dist/edit-modes/rotate-mode.js +8 -5
- package/dist/edit-modes/scale-mode.d.ts +1 -1
- package/dist/edit-modes/scale-mode.js +8 -5
- package/dist/edit-modes/snappable-mode.d.ts +1 -1
- package/dist/edit-modes/snappable-mode.js +8 -5
- package/dist/edit-modes/split-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/split-polygon-mode.js +12 -9
- package/dist/edit-modes/three-click-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/three-click-polygon-mode.js +9 -6
- package/dist/edit-modes/transform-mode.d.ts +1 -1
- package/dist/edit-modes/transform-mode.js +4 -1
- package/dist/edit-modes/translate-mode.d.ts +1 -1
- package/dist/edit-modes/translate-mode.js +7 -4
- package/dist/edit-modes/two-click-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/two-click-polygon-mode.js +9 -6
- package/dist/edit-modes/types.d.ts +1 -1
- package/dist/edit-modes/types.js +3 -0
- package/dist/edit-modes/utils.d.ts +1 -1
- package/dist/edit-modes/utils.js +21 -19
- package/dist/edit-modes/view-mode.js +3 -0
- package/dist/editable-layers/editable-geojson-layer.d.ts +4 -4
- package/dist/editable-layers/editable-geojson-layer.js +27 -26
- package/dist/editable-layers/editable-h3-cluster-layer.d.ts +2 -2
- package/dist/editable-layers/editable-h3-cluster-layer.js +6 -3
- package/dist/editable-layers/editable-layer.d.ts +5 -5
- package/dist/editable-layers/editable-layer.js +18 -15
- package/dist/editable-layers/editable-path-layer.d.ts +1 -1
- package/dist/editable-layers/editable-path-layer.js +10 -7
- package/dist/editable-layers/elevated-edit-handle-layer.d.ts +1 -1
- package/dist/editable-layers/elevated-edit-handle-layer.js +6 -3
- package/dist/editable-layers/junction-scatterplot-layer.d.ts +2 -2
- package/dist/editable-layers/junction-scatterplot-layer.js +10 -7
- package/dist/editable-layers/selection-layer.d.ts +1 -1
- package/dist/editable-layers/selection-layer.js +5 -2
- package/dist/index.cjs +65 -537
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +19 -20
- package/dist/index.js +20 -18
- package/dist/lib/constants.js +3 -0
- package/dist/lib/deck-renderer/deck-cache.d.ts +1 -1
- package/dist/lib/deck-renderer/deck-cache.js +1 -1
- package/dist/lib/deck-renderer/deck-drawer.d.ts +2 -3
- package/dist/lib/deck-renderer/deck-drawer.js +12 -12
- package/dist/lib/feature.d.ts +4 -4
- package/dist/lib/feature.js +4 -1
- package/dist/lib/layer-mouse-event.d.ts +2 -2
- package/dist/lib/layer-mouse-event.js +4 -1
- package/dist/lib/layers/junctions-layer.d.ts +4 -4
- package/dist/lib/layers/junctions-layer.js +10 -7
- package/dist/lib/layers/segments-layer.d.ts +4 -4
- package/dist/lib/layers/segments-layer.js +11 -8
- package/dist/lib/layers/texts-layer.d.ts +3 -3
- package/dist/lib/layers/texts-layer.js +8 -5
- package/dist/lib/math.d.ts +1 -1
- package/dist/lib/math.js +3 -0
- package/dist/lib/{nebula.d.ts → nebula-core.d.ts} +2 -2
- package/dist/lib/{nebula.js → nebula-core.js} +7 -4
- package/dist/lib/nebula-layer.d.ts +2 -2
- package/dist/lib/nebula-layer.js +4 -1
- package/dist/lib/style.js +5 -2
- package/dist/mode-handlers/composite-mode-handler.d.ts +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.js +13 -10
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +3 -0
- package/dist/mode-handlers/draw-circle-from-center-handler.js +3 -0
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +3 -0
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +5 -2
- package/dist/mode-handlers/draw-line-string-handler.js +7 -4
- package/dist/mode-handlers/draw-point-handler.js +4 -1
- package/dist/mode-handlers/draw-polygon-handler.d.ts +1 -1
- package/dist/mode-handlers/draw-polygon-handler.js +10 -7
- package/dist/mode-handlers/draw-rectangle-handler.js +3 -0
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +11 -8
- package/dist/mode-handlers/duplicate-handler.js +3 -0
- package/dist/mode-handlers/elevation-handler.d.ts +2 -2
- package/dist/mode-handlers/elevation-handler.js +8 -5
- package/dist/mode-handlers/extrude-handler.js +10 -7
- package/dist/mode-handlers/mode-handler.d.ts +1 -1
- package/dist/mode-handlers/mode-handler.js +17 -14
- package/dist/mode-handlers/modify-handler.d.ts +2 -2
- package/dist/mode-handlers/modify-handler.js +18 -15
- package/dist/mode-handlers/rotate-handler.d.ts +1 -1
- package/dist/mode-handlers/rotate-handler.js +4 -1
- package/dist/mode-handlers/scale-handler.d.ts +1 -1
- package/dist/mode-handlers/scale-handler.js +5 -2
- package/dist/mode-handlers/snappable-handler.d.ts +1 -1
- package/dist/mode-handlers/snappable-handler.js +6 -3
- package/dist/mode-handlers/split-polygon-handler.js +11 -8
- package/dist/mode-handlers/three-click-polygon-handler.js +3 -0
- package/dist/mode-handlers/translate-handler.d.ts +1 -1
- package/dist/mode-handlers/translate-handler.js +4 -1
- package/dist/mode-handlers/two-click-polygon-handler.js +3 -0
- package/dist/mode-handlers/view-handler.d.ts +1 -1
- package/dist/mode-handlers/view-handler.js +3 -0
- package/dist/shaderlib/color/color.d.ts +7 -6
- package/dist/shaderlib/color/color.js +7 -4
- package/dist/shaderlib/utils/utils.d.ts +2 -2
- package/dist/shaderlib/utils/utils.js +5 -2
- package/dist/{curve-utils.js → utils/curve-utils.js} +7 -4
- package/dist/{geojson-types.d.ts → utils/geojson-types.d.ts} +2 -25
- package/dist/utils/geojson-types.js +4 -0
- package/dist/{memoize.d.ts → utils/memoize.d.ts} +1 -1
- package/dist/{memoize.js → utils/memoize.js} +4 -1
- package/dist/{translateFromCenter.js → utils/translate-from-center.js} +4 -1
- package/dist/utils/types.js +4 -0
- package/dist/{utils.js → utils/utils.js} +8 -6
- package/package.json +10 -10
- package/src/constants.ts +5 -1
- package/src/edit-modes/composite-mode.ts +9 -5
- package/src/edit-modes/draw-90degree-polygon-mode.ts +38 -34
- package/src/edit-modes/draw-circle-by-diameter-mode.ts +16 -12
- package/src/edit-modes/draw-circle-from-center-mode.ts +15 -11
- package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +8 -4
- package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +9 -5
- package/src/edit-modes/draw-line-string-mode.ts +29 -25
- package/src/edit-modes/draw-point-mode.ts +13 -9
- package/src/edit-modes/draw-polygon-by-dragging-mode.ts +16 -16
- package/src/edit-modes/draw-polygon-mode.ts +28 -23
- package/src/edit-modes/draw-rectangle-from-center-mode.ts +6 -2
- package/src/edit-modes/draw-rectangle-mode.ts +6 -2
- package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +12 -8
- package/src/edit-modes/draw-square-from-center-mode.ts +7 -3
- package/src/edit-modes/draw-square-mode.ts +7 -3
- package/src/edit-modes/duplicate-mode.ts +7 -3
- package/src/edit-modes/edit-mode.ts +5 -1
- package/src/edit-modes/elevation-mode.ts +13 -9
- package/src/edit-modes/extend-line-string-mode.ts +16 -12
- package/src/edit-modes/extrude-mode.ts +22 -18
- package/src/edit-modes/geojson-edit-mode.ts +37 -33
- package/src/edit-modes/immutable-feature-collection.ts +28 -22
- package/src/edit-modes/measure-angle-mode.ts +66 -59
- package/src/edit-modes/measure-area-mode.ts +13 -10
- package/src/edit-modes/measure-distance-mode.ts +37 -33
- package/src/edit-modes/modify-mode.ts +36 -32
- package/src/edit-modes/resize-circle-mode.ts +8 -5
- package/src/edit-modes/rotate-mode.ts +22 -18
- package/src/edit-modes/scale-mode.ts +29 -23
- package/src/edit-modes/snappable-mode.ts +19 -15
- package/src/edit-modes/split-polygon-mode.ts +25 -21
- package/src/edit-modes/three-click-polygon-mode.ts +15 -11
- package/src/edit-modes/transform-mode.ts +15 -11
- package/src/edit-modes/translate-mode.ts +15 -11
- package/src/edit-modes/two-click-polygon-mode.ts +15 -11
- package/src/edit-modes/types.ts +5 -1
- package/src/edit-modes/utils.ts +33 -30
- package/src/edit-modes/view-mode.ts +5 -1
- package/src/editable-layers/editable-geojson-layer.ts +44 -41
- package/src/editable-layers/editable-h3-cluster-layer.ts +17 -14
- package/src/editable-layers/editable-layer.ts +42 -32
- package/src/editable-layers/editable-path-layer.ts +12 -8
- package/src/editable-layers/elevated-edit-handle-layer.ts +11 -7
- package/src/editable-layers/junction-scatterplot-layer.ts +15 -11
- package/src/editable-layers/selection-layer.ts +11 -7
- package/src/index.ts +68 -65
- package/src/lib/constants.ts +4 -0
- package/src/lib/deck-renderer/deck-cache.ts +1 -1
- package/src/lib/deck-renderer/deck-drawer.ts +28 -28
- package/src/lib/feature.ts +7 -3
- package/src/lib/layer-mouse-event.ts +7 -6
- package/src/lib/layers/junctions-layer.ts +14 -10
- package/src/lib/layers/segments-layer.ts +24 -20
- package/src/lib/layers/texts-layer.ts +18 -14
- package/src/lib/math.ts +5 -1
- package/src/lib/{nebula.ts → nebula-core.ts} +8 -4
- package/src/lib/nebula-layer.ts +9 -5
- package/src/lib/style.ts +6 -2
- package/src/mode-handlers/composite-mode-handler.ts +6 -6
- package/src/mode-handlers/draw-90degree-polygon-handler.ts +22 -18
- package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +10 -6
- package/src/mode-handlers/draw-circle-from-center-handler.ts +10 -6
- package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +9 -5
- package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +12 -8
- package/src/mode-handlers/draw-line-string-handler.ts +12 -8
- package/src/mode-handlers/draw-point-handler.ts +9 -5
- package/src/mode-handlers/draw-polygon-handler.ts +16 -12
- package/src/mode-handlers/draw-rectangle-handler.ts +8 -4
- package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +17 -13
- package/src/mode-handlers/duplicate-handler.ts +8 -4
- package/src/mode-handlers/elevation-handler.ts +14 -10
- package/src/mode-handlers/extrude-handler.ts +15 -11
- package/src/mode-handlers/mode-handler.ts +26 -28
- package/src/mode-handlers/modify-handler.ts +29 -25
- package/src/mode-handlers/rotate-handler.ts +13 -17
- package/src/mode-handlers/scale-handler.ts +13 -13
- package/src/mode-handlers/snappable-handler.ts +28 -24
- package/src/mode-handlers/split-polygon-handler.ts +22 -18
- package/src/mode-handlers/three-click-polygon-handler.ts +6 -2
- package/src/mode-handlers/translate-handler.ts +12 -8
- package/src/mode-handlers/two-click-polygon-handler.ts +6 -2
- package/src/mode-handlers/view-handler.ts +7 -3
- package/src/shaderlib/color/color.ts +10 -5
- package/src/shaderlib/utils/utils.ts +6 -2
- package/src/{curve-utils.ts → utils/curve-utils.ts} +11 -7
- package/src/{geojson-types.ts → utils/geojson-types.ts} +16 -31
- package/src/{memoize.ts → utils/memoize.ts} +5 -1
- package/src/{translateFromCenter.ts → utils/translate-from-center.ts} +8 -4
- package/src/{types.ts → utils/types.ts} +4 -0
- package/src/{utils.ts → utils/utils.ts} +14 -11
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.d.ts +0 -4
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.js +0 -55
- package/dist/editable-layers/path-marker-layer/create-path-markers.d.ts +0 -16
- package/dist/editable-layers/path-marker-layer/create-path-markers.js +0 -75
- package/dist/editable-layers/path-marker-layer/path-marker-layer.d.ts +0 -40
- package/dist/editable-layers/path-marker-layer/path-marker-layer.js +0 -121
- package/dist/editable-layers/path-marker-layer/polyline.d.ts +0 -18
- package/dist/editable-layers/path-marker-layer/polyline.js +0 -37
- package/dist/editable-layers/path-outline-layer/path-outline-layer.d.ts +0 -26
- package/dist/editable-layers/path-outline-layer/path-outline-layer.js +0 -106
- package/dist/geojson-types.js +0 -2
- package/dist/shaderlib/outline/outline.d.ts +0 -8
- package/dist/shaderlib/outline/outline.js +0 -97
- package/dist/types.js +0 -1
- package/src/editable-layers/path-marker-layer/arrow-2d-geometry.ts +0 -61
- package/src/editable-layers/path-marker-layer/create-path-markers.ts +0 -107
- package/src/editable-layers/path-marker-layer/path-marker-layer.ts +0 -179
- package/src/editable-layers/path-marker-layer/polyline.ts +0 -40
- package/src/editable-layers/path-outline-layer/path-outline-layer.ts +0 -147
- package/src/shaderlib/outline/outline.ts +0 -101
- /package/dist/{curve-utils.d.ts → utils/curve-utils.d.ts} +0 -0
- /package/dist/{translateFromCenter.d.ts → utils/translate-from-center.d.ts} +0 -0
- /package/dist/{types.d.ts → utils/types.d.ts} +0 -0
- /package/dist/{utils.d.ts → utils/utils.d.ts} +0 -0
|
@@ -1,25 +1,23 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
2
6
|
|
|
3
7
|
import turfUnion from '@turf/union';
|
|
4
8
|
import turfDifference from '@turf/difference';
|
|
5
9
|
import turfIntersect from '@turf/intersect';
|
|
6
10
|
|
|
7
|
-
import {
|
|
8
|
-
FeatureCollection,
|
|
9
|
-
Feature,
|
|
10
|
-
Polygon,
|
|
11
|
-
Geometry,
|
|
12
|
-
Position,
|
|
13
|
-
} from '../geojson-types';
|
|
11
|
+
import {FeatureCollection, Feature, Polygon, Geometry, Position} from '../utils/geojson-types';
|
|
14
12
|
|
|
15
13
|
import {
|
|
16
14
|
ClickEvent,
|
|
17
15
|
Pick,
|
|
18
16
|
PointerMoveEvent,
|
|
19
17
|
StartDraggingEvent,
|
|
20
|
-
StopDraggingEvent
|
|
18
|
+
StopDraggingEvent
|
|
21
19
|
} from '../edit-modes/types';
|
|
22
|
-
import {
|
|
20
|
+
import {ImmutableFeatureCollection} from '../edit-modes/immutable-feature-collection';
|
|
23
21
|
|
|
24
22
|
export type EditHandleType = 'existing' | 'intermediate' | 'snap';
|
|
25
23
|
|
|
@@ -75,13 +73,13 @@ export class ModeHandler {
|
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
getSelectedFeaturesAsFeatureCollection(): FeatureCollection {
|
|
78
|
-
const {
|
|
76
|
+
const {features} = this.featureCollection.getObject();
|
|
79
77
|
const selectedFeatures = this.getSelectedFeatureIndexes().map(
|
|
80
78
|
(selectedIndex) => features[selectedIndex]
|
|
81
79
|
);
|
|
82
80
|
return {
|
|
83
81
|
type: 'FeatureCollection',
|
|
84
|
-
features: selectedFeatures
|
|
82
|
+
features: selectedFeatures
|
|
85
83
|
};
|
|
86
84
|
}
|
|
87
85
|
|
|
@@ -145,13 +143,13 @@ export class ModeHandler {
|
|
|
145
143
|
return [];
|
|
146
144
|
}
|
|
147
145
|
|
|
148
|
-
getCursor({
|
|
146
|
+
getCursor({isDragging}: {isDragging: boolean}): string {
|
|
149
147
|
return 'cell';
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
isSelectionPicked(picks: Pick[]): boolean {
|
|
153
151
|
if (!picks.length) return false;
|
|
154
|
-
const pickedIndexes = picks.map(({
|
|
152
|
+
const pickedIndexes = picks.map(({index}) => index);
|
|
155
153
|
const selectedFeatureIndexes = this.getSelectedFeatureIndexes();
|
|
156
154
|
return selectedFeatureIndexes.some((index) => pickedIndexes.includes(index));
|
|
157
155
|
}
|
|
@@ -164,7 +162,7 @@ export class ModeHandler {
|
|
|
164
162
|
.addFeature({
|
|
165
163
|
type: 'Feature',
|
|
166
164
|
properties: {},
|
|
167
|
-
geometry: geometryAsAny
|
|
165
|
+
geometry: geometryAsAny
|
|
168
166
|
})
|
|
169
167
|
.getObject();
|
|
170
168
|
|
|
@@ -173,8 +171,8 @@ export class ModeHandler {
|
|
|
173
171
|
editType: 'addFeature',
|
|
174
172
|
featureIndexes: [updatedData.features.length - 1],
|
|
175
173
|
editContext: {
|
|
176
|
-
featureIndexes: [updatedData.features.length - 1]
|
|
177
|
-
}
|
|
174
|
+
featureIndexes: [updatedData.features.length - 1]
|
|
175
|
+
}
|
|
178
176
|
};
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -184,12 +182,12 @@ export class ModeHandler {
|
|
|
184
182
|
const initialIndex = updatedData.getObject().features.length;
|
|
185
183
|
const updatedIndexes: number[] = [];
|
|
186
184
|
for (const feature of features) {
|
|
187
|
-
const {
|
|
185
|
+
const {properties, geometry} = feature;
|
|
188
186
|
const geometryAsAny: any = geometry;
|
|
189
187
|
updatedData = updatedData.addFeature({
|
|
190
188
|
type: 'Feature',
|
|
191
189
|
properties,
|
|
192
|
-
geometry: geometryAsAny
|
|
190
|
+
geometry: geometryAsAny
|
|
193
191
|
});
|
|
194
192
|
updatedIndexes.push(initialIndex + updatedIndexes.length);
|
|
195
193
|
}
|
|
@@ -199,8 +197,8 @@ export class ModeHandler {
|
|
|
199
197
|
editType: 'addFeature',
|
|
200
198
|
featureIndexes: updatedIndexes,
|
|
201
199
|
editContext: {
|
|
202
|
-
featureIndexes: updatedIndexes
|
|
203
|
-
}
|
|
200
|
+
featureIndexes: updatedIndexes
|
|
201
|
+
}
|
|
204
202
|
};
|
|
205
203
|
}
|
|
206
204
|
|
|
@@ -222,7 +220,7 @@ export class ModeHandler {
|
|
|
222
220
|
|
|
223
221
|
const feature = {
|
|
224
222
|
type: 'Feature',
|
|
225
|
-
geometry
|
|
223
|
+
geometry
|
|
226
224
|
};
|
|
227
225
|
|
|
228
226
|
let updatedGeometry;
|
|
@@ -258,8 +256,8 @@ export class ModeHandler {
|
|
|
258
256
|
editType: 'unionGeometry',
|
|
259
257
|
featureIndexes: [featureIndex],
|
|
260
258
|
editContext: {
|
|
261
|
-
featureIndexes: [featureIndex]
|
|
262
|
-
}
|
|
259
|
+
featureIndexes: [featureIndex]
|
|
260
|
+
}
|
|
263
261
|
};
|
|
264
262
|
|
|
265
263
|
return editAction;
|
|
@@ -277,7 +275,7 @@ export class ModeHandler {
|
|
|
277
275
|
editAction: EditAction | null | undefined;
|
|
278
276
|
cancelMapPan: boolean;
|
|
279
277
|
} {
|
|
280
|
-
return {
|
|
278
|
+
return {editAction: null, cancelMapPan: false};
|
|
281
279
|
}
|
|
282
280
|
|
|
283
281
|
handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined {
|
|
@@ -302,7 +300,7 @@ export function getPickedEditHandle(
|
|
|
302
300
|
export function getIntermediatePosition(position1: Position, position2: Position): Position {
|
|
303
301
|
const intermediatePosition: Position = [
|
|
304
302
|
(position1[0] + position2[0]) / 2.0,
|
|
305
|
-
(position1[1] + position2[1]) / 2.0
|
|
303
|
+
(position1[1] + position2[1]) / 2.0
|
|
306
304
|
];
|
|
307
305
|
|
|
308
306
|
return intermediatePosition;
|
|
@@ -323,8 +321,8 @@ export function getEditHandlesForGeometry(
|
|
|
323
321
|
position: geometry.coordinates,
|
|
324
322
|
positionIndexes: [],
|
|
325
323
|
featureIndex,
|
|
326
|
-
type: editHandleType
|
|
327
|
-
}
|
|
324
|
+
type: editHandleType
|
|
325
|
+
}
|
|
328
326
|
];
|
|
329
327
|
break;
|
|
330
328
|
case 'MultiPoint':
|
|
@@ -387,7 +385,7 @@ function getEditHandlesForCoordinates(
|
|
|
387
385
|
position,
|
|
388
386
|
positionIndexes: [...positionIndexPrefix, i],
|
|
389
387
|
featureIndex,
|
|
390
|
-
type: editHandleType
|
|
388
|
+
type: editHandleType
|
|
391
389
|
});
|
|
392
390
|
}
|
|
393
391
|
return editHandles;
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
6
|
+
import {point, lineString as toLineString} from '@turf/helpers';
|
|
7
|
+
import {Position, FeatureOf, Point, LineString} from '../utils/geojson-types';
|
|
4
8
|
import {
|
|
5
9
|
recursivelyTraverseNestedArrays,
|
|
6
10
|
nearestPointOnProjectedLine,
|
|
7
|
-
NearestPointType
|
|
8
|
-
} from '../utils';
|
|
11
|
+
NearestPointType
|
|
12
|
+
} from '../utils/utils';
|
|
9
13
|
import {
|
|
10
14
|
ClickEvent,
|
|
11
15
|
PointerMoveEvent,
|
|
12
16
|
StartDraggingEvent,
|
|
13
|
-
StopDraggingEvent
|
|
17
|
+
StopDraggingEvent
|
|
14
18
|
} from '../edit-modes/types';
|
|
15
19
|
import {
|
|
16
20
|
EditAction,
|
|
17
21
|
EditHandle,
|
|
18
22
|
ModeHandler,
|
|
19
23
|
getPickedEditHandle,
|
|
20
|
-
getEditHandlesForGeometry
|
|
24
|
+
getEditHandlesForGeometry
|
|
21
25
|
} from './mode-handler';
|
|
22
26
|
|
|
23
27
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
@@ -26,11 +30,11 @@ export class ModifyHandler extends ModeHandler {
|
|
|
26
30
|
|
|
27
31
|
getEditHandles(picks?: Array<Record<string, any>>, mapCoords?: Position): EditHandle[] {
|
|
28
32
|
let handles: EditHandle[] = [];
|
|
29
|
-
const {
|
|
33
|
+
const {features} = this.featureCollection.getObject();
|
|
30
34
|
|
|
31
35
|
for (const index of this.getSelectedFeatureIndexes()) {
|
|
32
36
|
if (index < features.length) {
|
|
33
|
-
const {
|
|
37
|
+
const {geometry} = features[index];
|
|
34
38
|
handles.push(...getEditHandlesForGeometry(geometry, index));
|
|
35
39
|
} else {
|
|
36
40
|
console.warn(`selectedFeatureIndexes out of range ${index}`); // eslint-disable-line no-console,no-undef
|
|
@@ -78,8 +82,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
78
82
|
// tack on the lone intermediate point to the set of handles
|
|
79
83
|
if (intermediatePoint) {
|
|
80
84
|
const {
|
|
81
|
-
geometry: {
|
|
82
|
-
properties: {
|
|
85
|
+
geometry: {coordinates: position},
|
|
86
|
+
properties: {index}
|
|
83
87
|
} = intermediatePoint;
|
|
84
88
|
handles = [
|
|
85
89
|
...handles,
|
|
@@ -87,8 +91,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
87
91
|
position,
|
|
88
92
|
positionIndexes: [...positionIndexPrefix, index + 1],
|
|
89
93
|
featureIndex: featureAsPick.index,
|
|
90
|
-
type: 'intermediate'
|
|
91
|
-
}
|
|
94
|
+
type: 'intermediate'
|
|
95
|
+
}
|
|
92
96
|
];
|
|
93
97
|
}
|
|
94
98
|
}
|
|
@@ -99,7 +103,7 @@ export class ModifyHandler extends ModeHandler {
|
|
|
99
103
|
|
|
100
104
|
// turf.js does not support elevation for nearestPointOnLine
|
|
101
105
|
nearestPointOnLine(line: FeatureOf<LineString>, inPoint: FeatureOf<Point>): NearestPointType {
|
|
102
|
-
const {
|
|
106
|
+
const {coordinates} = line.geometry;
|
|
103
107
|
if (coordinates.some((coord) => coord.length > 2)) {
|
|
104
108
|
const modeConfig = this.getModeConfig();
|
|
105
109
|
if (modeConfig && modeConfig.viewport) {
|
|
@@ -138,8 +142,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
138
142
|
featureIndexes: [clickedEditHandle.featureIndex],
|
|
139
143
|
editContext: {
|
|
140
144
|
positionIndexes: clickedEditHandle.positionIndexes,
|
|
141
|
-
position: clickedEditHandle.position
|
|
142
|
-
}
|
|
145
|
+
position: clickedEditHandle.position
|
|
146
|
+
}
|
|
143
147
|
};
|
|
144
148
|
}
|
|
145
149
|
} else if (clickedEditHandle.type === 'intermediate') {
|
|
@@ -158,8 +162,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
158
162
|
featureIndexes: [clickedEditHandle.featureIndex],
|
|
159
163
|
editContext: {
|
|
160
164
|
positionIndexes: clickedEditHandle.positionIndexes,
|
|
161
|
-
position: clickedEditHandle.position
|
|
162
|
-
}
|
|
165
|
+
position: clickedEditHandle.position
|
|
166
|
+
}
|
|
163
167
|
};
|
|
164
168
|
}
|
|
165
169
|
}
|
|
@@ -188,15 +192,15 @@ export class ModifyHandler extends ModeHandler {
|
|
|
188
192
|
featureIndexes: [editHandle.featureIndex],
|
|
189
193
|
editContext: {
|
|
190
194
|
positionIndexes: editHandle.positionIndexes,
|
|
191
|
-
position: event.mapCoords
|
|
192
|
-
}
|
|
195
|
+
position: event.mapCoords
|
|
196
|
+
}
|
|
193
197
|
};
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
// Cancel map panning if pointer went down on an edit handle
|
|
197
201
|
const cancelMapPan = Boolean(editHandle);
|
|
198
202
|
|
|
199
|
-
return {
|
|
203
|
+
return {editAction, cancelMapPan};
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined {
|
|
@@ -216,8 +220,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
216
220
|
featureIndexes: [editHandle.featureIndex],
|
|
217
221
|
editContext: {
|
|
218
222
|
positionIndexes: editHandle.positionIndexes,
|
|
219
|
-
position: event.mapCoords
|
|
220
|
-
}
|
|
223
|
+
position: event.mapCoords
|
|
224
|
+
}
|
|
221
225
|
};
|
|
222
226
|
}
|
|
223
227
|
|
|
@@ -240,15 +244,15 @@ export class ModifyHandler extends ModeHandler {
|
|
|
240
244
|
featureIndexes: [editHandle.featureIndex],
|
|
241
245
|
editContext: {
|
|
242
246
|
positionIndexes: editHandle.positionIndexes,
|
|
243
|
-
position: event.mapCoords
|
|
244
|
-
}
|
|
247
|
+
position: event.mapCoords
|
|
248
|
+
}
|
|
245
249
|
};
|
|
246
250
|
}
|
|
247
251
|
|
|
248
252
|
return editAction;
|
|
249
253
|
}
|
|
250
254
|
|
|
251
|
-
getCursor({
|
|
255
|
+
getCursor({isDragging}: {isDragging: boolean}): string {
|
|
252
256
|
const picks = this._lastPointerMovePicks;
|
|
253
257
|
|
|
254
258
|
if (picks && picks.length > 0) {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import turfCentroid from '@turf/centroid';
|
|
2
6
|
import turfBearing from '@turf/bearing';
|
|
3
7
|
import turfTransformRotate from '@turf/transform-rotate';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import {FeatureCollection, Position} from '../utils/geojson-types';
|
|
9
|
+
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
10
|
+
import {EditAction, ModeHandler} from './mode-handler';
|
|
7
11
|
|
|
8
12
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
9
13
|
export class RotateHandler extends ModeHandler {
|
|
@@ -20,19 +24,15 @@ export class RotateHandler extends ModeHandler {
|
|
|
20
24
|
|
|
21
25
|
if (!this._isRotatable || !event.pointerDownMapCoords) {
|
|
22
26
|
// Nothing to do
|
|
23
|
-
return {
|
|
27
|
+
return {editAction: null, cancelMapPan: false};
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
if (event.isDragging && this._geometryBeingRotated) {
|
|
27
31
|
// Rotate the geometry
|
|
28
|
-
editAction = this.getRotateAction(
|
|
29
|
-
event.pointerDownMapCoords,
|
|
30
|
-
event.mapCoords,
|
|
31
|
-
'rotating'
|
|
32
|
-
);
|
|
32
|
+
editAction = this.getRotateAction(event.pointerDownMapCoords, event.mapCoords, 'rotating');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return {
|
|
35
|
+
return {editAction, cancelMapPan: true};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined {
|
|
@@ -49,18 +49,14 @@ export class RotateHandler extends ModeHandler {
|
|
|
49
49
|
|
|
50
50
|
if (this._geometryBeingRotated) {
|
|
51
51
|
// Rotate the geometry
|
|
52
|
-
editAction = this.getRotateAction(
|
|
53
|
-
event.pointerDownMapCoords,
|
|
54
|
-
event.mapCoords,
|
|
55
|
-
'rotated'
|
|
56
|
-
);
|
|
52
|
+
editAction = this.getRotateAction(event.pointerDownMapCoords, event.mapCoords, 'rotated');
|
|
57
53
|
this._geometryBeingRotated = null;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
return editAction;
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
getCursor({
|
|
59
|
+
getCursor({isDragging}: {isDragging: boolean}): string {
|
|
64
60
|
if (this._isRotatable) {
|
|
65
61
|
// TODO: look at doing SVG cursors to get a better "rotate" cursor
|
|
66
62
|
return 'move';
|
|
@@ -95,7 +91,7 @@ export class RotateHandler extends ModeHandler {
|
|
|
95
91
|
updatedData: updatedData.getObject(),
|
|
96
92
|
editType,
|
|
97
93
|
featureIndexes: selectedIndexes,
|
|
98
|
-
editContext: null
|
|
94
|
+
editContext: null
|
|
99
95
|
};
|
|
100
96
|
}
|
|
101
97
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import turfCentroid from '@turf/centroid';
|
|
2
6
|
import turfDistance from '@turf/distance';
|
|
3
7
|
import turfTransformScale from '@turf/transform-scale';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import {FeatureCollection, Position} from '../utils/geojson-types';
|
|
9
|
+
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
10
|
+
import {EditAction, ModeHandler} from './mode-handler';
|
|
7
11
|
|
|
8
12
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
9
13
|
export class ScaleHandler extends ModeHandler {
|
|
@@ -20,19 +24,15 @@ export class ScaleHandler extends ModeHandler {
|
|
|
20
24
|
|
|
21
25
|
if (!this._isScalable || !event.pointerDownMapCoords) {
|
|
22
26
|
// Nothing to do
|
|
23
|
-
return {
|
|
27
|
+
return {editAction: null, cancelMapPan: false};
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
if (event.isDragging && this._geometryBeingScaled) {
|
|
27
31
|
// Scale the geometry
|
|
28
|
-
editAction = this.getScaleAction(
|
|
29
|
-
event.pointerDownMapCoords,
|
|
30
|
-
event.mapCoords,
|
|
31
|
-
'scaling'
|
|
32
|
-
);
|
|
32
|
+
editAction = this.getScaleAction(event.pointerDownMapCoords, event.mapCoords, 'scaling');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return {
|
|
35
|
+
return {editAction, cancelMapPan: true};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined {
|
|
@@ -56,7 +56,7 @@ export class ScaleHandler extends ModeHandler {
|
|
|
56
56
|
return editAction;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
getCursor({
|
|
59
|
+
getCursor({isDragging}: {isDragging: boolean}): string {
|
|
60
60
|
if (this._isScalable) {
|
|
61
61
|
// TODO: look at doing SVG cursors to get a better "scale" cursor
|
|
62
62
|
return 'move';
|
|
@@ -76,7 +76,7 @@ export class ScaleHandler extends ModeHandler {
|
|
|
76
76
|
this._geometryBeingScaled,
|
|
77
77
|
factor,
|
|
78
78
|
{
|
|
79
|
-
origin: centroid
|
|
79
|
+
origin: centroid
|
|
80
80
|
}
|
|
81
81
|
);
|
|
82
82
|
|
|
@@ -93,7 +93,7 @@ export class ScaleHandler extends ModeHandler {
|
|
|
93
93
|
updatedData: updatedData.getObject(),
|
|
94
94
|
editType,
|
|
95
95
|
featureIndexes: selectedIndexes,
|
|
96
|
-
editContext: null
|
|
96
|
+
editContext: null
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Feature, FeatureCollection, Position} from '../utils/geojson-types';
|
|
6
|
+
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
3
7
|
import {
|
|
4
8
|
EditHandle,
|
|
5
9
|
EditAction,
|
|
6
10
|
ModeHandler,
|
|
7
11
|
getPickedEditHandle,
|
|
8
|
-
getEditHandlesForGeometry
|
|
12
|
+
getEditHandlesForGeometry
|
|
9
13
|
} from './mode-handler';
|
|
10
14
|
|
|
11
|
-
type HandlePicks = {
|
|
15
|
+
type HandlePicks = {pickedHandle?: EditHandle; potentialSnapHandle?: EditHandle};
|
|
12
16
|
|
|
13
17
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
14
18
|
export class SnappableHandler extends ModeHandler {
|
|
@@ -38,39 +42,39 @@ export class SnappableHandler extends ModeHandler {
|
|
|
38
42
|
// @ts-expect-error narrow event type
|
|
39
43
|
return Object.assign({}, event, {
|
|
40
44
|
mapCoords: snapPoint,
|
|
41
|
-
pointerDownMapCoords: this._startDragSnapHandlePosition
|
|
45
|
+
pointerDownMapCoords: this._startDragSnapHandlePosition
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
_getEditHandlePicks(event: PointerMoveEvent): HandlePicks {
|
|
46
|
-
const {
|
|
50
|
+
const {picks} = event;
|
|
47
51
|
|
|
48
52
|
const potentialSnapHandle = picks.find(
|
|
49
53
|
(pick) => pick.object && pick.object.type === 'intermediate'
|
|
50
54
|
);
|
|
51
|
-
const handles = {
|
|
55
|
+
const handles = {potentialSnapHandle: potentialSnapHandle && potentialSnapHandle.object};
|
|
52
56
|
|
|
53
57
|
const pickedHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
54
58
|
if (pickedHandle) {
|
|
55
|
-
return {
|
|
59
|
+
return {...handles, pickedHandle};
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
return handles;
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
_updatePickedHandlePosition(editAction: EditAction) {
|
|
62
|
-
const {
|
|
66
|
+
const {pickedHandle = {} as EditHandle} = this._editHandlePicks || {};
|
|
63
67
|
|
|
64
68
|
if (pickedHandle && editAction) {
|
|
65
|
-
const {
|
|
69
|
+
const {featureIndexes, updatedData} = editAction;
|
|
66
70
|
|
|
67
71
|
for (let i = 0; i < featureIndexes.length; i++) {
|
|
68
72
|
const selectedIndex = featureIndexes[i];
|
|
69
73
|
const updatedFeature = updatedData.features[selectedIndex];
|
|
70
74
|
|
|
71
|
-
const {
|
|
75
|
+
const {positionIndexes, featureIndex} = pickedHandle;
|
|
72
76
|
if (selectedIndex >= 0 && featureIndex === selectedIndex) {
|
|
73
|
-
const {
|
|
77
|
+
const {coordinates} = updatedFeature.geometry;
|
|
74
78
|
pickedHandle.position = positionIndexes.reduce(
|
|
75
79
|
(a: any[], b: number) => a[b],
|
|
76
80
|
coordinates
|
|
@@ -85,12 +89,12 @@ export class SnappableHandler extends ModeHandler {
|
|
|
85
89
|
// that live in the current layer. Otherwise, this method will simply return the
|
|
86
90
|
// features from the current layer
|
|
87
91
|
_getSnapTargets(): Feature[] {
|
|
88
|
-
let {
|
|
92
|
+
let {additionalSnapTargets} = this.getModeConfig() || {};
|
|
89
93
|
additionalSnapTargets = additionalSnapTargets || [];
|
|
90
94
|
|
|
91
95
|
const features = [
|
|
92
96
|
...this._handler.featureCollection.getObject().features,
|
|
93
|
-
...additionalSnapTargets
|
|
97
|
+
...additionalSnapTargets
|
|
94
98
|
];
|
|
95
99
|
return features;
|
|
96
100
|
}
|
|
@@ -105,7 +109,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
105
109
|
i < features.length && !this._handler.getSelectedFeatureIndexes().includes(i);
|
|
106
110
|
|
|
107
111
|
if (isCurrentIndexFeatureNotSelected) {
|
|
108
|
-
const {
|
|
112
|
+
const {geometry} = features[i];
|
|
109
113
|
handles.push(...getEditHandlesForGeometry(geometry, i, 'intermediate'));
|
|
110
114
|
}
|
|
111
115
|
}
|
|
@@ -116,21 +120,21 @@ export class SnappableHandler extends ModeHandler {
|
|
|
116
120
|
// selected feature. If a snap handle has been picked, display said snap handle
|
|
117
121
|
// along with all snappable points on all non-selected features.
|
|
118
122
|
getEditHandles(picks?: Array<Record<string, any>>, mapCoords?: Position): any[] {
|
|
119
|
-
const {
|
|
123
|
+
const {enableSnapping} = this._modeConfig || {};
|
|
120
124
|
const handles = this._handler.getEditHandles(picks, mapCoords);
|
|
121
125
|
|
|
122
126
|
if (!enableSnapping) return handles;
|
|
123
|
-
const {
|
|
127
|
+
const {pickedHandle} = this._editHandlePicks || {};
|
|
124
128
|
|
|
125
129
|
if (pickedHandle) {
|
|
126
130
|
handles.push(...this._getNonPickedIntermediateHandles(), pickedHandle);
|
|
127
131
|
return handles;
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
const {
|
|
134
|
+
const {features} = this._handler.featureCollection.getObject();
|
|
131
135
|
for (const index of this._handler.getSelectedFeatureIndexes()) {
|
|
132
136
|
if (index < features.length) {
|
|
133
|
-
const {
|
|
137
|
+
const {geometry} = features[index];
|
|
134
138
|
handles.push(...getEditHandlesForGeometry(geometry, index, 'snap'));
|
|
135
139
|
}
|
|
136
140
|
}
|
|
@@ -139,7 +143,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
139
143
|
}
|
|
140
144
|
|
|
141
145
|
_getSnapAwareEvent(event: Record<string, any>): Record<string, any> {
|
|
142
|
-
const {
|
|
146
|
+
const {potentialSnapHandle} = this._editHandlePicks || {};
|
|
143
147
|
|
|
144
148
|
return potentialSnapHandle && potentialSnapHandle.position
|
|
145
149
|
? this._getSnappedMouseEvent(event, potentialSnapHandle.position)
|
|
@@ -147,7 +151,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
handleStartDragging(event: StartDraggingEvent): EditAction | null | undefined {
|
|
150
|
-
this._startDragSnapHandlePosition = (getPickedEditHandle(event.picks) || {}).position
|
|
154
|
+
this._startDragSnapHandlePosition = (getPickedEditHandle(event.picks) || {}).position;
|
|
151
155
|
return this._handler.handleStartDragging(event);
|
|
152
156
|
}
|
|
153
157
|
|
|
@@ -159,7 +163,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
159
163
|
return modeActionSummary;
|
|
160
164
|
}
|
|
161
165
|
|
|
162
|
-
getCursor(event: {
|
|
166
|
+
getCursor(event: {isDragging: boolean}): string {
|
|
163
167
|
return this._handler.getCursor(event);
|
|
164
168
|
}
|
|
165
169
|
|
|
@@ -167,14 +171,14 @@ export class SnappableHandler extends ModeHandler {
|
|
|
167
171
|
editAction: EditAction | null | undefined;
|
|
168
172
|
cancelMapPan: boolean;
|
|
169
173
|
} {
|
|
170
|
-
const {
|
|
174
|
+
const {enableSnapping} = this._handler.getModeConfig() || {};
|
|
171
175
|
|
|
172
176
|
if (enableSnapping) {
|
|
173
177
|
this._editHandlePicks = this._getEditHandlePicks(event);
|
|
174
178
|
}
|
|
175
179
|
// @ts-expect-error narrow event type
|
|
176
180
|
const modeActionSummary = this._handler.handlePointerMove(this._getSnapAwareEvent(event));
|
|
177
|
-
const {
|
|
181
|
+
const {editAction} = modeActionSummary;
|
|
178
182
|
if (editAction) {
|
|
179
183
|
this._updatePickedHandlePosition(editAction);
|
|
180
184
|
}
|