@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
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import throttle from 'lodash.throttle';
|
|
6
6
|
import {ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps} from './types';
|
|
7
|
-
import {Polygon,
|
|
7
|
+
import {Polygon, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
8
8
|
import {getPickedEditHandle} from './utils';
|
|
9
9
|
import {DrawPolygonMode} from './draw-polygon-mode';
|
|
10
10
|
|
|
11
|
-
type DraggingHandler = (event: DraggingEvent, props: ModeProps<
|
|
11
|
+
type DraggingHandler = (event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) => void;
|
|
12
12
|
|
|
13
13
|
export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
14
14
|
handleDraggingThrottled: DraggingHandler | null | undefined = null;
|
|
15
15
|
|
|
16
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
16
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
17
17
|
// No-op
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
20
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
21
21
|
event.cancelPan();
|
|
22
22
|
if (props.modeConfig && props.modeConfig.throttleMs) {
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
@@ -28,7 +28,7 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
31
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
32
32
|
this.addClickSequence(event);
|
|
33
33
|
const clickSequence = this.getClickSequence();
|
|
34
34
|
// @ts-expect-error cancel() not typed
|
|
@@ -52,7 +52,7 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
52
52
|
this.resetClickSequence();
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
handleDraggingAux(event: DraggingEvent, props: ModeProps<
|
|
55
|
+
handleDraggingAux(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
56
56
|
const {picks} = event;
|
|
57
57
|
const clickedEditHandle = getPickedEditHandle(picks);
|
|
58
58
|
|
|
@@ -69,13 +69,13 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
72
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
73
73
|
if (this.handleDraggingThrottled) {
|
|
74
74
|
this.handleDraggingThrottled(event, props);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
handleKeyUp(event: KeyboardEvent, props: ModeProps<
|
|
78
|
+
handleKeyUp(event: KeyboardEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
79
79
|
if (event.key === 'Enter') {
|
|
80
80
|
const clickSequence = this.getClickSequence();
|
|
81
81
|
if (clickSequence.length > 2) {
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import lineIntersect from '@turf/line-intersect';
|
|
6
|
-
import {
|
|
7
|
-
import booleanWithin from
|
|
8
|
-
|
|
5
|
+
import {lineIntersect} from '@turf/line-intersect';
|
|
6
|
+
import {polygon as turfPolygon} from '@turf/helpers';
|
|
7
|
+
import {booleanWithin} from '@turf/boolean-within';
|
|
8
|
+
import type {Geometry} from 'geojson';
|
|
9
|
+
import {kinks} from '@turf/kinks';
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
12
|
ClickEvent,
|
|
@@ -16,94 +17,88 @@ import {
|
|
|
16
17
|
GuideFeature,
|
|
17
18
|
DoubleClickEvent
|
|
18
19
|
} from './types';
|
|
19
|
-
import {Position, FeatureCollection,
|
|
20
|
+
import {Position, FeatureCollection, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
20
21
|
import {getPickedEditHandle} from './utils';
|
|
21
22
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
22
|
-
import {
|
|
23
|
-
|
|
23
|
+
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
24
24
|
|
|
25
25
|
export class DrawPolygonMode extends GeoJsonEditMode {
|
|
26
|
-
|
|
27
|
-
holeSequence: Position[] = [];
|
|
26
|
+
holeSequence: Position[] = [];
|
|
28
27
|
isDrawingHole = false;
|
|
29
28
|
|
|
30
29
|
createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {
|
|
31
|
-
const {
|
|
30
|
+
const {lastPointerMoveEvent} = props;
|
|
32
31
|
const clickSequence = this.getClickSequence();
|
|
33
32
|
const holeSequence = this.holeSequence;
|
|
34
|
-
const lastCoords = lastPointerMoveEvent
|
|
35
|
-
? [lastPointerMoveEvent.mapCoords]
|
|
36
|
-
: [];
|
|
33
|
+
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
|
|
37
34
|
|
|
38
35
|
let geometry: Geometry;
|
|
39
36
|
|
|
40
37
|
if (this.isDrawingHole && holeSequence.length > 1) {
|
|
41
38
|
geometry = {
|
|
42
|
-
type:
|
|
39
|
+
type: 'Polygon',
|
|
43
40
|
coordinates: [
|
|
44
41
|
[...clickSequence, clickSequence[0]],
|
|
45
|
-
[...holeSequence, ...lastCoords, holeSequence[0]]
|
|
46
|
-
]
|
|
42
|
+
[...holeSequence, ...lastCoords, holeSequence[0]]
|
|
43
|
+
]
|
|
47
44
|
};
|
|
48
45
|
} else if (clickSequence.length > 2) {
|
|
49
46
|
geometry = {
|
|
50
|
-
type:
|
|
51
|
-
coordinates: [[...clickSequence, ...lastCoords, clickSequence[0]]]
|
|
47
|
+
type: 'Polygon',
|
|
48
|
+
coordinates: [[...clickSequence, ...lastCoords, clickSequence[0]]]
|
|
52
49
|
};
|
|
53
50
|
} else {
|
|
54
51
|
geometry = {
|
|
55
|
-
type:
|
|
56
|
-
coordinates: [...clickSequence, ...lastCoords]
|
|
52
|
+
type: 'LineString',
|
|
53
|
+
coordinates: [...clickSequence, ...lastCoords]
|
|
57
54
|
};
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
return {
|
|
61
|
-
type:
|
|
58
|
+
type: 'Feature',
|
|
62
59
|
properties: {
|
|
63
|
-
guideType:
|
|
60
|
+
guideType: 'tentative'
|
|
64
61
|
},
|
|
65
|
-
geometry
|
|
62
|
+
geometry
|
|
66
63
|
};
|
|
67
64
|
}
|
|
68
65
|
|
|
69
66
|
getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {
|
|
70
67
|
const guides: GuideFeatureCollection = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
guides.features.push(...handles);
|
|
97
|
-
return guides;
|
|
68
|
+
type: 'FeatureCollection',
|
|
69
|
+
features: []
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const tentative = this.createTentativeFeature(props);
|
|
73
|
+
if (tentative) guides.features.push(tentative);
|
|
74
|
+
|
|
75
|
+
const sequence = this.isDrawingHole ? this.holeSequence : this.getClickSequence();
|
|
76
|
+
|
|
77
|
+
const handles: GuideFeature[] = sequence.map((coord, index) => ({
|
|
78
|
+
type: 'Feature',
|
|
79
|
+
properties: {
|
|
80
|
+
guideType: 'editHandle',
|
|
81
|
+
editHandleType: 'existing',
|
|
82
|
+
featureIndex: -1,
|
|
83
|
+
positionIndexes: [index]
|
|
84
|
+
},
|
|
85
|
+
geometry: {
|
|
86
|
+
type: 'Point',
|
|
87
|
+
coordinates: coord
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
guides.features.push(...handles);
|
|
92
|
+
return guides;
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
// eslint-disable-next-line complexity, max-statements
|
|
101
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
96
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
102
97
|
const {picks} = event;
|
|
103
98
|
const clickedEditHandle = getPickedEditHandle(picks);
|
|
104
99
|
const clickSequence = this.getClickSequence();
|
|
105
100
|
const coords = event.mapCoords;
|
|
106
|
-
|
|
101
|
+
|
|
107
102
|
// Check if they clicked on an edit handle to complete the polygon
|
|
108
103
|
if (
|
|
109
104
|
!this.isDrawingHole &&
|
|
@@ -117,7 +112,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
117
112
|
this.finishDrawing(props);
|
|
118
113
|
return;
|
|
119
114
|
}
|
|
120
|
-
|
|
115
|
+
|
|
121
116
|
// Check if they clicked near the first point to complete the polygon
|
|
122
117
|
if (!this.isDrawingHole && clickSequence.length > 2) {
|
|
123
118
|
if (isNearFirstPoint(coords, clickSequence[0])) {
|
|
@@ -126,28 +121,25 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
126
121
|
return;
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
|
-
|
|
124
|
+
|
|
130
125
|
if (this.isDrawingHole) {
|
|
131
126
|
const current = this.holeSequence;
|
|
132
127
|
current.push(coords);
|
|
133
128
|
|
|
134
129
|
if (current.length > 2) {
|
|
135
130
|
const poly: Geometry = {
|
|
136
|
-
type:
|
|
131
|
+
type: 'Polygon',
|
|
137
132
|
coordinates: [
|
|
138
133
|
[...clickSequence, clickSequence[0]],
|
|
139
|
-
[...current, current[0]]
|
|
140
|
-
]
|
|
134
|
+
[...current, current[0]]
|
|
135
|
+
]
|
|
141
136
|
};
|
|
142
137
|
|
|
143
138
|
this.resetClickSequence();
|
|
144
139
|
this.holeSequence = [];
|
|
145
140
|
this.isDrawingHole = false;
|
|
146
141
|
|
|
147
|
-
const editAction = this.getAddFeatureOrBooleanPolygonAction(
|
|
148
|
-
poly,
|
|
149
|
-
props,
|
|
150
|
-
);
|
|
142
|
+
const editAction = this.getAddFeatureOrBooleanPolygonAction(poly, props);
|
|
151
143
|
if (editAction) props.onEdit(editAction);
|
|
152
144
|
}
|
|
153
145
|
return;
|
|
@@ -173,24 +165,24 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
173
165
|
}
|
|
174
166
|
}
|
|
175
167
|
|
|
176
|
-
handleDoubleClick(_event: DoubleClickEvent, props: ModeProps<
|
|
168
|
+
handleDoubleClick(_event: DoubleClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
177
169
|
this.finishDrawing(props);
|
|
178
170
|
this.resetClickSequence();
|
|
179
171
|
}
|
|
180
172
|
|
|
181
|
-
handleKeyUp(event: KeyboardEvent, props: ModeProps<
|
|
182
|
-
if (event.key ===
|
|
173
|
+
handleKeyUp(event: KeyboardEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
174
|
+
if (event.key === 'Enter') {
|
|
183
175
|
this.finishDrawing(props);
|
|
184
176
|
this.resetClickSequence();
|
|
185
|
-
} else if (event.key ===
|
|
177
|
+
} else if (event.key === 'Escape') {
|
|
186
178
|
this.resetClickSequence();
|
|
187
179
|
this.holeSequence = [];
|
|
188
180
|
this.isDrawingHole = false;
|
|
189
181
|
|
|
190
182
|
props.onEdit({
|
|
191
183
|
updatedData: props.data,
|
|
192
|
-
editType:
|
|
193
|
-
editContext: {}
|
|
184
|
+
editType: 'cancelFeature',
|
|
185
|
+
editContext: {}
|
|
194
186
|
});
|
|
195
187
|
}
|
|
196
188
|
}
|
|
@@ -201,7 +193,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
201
193
|
}
|
|
202
194
|
|
|
203
195
|
// eslint-disable-next-line max-statements, complexity
|
|
204
|
-
finishDrawing(props: ModeProps<
|
|
196
|
+
finishDrawing(props: ModeProps<SimpleFeatureCollection>) {
|
|
205
197
|
const clickSequence = this.getClickSequence();
|
|
206
198
|
const polygon = [...clickSequence, clickSequence[0]];
|
|
207
199
|
|
|
@@ -210,27 +202,16 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
210
202
|
const canAddHole = canAddHoleToPolygon(props);
|
|
211
203
|
const canOverlap = canPolygonOverlap(props);
|
|
212
204
|
|
|
213
|
-
|
|
214
205
|
// Check if the polygon intersects itself (excluding shared start/end point)
|
|
215
206
|
if (!canOverlap) {
|
|
216
|
-
const overlapping =
|
|
217
|
-
|
|
218
|
-
newPolygon,
|
|
219
|
-
).features.filter(
|
|
220
|
-
(intersection) =>
|
|
221
|
-
!newPolygon.geometry.coordinates[0].some(
|
|
222
|
-
(coord) =>
|
|
223
|
-
coord[0] === intersection.geometry.coordinates[0] &&
|
|
224
|
-
coord[1] === intersection.geometry.coordinates[1],
|
|
225
|
-
),
|
|
226
|
-
);
|
|
227
|
-
|
|
207
|
+
const overlapping = kinks(newPolygon).features;
|
|
208
|
+
|
|
228
209
|
if (overlapping.length > 0) {
|
|
229
210
|
// ❌ Invalid polygon: overlaps
|
|
230
211
|
props.onEdit({
|
|
231
212
|
updatedData: props.data,
|
|
232
|
-
editType:
|
|
233
|
-
editContext: {
|
|
213
|
+
editType: 'invalidPolygon',
|
|
214
|
+
editContext: {reason: 'overlaps'}
|
|
234
215
|
});
|
|
235
216
|
this.resetClickSequence();
|
|
236
217
|
return;
|
|
@@ -244,14 +225,14 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
244
225
|
return;
|
|
245
226
|
}
|
|
246
227
|
}
|
|
247
|
-
|
|
228
|
+
|
|
248
229
|
// If no valid hole was found, add the polygon as a new feature
|
|
249
230
|
const editAction = this.getAddFeatureOrBooleanPolygonAction(
|
|
250
231
|
{
|
|
251
|
-
type:
|
|
252
|
-
coordinates: [[...this.getClickSequence(), this.getClickSequence()[0]]]
|
|
232
|
+
type: 'Polygon',
|
|
233
|
+
coordinates: [[...this.getClickSequence(), this.getClickSequence()[0]]]
|
|
253
234
|
},
|
|
254
|
-
props
|
|
235
|
+
props
|
|
255
236
|
);
|
|
256
237
|
if (editAction) props.onEdit(editAction);
|
|
257
238
|
this.resetClickSequence();
|
|
@@ -261,18 +242,24 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
261
242
|
private tryAddHoleToExistingPolygon(
|
|
262
243
|
newPolygon: any,
|
|
263
244
|
polygon: Position[],
|
|
264
|
-
props: ModeProps<
|
|
265
|
-
): {
|
|
245
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
246
|
+
): {handled: boolean} {
|
|
266
247
|
for (const [featureIndex, feature] of props.data.features.entries()) {
|
|
267
|
-
if (feature.geometry.type ===
|
|
268
|
-
const result = this.validateAndCreateHole(
|
|
248
|
+
if (feature.geometry.type === 'Polygon') {
|
|
249
|
+
const result = this.validateAndCreateHole(
|
|
250
|
+
feature,
|
|
251
|
+
featureIndex,
|
|
252
|
+
newPolygon,
|
|
253
|
+
polygon,
|
|
254
|
+
props
|
|
255
|
+
);
|
|
269
256
|
if (result.handled) {
|
|
270
257
|
return result;
|
|
271
258
|
}
|
|
272
259
|
}
|
|
273
260
|
}
|
|
274
|
-
|
|
275
|
-
return {
|
|
261
|
+
|
|
262
|
+
return {handled: false};
|
|
276
263
|
}
|
|
277
264
|
|
|
278
265
|
private validateAndCreateHole(
|
|
@@ -280,31 +267,31 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
280
267
|
featureIndex: number,
|
|
281
268
|
newPolygon: any,
|
|
282
269
|
polygon: Position[],
|
|
283
|
-
props: ModeProps<
|
|
284
|
-
): {
|
|
270
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
271
|
+
): {handled: boolean} {
|
|
285
272
|
const outer = turfPolygon(feature.geometry.coordinates);
|
|
286
273
|
|
|
287
274
|
// Check existing holes for conflicts
|
|
288
275
|
for (let i = 1; i < feature.geometry.coordinates.length; i++) {
|
|
289
276
|
const hole = turfPolygon([feature.geometry.coordinates[i]]);
|
|
290
277
|
const intersection = lineIntersect(hole, newPolygon);
|
|
291
|
-
|
|
278
|
+
|
|
292
279
|
if (intersection.features.length > 0) {
|
|
293
280
|
props.onEdit({
|
|
294
281
|
updatedData: props.data,
|
|
295
|
-
editType:
|
|
296
|
-
editContext: {
|
|
282
|
+
editType: 'invalidHole',
|
|
283
|
+
editContext: {reason: 'intersects-existing-hole'}
|
|
297
284
|
});
|
|
298
|
-
return {
|
|
285
|
+
return {handled: true};
|
|
299
286
|
}
|
|
300
287
|
|
|
301
288
|
if (booleanWithin(hole, newPolygon) || booleanWithin(newPolygon, hole)) {
|
|
302
289
|
props.onEdit({
|
|
303
290
|
updatedData: props.data,
|
|
304
|
-
editType:
|
|
305
|
-
editContext: {
|
|
291
|
+
editType: 'invalidHole',
|
|
292
|
+
editContext: {reason: 'contains-or-contained-by-existing-hole'}
|
|
306
293
|
});
|
|
307
|
-
return {
|
|
294
|
+
return {handled: true};
|
|
308
295
|
}
|
|
309
296
|
}
|
|
310
297
|
|
|
@@ -313,19 +300,19 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
313
300
|
if (intersectionWithOuter.features.length > 0) {
|
|
314
301
|
props.onEdit({
|
|
315
302
|
updatedData: props.data,
|
|
316
|
-
editType:
|
|
317
|
-
editContext: {
|
|
303
|
+
editType: 'invalidPolygon',
|
|
304
|
+
editContext: {reason: 'intersects-existing-polygon'}
|
|
318
305
|
});
|
|
319
|
-
return {
|
|
306
|
+
return {handled: true};
|
|
320
307
|
}
|
|
321
308
|
|
|
322
309
|
if (booleanWithin(outer, newPolygon)) {
|
|
323
310
|
props.onEdit({
|
|
324
311
|
updatedData: props.data,
|
|
325
|
-
editType:
|
|
326
|
-
editContext: {
|
|
312
|
+
editType: 'invalidPolygon',
|
|
313
|
+
editContext: {reason: 'contains-existing-polygon'}
|
|
327
314
|
});
|
|
328
|
-
return {
|
|
315
|
+
return {handled: true};
|
|
329
316
|
}
|
|
330
317
|
|
|
331
318
|
// Check if new polygon is within outer polygon (valid hole)
|
|
@@ -333,45 +320,37 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
333
320
|
const updatedData = new ImmutableFeatureCollection(props.data)
|
|
334
321
|
.replaceGeometry(featureIndex, {
|
|
335
322
|
...feature.geometry,
|
|
336
|
-
coordinates: [...feature.geometry.coordinates, polygon]
|
|
323
|
+
coordinates: [...feature.geometry.coordinates, polygon]
|
|
337
324
|
})
|
|
338
325
|
.getObject();
|
|
339
326
|
|
|
340
327
|
props.onEdit({
|
|
341
328
|
updatedData,
|
|
342
|
-
editType:
|
|
343
|
-
editContext: {
|
|
329
|
+
editType: 'addHole',
|
|
330
|
+
editContext: {hole: newPolygon.geometry}
|
|
344
331
|
});
|
|
345
|
-
return {
|
|
332
|
+
return {handled: true};
|
|
346
333
|
}
|
|
347
|
-
return {
|
|
334
|
+
return {handled: false};
|
|
348
335
|
}
|
|
349
336
|
}
|
|
350
337
|
|
|
351
338
|
// Helper function to check if a point is near the first point in the sequence
|
|
352
|
-
function isNearFirstPoint(
|
|
353
|
-
click: Position,
|
|
354
|
-
first: Position,
|
|
355
|
-
threshold = 1e-4,
|
|
356
|
-
): boolean {
|
|
339
|
+
function isNearFirstPoint(click: Position, first: Position, threshold = 1e-4): boolean {
|
|
357
340
|
const dx = click[0] - first[0];
|
|
358
341
|
const dy = click[1] - first[1];
|
|
359
342
|
return dx * dx + dy * dy < threshold * threshold;
|
|
360
343
|
}
|
|
361
344
|
|
|
362
345
|
// Helper function to determine if a hole can be added to a polygon
|
|
363
|
-
function canAddHoleToPolygon(
|
|
364
|
-
props: ModeProps<FeatureCollection>
|
|
365
|
-
): boolean {
|
|
346
|
+
function canAddHoleToPolygon(props: ModeProps<FeatureCollection>): boolean {
|
|
366
347
|
// For simplicity, always return true in this example.
|
|
367
348
|
// Implement your own logic based on application requirements.
|
|
368
349
|
return props.modeConfig?.allowHoles ?? false;
|
|
369
350
|
}
|
|
370
351
|
|
|
371
352
|
// Helper function to determine if a polygon can intersect itself
|
|
372
|
-
function canPolygonOverlap(
|
|
373
|
-
props: ModeProps<FeatureCollection>
|
|
374
|
-
): boolean {
|
|
353
|
+
function canPolygonOverlap(props: ModeProps<FeatureCollection>): boolean {
|
|
375
354
|
// Return the value of allowSelfIntersection (defaults to false for safety)
|
|
376
355
|
return props.modeConfig?.allowSelfIntersection ?? false;
|
|
377
356
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
6
|
-
import {Position, Polygon,
|
|
6
|
+
import {Position, Polygon, Feature} from '../utils/geojson-types';
|
|
7
7
|
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
8
8
|
|
|
9
9
|
export class DrawRectangleFromCenterMode extends TwoClickPolygonMode {
|
|
10
|
-
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any):
|
|
10
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): Feature<Polygon> {
|
|
11
11
|
const longitude =
|
|
12
12
|
coord1[0] > coord2[0]
|
|
13
13
|
? coord1[0] + Math.abs(coord1[0] - coord2[0])
|
|
@@ -21,7 +21,6 @@ export class DrawRectangleFromCenterMode extends TwoClickPolygonMode {
|
|
|
21
21
|
rectangle.properties = rectangle.properties || {};
|
|
22
22
|
rectangle.properties.shape = 'Rectangle';
|
|
23
23
|
|
|
24
|
-
// @ts-expect-error turf typing too wide
|
|
25
24
|
return rectangle;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
6
|
-
import {Position, Polygon,
|
|
6
|
+
import {Position, Polygon, Feature} from '../utils/geojson-types';
|
|
7
7
|
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
8
8
|
|
|
9
9
|
export class DrawRectangleMode extends TwoClickPolygonMode {
|
|
10
|
-
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any):
|
|
10
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): Feature<Polygon> {
|
|
11
11
|
const rectangle = bboxPolygon([coord1[0], coord1[1], coord2[0], coord2[1]]);
|
|
12
12
|
rectangle.properties = rectangle.properties || {};
|
|
13
13
|
rectangle.properties.shape = 'Rectangle';
|
|
14
14
|
|
|
15
|
-
// @ts-expect-error turf typing too wide
|
|
16
15
|
return rectangle;
|
|
17
16
|
}
|
|
18
17
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {generatePointsParallelToLinePoints} from './utils';
|
|
6
|
-
import {Position, Polygon,
|
|
6
|
+
import {Position, Polygon, Feature} from '../utils/geojson-types';
|
|
7
7
|
import {ThreeClickPolygonMode} from './three-click-polygon-mode';
|
|
8
8
|
|
|
9
9
|
export class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
@@ -12,7 +12,7 @@ export class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
|
12
12
|
coord2: Position,
|
|
13
13
|
coord3: Position,
|
|
14
14
|
modeConfig: any
|
|
15
|
-
):
|
|
15
|
+
): Feature<Polygon> | null | undefined {
|
|
16
16
|
const [p3, p4] = generatePointsParallelToLinePoints(coord1, coord2, coord3);
|
|
17
17
|
|
|
18
18
|
return {
|
|
@@ -6,11 +6,11 @@ import bboxPolygon from '@turf/bbox-polygon';
|
|
|
6
6
|
import turfDistance from '@turf/distance';
|
|
7
7
|
import turfAlong from '@turf/along';
|
|
8
8
|
import {point, lineString as turfLineString} from '@turf/helpers';
|
|
9
|
-
import {Position, Polygon,
|
|
9
|
+
import {Position, Polygon, Feature} from '../utils/geojson-types';
|
|
10
10
|
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
11
11
|
|
|
12
12
|
export class DrawSquareFromCenterMode extends TwoClickPolygonMode {
|
|
13
|
-
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any):
|
|
13
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): Feature<Polygon> {
|
|
14
14
|
// get the coordinates of the other two rectangle vertices
|
|
15
15
|
const coord3 = [coord2[0], coord1[1]];
|
|
16
16
|
const coord4 = [coord1[0], coord2[1]];
|
|
@@ -44,7 +44,6 @@ export class DrawSquareFromCenterMode extends TwoClickPolygonMode {
|
|
|
44
44
|
square.properties = square.properties || {};
|
|
45
45
|
square.properties.shape = 'Square';
|
|
46
46
|
|
|
47
|
-
// @ts-expect-error turf typing too wide
|
|
48
47
|
return square;
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -6,11 +6,11 @@ import bboxPolygon from '@turf/bbox-polygon';
|
|
|
6
6
|
import turfDistance from '@turf/distance';
|
|
7
7
|
import turfAlong from '@turf/along';
|
|
8
8
|
import {point, lineString as turfLineString} from '@turf/helpers';
|
|
9
|
-
import {Position, Polygon,
|
|
9
|
+
import {Position, Polygon, Feature} from '../utils/geojson-types';
|
|
10
10
|
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
11
11
|
|
|
12
12
|
export class DrawSquareMode extends TwoClickPolygonMode {
|
|
13
|
-
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any):
|
|
13
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): Feature<Polygon> {
|
|
14
14
|
// get the coordinates of the other two rectangle vertices
|
|
15
15
|
const coord3 = [coord2[0], coord1[1]];
|
|
16
16
|
const coord4 = [coord1[0], coord2[1]];
|
|
@@ -34,7 +34,6 @@ export class DrawSquareMode extends TwoClickPolygonMode {
|
|
|
34
34
|
square.properties = square.properties || {};
|
|
35
35
|
square.properties.shape = 'Square';
|
|
36
36
|
|
|
37
|
-
// @ts-expect-error turf types too wide
|
|
38
37
|
return square;
|
|
39
38
|
}
|
|
40
39
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {StartDraggingEvent, ModeProps} from './types';
|
|
6
|
-
import {FeatureCollection} from '../utils/geojson-types';
|
|
6
|
+
import {FeatureCollection, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
7
7
|
import {TranslateMode} from './translate-mode';
|
|
8
8
|
|
|
9
9
|
export class DuplicateMode extends TranslateMode {
|
|
10
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
10
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
11
11
|
super.handleStartDragging(event, props);
|
|
12
12
|
|
|
13
13
|
if (this._geometryBeforeTranslate) {
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Position,
|
|
7
|
+
LineString,
|
|
8
|
+
FeatureCollection,
|
|
9
|
+
SimpleFeatureCollection
|
|
10
|
+
} from '../utils/geojson-types';
|
|
6
11
|
import {ClickEvent, PointerMoveEvent, ModeProps, GuideFeatureCollection} from './types';
|
|
7
12
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
8
13
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
9
14
|
|
|
10
15
|
export class ExtendLineStringMode extends GeoJsonEditMode {
|
|
11
|
-
getSingleSelectedLineString(
|
|
16
|
+
getSingleSelectedLineString(
|
|
17
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
18
|
+
): LineString | null | undefined {
|
|
12
19
|
const selectedGeometry = this.getSelectedGeometry(props);
|
|
13
20
|
|
|
14
21
|
if (selectedGeometry && selectedGeometry.type === 'LineString') {
|
|
@@ -17,7 +24,7 @@ export class ExtendLineStringMode extends GeoJsonEditMode {
|
|
|
17
24
|
return null;
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
27
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
21
28
|
const {selectedIndexes} = props;
|
|
22
29
|
const selectedLineString = this.getSingleSelectedLineString(props);
|
|
23
30
|
|
|
@@ -49,7 +56,7 @@ export class ExtendLineStringMode extends GeoJsonEditMode {
|
|
|
49
56
|
});
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
getGuides(props: ModeProps<
|
|
59
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
53
60
|
const guides: GuideFeatureCollection = {
|
|
54
61
|
type: 'FeatureCollection',
|
|
55
62
|
features: []
|