@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {SimpleFeature, SimpleFeatureCollection, Position} from '../utils/geojson-types';
|
|
6
6
|
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
7
7
|
import {
|
|
8
8
|
EditHandle,
|
|
@@ -25,7 +25,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
25
25
|
this._handler = handler;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
setFeatureCollection(featureCollection:
|
|
28
|
+
setFeatureCollection(featureCollection: SimpleFeatureCollection): void {
|
|
29
29
|
this._handler.setFeatureCollection(featureCollection);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -88,7 +88,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
88
88
|
// method will return those features along with the features
|
|
89
89
|
// that live in the current layer. Otherwise, this method will simply return the
|
|
90
90
|
// features from the current layer
|
|
91
|
-
_getSnapTargets():
|
|
91
|
+
_getSnapTargets(): SimpleFeature[] {
|
|
92
92
|
let {additionalSnapTargets} = this.getModeConfig() || {};
|
|
93
93
|
additionalSnapTargets = additionalSnapTargets || [];
|
|
94
94
|
|
|
@@ -6,16 +6,16 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
|
|
|
6
6
|
import turfDifference from '@turf/difference';
|
|
7
7
|
import turfBuffer from '@turf/buffer';
|
|
8
8
|
import lineIntersect from '@turf/line-intersect';
|
|
9
|
-
import {lineString} from '@turf/helpers';
|
|
9
|
+
import {feature as turfFeature, featureCollection, lineString} from '@turf/helpers';
|
|
10
10
|
import turfBearing from '@turf/bearing';
|
|
11
11
|
import turfDistance from '@turf/distance';
|
|
12
12
|
import turfDestination from '@turf/destination';
|
|
13
13
|
import turfPolygonToLine from '@turf/polygon-to-line';
|
|
14
|
-
import type {NearestPointOnLine} from '@turf/nearest-point-on-line';
|
|
15
14
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
16
15
|
import {generatePointsParallelToLinePoints} from '../utils/utils';
|
|
17
16
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
18
17
|
import {ClickEvent, PointerMoveEvent} from '../edit-modes/types';
|
|
18
|
+
import {PolygonGeometry} from '../utils/geojson-types';
|
|
19
19
|
|
|
20
20
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
21
21
|
export class SplitPolygonHandler extends ModeHandler {
|
|
@@ -33,7 +33,7 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
33
33
|
|
|
34
34
|
const lines = feature.type === 'FeatureCollection' ? feature.features : [feature];
|
|
35
35
|
let minDistance = Number.MAX_SAFE_INTEGER;
|
|
36
|
-
let closestPoint:
|
|
36
|
+
let closestPoint: ReturnType<typeof nearestPointOnLine> | null = null;
|
|
37
37
|
// If Multipolygon, then we should find nearest polygon line and stick split to it.
|
|
38
38
|
lines.forEach((line) => {
|
|
39
39
|
const snapPoint = nearestPointOnLine(line, firstPoint);
|
|
@@ -120,7 +120,8 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
120
120
|
geometry: {
|
|
121
121
|
type: 'LineString',
|
|
122
122
|
coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords)]
|
|
123
|
-
}
|
|
123
|
+
},
|
|
124
|
+
properties: {}
|
|
124
125
|
});
|
|
125
126
|
|
|
126
127
|
return result;
|
|
@@ -138,10 +139,10 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
138
139
|
gap = 0.1;
|
|
139
140
|
units = 'centimeters';
|
|
140
141
|
}
|
|
141
|
-
// @ts-expect-error turf type diff
|
|
142
142
|
const buffer = turfBuffer(tentativeFeature, gap, {units});
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const updatedGeometry = turfDifference(
|
|
144
|
+
featureCollection([turfFeature(selectedGeometry as PolygonGeometry), buffer])
|
|
145
|
+
);
|
|
145
146
|
this._setTentativeFeature(null);
|
|
146
147
|
if (!updatedGeometry) {
|
|
147
148
|
// eslint-disable-next-line no-console,no-undef
|
|
@@ -6,13 +6,13 @@ import turfBearing from '@turf/bearing';
|
|
|
6
6
|
import turfDistance from '@turf/distance';
|
|
7
7
|
import turfTransformTranslate from '@turf/transform-translate';
|
|
8
8
|
import {point} from '@turf/helpers';
|
|
9
|
-
import {
|
|
9
|
+
import {SimpleFeatureCollection, Position} from '../utils/geojson-types';
|
|
10
10
|
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
11
11
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
12
12
|
|
|
13
13
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
14
14
|
export class TranslateHandler extends ModeHandler {
|
|
15
|
-
_geometryBeforeTranslate:
|
|
15
|
+
_geometryBeforeTranslate: SimpleFeatureCollection | null | undefined;
|
|
16
16
|
_isTranslatable: boolean = undefined!;
|
|
17
17
|
|
|
18
18
|
handlePointerMove(event: PointerMoveEvent): {
|
|
@@ -87,9 +87,7 @@ export class TranslateHandler extends ModeHandler {
|
|
|
87
87
|
const distanceMoved = turfDistance(p1, p2);
|
|
88
88
|
const direction = turfBearing(p1, p2);
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
const movedFeatures: FeatureCollection = turfTransformTranslate(
|
|
92
|
-
// @ts-expect-error turf type diff
|
|
90
|
+
const movedFeatures: SimpleFeatureCollection = turfTransformTranslate(
|
|
93
91
|
this._geometryBeforeTranslate,
|
|
94
92
|
distanceMoved,
|
|
95
93
|
direction
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
// Geometry types
|
|
6
|
-
|
|
7
5
|
import type {
|
|
8
6
|
Point,
|
|
9
7
|
LineString,
|
|
@@ -11,64 +9,43 @@ import type {
|
|
|
11
9
|
MultiPoint,
|
|
12
10
|
MultiLineString,
|
|
13
11
|
MultiPolygon,
|
|
14
|
-
Position
|
|
12
|
+
Position,
|
|
13
|
+
Feature,
|
|
14
|
+
FeatureCollection
|
|
15
15
|
} from 'geojson';
|
|
16
16
|
|
|
17
|
-
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
| LineStringCoordinates
|
|
29
|
-
| PolygonCoordinates
|
|
30
|
-
| MultiPointCoordinates
|
|
31
|
-
| MultiLineStringCoordinates
|
|
32
|
-
| MultiPolygonCoordinates;
|
|
33
|
-
|
|
34
|
-
export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
35
|
-
|
|
36
|
-
export type Polygonal = Polygon | MultiPolygon;
|
|
37
|
-
|
|
38
|
-
// Feature types
|
|
17
|
+
export {
|
|
18
|
+
Point,
|
|
19
|
+
LineString,
|
|
20
|
+
Polygon,
|
|
21
|
+
MultiPoint,
|
|
22
|
+
MultiLineString,
|
|
23
|
+
MultiPolygon,
|
|
24
|
+
Position,
|
|
25
|
+
Feature,
|
|
26
|
+
FeatureCollection
|
|
27
|
+
};
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
/** Simple geometries (excludes GeometryCollection) */
|
|
30
|
+
export type SimpleGeometry =
|
|
31
|
+
| Point
|
|
32
|
+
| LineString
|
|
33
|
+
| Polygon
|
|
34
|
+
| MultiPoint
|
|
35
|
+
| MultiLineString
|
|
36
|
+
| MultiPolygon;
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
geometry: T;
|
|
45
|
-
properties?: {
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
};
|
|
48
|
-
id?: string | number;
|
|
49
|
-
bbox?: BoundingBoxArray;
|
|
50
|
-
};
|
|
38
|
+
/** Feature with any geometry except GeometryCollection */
|
|
39
|
+
export type SimpleFeature = Feature<SimpleGeometry>;
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
geometry: T;
|
|
55
|
-
properties: P;
|
|
56
|
-
};
|
|
41
|
+
/** FeatureCollection with any geometries except GeometryCollection */
|
|
42
|
+
export type SimpleFeatureCollection = FeatureCollection<SimpleGeometry>;
|
|
57
43
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| FeatureOf<LineString>
|
|
61
|
-
| FeatureOf<Polygon>
|
|
62
|
-
| FeatureOf<MultiPoint>
|
|
63
|
-
| FeatureOf<MultiLineString>
|
|
64
|
-
| FeatureOf<MultiPolygon>;
|
|
44
|
+
/** Coordinates of any geometry except GeometryCollection */
|
|
45
|
+
export type SimpleGeometryCoordinates = SimpleGeometry['coordinates'];
|
|
65
46
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
features: Feature[];
|
|
69
|
-
properties?: {};
|
|
70
|
-
id?: string | number;
|
|
71
|
-
bbox?: BoundingBoxArray;
|
|
72
|
-
};
|
|
47
|
+
/** Polygon and MultiPolygon geometries */
|
|
48
|
+
export type PolygonGeometry = Polygon | MultiPolygon;
|
|
73
49
|
|
|
50
|
+
/** A Feature or FeatureCollection */
|
|
74
51
|
export type AnyGeoJson = Feature | FeatureCollection;
|
|
@@ -6,45 +6,27 @@ import turfCenter from '@turf/center';
|
|
|
6
6
|
import turfRhumbBearing from '@turf/rhumb-bearing';
|
|
7
7
|
import turfRhumbDistance from '@turf/rhumb-distance';
|
|
8
8
|
import turfRhumbDestination from '@turf/rhumb-destination';
|
|
9
|
-
import type {
|
|
10
|
-
Position as TurfPosition,
|
|
11
|
-
Feature as TurfFeature,
|
|
12
|
-
Geometry as TurfGeometry
|
|
13
|
-
} from '@turf/helpers';
|
|
14
9
|
import {mapCoords} from '../edit-modes/utils';
|
|
15
|
-
import type {
|
|
10
|
+
import type {SimpleFeature} from './geojson-types';
|
|
16
11
|
|
|
17
12
|
// This function takes feature's center, moves it,
|
|
18
13
|
// and builds new feature around it keeping the proportions
|
|
19
|
-
export function translateFromCenter(
|
|
20
|
-
feature
|
|
21
|
-
distance: number,
|
|
22
|
-
direction: number
|
|
23
|
-
) {
|
|
24
|
-
const initialCenterPoint = turfCenter(feature as TurfFeature);
|
|
14
|
+
export function translateFromCenter(feature: SimpleFeature, distance: number, direction: number) {
|
|
15
|
+
const initialCenterPoint = turfCenter(feature);
|
|
25
16
|
|
|
26
17
|
const movedCenterPoint = turfRhumbDestination(initialCenterPoint, distance, direction);
|
|
27
18
|
|
|
28
|
-
const movedCoordinates = mapCoords(
|
|
29
|
-
|
|
30
|
-
(coordinate)
|
|
31
|
-
const rhumbDistance = turfRhumbDistance(
|
|
32
|
-
initialCenterPoint.geometry.coordinates,
|
|
33
|
-
coordinate as TurfPosition
|
|
34
|
-
);
|
|
35
|
-
const rhumbDirection = turfRhumbBearing(
|
|
36
|
-
initialCenterPoint.geometry.coordinates,
|
|
37
|
-
coordinate as TurfPosition
|
|
38
|
-
);
|
|
19
|
+
const movedCoordinates = mapCoords(feature.geometry.coordinates, (coordinate) => {
|
|
20
|
+
const rhumbDistance = turfRhumbDistance(initialCenterPoint.geometry.coordinates, coordinate);
|
|
21
|
+
const rhumbDirection = turfRhumbBearing(initialCenterPoint.geometry.coordinates, coordinate);
|
|
39
22
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
23
|
+
const movedPosition = turfRhumbDestination(
|
|
24
|
+
movedCenterPoint.geometry.coordinates,
|
|
25
|
+
rhumbDistance,
|
|
26
|
+
rhumbDirection
|
|
27
|
+
).geometry.coordinates;
|
|
28
|
+
return movedPosition;
|
|
29
|
+
});
|
|
48
30
|
|
|
49
31
|
feature.geometry.coordinates = movedCoordinates;
|
|
50
32
|
|
package/src/utils/utils.ts
CHANGED
|
@@ -6,13 +6,13 @@ import destination from '@turf/destination';
|
|
|
6
6
|
import bearing from '@turf/bearing';
|
|
7
7
|
import pointToLineDistance from '@turf/point-to-line-distance';
|
|
8
8
|
import {point} from '@turf/helpers';
|
|
9
|
-
import {WebMercatorViewport} from '
|
|
10
|
-
import {
|
|
9
|
+
import {WebMercatorViewport} from '@math.gl/web-mercator';
|
|
10
|
+
import {Feature, LineString, Point, Position} from './geojson-types';
|
|
11
11
|
import {Viewport} from './types';
|
|
12
12
|
|
|
13
13
|
// TODO edit-modes: delete and use edit-modes/utils instead
|
|
14
14
|
|
|
15
|
-
export type NearestPointType =
|
|
15
|
+
export type NearestPointType = Feature<Point, {dist: number; index: number}>;
|
|
16
16
|
|
|
17
17
|
export function toDeckColor(
|
|
18
18
|
color?: [number, number, number, number] | number,
|
|
@@ -106,8 +106,8 @@ export function mix(a: number, b: number, ratio: number): number {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export function nearestPointOnProjectedLine(
|
|
109
|
-
line:
|
|
110
|
-
inPoint:
|
|
109
|
+
line: Feature<LineString>,
|
|
110
|
+
inPoint: Feature<Point>,
|
|
111
111
|
viewport: Viewport
|
|
112
112
|
): NearestPointType {
|
|
113
113
|
const wmViewport = new WebMercatorViewport(viewport);
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {render} from 'preact';
|
|
6
6
|
import type {ComponentChild, JSX} from 'preact';
|
|
7
|
-
import {
|
|
8
|
-
Widget,
|
|
9
|
-
type WidgetProps,
|
|
10
|
-
type WidgetPlacement,
|
|
11
|
-
type Deck
|
|
12
|
-
} from '@deck.gl/core';
|
|
7
|
+
import {Widget, type WidgetProps, type WidgetPlacement, type Deck} from '@deck.gl/core';
|
|
13
8
|
import type {
|
|
14
9
|
GeoJsonEditModeConstructor,
|
|
15
10
|
GeoJsonEditModeType
|
|
@@ -106,6 +101,7 @@ const BUTTON_LABEL_STYLE: JSX.CSSProperties = {
|
|
|
106
101
|
export class EditModeTrayWidget extends Widget<EditModeTrayWidgetProps> {
|
|
107
102
|
static override defaultProps = {
|
|
108
103
|
id: 'edit-mode-tray',
|
|
104
|
+
_container: null,
|
|
109
105
|
placement: 'top-left',
|
|
110
106
|
layout: 'vertical',
|
|
111
107
|
modes: [],
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {render} from 'preact';
|
|
6
|
+
import type {JSX} from 'preact';
|
|
7
|
+
import {Widget, type WidgetProps, type WidgetPlacement, type Deck} from '@deck.gl/core';
|
|
8
|
+
|
|
9
|
+
export type BooleanOperation = 'union' | 'difference' | 'intersection' | null;
|
|
10
|
+
|
|
11
|
+
export type EditorToolbarWidgetProps = WidgetProps & {
|
|
12
|
+
/** Placement for the widget root element. */
|
|
13
|
+
placement?: WidgetPlacement;
|
|
14
|
+
/** Currently active boolean operation. */
|
|
15
|
+
booleanOperation?: BooleanOperation;
|
|
16
|
+
/** Number of features in the current dataset. */
|
|
17
|
+
featureCount?: number;
|
|
18
|
+
/** Callback fired when the user selects a boolean operation. */
|
|
19
|
+
onSetBooleanOperation?: (op: BooleanOperation) => void;
|
|
20
|
+
/** Callback fired when the user clicks the clear button. */
|
|
21
|
+
onClear?: () => void;
|
|
22
|
+
/** Callback fired when the user clicks the export button. */
|
|
23
|
+
onExport?: () => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// --- Styles (match EditModeTrayWidget visual language) ---
|
|
27
|
+
|
|
28
|
+
const ROOT_STYLE: Partial<CSSStyleDeclaration> = {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'column',
|
|
32
|
+
gap: '6px',
|
|
33
|
+
pointerEvents: 'auto',
|
|
34
|
+
userSelect: 'none',
|
|
35
|
+
zIndex: '99'
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const TRAY_STYLE: JSX.CSSProperties = {
|
|
39
|
+
display: 'flex',
|
|
40
|
+
gap: '4px',
|
|
41
|
+
background: 'rgba(36, 40, 41, 0.88)',
|
|
42
|
+
borderRadius: '999px',
|
|
43
|
+
padding: '5px 8px',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.25)'
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const BUTTON_STYLE: JSX.CSSProperties = {
|
|
50
|
+
appearance: 'none',
|
|
51
|
+
background: 'transparent',
|
|
52
|
+
border: 'none',
|
|
53
|
+
color: '#f0f0f0',
|
|
54
|
+
height: '30px',
|
|
55
|
+
padding: '0 8px',
|
|
56
|
+
display: 'flex',
|
|
57
|
+
alignItems: 'center',
|
|
58
|
+
justifyContent: 'center',
|
|
59
|
+
gap: '4px',
|
|
60
|
+
borderRadius: '15px',
|
|
61
|
+
cursor: 'pointer',
|
|
62
|
+
fontSize: '11px',
|
|
63
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
64
|
+
fontWeight: '500',
|
|
65
|
+
transition: 'background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease',
|
|
66
|
+
whiteSpace: 'nowrap'
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const BUTTON_ACTIVE_STYLE: JSX.CSSProperties = {
|
|
70
|
+
background: '#0071e3',
|
|
71
|
+
color: '#ffffff',
|
|
72
|
+
boxShadow: '0 0 0 2px rgba(255, 255, 255, 0.35)'
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const DIVIDER_STYLE: JSX.CSSProperties = {
|
|
76
|
+
width: '1px',
|
|
77
|
+
height: '20px',
|
|
78
|
+
background: 'rgba(255, 255, 255, 0.2)',
|
|
79
|
+
margin: '0 2px',
|
|
80
|
+
flexShrink: '0'
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const BADGE_STYLE: JSX.CSSProperties = {
|
|
84
|
+
color: 'rgba(255, 255, 255, 0.6)',
|
|
85
|
+
fontSize: '11px',
|
|
86
|
+
padding: '0 6px',
|
|
87
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
88
|
+
whiteSpace: 'nowrap'
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// --- SVG Icons (14x14) ---
|
|
92
|
+
|
|
93
|
+
function PencilIcon() {
|
|
94
|
+
return (
|
|
95
|
+
<svg
|
|
96
|
+
width="14"
|
|
97
|
+
height="14"
|
|
98
|
+
viewBox="0 0 14 14"
|
|
99
|
+
fill="none"
|
|
100
|
+
stroke="currentColor"
|
|
101
|
+
strokeWidth="1.5"
|
|
102
|
+
strokeLinecap="round"
|
|
103
|
+
strokeLinejoin="round"
|
|
104
|
+
>
|
|
105
|
+
<path d="M10 1.5l2.5 2.5L4.5 12H2v-2.5z" />
|
|
106
|
+
</svg>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function SubtractIcon() {
|
|
111
|
+
return (
|
|
112
|
+
<svg
|
|
113
|
+
width="14"
|
|
114
|
+
height="14"
|
|
115
|
+
viewBox="0 0 14 14"
|
|
116
|
+
fill="none"
|
|
117
|
+
stroke="currentColor"
|
|
118
|
+
strokeWidth="1.1"
|
|
119
|
+
>
|
|
120
|
+
<rect x="1" y="1" width="8" height="8" rx="1.5" />
|
|
121
|
+
<rect x="5" y="5" width="8" height="8" rx="1.5" fill="rgba(36,40,41,0.88)" />
|
|
122
|
+
</svg>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function UnionIcon() {
|
|
127
|
+
return (
|
|
128
|
+
<svg
|
|
129
|
+
width="14"
|
|
130
|
+
height="14"
|
|
131
|
+
viewBox="0 0 14 14"
|
|
132
|
+
fill="none"
|
|
133
|
+
stroke="currentColor"
|
|
134
|
+
strokeWidth="1.1"
|
|
135
|
+
>
|
|
136
|
+
<rect x="1" y="1" width="8" height="8" rx="1.5" />
|
|
137
|
+
<rect x="5" y="5" width="8" height="8" rx="1.5" />
|
|
138
|
+
</svg>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function IntersectIcon() {
|
|
143
|
+
return (
|
|
144
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" strokeWidth="1.1">
|
|
145
|
+
<rect x="1" y="1" width="8" height="8" rx="1.5" stroke="currentColor" opacity="0.4" />
|
|
146
|
+
<rect x="5" y="5" width="8" height="8" rx="1.5" stroke="currentColor" opacity="0.4" />
|
|
147
|
+
<rect x="5" y="5" width="4" height="4" fill="currentColor" opacity="0.6" />
|
|
148
|
+
</svg>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function TrashIcon() {
|
|
153
|
+
return (
|
|
154
|
+
<svg
|
|
155
|
+
width="14"
|
|
156
|
+
height="14"
|
|
157
|
+
viewBox="0 0 14 14"
|
|
158
|
+
fill="none"
|
|
159
|
+
stroke="currentColor"
|
|
160
|
+
strokeWidth="1.3"
|
|
161
|
+
strokeLinecap="round"
|
|
162
|
+
strokeLinejoin="round"
|
|
163
|
+
>
|
|
164
|
+
<path d="M2.5 4h9M5.5 4V2.5h3V4M3.5 4l.5 8h6l.5-8" />
|
|
165
|
+
</svg>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function DownloadIcon() {
|
|
170
|
+
return (
|
|
171
|
+
<svg
|
|
172
|
+
width="14"
|
|
173
|
+
height="14"
|
|
174
|
+
viewBox="0 0 14 14"
|
|
175
|
+
fill="none"
|
|
176
|
+
stroke="currentColor"
|
|
177
|
+
strokeWidth="1.3"
|
|
178
|
+
strokeLinecap="round"
|
|
179
|
+
strokeLinejoin="round"
|
|
180
|
+
>
|
|
181
|
+
<path d="M7 2v7M4.5 6.5L7 9l2.5-2.5M2.5 11.5h9" />
|
|
182
|
+
</svg>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// --- Widget ---
|
|
187
|
+
|
|
188
|
+
const BOOLEAN_OPS: Array<{
|
|
189
|
+
op: BooleanOperation;
|
|
190
|
+
icon: () => JSX.Element;
|
|
191
|
+
label: string;
|
|
192
|
+
title: string;
|
|
193
|
+
}> = [
|
|
194
|
+
{op: null, icon: PencilIcon, label: 'Edit', title: 'Draw new features'},
|
|
195
|
+
{op: 'difference', icon: SubtractIcon, label: 'Sub', title: 'Subtract from selection'},
|
|
196
|
+
{op: 'union', icon: UnionIcon, label: 'Union', title: 'Union with selection'},
|
|
197
|
+
{op: 'intersection', icon: IntersectIcon, label: 'Sect', title: 'Intersect with selection'}
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
export class EditorToolbarWidget extends Widget<EditorToolbarWidgetProps> {
|
|
201
|
+
static override defaultProps = {
|
|
202
|
+
id: 'editor-toolbar',
|
|
203
|
+
_container: null,
|
|
204
|
+
placement: 'bottom-left',
|
|
205
|
+
booleanOperation: null,
|
|
206
|
+
featureCount: 0,
|
|
207
|
+
style: {},
|
|
208
|
+
className: ''
|
|
209
|
+
} satisfies Required<WidgetProps> &
|
|
210
|
+
Required<Pick<EditorToolbarWidgetProps, 'placement'>> &
|
|
211
|
+
EditorToolbarWidgetProps;
|
|
212
|
+
|
|
213
|
+
placement: WidgetPlacement = 'bottom-left';
|
|
214
|
+
className = 'deck-widget-editor-toolbar';
|
|
215
|
+
deck?: Deck | null = null;
|
|
216
|
+
private appliedCustomClassName: string | null = null;
|
|
217
|
+
|
|
218
|
+
constructor(props: EditorToolbarWidgetProps = {}) {
|
|
219
|
+
super({...EditorToolbarWidget.defaultProps, ...props});
|
|
220
|
+
this.placement = props.placement ?? EditorToolbarWidget.defaultProps.placement;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
override setProps(props: Partial<EditorToolbarWidgetProps>): void {
|
|
224
|
+
if (props.placement !== undefined) {
|
|
225
|
+
this.placement = props.placement;
|
|
226
|
+
}
|
|
227
|
+
super.setProps(props);
|
|
228
|
+
this.renderToolbar();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
override onAdd({deck}: {deck: Deck}): void {
|
|
232
|
+
this.deck = deck;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
override onRemove(): void {
|
|
236
|
+
this.deck = null;
|
|
237
|
+
const root = this.rootElement;
|
|
238
|
+
if (root) {
|
|
239
|
+
render(null, root);
|
|
240
|
+
}
|
|
241
|
+
this.rootElement = null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
override onRenderHTML(rootElement: HTMLElement): void {
|
|
245
|
+
const style = {...ROOT_STYLE, ...this.props.style};
|
|
246
|
+
Object.assign(rootElement.style, style);
|
|
247
|
+
if (this.appliedCustomClassName && this.appliedCustomClassName !== this.props.className) {
|
|
248
|
+
rootElement.classList.remove(this.appliedCustomClassName);
|
|
249
|
+
this.appliedCustomClassName = null;
|
|
250
|
+
}
|
|
251
|
+
if (this.props.className) {
|
|
252
|
+
rootElement.classList.add(this.props.className);
|
|
253
|
+
this.appliedCustomClassName = this.props.className;
|
|
254
|
+
}
|
|
255
|
+
rootElement.classList.add(this.className);
|
|
256
|
+
this.renderToolbar();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private renderToolbar() {
|
|
260
|
+
const root = this.rootElement;
|
|
261
|
+
if (!root) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const booleanOp = this.props.booleanOperation ?? null;
|
|
266
|
+
const featureCount = this.props.featureCount ?? 0;
|
|
267
|
+
|
|
268
|
+
const stopEvent = (event: Event) => {
|
|
269
|
+
event.stopPropagation();
|
|
270
|
+
if (typeof (event as any).stopImmediatePropagation === 'function') {
|
|
271
|
+
(event as any).stopImmediatePropagation();
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const ui = (
|
|
276
|
+
<div
|
|
277
|
+
style={TRAY_STYLE}
|
|
278
|
+
onPointerDown={stopEvent}
|
|
279
|
+
onPointerMove={stopEvent}
|
|
280
|
+
onPointerUp={stopEvent}
|
|
281
|
+
onMouseDown={stopEvent}
|
|
282
|
+
onMouseMove={stopEvent}
|
|
283
|
+
onMouseUp={stopEvent}
|
|
284
|
+
onTouchStart={stopEvent}
|
|
285
|
+
onTouchMove={stopEvent}
|
|
286
|
+
onTouchEnd={stopEvent}
|
|
287
|
+
>
|
|
288
|
+
{/* Boolean operation toggle buttons */}
|
|
289
|
+
{BOOLEAN_OPS.map(({op, icon: Icon, label, title}) => {
|
|
290
|
+
const active = booleanOp === op;
|
|
291
|
+
return (
|
|
292
|
+
<button
|
|
293
|
+
key={label}
|
|
294
|
+
type="button"
|
|
295
|
+
title={title}
|
|
296
|
+
aria-pressed={active}
|
|
297
|
+
style={{...BUTTON_STYLE, ...(active ? BUTTON_ACTIVE_STYLE : {})}}
|
|
298
|
+
onClick={(event) => {
|
|
299
|
+
stopEvent(event);
|
|
300
|
+
this.props.onSetBooleanOperation?.(op);
|
|
301
|
+
}}
|
|
302
|
+
>
|
|
303
|
+
<Icon />
|
|
304
|
+
<span>{label}</span>
|
|
305
|
+
</button>
|
|
306
|
+
);
|
|
307
|
+
})}
|
|
308
|
+
|
|
309
|
+
<div style={DIVIDER_STYLE} />
|
|
310
|
+
|
|
311
|
+
{/* Clear button */}
|
|
312
|
+
<button
|
|
313
|
+
type="button"
|
|
314
|
+
title="Clear all features"
|
|
315
|
+
style={BUTTON_STYLE}
|
|
316
|
+
onClick={(event) => {
|
|
317
|
+
stopEvent(event);
|
|
318
|
+
this.props.onClear?.();
|
|
319
|
+
}}
|
|
320
|
+
>
|
|
321
|
+
<TrashIcon />
|
|
322
|
+
</button>
|
|
323
|
+
|
|
324
|
+
{/* Export button */}
|
|
325
|
+
<button
|
|
326
|
+
type="button"
|
|
327
|
+
title="Download as GeoJSON"
|
|
328
|
+
style={BUTTON_STYLE}
|
|
329
|
+
onClick={(event) => {
|
|
330
|
+
stopEvent(event);
|
|
331
|
+
this.props.onExport?.();
|
|
332
|
+
}}
|
|
333
|
+
>
|
|
334
|
+
<DownloadIcon />
|
|
335
|
+
</button>
|
|
336
|
+
|
|
337
|
+
<div style={DIVIDER_STYLE} />
|
|
338
|
+
|
|
339
|
+
{/* Feature count badge */}
|
|
340
|
+
<span style={BADGE_STYLE}>
|
|
341
|
+
{featureCount} feature{featureCount !== 1 ? 's' : ''}
|
|
342
|
+
</span>
|
|
343
|
+
</div>
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
render(ui, root);
|
|
347
|
+
}
|
|
348
|
+
}
|
package/dist/lib/constants.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.
|
|
3
|
-
* Required in order to maintain the same appearance after upgrading to deck.gl v8.5.
|
|
4
|
-
* https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md
|
|
5
|
-
*/
|
|
6
|
-
export declare const PROJECTED_PIXEL_SIZE_MULTIPLIER: number;
|
|
7
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,QAAQ,CAAC"}
|