@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
|
@@ -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,10 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
65
64
|
);
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
_getUpdatedData = (
|
|
67
|
+
_getUpdatedData = (
|
|
68
|
+
props: ModeProps<SimpleFeatureCollection>,
|
|
69
|
+
editedData: SimpleFeatureCollection
|
|
70
|
+
) => {
|
|
69
71
|
let updatedData = new ImmutableFeatureCollection(props.data);
|
|
70
72
|
const selectedIndexes = props.selectedIndexes;
|
|
71
73
|
for (let i = 0; i < selectedIndexes.length; i++) {
|
|
@@ -82,7 +84,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
82
84
|
startDragPoint: Position,
|
|
83
85
|
currentPoint: Position,
|
|
84
86
|
editType: string,
|
|
85
|
-
props: ModeProps<
|
|
87
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
86
88
|
) => {
|
|
87
89
|
if (!this._selectedEditHandle) {
|
|
88
90
|
return null;
|
|
@@ -93,13 +95,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
93
95
|
|
|
94
96
|
const scaleFactor = getScaleFactor(origin, startDragPoint, currentPoint);
|
|
95
97
|
|
|
96
|
-
|
|
97
|
-
const scaledFeatures: FeatureCollection = turfTransformScale(
|
|
98
|
-
// @ts-expect-error turf types diff
|
|
99
|
-
this._geometryBeingScaled,
|
|
100
|
-
scaleFactor,
|
|
101
|
-
{origin}
|
|
102
|
-
);
|
|
98
|
+
const scaledFeatures = turfTransformScale(this._geometryBeingScaled, scaleFactor, {origin});
|
|
103
99
|
|
|
104
100
|
return {
|
|
105
101
|
updatedData: this._getUpdatedData(props, scaledFeatures),
|
|
@@ -110,7 +106,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
110
106
|
};
|
|
111
107
|
};
|
|
112
108
|
|
|
113
|
-
updateCursor = (props: ModeProps<
|
|
109
|
+
updateCursor = (props: ModeProps<SimpleFeatureCollection>) => {
|
|
114
110
|
if (this._selectedEditHandle) {
|
|
115
111
|
if (this._cursor) {
|
|
116
112
|
props.onUpdateCursor(this._cursor);
|
|
@@ -118,7 +114,6 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
118
114
|
const cursorGeometry = this.getSelectedFeaturesAsFeatureCollection(props);
|
|
119
115
|
|
|
120
116
|
// Get resize cursor direction from the hovered scale editHandle (e.g. nesw or nwse)
|
|
121
|
-
// @ts-expect-error turf types diff
|
|
122
117
|
const centroid = turfCentroid(cursorGeometry);
|
|
123
118
|
const bearing = turfBearing(centroid, this._selectedEditHandle);
|
|
124
119
|
const positiveBearing = bearing < 0 ? bearing + 180 : bearing;
|
|
@@ -138,7 +133,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
138
133
|
}
|
|
139
134
|
};
|
|
140
135
|
|
|
141
|
-
handlePointerMove(event: PointerMoveEvent, props: ModeProps<
|
|
136
|
+
handlePointerMove(event: PointerMoveEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
142
137
|
if (!this._isScaling) {
|
|
143
138
|
const selectedEditHandle = getPickedEditHandle(event.picks);
|
|
144
139
|
this._selectedEditHandle =
|
|
@@ -150,7 +145,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
150
145
|
}
|
|
151
146
|
}
|
|
152
147
|
|
|
153
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
148
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
154
149
|
if (this._selectedEditHandle) {
|
|
155
150
|
event.cancelPan();
|
|
156
151
|
this._isScaling = true;
|
|
@@ -158,7 +153,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
158
153
|
}
|
|
159
154
|
}
|
|
160
155
|
|
|
161
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
156
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
162
157
|
if (!this._isScaling) {
|
|
163
158
|
return;
|
|
164
159
|
}
|
|
@@ -178,7 +173,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
178
173
|
event.cancelPan();
|
|
179
174
|
}
|
|
180
175
|
|
|
181
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
176
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
182
177
|
if (this._isScaling) {
|
|
183
178
|
// Scale the geometry
|
|
184
179
|
const scaleAction = this.getScaleAction(
|
|
@@ -200,7 +195,7 @@ export class ScaleMode extends GeoJsonEditMode {
|
|
|
200
195
|
}
|
|
201
196
|
}
|
|
202
197
|
|
|
203
|
-
getGuides(props: ModeProps<
|
|
198
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
204
199
|
this._cornerGuidePoints = [];
|
|
205
200
|
const selectedGeometry = this.getSelectedFeaturesAsFeatureCollection(props);
|
|
206
201
|
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Position,
|
|
7
|
+
FeatureCollection,
|
|
8
|
+
SimpleFeatureCollection,
|
|
9
|
+
SimpleFeature
|
|
10
|
+
} from '../utils/geojson-types';
|
|
6
11
|
import {
|
|
7
12
|
PointerMoveEvent,
|
|
8
13
|
StartDraggingEvent,
|
|
@@ -55,7 +60,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
55
60
|
|
|
56
61
|
_getUpdatedSnapSourceHandle(
|
|
57
62
|
snapSourceHandle: EditHandleFeature,
|
|
58
|
-
data:
|
|
63
|
+
data: SimpleFeatureCollection
|
|
59
64
|
): EditHandleFeature {
|
|
60
65
|
const {featureIndex, positionIndexes} = snapSourceHandle.properties;
|
|
61
66
|
if (!Array.isArray(positionIndexes)) {
|
|
@@ -82,7 +87,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
82
87
|
// method will return those features along with the features
|
|
83
88
|
// that live in the current layer. Otherwise, this method will simply return the
|
|
84
89
|
// features from the current layer
|
|
85
|
-
_getSnapTargets(props: ModeProps<
|
|
90
|
+
_getSnapTargets(props: ModeProps<SimpleFeatureCollection>): SimpleFeature[] {
|
|
86
91
|
let {additionalSnapTargets} = props.modeConfig || {};
|
|
87
92
|
additionalSnapTargets = additionalSnapTargets || [];
|
|
88
93
|
|
|
@@ -90,7 +95,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
90
95
|
return features;
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
_getSnapTargetHandles(props: ModeProps<
|
|
98
|
+
_getSnapTargetHandles(props: ModeProps<SimpleFeatureCollection>): EditHandleFeature[] {
|
|
94
99
|
const handles: EditHandleFeature[] = [];
|
|
95
100
|
const features = this._getSnapTargets(props);
|
|
96
101
|
|
|
@@ -109,7 +114,7 @@ export class SnappableMode extends GeoJsonEditMode {
|
|
|
109
114
|
// If no snap handle has been picked, only display the edit handles of the
|
|
110
115
|
// selected feature. If a snap handle has been picked, display said snap handle
|
|
111
116
|
// along with all snappable points on all non-selected features.
|
|
112
|
-
getGuides(props: ModeProps<
|
|
117
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
113
118
|
const {modeConfig, lastPointerMoveEvent} = props;
|
|
114
119
|
const {enableSnapping} = modeConfig || {};
|
|
115
120
|
|
|
@@ -6,16 +6,15 @@ 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 type {Point} from '
|
|
10
|
-
import {lineString} from '@turf/helpers';
|
|
9
|
+
import type {Point} from 'geojson';
|
|
10
|
+
import {feature as turfFeature, featureCollection, lineString} from '@turf/helpers';
|
|
11
11
|
import turfBearing from '@turf/bearing';
|
|
12
12
|
import turfDistance from '@turf/distance';
|
|
13
13
|
import turfDestination from '@turf/destination';
|
|
14
14
|
import turfPolygonToLine from '@turf/polygon-to-line';
|
|
15
|
-
import type {NearestPointOnLine} from '@turf/nearest-point-on-line';
|
|
16
15
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
17
16
|
import {generatePointsParallelToLinePoints} from './utils';
|
|
18
|
-
import {FeatureCollection} from '../utils/geojson-types';
|
|
17
|
+
import {FeatureCollection, PolygonGeometry, SimpleFeatureCollection} from '../utils/geojson-types';
|
|
19
18
|
import {
|
|
20
19
|
ClickEvent,
|
|
21
20
|
PointerMoveEvent,
|
|
@@ -27,7 +26,11 @@ import {GeoJsonEditMode, GeoJsonEditAction} from './geojson-edit-mode';
|
|
|
27
26
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
28
27
|
|
|
29
28
|
export class SplitPolygonMode extends GeoJsonEditMode {
|
|
30
|
-
calculateMapCoords(
|
|
29
|
+
calculateMapCoords(
|
|
30
|
+
clickSequence: any,
|
|
31
|
+
mapCoords: any,
|
|
32
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
33
|
+
) {
|
|
31
34
|
const modeConfig = props.modeConfig;
|
|
32
35
|
if (!modeConfig || !modeConfig.lock90Degree || !clickSequence.length) {
|
|
33
36
|
return mapCoords;
|
|
@@ -36,12 +39,11 @@ export class SplitPolygonMode extends GeoJsonEditMode {
|
|
|
36
39
|
// if first point is clicked, then find closest polygon point and build ~90deg vector
|
|
37
40
|
const firstPoint = clickSequence[0];
|
|
38
41
|
const selectedGeometry = this.getSelectedGeometry(props);
|
|
39
|
-
|
|
40
|
-
const feature = turfPolygonToLine(selectedGeometry);
|
|
42
|
+
const feature = turfPolygonToLine(selectedGeometry as PolygonGeometry);
|
|
41
43
|
|
|
42
44
|
const lines = feature.type === 'FeatureCollection' ? feature.features : [feature];
|
|
43
45
|
let minDistance = Number.MAX_SAFE_INTEGER;
|
|
44
|
-
let closestPoint:
|
|
46
|
+
let closestPoint: ReturnType<typeof nearestPointOnLine> | null = null;
|
|
45
47
|
// If Multipolygon, then we should find nearest polygon line and stick split to it.
|
|
46
48
|
lines.forEach((line) => {
|
|
47
49
|
const snapPoint = nearestPointOnLine(line, firstPoint);
|
|
@@ -75,7 +77,7 @@ export class SplitPolygonMode extends GeoJsonEditMode {
|
|
|
75
77
|
return nearestPt;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
getGuides(props: ModeProps<
|
|
80
|
+
getGuides(props: ModeProps<SimpleFeatureCollection>): GuideFeatureCollection {
|
|
79
81
|
const clickSequence = this.getClickSequence();
|
|
80
82
|
|
|
81
83
|
const guides: GuideFeatureCollection = {
|
|
@@ -104,7 +106,7 @@ export class SplitPolygonMode extends GeoJsonEditMode {
|
|
|
104
106
|
return guides;
|
|
105
107
|
}
|
|
106
108
|
|
|
107
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
109
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
108
110
|
const tentativeFeature = this.getTentativeGuide(props);
|
|
109
111
|
|
|
110
112
|
const selectedGeometry = this.getSelectedGeometry(props);
|
|
@@ -129,8 +131,7 @@ export class SplitPolygonMode extends GeoJsonEditMode {
|
|
|
129
131
|
coordinates: clickSequence[clickSequence.length - 1]
|
|
130
132
|
};
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
const isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry);
|
|
134
|
+
const isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry as PolygonGeometry);
|
|
134
135
|
if (clickSequence.length > 1 && tentativeFeature && !isPointInPolygon) {
|
|
135
136
|
this.resetClickSequence();
|
|
136
137
|
// @ts-expect-error narrow type
|
|
@@ -151,7 +152,7 @@ export class SplitPolygonMode extends GeoJsonEditMode {
|
|
|
151
152
|
props.onUpdateCursor('cell');
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
splitPolygon(tentativeFeature: TentativeFeature, props: ModeProps<
|
|
155
|
+
splitPolygon(tentativeFeature: TentativeFeature, props: ModeProps<SimpleFeatureCollection>) {
|
|
155
156
|
const selectedGeometry = this.getSelectedGeometry(props);
|
|
156
157
|
const featureIndex = props.selectedIndexes[0];
|
|
157
158
|
const modeConfig = props.modeConfig || {};
|
|
@@ -164,8 +165,9 @@ export class SplitPolygonMode extends GeoJsonEditMode {
|
|
|
164
165
|
}
|
|
165
166
|
|
|
166
167
|
const buffer = turfBuffer(tentativeFeature, gap, {units});
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
const updatedGeometry = turfDifference(
|
|
169
|
+
featureCollection([turfFeature(selectedGeometry as PolygonGeometry), buffer])
|
|
170
|
+
);
|
|
169
171
|
if (!updatedGeometry) {
|
|
170
172
|
// eslint-disable-next-line no-console,no-undef
|
|
171
173
|
console.warn('Canceling edit. Split Polygon erased');
|
|
@@ -9,26 +9,31 @@ import {
|
|
|
9
9
|
GuideFeatureCollection,
|
|
10
10
|
TentativeFeature
|
|
11
11
|
} from './types';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
Position,
|
|
14
|
+
Polygon,
|
|
15
|
+
Feature,
|
|
16
|
+
FeatureCollection,
|
|
17
|
+
SimpleFeatureCollection
|
|
18
|
+
} from '../utils/geojson-types';
|
|
13
19
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
14
|
-
import omit from 'lodash.omit';
|
|
15
20
|
|
|
16
21
|
export class ThreeClickPolygonMode extends GeoJsonEditMode {
|
|
17
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
22
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
18
23
|
this.addClickSequence(event);
|
|
24
|
+
|
|
25
|
+
const {modeConfig} = props;
|
|
19
26
|
const clickSequence = this.getClickSequence();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const editAction = this.getAddFeatureOrBooleanPolygonAction(
|
|
28
|
-
tentativeFeature.geometry,
|
|
29
|
-
props,
|
|
30
|
-
omit(tentativeFeature.properties, 'guideType')
|
|
27
|
+
|
|
28
|
+
if (clickSequence.length > 2) {
|
|
29
|
+
const {geometry, properties} = this.getThreeClickPolygon(
|
|
30
|
+
clickSequence[0],
|
|
31
|
+
clickSequence[1],
|
|
32
|
+
clickSequence[2],
|
|
33
|
+
modeConfig
|
|
31
34
|
);
|
|
35
|
+
|
|
36
|
+
const editAction = this.getAddFeatureOrBooleanPolygonAction(geometry, props, properties);
|
|
32
37
|
this.resetClickSequence();
|
|
33
38
|
|
|
34
39
|
if (editAction) {
|
|
@@ -46,14 +51,12 @@ export class ThreeClickPolygonMode extends GeoJsonEditMode {
|
|
|
46
51
|
features: []
|
|
47
52
|
};
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const hoveredCoord = lastPointerMoveEvent.mapCoords;
|
|
54
|
+
const coords = [
|
|
55
|
+
...clickSequence,
|
|
56
|
+
...(lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [])
|
|
57
|
+
];
|
|
55
58
|
|
|
56
|
-
if (
|
|
59
|
+
if (coords.length === 2) {
|
|
57
60
|
guides.features.push({
|
|
58
61
|
type: 'Feature',
|
|
59
62
|
properties: {
|
|
@@ -61,24 +64,18 @@ export class ThreeClickPolygonMode extends GeoJsonEditMode {
|
|
|
61
64
|
},
|
|
62
65
|
geometry: {
|
|
63
66
|
type: 'LineString',
|
|
64
|
-
coordinates: [
|
|
67
|
+
coordinates: [coords[0], coords[1]]
|
|
65
68
|
}
|
|
66
69
|
});
|
|
67
|
-
} else {
|
|
68
|
-
const polygon = this.getThreeClickPolygon(
|
|
69
|
-
clickSequence[0],
|
|
70
|
-
clickSequence[1],
|
|
71
|
-
hoveredCoord,
|
|
72
|
-
modeConfig
|
|
73
|
-
);
|
|
70
|
+
} else if (coords.length > 2) {
|
|
71
|
+
const polygon = this.getThreeClickPolygon(coords[0], coords[1], coords[2], modeConfig);
|
|
74
72
|
if (polygon) {
|
|
75
73
|
guides.features.push({
|
|
76
|
-
|
|
74
|
+
...polygon,
|
|
77
75
|
properties: {
|
|
78
76
|
...polygon.properties,
|
|
79
77
|
guideType: 'tentative'
|
|
80
|
-
}
|
|
81
|
-
geometry: polygon.geometry
|
|
78
|
+
}
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
81
|
}
|
|
@@ -91,7 +88,7 @@ export class ThreeClickPolygonMode extends GeoJsonEditMode {
|
|
|
91
88
|
coord2: Position,
|
|
92
89
|
coord3: Position,
|
|
93
90
|
modeConfig: any
|
|
94
|
-
):
|
|
91
|
+
): Feature<Polygon> | null | undefined {
|
|
95
92
|
return null;
|
|
96
93
|
}
|
|
97
94
|
|
|
@@ -5,10 +5,14 @@
|
|
|
5
5
|
import turfBearing from '@turf/bearing';
|
|
6
6
|
import turfDistance from '@turf/distance';
|
|
7
7
|
import clone from '@turf/clone';
|
|
8
|
-
import type {Feature as TurfFeature, Geometry as TurfGeometry} from '@turf/helpers';
|
|
9
8
|
import {point} from '@turf/helpers';
|
|
10
|
-
import {WebMercatorViewport} from '
|
|
11
|
-
import {
|
|
9
|
+
import {WebMercatorViewport} from '@math.gl/web-mercator';
|
|
10
|
+
import {
|
|
11
|
+
FeatureCollection,
|
|
12
|
+
Position,
|
|
13
|
+
SimpleGeometry,
|
|
14
|
+
SimpleFeatureCollection
|
|
15
|
+
} from '../utils/geojson-types';
|
|
12
16
|
import {
|
|
13
17
|
PointerMoveEvent,
|
|
14
18
|
StartDraggingEvent,
|
|
@@ -22,10 +26,10 @@ import {GeoJsonEditMode, GeoJsonEditAction} from './geojson-edit-mode';
|
|
|
22
26
|
import {ImmutableFeatureCollection} from './immutable-feature-collection';
|
|
23
27
|
|
|
24
28
|
export class TranslateMode extends GeoJsonEditMode {
|
|
25
|
-
_geometryBeforeTranslate:
|
|
29
|
+
_geometryBeforeTranslate: SimpleFeatureCollection | null | undefined;
|
|
26
30
|
_isTranslatable: boolean = undefined!;
|
|
27
31
|
|
|
28
|
-
handleDragging(event: DraggingEvent, props: ModeProps<
|
|
32
|
+
handleDragging(event: DraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
29
33
|
if (!this._isTranslatable) {
|
|
30
34
|
// Nothing to do
|
|
31
35
|
return;
|
|
@@ -55,7 +59,7 @@ export class TranslateMode extends GeoJsonEditMode {
|
|
|
55
59
|
this.updateCursor(props);
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
62
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
59
63
|
if (!this._isTranslatable) {
|
|
60
64
|
return;
|
|
61
65
|
}
|
|
@@ -64,7 +68,7 @@ export class TranslateMode extends GeoJsonEditMode {
|
|
|
64
68
|
this._geometryBeforeTranslate = this.getSelectedFeaturesAsFeatureCollection(props);
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
71
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
68
72
|
if (this._geometryBeforeTranslate) {
|
|
69
73
|
// Translate the geometry
|
|
70
74
|
const editAction = this.getTranslateAction(
|
|
@@ -95,7 +99,7 @@ export class TranslateMode extends GeoJsonEditMode {
|
|
|
95
99
|
startDragPoint: Position,
|
|
96
100
|
currentPoint: Position,
|
|
97
101
|
editType: string,
|
|
98
|
-
props: ModeProps<
|
|
102
|
+
props: ModeProps<SimpleFeatureCollection>
|
|
99
103
|
): GeoJsonEditAction | null | undefined {
|
|
100
104
|
if (!this._geometryBeforeTranslate) {
|
|
101
105
|
return null;
|
|
@@ -131,11 +135,10 @@ export class TranslateMode extends GeoJsonEditMode {
|
|
|
131
135
|
return null;
|
|
132
136
|
});
|
|
133
137
|
|
|
134
|
-
// @ts-expect-error turf types
|
|
135
138
|
updatedData = updatedData.replaceGeometry(selectedIndex, {
|
|
136
139
|
type: feature.geometry.type,
|
|
137
140
|
coordinates
|
|
138
|
-
});
|
|
141
|
+
} as SimpleGeometry);
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
} else {
|
|
@@ -146,13 +149,13 @@ export class TranslateMode extends GeoJsonEditMode {
|
|
|
146
149
|
const direction = turfBearing(p1, p2);
|
|
147
150
|
|
|
148
151
|
const movedFeatures = this._geometryBeforeTranslate.features.map((feature) =>
|
|
149
|
-
translateFromCenter(clone(feature
|
|
152
|
+
translateFromCenter(clone(feature), distanceMoved, direction)
|
|
150
153
|
);
|
|
151
154
|
|
|
152
155
|
for (let i = 0; i < selectedIndexes.length; i++) {
|
|
153
156
|
const selectedIndex = selectedIndexes[i];
|
|
154
157
|
const movedFeature = movedFeatures[i];
|
|
155
|
-
updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry
|
|
158
|
+
updatedData = updatedData.replaceGeometry(selectedIndex, movedFeature.geometry);
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
|
|
@@ -11,12 +11,18 @@ import {
|
|
|
11
11
|
GuideFeatureCollection,
|
|
12
12
|
TentativeFeature
|
|
13
13
|
} from './types';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Polygon,
|
|
16
|
+
FeatureCollection,
|
|
17
|
+
Feature,
|
|
18
|
+
Position,
|
|
19
|
+
SimpleFeatureCollection
|
|
20
|
+
} from '../utils/geojson-types';
|
|
15
21
|
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
16
22
|
import omit from 'lodash.omit';
|
|
17
23
|
|
|
18
24
|
export class TwoClickPolygonMode extends GeoJsonEditMode {
|
|
19
|
-
handleClick(event: ClickEvent, props: ModeProps<
|
|
25
|
+
handleClick(event: ClickEvent, props: ModeProps<SimpleFeatureCollection>) {
|
|
20
26
|
if (props.modeConfig && props.modeConfig.dragToDraw) {
|
|
21
27
|
// handled in drag handlers
|
|
22
28
|
return;
|
|
@@ -27,7 +33,7 @@ export class TwoClickPolygonMode extends GeoJsonEditMode {
|
|
|
27
33
|
this.checkAndFinishPolygon(props);
|
|
28
34
|
}
|
|
29
35
|
|
|
30
|
-
handleStartDragging(event: StartDraggingEvent, props: ModeProps<
|
|
36
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
31
37
|
if (!props.modeConfig || !props.modeConfig.dragToDraw) {
|
|
32
38
|
// handled in click handlers
|
|
33
39
|
return;
|
|
@@ -37,7 +43,7 @@ export class TwoClickPolygonMode extends GeoJsonEditMode {
|
|
|
37
43
|
event.cancelPan();
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
handleStopDragging(event: StopDraggingEvent, props: ModeProps<
|
|
46
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<SimpleFeatureCollection>): void {
|
|
41
47
|
if (!props.modeConfig || !props.modeConfig.dragToDraw) {
|
|
42
48
|
// handled in click handlers
|
|
43
49
|
return;
|
|
@@ -47,7 +53,7 @@ export class TwoClickPolygonMode extends GeoJsonEditMode {
|
|
|
47
53
|
this.checkAndFinishPolygon(props);
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
checkAndFinishPolygon(props: ModeProps<
|
|
56
|
+
checkAndFinishPolygon(props: ModeProps<SimpleFeatureCollection>) {
|
|
51
57
|
const clickSequence = this.getClickSequence();
|
|
52
58
|
const tentativeFeature = this.getTentativeGuide(props);
|
|
53
59
|
|
|
@@ -56,7 +62,7 @@ export class TwoClickPolygonMode extends GeoJsonEditMode {
|
|
|
56
62
|
tentativeFeature &&
|
|
57
63
|
tentativeFeature.geometry.type === 'Polygon'
|
|
58
64
|
) {
|
|
59
|
-
const feature:
|
|
65
|
+
const feature: Feature<Polygon> = {
|
|
60
66
|
type: 'Feature',
|
|
61
67
|
properties: omit(tentativeFeature.properties, 'guideType'),
|
|
62
68
|
geometry: {
|
|
@@ -110,7 +116,7 @@ export class TwoClickPolygonMode extends GeoJsonEditMode {
|
|
|
110
116
|
coord1: Position,
|
|
111
117
|
coord2: Position,
|
|
112
118
|
modeConfig: any
|
|
113
|
-
):
|
|
119
|
+
): Feature<Polygon> | null | undefined {
|
|
114
120
|
return null;
|
|
115
121
|
}
|
|
116
122
|
|
package/src/edit-modes/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Position, Point,
|
|
5
|
+
import {Position, Point, SimpleGeometry, Feature} from '../utils/geojson-types';
|
|
6
6
|
|
|
7
7
|
export type ScreenCoordinates = [number, number];
|
|
8
8
|
|
|
@@ -92,7 +92,7 @@ export type EditHandleType =
|
|
|
92
92
|
| 'scale'
|
|
93
93
|
| 'rotate';
|
|
94
94
|
|
|
95
|
-
export type EditHandleFeature =
|
|
95
|
+
export type EditHandleFeature = Feature<
|
|
96
96
|
Point,
|
|
97
97
|
{
|
|
98
98
|
guideType: 'editHandle';
|
|
@@ -103,8 +103,8 @@ export type EditHandleFeature = FeatureWithProps<
|
|
|
103
103
|
}
|
|
104
104
|
>;
|
|
105
105
|
|
|
106
|
-
export type TentativeFeature =
|
|
107
|
-
|
|
106
|
+
export type TentativeFeature = Feature<
|
|
107
|
+
SimpleGeometry,
|
|
108
108
|
{
|
|
109
109
|
guideType: 'tentative';
|
|
110
110
|
shape?: string;
|
package/src/edit-modes/utils.ts
CHANGED
|
@@ -8,23 +8,21 @@ import destination from '@turf/destination';
|
|
|
8
8
|
import bearing from '@turf/bearing';
|
|
9
9
|
import pointToLineDistance from '@turf/point-to-line-distance';
|
|
10
10
|
import {flattenEach} from '@turf/meta';
|
|
11
|
-
// import type {MultiLineString} from '@turf/helpers';
|
|
12
11
|
import {point} from '@turf/helpers';
|
|
13
12
|
import {getCoords} from '@turf/invariant';
|
|
14
|
-
import {WebMercatorViewport} from '
|
|
13
|
+
import {WebMercatorViewport} from '@math.gl/web-mercator';
|
|
15
14
|
import {Viewport, Pick, EditHandleFeature, EditHandleType, StartDraggingEvent} from './types';
|
|
16
15
|
import {
|
|
17
|
-
|
|
16
|
+
SimpleGeometry,
|
|
18
17
|
Position,
|
|
19
18
|
Point,
|
|
20
19
|
LineString,
|
|
21
20
|
Polygon,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
AnyCoordinates
|
|
21
|
+
Feature,
|
|
22
|
+
SimpleGeometryCoordinates
|
|
25
23
|
} from '../utils/geojson-types';
|
|
26
24
|
|
|
27
|
-
export type NearestPointType =
|
|
25
|
+
export type NearestPointType = Feature<Point, {dist: number; index: number}>;
|
|
28
26
|
|
|
29
27
|
export function toDeckColor(
|
|
30
28
|
color?: [number, number, number, number] | number,
|
|
@@ -119,8 +117,8 @@ export function mix(a: number, b: number, ratio: number): number {
|
|
|
119
117
|
}
|
|
120
118
|
|
|
121
119
|
export function nearestPointOnProjectedLine(
|
|
122
|
-
line:
|
|
123
|
-
inPoint:
|
|
120
|
+
line: Feature<LineString>,
|
|
121
|
+
inPoint: Feature<Point>,
|
|
124
122
|
viewport: Viewport
|
|
125
123
|
): NearestPointType {
|
|
126
124
|
const wmViewport = new WebMercatorViewport(viewport);
|
|
@@ -187,8 +185,8 @@ export function nearestPointOnProjectedLine(
|
|
|
187
185
|
}
|
|
188
186
|
|
|
189
187
|
export function nearestPointOnLine( // <G extends LineString | MultiLineString>(
|
|
190
|
-
lines:
|
|
191
|
-
inPoint:
|
|
188
|
+
lines: Feature<LineString>,
|
|
189
|
+
inPoint: Feature<Point>,
|
|
192
190
|
viewport?: Viewport
|
|
193
191
|
): NearestPointType {
|
|
194
192
|
let mercator;
|
|
@@ -204,11 +202,9 @@ export function nearestPointOnLine( // <G extends LineString | MultiLineString>(
|
|
|
204
202
|
return closestPoint;
|
|
205
203
|
}
|
|
206
204
|
|
|
207
|
-
// @ts-expect-error TODO
|
|
208
205
|
// eslint-disable-next-line max-statements, complexity
|
|
209
206
|
flattenEach(lines, (line: any) => {
|
|
210
207
|
const coords: any = getCoords(line);
|
|
211
|
-
// @ts-expect-error TODO
|
|
212
208
|
const pointCoords: any = getCoords(inPoint);
|
|
213
209
|
|
|
214
210
|
let minDist;
|
|
@@ -369,7 +365,7 @@ export function getPickedEditHandles(picks: Pick[] | null | undefined): EditHand
|
|
|
369
365
|
}
|
|
370
366
|
|
|
371
367
|
export function getEditHandlesForGeometry(
|
|
372
|
-
geometry:
|
|
368
|
+
geometry: SimpleGeometry,
|
|
373
369
|
featureIndex: number,
|
|
374
370
|
editHandleType: EditHandleType = 'existing'
|
|
375
371
|
): EditHandleFeature[] {
|
|
@@ -474,7 +470,7 @@ function getEditHandlesForCoordinates(
|
|
|
474
470
|
* @returns Updated coordinates.
|
|
475
471
|
*/
|
|
476
472
|
export function updateRectanglePosition(
|
|
477
|
-
feature:
|
|
473
|
+
feature: Feature<Polygon>,
|
|
478
474
|
editHandleIndex: number,
|
|
479
475
|
coords: Position
|
|
480
476
|
): Position[][] | null {
|
|
@@ -501,9 +497,9 @@ export function updateRectanglePosition(
|
|
|
501
497
|
* @retuns Transformed coordinates.
|
|
502
498
|
*/
|
|
503
499
|
export function mapCoords(
|
|
504
|
-
coords:
|
|
500
|
+
coords: SimpleGeometryCoordinates,
|
|
505
501
|
callback: (coords: Position) => Position
|
|
506
|
-
):
|
|
502
|
+
): SimpleGeometryCoordinates {
|
|
507
503
|
if (typeof coords[0] === 'number') {
|
|
508
504
|
if (!isNaN(coords[0]) && isFinite(coords[0])) {
|
|
509
505
|
return callback(coords as Position);
|