@deck.gl-community/editable-layers 9.2.0-beta.6 → 9.2.5
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/edit-modes/draw-90degree-polygon-mode.d.ts +2 -2
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.js.map +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +2 -2
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.js +0 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.js.map +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +2 -2
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.js +0 -1
- package/dist/edit-modes/draw-circle-from-center-mode.js.map +1 -1
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +2 -2
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +1 -2
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js.map +1 -1
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +2 -2
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +0 -2
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js.map +1 -1
- package/dist/edit-modes/draw-line-string-mode.d.ts +5 -5
- package/dist/edit-modes/draw-line-string-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-line-string-mode.js.map +1 -1
- package/dist/edit-modes/draw-point-mode.d.ts +2 -2
- package/dist/edit-modes/draw-point-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-point-mode.js.map +1 -1
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +8 -8
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-by-dragging-mode.js.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.d.ts +5 -5
- package/dist/edit-modes/draw-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.js +48 -52
- package/dist/edit-modes/draw-polygon-mode.js.map +1 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +2 -2
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.js +0 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.js.map +1 -1
- package/dist/edit-modes/draw-rectangle-mode.d.ts +2 -2
- package/dist/edit-modes/draw-rectangle-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-rectangle-mode.js +0 -1
- package/dist/edit-modes/draw-rectangle-mode.js.map +1 -1
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +2 -2
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-from-center-mode.d.ts +2 -2
- package/dist/edit-modes/draw-square-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-from-center-mode.js +0 -1
- package/dist/edit-modes/draw-square-from-center-mode.js.map +1 -1
- package/dist/edit-modes/draw-square-mode.d.ts +2 -2
- package/dist/edit-modes/draw-square-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-mode.js +0 -1
- package/dist/edit-modes/draw-square-mode.js.map +1 -1
- package/dist/edit-modes/duplicate-mode.d.ts +2 -2
- package/dist/edit-modes/duplicate-mode.d.ts.map +1 -1
- package/dist/edit-modes/duplicate-mode.js.map +1 -1
- package/dist/edit-modes/extend-line-string-mode.d.ts +4 -4
- package/dist/edit-modes/extend-line-string-mode.d.ts.map +1 -1
- package/dist/edit-modes/extend-line-string-mode.js.map +1 -1
- package/dist/edit-modes/extrude-mode.d.ts +7 -7
- package/dist/edit-modes/extrude-mode.d.ts.map +1 -1
- package/dist/edit-modes/extrude-mode.js.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.d.ts +9 -9
- package/dist/edit-modes/geojson-edit-mode.d.ts.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.js +4 -7
- package/dist/edit-modes/geojson-edit-mode.js.map +1 -1
- package/dist/edit-modes/immutable-feature-collection.d.ts +7 -7
- package/dist/edit-modes/immutable-feature-collection.d.ts.map +1 -1
- package/dist/edit-modes/immutable-feature-collection.js.map +1 -1
- package/dist/edit-modes/measure-area-mode.d.ts +3 -3
- package/dist/edit-modes/measure-area-mode.d.ts.map +1 -1
- package/dist/edit-modes/measure-area-mode.js.map +1 -1
- package/dist/edit-modes/modify-mode.d.ts +8 -8
- package/dist/edit-modes/modify-mode.d.ts.map +1 -1
- package/dist/edit-modes/modify-mode.js +25 -23
- package/dist/edit-modes/modify-mode.js.map +1 -1
- package/dist/edit-modes/resize-circle-mode.d.ts +3 -3
- package/dist/edit-modes/resize-circle-mode.d.ts.map +1 -1
- package/dist/edit-modes/resize-circle-mode.js +1 -5
- package/dist/edit-modes/resize-circle-mode.js.map +1 -1
- package/dist/edit-modes/rotate-mode.d.ts +7 -7
- package/dist/edit-modes/rotate-mode.d.ts.map +1 -1
- package/dist/edit-modes/rotate-mode.js +2 -9
- package/dist/edit-modes/rotate-mode.js.map +1 -1
- package/dist/edit-modes/scale-mode.d.ts +11 -11
- package/dist/edit-modes/scale-mode.d.ts.map +1 -1
- package/dist/edit-modes/scale-mode.js +1 -6
- package/dist/edit-modes/scale-mode.js.map +1 -1
- package/dist/edit-modes/snappable-mode.d.ts +5 -5
- package/dist/edit-modes/snappable-mode.d.ts.map +1 -1
- package/dist/edit-modes/snappable-mode.js.map +1 -1
- package/dist/edit-modes/split-polygon-mode.d.ts +5 -5
- package/dist/edit-modes/split-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/split-polygon-mode.js +2 -5
- package/dist/edit-modes/split-polygon-mode.js.map +1 -1
- package/dist/edit-modes/three-click-polygon-mode.d.ts +3 -3
- package/dist/edit-modes/three-click-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/three-click-polygon-mode.js +14 -18
- package/dist/edit-modes/three-click-polygon-mode.js.map +1 -1
- package/dist/edit-modes/translate-mode.d.ts +6 -6
- package/dist/edit-modes/translate-mode.d.ts.map +1 -1
- package/dist/edit-modes/translate-mode.js +1 -2
- package/dist/edit-modes/translate-mode.js.map +1 -1
- package/dist/edit-modes/two-click-polygon-mode.d.ts +6 -6
- package/dist/edit-modes/two-click-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/two-click-polygon-mode.js.map +1 -1
- package/dist/edit-modes/types.d.ts +3 -3
- package/dist/edit-modes/types.d.ts.map +1 -1
- package/dist/edit-modes/utils.d.ts +7 -7
- package/dist/edit-modes/utils.d.ts.map +1 -1
- package/dist/edit-modes/utils.js +1 -4
- package/dist/edit-modes/utils.js.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.d.ts +5 -13
- package/dist/editable-layers/editable-geojson-layer.d.ts.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.js +20 -4
- package/dist/editable-layers/editable-geojson-layer.js.map +1 -1
- package/dist/editable-layers/selection-layer.d.ts +1 -2
- package/dist/editable-layers/selection-layer.d.ts.map +1 -1
- package/dist/editable-layers/selection-layer.js +2 -2
- package/dist/editable-layers/selection-layer.js.map +1 -1
- package/dist/index.cjs +430 -989
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -10
- package/dist/index.js.map +1 -1
- package/dist/mode-handlers/composite-mode-handler.d.ts +3 -3
- package/dist/mode-handlers/composite-mode-handler.d.ts.map +1 -1
- package/dist/mode-handlers/composite-mode-handler.js.map +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.js +4 -2
- package/dist/mode-handlers/draw-90degree-polygon-handler.js.map +1 -1
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +0 -1
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js.map +1 -1
- package/dist/mode-handlers/draw-circle-from-center-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-circle-from-center-handler.js +0 -1
- package/dist/mode-handlers/draw-circle-from-center-handler.js.map +1 -1
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +1 -2
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js.map +1 -1
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +2 -2
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js.map +1 -1
- package/dist/mode-handlers/draw-point-handler.js.map +1 -1
- package/dist/mode-handlers/draw-polygon-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-polygon-handler.js +4 -2
- package/dist/mode-handlers/draw-polygon-handler.js.map +1 -1
- package/dist/mode-handlers/draw-rectangle-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-rectangle-handler.js +0 -1
- package/dist/mode-handlers/draw-rectangle-handler.js.map +1 -1
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +4 -2
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js.map +1 -1
- package/dist/mode-handlers/mode-handler.d.ts +12 -12
- package/dist/mode-handlers/mode-handler.d.ts.map +1 -1
- package/dist/mode-handlers/mode-handler.js +6 -7
- package/dist/mode-handlers/mode-handler.js.map +1 -1
- package/dist/mode-handlers/modify-handler.d.ts +2 -2
- package/dist/mode-handlers/modify-handler.d.ts.map +1 -1
- package/dist/mode-handlers/modify-handler.js +1 -4
- package/dist/mode-handlers/modify-handler.js.map +1 -1
- package/dist/mode-handlers/rotate-handler.d.ts +2 -2
- package/dist/mode-handlers/rotate-handler.d.ts.map +1 -1
- package/dist/mode-handlers/rotate-handler.js +2 -7
- package/dist/mode-handlers/rotate-handler.js.map +1 -1
- package/dist/mode-handlers/scale-handler.d.ts +2 -2
- package/dist/mode-handlers/scale-handler.d.ts.map +1 -1
- package/dist/mode-handlers/scale-handler.js +2 -7
- package/dist/mode-handlers/scale-handler.js.map +1 -1
- package/dist/mode-handlers/snappable-handler.d.ts +3 -3
- package/dist/mode-handlers/snappable-handler.d.ts.map +1 -1
- package/dist/mode-handlers/snappable-handler.js.map +1 -1
- package/dist/mode-handlers/split-polygon-handler.d.ts.map +1 -1
- package/dist/mode-handlers/split-polygon-handler.js +4 -5
- package/dist/mode-handlers/split-polygon-handler.js.map +1 -1
- package/dist/mode-handlers/translate-handler.d.ts +2 -2
- package/dist/mode-handlers/translate-handler.d.ts.map +1 -1
- package/dist/mode-handlers/translate-handler.js +1 -4
- package/dist/mode-handlers/translate-handler.js.map +1 -1
- package/dist/utils/geojson-types.d.ts +13 -34
- package/dist/utils/geojson-types.d.ts.map +1 -1
- package/dist/utils/translate-from-center.d.ts +2 -4
- package/dist/utils/translate-from-center.d.ts.map +1 -1
- package/dist/utils/translate-from-center.js.map +1 -1
- package/dist/utils/utils.d.ts +3 -3
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.d.ts +1 -0
- package/dist/widgets/edit-mode-tray-widget.d.ts.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.js +1 -0
- package/dist/widgets/edit-mode-tray-widget.js.map +1 -1
- package/dist/widgets/editor-toolbar-widget.d.ts +40 -0
- package/dist/widgets/editor-toolbar-widget.d.ts.map +1 -0
- package/dist/widgets/editor-toolbar-widget.js +170 -0
- package/dist/widgets/editor-toolbar-widget.js.map +1 -0
- package/package.json +47 -44
- package/src/edit-modes/draw-90degree-polygon-mode.ts +8 -2
- package/src/edit-modes/draw-circle-by-diameter-mode.ts +3 -3
- package/src/edit-modes/draw-circle-from-center-mode.ts +3 -3
- package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +4 -4
- package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +3 -4
- package/src/edit-modes/draw-line-string-mode.ts +10 -5
- package/src/edit-modes/draw-point-mode.ts +2 -2
- package/src/edit-modes/draw-polygon-by-dragging-mode.ts +8 -8
- package/src/edit-modes/draw-polygon-mode.ts +103 -124
- package/src/edit-modes/draw-rectangle-from-center-mode.ts +2 -3
- package/src/edit-modes/draw-rectangle-mode.ts +2 -3
- package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +2 -2
- package/src/edit-modes/draw-square-from-center-mode.ts +2 -3
- package/src/edit-modes/draw-square-mode.ts +2 -3
- package/src/edit-modes/duplicate-mode.ts +2 -2
- package/src/edit-modes/extend-line-string-mode.ts +11 -4
- package/src/edit-modes/extrude-mode.ts +7 -7
- package/src/edit-modes/geojson-edit-mode.ts +28 -19
- package/src/edit-modes/immutable-feature-collection.ts +10 -11
- package/src/edit-modes/measure-area-mode.ts +3 -3
- package/src/edit-modes/modify-mode.ts +42 -30
- package/src/edit-modes/resize-circle-mode.ts +10 -7
- package/src/edit-modes/rotate-mode.ts +11 -22
- package/src/edit-modes/scale-mode.ts +14 -19
- package/src/edit-modes/snappable-mode.ts +10 -5
- package/src/edit-modes/split-polygon-mode.ts +17 -15
- package/src/edit-modes/three-click-polygon-mode.ts +30 -33
- package/src/edit-modes/translate-mode.ts +15 -12
- package/src/edit-modes/two-click-polygon-mode.ts +13 -7
- package/src/edit-modes/types.ts +4 -4
- package/src/edit-modes/utils.ts +13 -17
- package/src/editable-layers/editable-geojson-layer.ts +35 -18
- package/src/editable-layers/selection-layer.ts +3 -3
- package/src/index.ts +11 -28
- package/src/mode-handlers/composite-mode-handler.ts +3 -3
- package/src/mode-handlers/draw-90degree-polygon-handler.ts +4 -2
- package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +0 -1
- package/src/mode-handlers/draw-circle-from-center-handler.ts +0 -1
- package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +1 -2
- package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +3 -2
- package/src/mode-handlers/draw-point-handler.ts +2 -2
- package/src/mode-handlers/draw-polygon-handler.ts +4 -2
- package/src/mode-handlers/draw-rectangle-handler.ts +0 -1
- package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +4 -2
- package/src/mode-handlers/mode-handler.ts +34 -20
- package/src/mode-handlers/modify-handler.ts +2 -4
- package/src/mode-handlers/rotate-handler.ts +5 -12
- package/src/mode-handlers/scale-handler.ts +6 -14
- package/src/mode-handlers/snappable-handler.ts +3 -3
- package/src/mode-handlers/split-polygon-handler.ts +8 -7
- package/src/mode-handlers/translate-handler.ts +3 -5
- package/src/utils/geojson-types.ts +31 -54
- package/src/utils/translate-from-center.ts +13 -31
- package/src/utils/utils.ts +5 -5
- package/src/widgets/edit-mode-tray-widget.tsx +2 -6
- package/src/widgets/editor-toolbar-widget.tsx +348 -0
- package/dist/lib/constants.d.ts +0 -7
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/constants.js +0 -10
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/deck-renderer/deck-cache.d.ts +0 -15
- package/dist/lib/deck-renderer/deck-cache.d.ts.map +0 -1
- package/dist/lib/deck-renderer/deck-cache.js +0 -52
- package/dist/lib/deck-renderer/deck-cache.js.map +0 -1
- package/dist/lib/deck-renderer/deck-drawer.d.ts +0 -63
- package/dist/lib/deck-renderer/deck-drawer.d.ts.map +0 -1
- package/dist/lib/deck-renderer/deck-drawer.js +0 -233
- package/dist/lib/deck-renderer/deck-drawer.js.map +0 -1
- package/dist/lib/feature.d.ts +0 -11
- package/dist/lib/feature.d.ts.map +0 -1
- package/dist/lib/feature.js +0 -20
- package/dist/lib/feature.js.map +0 -1
- package/dist/lib/layer-mouse-event.d.ts +0 -12
- package/dist/lib/layer-mouse-event.d.ts.map +0 -1
- package/dist/lib/layer-mouse-event.js +0 -28
- package/dist/lib/layer-mouse-event.js.map +0 -1
- package/dist/lib/layers/junctions-layer.d.ts +0 -9
- package/dist/lib/layers/junctions-layer.d.ts.map +0 -1
- package/dist/lib/layers/junctions-layer.js +0 -37
- package/dist/lib/layers/junctions-layer.js.map +0 -1
- package/dist/lib/layers/segments-layer.d.ts +0 -19
- package/dist/lib/layers/segments-layer.d.ts.map +0 -1
- package/dist/lib/layers/segments-layer.js +0 -98
- package/dist/lib/layers/segments-layer.js.map +0 -1
- package/dist/lib/layers/texts-layer.d.ts +0 -9
- package/dist/lib/layers/texts-layer.d.ts.map +0 -1
- package/dist/lib/layers/texts-layer.js +0 -36
- package/dist/lib/layers/texts-layer.js.map +0 -1
- package/dist/lib/math.d.ts +0 -12
- package/dist/lib/math.d.ts.map +0 -1
- package/dist/lib/math.js +0 -26
- package/dist/lib/math.js.map +0 -1
- package/dist/lib/nebula-core.d.ts +0 -35
- package/dist/lib/nebula-core.d.ts.map +0 -1
- package/dist/lib/nebula-core.js +0 -258
- package/dist/lib/nebula-core.js.map +0 -1
- package/dist/lib/nebula-layer.d.ts +0 -14
- package/dist/lib/nebula-layer.d.ts.map +0 -1
- package/dist/lib/nebula-layer.js +0 -30
- package/dist/lib/nebula-layer.js.map +0 -1
- package/dist/lib/style.d.ts +0 -20
- package/dist/lib/style.d.ts.map +0 -1
- package/dist/lib/style.js +0 -24
- package/dist/lib/style.js.map +0 -1
- package/dist/utils/curve-utils.d.ts +0 -3
- package/dist/utils/curve-utils.d.ts.map +0 -1
- package/dist/utils/curve-utils.js +0 -65
- package/dist/utils/curve-utils.js.map +0 -1
- package/src/lib/constants.ts +0 -10
- package/src/lib/deck-renderer/deck-cache.ts +0 -61
- package/src/lib/deck-renderer/deck-drawer.ts +0 -263
- package/src/lib/feature.ts +0 -31
- package/src/lib/layer-mouse-event.ts +0 -33
- package/src/lib/layers/junctions-layer.ts +0 -44
- package/src/lib/layers/segments-layer.ts +0 -112
- package/src/lib/layers/texts-layer.ts +0 -47
- package/src/lib/math.ts +0 -30
- package/src/lib/nebula-core.ts +0 -327
- package/src/lib/nebula-layer.ts +0 -37
- package/src/lib/style.ts +0 -26
- package/src/utils/curve-utils.ts +0 -81
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getPickedIntermediateEditHandle,
|
|
10
10
|
shouldCancelPan
|
|
11
11
|
} from './utils';
|
|
12
|
-
import {
|
|
12
|
+
import {SimpleFeatureCollection} from '../utils/geojson-types';
|
|
13
13
|
import {ModeProps, StartDraggingEvent, StopDraggingEvent, DraggingEvent} from './types';
|
|
14
14
|
import {ModifyMode} from './modify-mode';
|
|
15
15
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
@@ -19,7 +19,7 @@ export class ExtrudeMode extends ModifyMode {
|
|
|
19
19
|
|
|
20
20
|
isPointAdded = false;
|
|
21
21
|
|
|
22
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
22
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
23
23
|
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
24
24
|
|
|
25
25
|
if (editHandle) {
|
|
@@ -61,7 +61,7 @@ export class ExtrudeMode extends ModifyMode {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
64
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
65
65
|
if (shouldCancelPan(event)) {
|
|
66
66
|
event.cancelPan();
|
|
67
67
|
}
|
|
@@ -111,7 +111,7 @@ export class ExtrudeMode extends ModifyMode {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
114
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
115
115
|
const selectedFeatureIndexes = props.selectedIndexes;
|
|
116
116
|
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
117
117
|
if (selectedFeatureIndexes.length && editHandle) {
|
|
@@ -156,7 +156,7 @@ export class ExtrudeMode extends ModifyMode {
|
|
|
156
156
|
coordinatesSize(
|
|
157
157
|
positionIndexes: number[] | null | undefined,
|
|
158
158
|
featureIndex: number,
|
|
159
|
-
{features}:
|
|
159
|
+
{features}: SimpleFeatureCollection
|
|
160
160
|
) {
|
|
161
161
|
let size = 0;
|
|
162
162
|
if (Array.isArray(positionIndexes)) {
|
|
@@ -190,7 +190,7 @@ export class ExtrudeMode extends ModifyMode {
|
|
|
190
190
|
positionIndexes: number[] | null | undefined,
|
|
191
191
|
featureIndex: number,
|
|
192
192
|
size: number,
|
|
193
|
-
features:
|
|
193
|
+
features: SimpleFeatureCollection
|
|
194
194
|
) {
|
|
195
195
|
if (!Array.isArray(positionIndexes)) {
|
|
196
196
|
return false;
|
|
@@ -239,7 +239,7 @@ export class ExtrudeMode extends ModifyMode {
|
|
|
239
239
|
getPointForPositionIndexes(
|
|
240
240
|
positionIndexes: number[] | null | undefined,
|
|
241
241
|
featureIndex: number,
|
|
242
|
-
{features}:
|
|
242
|
+
{features}: SimpleFeatureCollection
|
|
243
243
|
) {
|
|
244
244
|
let p1;
|
|
245
245
|
if (Array.isArray(positionIndexes)) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import {featureCollection} from '@turf/helpers';
|
|
5
6
|
import turfUnion from '@turf/union';
|
|
6
7
|
import turfDifference from '@turf/difference';
|
|
7
8
|
import turfIntersect from '@turf/intersect';
|
|
@@ -20,12 +21,20 @@ import {
|
|
|
20
21
|
GuideFeatureCollection,
|
|
21
22
|
TentativeFeature
|
|
22
23
|
} from './types';
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
FeatureCollection,
|
|
26
|
+
Feature,
|
|
27
|
+
Polygon,
|
|
28
|
+
SimpleGeometry,
|
|
29
|
+
Position,
|
|
30
|
+
SimpleFeatureCollection,
|
|
31
|
+
SimpleFeature
|
|
32
|
+
} from '../utils/geojson-types';
|
|
24
33
|
import {getPickedEditHandles, getNonGuidePicks} from './utils';
|
|
25
34
|
import {EditMode} from './edit-mode';
|
|
26
35
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
27
36
|
|
|
28
|
-
export type GeoJsonEditAction = EditAction<
|
|
37
|
+
export type GeoJsonEditAction = EditAction<SimpleFeatureCollection>;
|
|
29
38
|
|
|
30
39
|
const DEFAULT_GUIDES: GuideFeatureCollection = {
|
|
31
40
|
type: 'FeatureCollection',
|
|
@@ -51,14 +60,16 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
51
60
|
return DEFAULT_TOOLTIPS;
|
|
52
61
|
}
|
|
53
62
|
|
|
54
|
-
getSelectedFeature(props: ModeProps<
|
|
63
|
+
getSelectedFeature(props: ModeProps<SimpleFeatureCollection>): SimpleFeature | null | undefined {
|
|
55
64
|
if (props.selectedIndexes.length === 1) {
|
|
56
65
|
return props.data.features[props.selectedIndexes[0]];
|
|
57
66
|
}
|
|
58
67
|
return null;
|
|
59
68
|
}
|
|
60
69
|
|
|
61
|
-
getSelectedGeometry(
|
|
70
|
+
getSelectedGeometry(
|
|
71
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
72
|
+
): SimpleGeometry | null | undefined {
|
|
62
73
|
const feature = this.getSelectedFeature(props);
|
|
63
74
|
if (feature) {
|
|
64
75
|
return feature.geometry;
|
|
@@ -66,7 +77,9 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
66
77
|
return null;
|
|
67
78
|
}
|
|
68
79
|
|
|
69
|
-
getSelectedFeaturesAsFeatureCollection(
|
|
80
|
+
getSelectedFeaturesAsFeatureCollection(
|
|
81
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
82
|
+
): SimpleFeatureCollection {
|
|
70
83
|
const {features} = props.data;
|
|
71
84
|
const selectedFeatures = props.selectedIndexes.map((selectedIndex) => features[selectedIndex]);
|
|
72
85
|
return {
|
|
@@ -104,21 +117,20 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
104
117
|
return props.selectedIndexes.some((index) => pickedIndexes.has(index));
|
|
105
118
|
}
|
|
106
119
|
|
|
107
|
-
rewindPolygon(feature:
|
|
120
|
+
rewindPolygon(feature: SimpleFeature): SimpleFeature {
|
|
108
121
|
const {geometry} = feature;
|
|
109
122
|
|
|
110
123
|
const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';
|
|
111
124
|
if (isPolygonal) {
|
|
112
|
-
|
|
113
|
-
return rewind(feature);
|
|
125
|
+
return rewind(feature) as SimpleFeature;
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
return feature;
|
|
117
129
|
}
|
|
118
130
|
|
|
119
131
|
getAddFeatureAction(
|
|
120
|
-
featureOrGeometry:
|
|
121
|
-
features:
|
|
132
|
+
featureOrGeometry: SimpleGeometry | Feature,
|
|
133
|
+
features: SimpleFeatureCollection,
|
|
122
134
|
featureProperties?: {}
|
|
123
135
|
): GeoJsonEditAction {
|
|
124
136
|
// Unsure why flow can't deal with Geometry type, but there I fixed it
|
|
@@ -149,8 +161,8 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
149
161
|
}
|
|
150
162
|
|
|
151
163
|
getAddManyFeaturesAction(
|
|
152
|
-
{features: featuresToAdd}:
|
|
153
|
-
features:
|
|
164
|
+
{features: featuresToAdd}: SimpleFeatureCollection,
|
|
165
|
+
features: SimpleFeatureCollection
|
|
154
166
|
): GeoJsonEditAction {
|
|
155
167
|
let updatedData = new ImmutableFeatureCollection(features);
|
|
156
168
|
const initialIndex = updatedData.getObject().features.length;
|
|
@@ -178,7 +190,7 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
178
190
|
// eslint-disable-next-line complexity
|
|
179
191
|
getAddFeatureOrBooleanPolygonAction(
|
|
180
192
|
featureOrGeometry: Polygon | Feature,
|
|
181
|
-
props: ModeProps<
|
|
193
|
+
props: ModeProps<SimpleFeatureCollection>,
|
|
182
194
|
featureProperties?: {}
|
|
183
195
|
): GeoJsonEditAction | null | undefined {
|
|
184
196
|
const featureOrGeometryAsAny: any = featureOrGeometry;
|
|
@@ -209,14 +221,11 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
209
221
|
|
|
210
222
|
let updatedGeometry;
|
|
211
223
|
if (modeConfig.booleanOperation === 'union') {
|
|
212
|
-
|
|
213
|
-
updatedGeometry = turfUnion(selectedFeature, feature);
|
|
224
|
+
updatedGeometry = turfUnion(featureCollection([selectedFeature, feature]));
|
|
214
225
|
} else if (modeConfig.booleanOperation === 'difference') {
|
|
215
|
-
|
|
216
|
-
updatedGeometry = turfDifference(selectedFeature, feature);
|
|
226
|
+
updatedGeometry = turfDifference(featureCollection([selectedFeature, feature]));
|
|
217
227
|
} else if (modeConfig.booleanOperation === 'intersection') {
|
|
218
|
-
|
|
219
|
-
updatedGeometry = turfIntersect(selectedFeature, feature);
|
|
228
|
+
updatedGeometry = turfIntersect(featureCollection([selectedFeature, feature]));
|
|
220
229
|
} else {
|
|
221
230
|
// eslint-disable-next-line no-console,no-undef
|
|
222
231
|
console.warn(`Invalid booleanOperation ${modeConfig.booleanOperation}`);
|
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Geometry,
|
|
6
|
+
SimpleFeatureCollection,
|
|
7
|
+
SimpleGeometry,
|
|
9
8
|
Polygon,
|
|
10
9
|
MultiLineString,
|
|
11
10
|
MultiPolygon,
|
|
12
11
|
Position,
|
|
13
|
-
|
|
12
|
+
SimpleFeature
|
|
14
13
|
} from '../utils/geojson-types';
|
|
15
14
|
|
|
16
15
|
export class ImmutableFeatureCollection {
|
|
17
|
-
featureCollection:
|
|
16
|
+
featureCollection: Readonly<SimpleFeatureCollection>;
|
|
18
17
|
|
|
19
|
-
constructor(featureCollection:
|
|
18
|
+
constructor(featureCollection: SimpleFeatureCollection) {
|
|
20
19
|
this.featureCollection = featureCollection;
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -162,7 +161,7 @@ export class ImmutableFeatureCollection {
|
|
|
162
161
|
return this.replaceGeometry(featureIndex, updatedGeometry);
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
replaceGeometry(featureIndex: number, geometry:
|
|
164
|
+
replaceGeometry(featureIndex: number, geometry: SimpleGeometry): ImmutableFeatureCollection {
|
|
166
165
|
const updatedFeature: any = {
|
|
167
166
|
...this.featureCollection.features[featureIndex],
|
|
168
167
|
geometry
|
|
@@ -180,11 +179,11 @@ export class ImmutableFeatureCollection {
|
|
|
180
179
|
return new ImmutableFeatureCollection(updatedFeatureCollection);
|
|
181
180
|
}
|
|
182
181
|
|
|
183
|
-
addFeature(feature:
|
|
182
|
+
addFeature(feature: SimpleFeature): ImmutableFeatureCollection {
|
|
184
183
|
return this.addFeatures([feature]);
|
|
185
184
|
}
|
|
186
185
|
|
|
187
|
-
addFeatures(features:
|
|
186
|
+
addFeatures(features: SimpleFeature[]): ImmutableFeatureCollection {
|
|
188
187
|
const updatedFeatureCollection = {
|
|
189
188
|
...this.featureCollection,
|
|
190
189
|
features: [...this.featureCollection.features, ...features]
|
|
@@ -351,7 +350,7 @@ function immutablyAddPosition(
|
|
|
351
350
|
];
|
|
352
351
|
}
|
|
353
352
|
|
|
354
|
-
function pruneGeometryIfNecessary(geometry:
|
|
353
|
+
function pruneGeometryIfNecessary(geometry: SimpleGeometry) {
|
|
355
354
|
switch (geometry.type) {
|
|
356
355
|
case 'Polygon':
|
|
357
356
|
prunePolygonIfNecessary(geometry);
|
|
@@ -413,7 +412,7 @@ function pruneMultiPolygonIfNecessary(geometry: MultiPolygon) {
|
|
|
413
412
|
}
|
|
414
413
|
}
|
|
415
414
|
|
|
416
|
-
function removeHoleIfNecessary(polygon:
|
|
415
|
+
function removeHoleIfNecessary(polygon: Polygon['coordinates'], holeIndex: number) {
|
|
417
416
|
const hole = polygon[holeIndex];
|
|
418
417
|
if (hole.length <= 3) {
|
|
419
418
|
polygon.splice(holeIndex, 1);
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import turfArea from '@turf/area';
|
|
6
6
|
import turfCentroid from '@turf/centroid';
|
|
7
7
|
import {ClickEvent, Tooltip, ModeProps} from './types';
|
|
8
|
-
import {FeatureCollection} from '../utils/geojson-types';
|
|
8
|
+
import {FeatureCollection, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
9
9
|
import {DrawPolygonMode} from './draw-polygon-mode';
|
|
10
10
|
|
|
11
11
|
const DEFAULT_TOOLTIPS = [];
|
|
12
12
|
|
|
13
13
|
export class MeasureAreaMode extends DrawPolygonMode {
|
|
14
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
14
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
15
15
|
const propsWithoutEdit = {
|
|
16
16
|
...props,
|
|
17
17
|
onEdit: () => {}
|
|
@@ -20,7 +20,7 @@ export class MeasureAreaMode extends DrawPolygonMode {
|
|
|
20
20
|
super.handleClick(event, propsWithoutEdit);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
handleKeyUp(event: KeyboardEvent, props: ModeProps<
|
|
23
|
+
handleKeyUp(event: KeyboardEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
24
24
|
const propsWithoutEdit = {
|
|
25
25
|
...props,
|
|
26
26
|
onEdit: () => {}
|
|
@@ -16,7 +16,14 @@ import {
|
|
|
16
16
|
NearestPointType,
|
|
17
17
|
shouldCancelPan
|
|
18
18
|
} from './utils';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
LineString,
|
|
21
|
+
Point,
|
|
22
|
+
Polygon,
|
|
23
|
+
FeatureCollection,
|
|
24
|
+
Feature,
|
|
25
|
+
SimpleFeatureCollection
|
|
26
|
+
} from '../utils/geojson-types';
|
|
20
27
|
import {
|
|
21
28
|
ModeProps,
|
|
22
29
|
ClickEvent,
|
|
@@ -34,7 +41,7 @@ import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
|
34
41
|
|
|
35
42
|
export class ModifyMode extends GeoJsonEditMode {
|
|
36
43
|
// eslint-disable-next-line complexity
|
|
37
|
-
getGuides(props: ModeProps<
|
|
44
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
38
45
|
const handles: GuideFeature[] = [];
|
|
39
46
|
|
|
40
47
|
const {data, lastPointerMoveEvent} = props;
|
|
@@ -76,7 +83,6 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
76
83
|
(lineString, prefix) => {
|
|
77
84
|
const lineStringFeature = toLineString(lineString);
|
|
78
85
|
const candidateIntermediatePoint = this.getNearestPoint(
|
|
79
|
-
// @ts-expect-error turf types too wide
|
|
80
86
|
lineStringFeature,
|
|
81
87
|
referencePoint,
|
|
82
88
|
props.modeConfig && props.modeConfig.viewport
|
|
@@ -121,8 +127,8 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
121
127
|
|
|
122
128
|
// turf.js does not support elevation for nearestPointOnLine
|
|
123
129
|
getNearestPoint(
|
|
124
|
-
line:
|
|
125
|
-
inPoint:
|
|
130
|
+
line: Feature<LineString>,
|
|
131
|
+
inPoint: Feature<Point>,
|
|
126
132
|
viewport: Viewport | null | undefined
|
|
127
133
|
): NearestPointType {
|
|
128
134
|
const {coordinates} = line.geometry;
|
|
@@ -139,32 +145,38 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
139
145
|
return nearestPointOnLine(line, inPoint, viewport);
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
148
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
143
149
|
const pickedExistingHandle = getPickedExistingEditHandle(event.picks);
|
|
144
150
|
const pickedIntermediateHandle = getPickedIntermediateEditHandle(event.picks);
|
|
145
151
|
|
|
146
152
|
if (pickedExistingHandle) {
|
|
147
153
|
const {featureIndex, positionIndexes} = pickedExistingHandle.properties;
|
|
148
154
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const feature = props.data.features[featureIndex];
|
|
156
|
+
const canRemovePosition = !(
|
|
157
|
+
props.modeConfig?.lockRectangles && feature?.properties.shape === 'Rectangle'
|
|
158
|
+
);
|
|
159
|
+
if (canRemovePosition) {
|
|
160
|
+
let updatedData;
|
|
161
|
+
try {
|
|
162
|
+
updatedData = new ImmutableFeatureCollection(props.data)
|
|
163
|
+
.removePosition(featureIndex, positionIndexes)
|
|
164
|
+
.getObject();
|
|
165
|
+
} catch (ignored) {
|
|
166
|
+
// This happens if user attempts to remove the last point
|
|
167
|
+
}
|
|
157
168
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
if (updatedData) {
|
|
170
|
+
props.onEdit({
|
|
171
|
+
updatedData,
|
|
172
|
+
editType: 'removePosition',
|
|
173
|
+
editContext: {
|
|
174
|
+
featureIndexes: [featureIndex],
|
|
175
|
+
positionIndexes,
|
|
176
|
+
position: pickedExistingHandle.geometry.coordinates
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
168
180
|
}
|
|
169
181
|
} else if (pickedIntermediateHandle) {
|
|
170
182
|
const {featureIndex, positionIndexes} = pickedIntermediateHandle.properties;
|
|
@@ -194,7 +206,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
194
206
|
}
|
|
195
207
|
}
|
|
196
208
|
|
|
197
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
209
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
198
210
|
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
199
211
|
|
|
200
212
|
if (editHandle) {
|
|
@@ -207,7 +219,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
207
219
|
|
|
208
220
|
_dragEditHandle(
|
|
209
221
|
editType: string,
|
|
210
|
-
props: ModeProps<
|
|
222
|
+
props: ModeProps<SimpleFeatureCollection>,
|
|
211
223
|
editHandle: EditHandleFeature,
|
|
212
224
|
event: StopDraggingEvent | DraggingEvent
|
|
213
225
|
) {
|
|
@@ -217,7 +229,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
217
229
|
let updatedData;
|
|
218
230
|
if (props.modeConfig?.lockRectangles && editedFeature.properties.shape === 'Rectangle') {
|
|
219
231
|
const coordinates = updateRectanglePosition(
|
|
220
|
-
editedFeature as
|
|
232
|
+
editedFeature as Feature<Polygon>,
|
|
221
233
|
editHandleProperties.positionIndexes[1],
|
|
222
234
|
event.mapCoords
|
|
223
235
|
) as any; // TODO
|
|
@@ -251,7 +263,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
251
263
|
props.onUpdateCursor(cursor);
|
|
252
264
|
}
|
|
253
265
|
|
|
254
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
266
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
255
267
|
if (shouldCancelPan(event)) {
|
|
256
268
|
event.cancelPan();
|
|
257
269
|
}
|
|
@@ -282,9 +294,9 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
282
294
|
}
|
|
283
295
|
}
|
|
284
296
|
|
|
285
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
297
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
286
298
|
const selectedFeatureIndexes = props.selectedIndexes;
|
|
287
|
-
const editHandle = getPickedEditHandle(event.
|
|
299
|
+
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
288
300
|
if (selectedFeatureIndexes.length && editHandle) {
|
|
289
301
|
this._dragEditHandle('finishMovePosition', props, editHandle, event);
|
|
290
302
|
}
|
|
@@ -14,7 +14,13 @@ import {
|
|
|
14
14
|
getPickedEditHandle,
|
|
15
15
|
NearestPointType
|
|
16
16
|
} from './utils';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
LineString,
|
|
19
|
+
Point,
|
|
20
|
+
FeatureCollection,
|
|
21
|
+
Feature,
|
|
22
|
+
SimpleFeatureCollection
|
|
23
|
+
} from '../utils/geojson-types';
|
|
18
24
|
import {Viewport} from '../utils/types';
|
|
19
25
|
import {
|
|
20
26
|
ModeProps,
|
|
@@ -69,7 +75,6 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
69
75
|
(lineString, prefix) => {
|
|
70
76
|
const lineStringFeature = toLineString(lineString);
|
|
71
77
|
const candidateIntermediatePoint = this.getNearestPoint(
|
|
72
|
-
// @ts-expect-error turf types too wide
|
|
73
78
|
lineStringFeature,
|
|
74
79
|
referencePoint,
|
|
75
80
|
props.modeConfig && props.modeConfig.viewport
|
|
@@ -114,8 +119,8 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
114
119
|
|
|
115
120
|
// turf.js does not support elevation for nearestPointOnLine
|
|
116
121
|
getNearestPoint(
|
|
117
|
-
line:
|
|
118
|
-
inPoint:
|
|
122
|
+
line: Feature<LineString>,
|
|
123
|
+
inPoint: Feature<Point>,
|
|
119
124
|
viewport: Viewport | null | undefined
|
|
120
125
|
): NearestPointType {
|
|
121
126
|
const {coordinates} = line.geometry;
|
|
@@ -129,11 +134,10 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
129
134
|
'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'
|
|
130
135
|
);
|
|
131
136
|
}
|
|
132
|
-
// @ts-expect-error turf types diff
|
|
133
137
|
return nearestPointOnLine(line, inPoint);
|
|
134
138
|
}
|
|
135
139
|
|
|
136
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
140
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
137
141
|
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
138
142
|
|
|
139
143
|
if (editHandle) {
|
|
@@ -143,7 +147,6 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
143
147
|
const editHandleProperties = editHandle.properties;
|
|
144
148
|
|
|
145
149
|
const feature = this.getSelectedFeature(props);
|
|
146
|
-
// @ts-expect-error turf types diff
|
|
147
150
|
const center = turfCenter(feature).geometry.coordinates;
|
|
148
151
|
const numberOfSteps = Object.entries(feature.geometry.coordinates[0]).length - 1;
|
|
149
152
|
const radius = Math.max(distance(center, event.mapCoords), 0.001);
|
|
@@ -22,19 +22,18 @@ import {
|
|
|
22
22
|
GuideFeatureCollection
|
|
23
23
|
} from './types';
|
|
24
24
|
import {getPickedEditHandle} from './utils';
|
|
25
|
-
import {FeatureCollection, Position} from '../utils/geojson-types';
|
|
25
|
+
import {FeatureCollection, Position, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
26
26
|
import {GeoJsonEditMode, GeoJsonEditAction, getIntermediatePosition} from './geojson-edit-mode';
|
|
27
27
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
28
28
|
|
|
29
29
|
export class RotateMode extends GeoJsonEditMode {
|
|
30
30
|
_selectedEditHandle: EditHandleFeature | null | undefined;
|
|
31
|
-
_geometryBeingRotated:
|
|
31
|
+
_geometryBeingRotated: SimpleFeatureCollection | null | undefined;
|
|
32
32
|
_isRotating = false;
|
|
33
33
|
|
|
34
34
|
_isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {
|
|
35
35
|
const {features} = geometry || {};
|
|
36
36
|
if (Array.isArray(features) && features.length === 1) {
|
|
37
|
-
// @ts-expect-error turf type diff
|
|
38
37
|
const {type}: {type: string} = getGeom(features[0]);
|
|
39
38
|
return type === 'Point';
|
|
40
39
|
}
|
|
@@ -43,7 +42,7 @@ export class RotateMode extends GeoJsonEditMode {
|
|
|
43
42
|
|
|
44
43
|
getIsRotating = () => this._isRotating;
|
|
45
44
|
|
|
46
|
-
getGuides(props: ModeProps<
|
|
45
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
47
46
|
const selectedGeometry =
|
|
48
47
|
this._geometryBeingRotated || this.getSelectedFeaturesAsFeatureCollection(props);
|
|
49
48
|
|
|
@@ -53,7 +52,6 @@ export class RotateMode extends GeoJsonEditMode {
|
|
|
53
52
|
|
|
54
53
|
if (this._isRotating) {
|
|
55
54
|
// Display rotate pivot
|
|
56
|
-
// @ts-expect-error turf types diff
|
|
57
55
|
return featureCollection([turfCentroid(selectedGeometry)]) as GuideFeatureCollection;
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -96,7 +94,7 @@ export class RotateMode extends GeoJsonEditMode {
|
|
|
96
94
|
return featureCollection(outFeatures);
|
|
97
95
|
}
|
|
98
96
|
|
|
99
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
97
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
100
98
|
if (!this._isRotating) {
|
|
101
99
|
return;
|
|
102
100
|
}
|
|
@@ -126,7 +124,7 @@ export class RotateMode extends GeoJsonEditMode {
|
|
|
126
124
|
this.updateCursor(props);
|
|
127
125
|
}
|
|
128
126
|
|
|
129
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
127
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
130
128
|
if (this._selectedEditHandle) {
|
|
131
129
|
event.cancelPan();
|
|
132
130
|
this._isRotating = true;
|
|
@@ -134,7 +132,7 @@ export class RotateMode extends GeoJsonEditMode {
|
|
|
134
132
|
}
|
|
135
133
|
}
|
|
136
134
|
|
|
137
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
135
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
138
136
|
if (this._isRotating) {
|
|
139
137
|
// Rotate the geometry
|
|
140
138
|
const rotateAction = this.getRotateAction(
|
|
@@ -167,25 +165,16 @@ export class RotateMode extends GeoJsonEditMode {
|
|
|
167
165
|
startDragPoint: Position,
|
|
168
166
|
currentPoint: Position,
|
|
169
167
|
editType: string,
|
|
170
|
-
props: ModeProps<
|
|
168
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
171
169
|
): GeoJsonEditAction | null | undefined {
|
|
172
170
|
if (!this._geometryBeingRotated) {
|
|
173
171
|
return null;
|
|
174
172
|
}
|
|
175
|
-
// @ts-expect-error turf types diff
|
|
176
173
|
const centroid = turfCentroid(this._geometryBeingRotated);
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const rotatedFeatures: FeatureCollection = turfTransformRotate(
|
|
182
|
-
// @ts-expect-error turf types too wide
|
|
183
|
-
this._geometryBeingRotated,
|
|
184
|
-
angle,
|
|
185
|
-
{
|
|
186
|
-
pivot: centroid
|
|
187
|
-
}
|
|
188
|
-
);
|
|
174
|
+
const angle = getRotationAngle(centroid.geometry.coordinates, startDragPoint, currentPoint);
|
|
175
|
+
const rotatedFeatures = turfTransformRotate(this._geometryBeingRotated, angle, {
|
|
176
|
+
pivot: centroid
|
|
177
|
+
});
|
|
189
178
|
|
|
190
179
|
let updatedData = new ImmutableFeatureCollection(props.data);
|
|
191
180
|
|