@deck.gl-community/editable-layers 9.2.0-beta.5 → 9.2.0-beta.8
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 +9 -5
- package/dist/edit-modes/draw-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.js +226 -81
- 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 +2 -4
- 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.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 +0 -3
- 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 +4 -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 +369 -995
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -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.map +1 -1
- package/package.json +33 -33
- package/src/edit-modes/draw-90degree-polygon-mode.ts +2 -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 +5 -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 +304 -100
- 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 +3 -3
- package/src/edit-modes/duplicate-mode.ts +2 -2
- package/src/edit-modes/extend-line-string-mode.ts +4 -4
- package/src/edit-modes/extrude-mode.ts +7 -7
- package/src/edit-modes/geojson-edit-mode.ts +16 -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 +13 -13
- package/src/edit-modes/resize-circle-mode.ts +6 -8
- package/src/edit-modes/rotate-mode.ts +9 -15
- package/src/edit-modes/scale-mode.ts +11 -15
- package/src/edit-modes/snappable-mode.ts +5 -5
- package/src/edit-modes/split-polygon-mode.ts +12 -16
- package/src/edit-modes/three-click-polygon-mode.ts +3 -3
- package/src/edit-modes/translate-mode.ts +10 -12
- package/src/edit-modes/two-click-polygon-mode.ts +7 -7
- package/src/edit-modes/types.ts +4 -4
- package/src/edit-modes/utils.ts +12 -16
- package/src/editable-layers/editable-geojson-layer.ts +19 -18
- package/src/editable-layers/selection-layer.ts +3 -3
- package/src/index.ts +8 -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 +20 -21
- package/src/mode-handlers/modify-handler.ts +2 -4
- package/src/mode-handlers/rotate-handler.ts +4 -8
- package/src/mode-handlers/scale-handler.ts +4 -8
- package/src/mode-handlers/snappable-handler.ts +3 -3
- package/src/mode-handlers/split-polygon-handler.ts +6 -7
- package/src/mode-handlers/translate-handler.ts +3 -5
- package/src/utils/geojson-types.ts +15 -54
- package/src/utils/translate-from-center.ts +6 -11
- package/src/utils/utils.ts +4 -4
- 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,12 @@ import {
|
|
|
20
21
|
GuideFeatureCollection,
|
|
21
22
|
TentativeFeature
|
|
22
23
|
} from './types';
|
|
23
|
-
import {FeatureCollection, Feature, Polygon,
|
|
24
|
+
import {FeatureCollection, Feature, Polygon, SimpleGeometry, Position, SimpleFeatureCollection, SimpleFeature} from '../utils/geojson-types';
|
|
24
25
|
import {getPickedEditHandles, getNonGuidePicks} from './utils';
|
|
25
26
|
import {EditMode} from './edit-mode';
|
|
26
27
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
27
28
|
|
|
28
|
-
export type GeoJsonEditAction = EditAction<
|
|
29
|
+
export type GeoJsonEditAction = EditAction<SimpleFeatureCollection>;
|
|
29
30
|
|
|
30
31
|
const DEFAULT_GUIDES: GuideFeatureCollection = {
|
|
31
32
|
type: 'FeatureCollection',
|
|
@@ -51,14 +52,14 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
51
52
|
return DEFAULT_TOOLTIPS;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
getSelectedFeature(props: ModeProps<
|
|
55
|
+
getSelectedFeature(props: ModeProps<SimpleFeatureCollection>): SimpleFeature | null | undefined {
|
|
55
56
|
if (props.selectedIndexes.length === 1) {
|
|
56
57
|
return props.data.features[props.selectedIndexes[0]];
|
|
57
58
|
}
|
|
58
59
|
return null;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
getSelectedGeometry(props: ModeProps<
|
|
62
|
+
getSelectedGeometry(props: ModeProps<SimpleFeatureCollection>): SimpleGeometry | null | undefined {
|
|
62
63
|
const feature = this.getSelectedFeature(props);
|
|
63
64
|
if (feature) {
|
|
64
65
|
return feature.geometry;
|
|
@@ -66,7 +67,7 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
66
67
|
return null;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
getSelectedFeaturesAsFeatureCollection(props: ModeProps<
|
|
70
|
+
getSelectedFeaturesAsFeatureCollection(props: ModeProps<SimpleFeatureCollection>): SimpleFeatureCollection {
|
|
70
71
|
const {features} = props.data;
|
|
71
72
|
const selectedFeatures = props.selectedIndexes.map((selectedIndex) => features[selectedIndex]);
|
|
72
73
|
return {
|
|
@@ -104,21 +105,20 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
104
105
|
return props.selectedIndexes.some((index) => pickedIndexes.has(index));
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
rewindPolygon(feature:
|
|
108
|
+
rewindPolygon(feature: SimpleFeature): SimpleFeature {
|
|
108
109
|
const {geometry} = feature;
|
|
109
110
|
|
|
110
111
|
const isPolygonal = geometry.type === 'Polygon' || geometry.type === 'MultiPolygon';
|
|
111
112
|
if (isPolygonal) {
|
|
112
|
-
|
|
113
|
-
return rewind(feature);
|
|
113
|
+
return rewind(feature) as SimpleFeature;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
return feature;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
getAddFeatureAction(
|
|
120
|
-
featureOrGeometry:
|
|
121
|
-
features:
|
|
120
|
+
featureOrGeometry: SimpleGeometry | Feature,
|
|
121
|
+
features: SimpleFeatureCollection,
|
|
122
122
|
featureProperties?: {}
|
|
123
123
|
): GeoJsonEditAction {
|
|
124
124
|
// Unsure why flow can't deal with Geometry type, but there I fixed it
|
|
@@ -149,8 +149,8 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
getAddManyFeaturesAction(
|
|
152
|
-
{features: featuresToAdd}:
|
|
153
|
-
features:
|
|
152
|
+
{features: featuresToAdd}: SimpleFeatureCollection,
|
|
153
|
+
features: SimpleFeatureCollection
|
|
154
154
|
): GeoJsonEditAction {
|
|
155
155
|
let updatedData = new ImmutableFeatureCollection(features);
|
|
156
156
|
const initialIndex = updatedData.getObject().features.length;
|
|
@@ -178,7 +178,7 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
178
178
|
// eslint-disable-next-line complexity
|
|
179
179
|
getAddFeatureOrBooleanPolygonAction(
|
|
180
180
|
featureOrGeometry: Polygon | Feature,
|
|
181
|
-
props: ModeProps<
|
|
181
|
+
props: ModeProps<SimpleFeatureCollection>,
|
|
182
182
|
featureProperties?: {}
|
|
183
183
|
): GeoJsonEditAction | null | undefined {
|
|
184
184
|
const featureOrGeometryAsAny: any = featureOrGeometry;
|
|
@@ -209,14 +209,11 @@ export class GeoJsonEditMode implements EditMode<FeatureCollection, GuideFeature
|
|
|
209
209
|
|
|
210
210
|
let updatedGeometry;
|
|
211
211
|
if (modeConfig.booleanOperation === 'union') {
|
|
212
|
-
|
|
213
|
-
updatedGeometry = turfUnion(selectedFeature, feature);
|
|
212
|
+
updatedGeometry = turfUnion(featureCollection([selectedFeature, feature]));
|
|
214
213
|
} else if (modeConfig.booleanOperation === 'difference') {
|
|
215
|
-
|
|
216
|
-
updatedGeometry = turfDifference(selectedFeature, feature);
|
|
214
|
+
updatedGeometry = turfDifference(featureCollection([selectedFeature, feature]));
|
|
217
215
|
} else if (modeConfig.booleanOperation === 'intersection') {
|
|
218
|
-
|
|
219
|
-
updatedGeometry = turfIntersect(selectedFeature, feature);
|
|
216
|
+
updatedGeometry = turfIntersect(featureCollection([selectedFeature, feature]));
|
|
220
217
|
} else {
|
|
221
218
|
// eslint-disable-next-line no-console,no-undef
|
|
222
219
|
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,7 @@ import {
|
|
|
16
16
|
NearestPointType,
|
|
17
17
|
shouldCancelPan
|
|
18
18
|
} from './utils';
|
|
19
|
-
import {LineString, Point, Polygon, FeatureCollection,
|
|
19
|
+
import {LineString, Point, Polygon, FeatureCollection, Feature, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
20
20
|
import {
|
|
21
21
|
ModeProps,
|
|
22
22
|
ClickEvent,
|
|
@@ -34,7 +34,7 @@ import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
|
34
34
|
|
|
35
35
|
export class ModifyMode extends GeoJsonEditMode {
|
|
36
36
|
// eslint-disable-next-line complexity
|
|
37
|
-
getGuides(props: ModeProps<
|
|
37
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
38
38
|
const handles: GuideFeature[] = [];
|
|
39
39
|
|
|
40
40
|
const {data, lastPointerMoveEvent} = props;
|
|
@@ -76,7 +76,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
76
76
|
(lineString, prefix) => {
|
|
77
77
|
const lineStringFeature = toLineString(lineString);
|
|
78
78
|
const candidateIntermediatePoint = this.getNearestPoint(
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
lineStringFeature,
|
|
81
81
|
referencePoint,
|
|
82
82
|
props.modeConfig && props.modeConfig.viewport
|
|
@@ -121,8 +121,8 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
121
121
|
|
|
122
122
|
// turf.js does not support elevation for nearestPointOnLine
|
|
123
123
|
getNearestPoint(
|
|
124
|
-
line:
|
|
125
|
-
inPoint:
|
|
124
|
+
line: Feature<LineString>,
|
|
125
|
+
inPoint: Feature<Point>,
|
|
126
126
|
viewport: Viewport | null | undefined
|
|
127
127
|
): NearestPointType {
|
|
128
128
|
const {coordinates} = line.geometry;
|
|
@@ -139,12 +139,12 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
139
139
|
return nearestPointOnLine(line, inPoint, viewport);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
142
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
143
143
|
const pickedExistingHandle = getPickedExistingEditHandle(event.picks);
|
|
144
144
|
const pickedIntermediateHandle = getPickedIntermediateEditHandle(event.picks);
|
|
145
145
|
|
|
146
146
|
if (pickedExistingHandle) {
|
|
147
|
-
const {featureIndex, positionIndexes} = pickedExistingHandle.properties;
|
|
147
|
+
const { featureIndex, positionIndexes } = pickedExistingHandle.properties;
|
|
148
148
|
|
|
149
149
|
let updatedData;
|
|
150
150
|
try {
|
|
@@ -194,7 +194,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
197
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
198
198
|
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
199
199
|
|
|
200
200
|
if (editHandle) {
|
|
@@ -207,7 +207,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
207
207
|
|
|
208
208
|
_dragEditHandle(
|
|
209
209
|
editType: string,
|
|
210
|
-
props: ModeProps<
|
|
210
|
+
props: ModeProps<SimpleFeatureCollection>,
|
|
211
211
|
editHandle: EditHandleFeature,
|
|
212
212
|
event: StopDraggingEvent | DraggingEvent
|
|
213
213
|
) {
|
|
@@ -217,7 +217,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
217
217
|
let updatedData;
|
|
218
218
|
if (props.modeConfig?.lockRectangles && editedFeature.properties.shape === 'Rectangle') {
|
|
219
219
|
const coordinates = updateRectanglePosition(
|
|
220
|
-
editedFeature as
|
|
220
|
+
editedFeature as Feature<Polygon>,
|
|
221
221
|
editHandleProperties.positionIndexes[1],
|
|
222
222
|
event.mapCoords
|
|
223
223
|
) as any; // TODO
|
|
@@ -251,7 +251,7 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
251
251
|
props.onUpdateCursor(cursor);
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
254
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
255
255
|
if (shouldCancelPan(event)) {
|
|
256
256
|
event.cancelPan();
|
|
257
257
|
}
|
|
@@ -282,9 +282,9 @@ export class ModifyMode extends GeoJsonEditMode {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
285
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
286
286
|
const selectedFeatureIndexes = props.selectedIndexes;
|
|
287
|
-
const editHandle = getPickedEditHandle(event.
|
|
287
|
+
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
288
288
|
if (selectedFeatureIndexes.length && editHandle) {
|
|
289
289
|
this._dragEditHandle('finishMovePosition', props, editHandle, event);
|
|
290
290
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
getPickedEditHandle,
|
|
15
15
|
NearestPointType
|
|
16
16
|
} from './utils';
|
|
17
|
-
import {LineString, Point, FeatureCollection,
|
|
17
|
+
import {LineString, Point, FeatureCollection, Feature, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
18
18
|
import {Viewport} from '../utils/types';
|
|
19
19
|
import {
|
|
20
20
|
ModeProps,
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
DraggingEvent,
|
|
25
25
|
EditHandleFeature,
|
|
26
26
|
GuideFeatureCollection,
|
|
27
|
-
GuideFeature
|
|
27
|
+
GuideFeature,
|
|
28
28
|
} from './types';
|
|
29
29
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
30
30
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
@@ -69,7 +69,7 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
69
69
|
(lineString, prefix) => {
|
|
70
70
|
const lineStringFeature = toLineString(lineString);
|
|
71
71
|
const candidateIntermediatePoint = this.getNearestPoint(
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
lineStringFeature,
|
|
74
74
|
referencePoint,
|
|
75
75
|
props.modeConfig && props.modeConfig.viewport
|
|
@@ -114,8 +114,8 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
114
114
|
|
|
115
115
|
// turf.js does not support elevation for nearestPointOnLine
|
|
116
116
|
getNearestPoint(
|
|
117
|
-
line:
|
|
118
|
-
inPoint:
|
|
117
|
+
line: Feature<LineString>,
|
|
118
|
+
inPoint: Feature<Point>,
|
|
119
119
|
viewport: Viewport | null | undefined
|
|
120
120
|
): NearestPointType {
|
|
121
121
|
const {coordinates} = line.geometry;
|
|
@@ -129,11 +129,10 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
129
129
|
'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
|
-
// @ts-expect-error turf types diff
|
|
133
132
|
return nearestPointOnLine(line, inPoint);
|
|
134
133
|
}
|
|
135
134
|
|
|
136
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
135
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
137
136
|
const editHandle = getPickedEditHandle(event.pointerDownPicks);
|
|
138
137
|
|
|
139
138
|
if (editHandle) {
|
|
@@ -143,7 +142,6 @@ export class ResizeCircleMode extends GeoJsonEditMode {
|
|
|
143
142
|
const editHandleProperties = editHandle.properties;
|
|
144
143
|
|
|
145
144
|
const feature = this.getSelectedFeature(props);
|
|
146
|
-
// @ts-expect-error turf types diff
|
|
147
145
|
const center = turfCenter(feature).geometry.coordinates;
|
|
148
146
|
const numberOfSteps = Object.entries(feature.geometry.coordinates[0]).length - 1;
|
|
149
147
|
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,19 +165,15 @@ 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
|
|
174
|
+
const angle = getRotationAngle(centroid.geometry.coordinates, startDragPoint, currentPoint);
|
|
175
|
+
const rotatedFeatures = turfTransformRotate(
|
|
179
176
|
|
|
180
|
-
// @ts-expect-error turf types too wide
|
|
181
|
-
const rotatedFeatures: FeatureCollection = turfTransformRotate(
|
|
182
|
-
// @ts-expect-error turf types too wide
|
|
183
177
|
this._geometryBeingRotated,
|
|
184
178
|
angle,
|
|
185
179
|
{
|
|
@@ -12,7 +12,7 @@ import {coordEach} from '@turf/meta';
|
|
|
12
12
|
import turfDistance from '@turf/distance';
|
|
13
13
|
import turfTransformScale from '@turf/transform-scale';
|
|
14
14
|
import {getCoord, getGeom} from '@turf/invariant';
|
|
15
|
-
import {FeatureCollection, Position} from '../utils/geojson-types';
|
|
15
|
+
import {FeatureCollection, Position, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
16
16
|
import {
|
|
17
17
|
ModeProps,
|
|
18
18
|
PointerMoveEvent,
|
|
@@ -27,7 +27,7 @@ import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
|
27
27
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
28
28
|
|
|
29
29
|
export class ScaleMode extends GeoJsonEditMode {
|
|
30
|
-
_geometryBeingScaled:
|
|
30
|
+
_geometryBeingScaled: SimpleFeatureCollection | null | undefined;
|
|
31
31
|
_selectedEditHandle: EditHandleFeature | null | undefined;
|
|
32
32
|
_cornerGuidePoints: Array<EditHandleFeature> = [];
|
|
33
33
|
_cursor: string | null | undefined;
|
|
@@ -36,7 +36,6 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
36
36
|
_isSinglePointGeometrySelected = (geometry: FeatureCollection | null | undefined): boolean => {
|
|
37
37
|
const {features} = geometry || {};
|
|
38
38
|
if (Array.isArray(features) && features.length === 1) {
|
|
39
|
-
// @ts-expect-error turf types diff
|
|
40
39
|
const {type}: {type: string} = getGeom(features[0]);
|
|
41
40
|
return type === 'Point';
|
|
42
41
|
}
|
|
@@ -65,7 +64,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
65
64
|
);
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
_getUpdatedData = (props: ModeProps<
|
|
67
|
+
_getUpdatedData = (props: ModeProps<SimpleFeatureCollection>, editedData: SimpleFeatureCollection) => {
|
|
69
68
|
let updatedData = new ImmutableFeatureCollection(props.data);
|
|
70
69
|
const selectedIndexes = props.selectedIndexes;
|
|
71
70
|
for (let i = 0; i < selectedIndexes.length; i++) {
|
|
@@ -82,7 +81,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
82
81
|
startDragPoint: Position,
|
|
83
82
|
currentPoint: Position,
|
|
84
83
|
editType: string,
|
|
85
|
-
props: ModeProps<
|
|
84
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
86
85
|
) => {
|
|
87
86
|
if (!this._selectedEditHandle) {
|
|
88
87
|
return null;
|
|
@@ -93,9 +92,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
93
92
|
|
|
94
93
|
const scaleFactor = getScaleFactor(origin, startDragPoint, currentPoint);
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
const scaledFeatures: FeatureCollection = turfTransformScale(
|
|
98
|
-
// @ts-expect-error turf types diff
|
|
95
|
+
const scaledFeatures = turfTransformScale(
|
|
99
96
|
this._geometryBeingScaled,
|
|
100
97
|
scaleFactor,
|
|
101
98
|
{origin}
|
|
@@ -110,7 +107,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
110
107
|
};
|
|
111
108
|
};
|
|
112
109
|
|
|
113
|
-
updateCursor = (props: ModeProps<
|
|
110
|
+
updateCursor = (props: ModeProps<SimpleFeatureCollection>) => {
|
|
114
111
|
if (this._selectedEditHandle) {
|
|
115
112
|
if (this._cursor) {
|
|
116
113
|
props.onUpdateCursor(this._cursor);
|
|
@@ -118,7 +115,6 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
118
115
|
const cursorGeometry = this.getSelectedFeaturesAsFeatureCollection(props);
|
|
119
116
|
|
|
120
117
|
// Get resize cursor direction from the hovered scale editHandle (e.g. nesw or nwse)
|
|
121
|
-
// @ts-expect-error turf types diff
|
|
122
118
|
const centroid = turfCentroid(cursorGeometry);
|
|
123
119
|
const bearing = turfBearing(centroid, this._selectedEditHandle);
|
|
124
120
|
const positiveBearing = bearing < 0 ? bearing + 180 : bearing;
|
|
@@ -138,7 +134,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
138
134
|
}
|
|
139
135
|
};
|
|
140
136
|
|
|
141
|
-
handlePointerMove(event: PointerMoveEvent, props: ModeProps<
|
|
137
|
+
handlePointerMove(event: PointerMoveEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
142
138
|
if (!this._isScaling) {
|
|
143
139
|
const selectedEditHandle = getPickedEditHandle(event.picks);
|
|
144
140
|
this._selectedEditHandle =
|
|
@@ -150,7 +146,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
148
|
|
|
153
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
149
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
154
150
|
if (this._selectedEditHandle) {
|
|
155
151
|
event.cancelPan();
|
|
156
152
|
this._isScaling = true;
|
|
@@ -158,7 +154,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
156
|
|
|
161
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
157
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
162
158
|
if (!this._isScaling) {
|
|
163
159
|
return;
|
|
164
160
|
}
|
|
@@ -178,7 +174,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
178
174
|
event.cancelPan();
|
|
179
175
|
}
|
|
180
176
|
|
|
181
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
177
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
182
178
|
if (this._isScaling) {
|
|
183
179
|
// Scale the geometry
|
|
184
180
|
const scaleAction = this.getScaleAction(
|
|
@@ -200,7 +196,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
200
196
|
}
|
|
201
197
|
}
|
|
202
198
|
|
|
203
|
-
getGuides(props: ModeProps<
|
|
199
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
204
200
|
this._cornerGuidePoints = [];
|
|
205
201
|
const selectedGeometry = this.getSelectedFeaturesAsFeatureCollection(props);
|
|
206
202
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Position,
|
|
5
|
+
import {Position, FeatureCollection, SimpleFeatureCollection, SimpleFeature} from '../utils/geojson-types';
|
|
6
6
|
import {
|
|
7
7
|
PointerMoveEvent,
|
|
8
8
|
StartDraggingEvent,
|
|
@@ -55,7 +55,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
55
55
|
|
|
56
56
|
_getUpdatedSnapSourceHandle(
|
|
57
57
|
snapSourceHandle: EditHandleFeature,
|
|
58
|
-
data:
|
|
58
|
+
data: SimpleFeatureCollection
|
|
59
59
|
): EditHandleFeature {
|
|
60
60
|
const {featureIndex, positionIndexes} = snapSourceHandle.properties;
|
|
61
61
|
if (!Array.isArray(positionIndexes)) {
|
|
@@ -82,7 +82,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
82
82
|
// method will return those features along with the features
|
|
83
83
|
// that live in the current layer. Otherwise, this method will simply return the
|
|
84
84
|
// features from the current layer
|
|
85
|
-
_getSnapTargets(props: ModeProps<
|
|
85
|
+
_getSnapTargets(props: ModeProps<SimpleFeatureCollection>): SimpleFeature[] {
|
|
86
86
|
let {additionalSnapTargets} = props.modeConfig || {};
|
|
87
87
|
additionalSnapTargets = additionalSnapTargets || [];
|
|
88
88
|
|
|
@@ -90,7 +90,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
90
90
|
return features;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
_getSnapTargetHandles(props: ModeProps<
|
|
93
|
+
_getSnapTargetHandles(props: ModeProps<SimpleFeatureCollection>): EditHandleFeature[] {
|
|
94
94
|
const handles: EditHandleFeature[] = [];
|
|
95
95
|
const features = this._getSnapTargets(props);
|
|
96
96
|
|
|
@@ -109,7 +109,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
109
109
|
// If no snap handle has been picked, only display the edit handles of the
|
|
110
110
|
// selected feature. If a snap handle has been picked, display said snap handle
|
|
111
111
|
// along with all snappable points on all non-selected features.
|
|
112
|
-
getGuides(props: ModeProps<
|
|
112
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
113
113
|
const {modeConfig, lastPointerMoveEvent} = props;
|
|
114
114
|
const {enableSnapping} = modeConfig || {};
|
|
115
115
|
|