@deck.gl-community/editable-layers 9.0.0-alpha.1 → 9.0.2
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/LICENSE +19 -0
- package/README.md +2 -81
- package/dist/constants.js +4 -1
- package/dist/edit-modes/composite-mode.d.ts +1 -1
- package/dist/edit-modes/composite-mode.js +4 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.js +29 -24
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.js +7 -4
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.js +7 -4
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +1 -1
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +3 -0
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +1 -1
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +3 -0
- package/dist/edit-modes/draw-line-string-mode.d.ts +1 -1
- package/dist/edit-modes/draw-line-string-mode.js +19 -16
- package/dist/edit-modes/draw-point-mode.d.ts +1 -1
- package/dist/edit-modes/draw-point-mode.js +7 -4
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +1 -1
- package/dist/edit-modes/draw-polygon-by-dragging-mode.js +10 -5
- package/dist/edit-modes/draw-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/draw-polygon-mode.js +20 -16
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.js +3 -0
- package/dist/edit-modes/draw-rectangle-mode.d.ts +1 -1
- package/dist/edit-modes/draw-rectangle-mode.js +3 -0
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +1 -1
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.js +8 -5
- package/dist/edit-modes/draw-square-from-center-mode.d.ts +1 -1
- package/dist/edit-modes/draw-square-from-center-mode.js +3 -0
- package/dist/edit-modes/draw-square-mode.d.ts +1 -1
- package/dist/edit-modes/draw-square-mode.js +3 -0
- package/dist/edit-modes/duplicate-mode.d.ts +1 -1
- package/dist/edit-modes/duplicate-mode.js +3 -0
- package/dist/edit-modes/edit-mode.js +3 -1
- package/dist/edit-modes/elevation-mode.d.ts +2 -2
- package/dist/edit-modes/elevation-mode.js +8 -5
- package/dist/edit-modes/extend-line-string-mode.d.ts +1 -1
- package/dist/edit-modes/extend-line-string-mode.js +9 -6
- package/dist/edit-modes/extrude-mode.d.ts +1 -1
- package/dist/edit-modes/extrude-mode.js +10 -7
- package/dist/edit-modes/geojson-edit-mode.d.ts +1 -1
- package/dist/edit-modes/geojson-edit-mode.js +18 -15
- package/dist/edit-modes/immutable-feature-collection.d.ts +2 -1
- package/dist/edit-modes/immutable-feature-collection.js +25 -20
- package/dist/edit-modes/measure-angle-mode.d.ts +1 -1
- package/dist/edit-modes/measure-angle-mode.js +8 -8
- package/dist/edit-modes/measure-area-mode.d.ts +1 -1
- package/dist/edit-modes/measure-area-mode.js +7 -5
- package/dist/edit-modes/measure-distance-mode.d.ts +1 -1
- package/dist/edit-modes/measure-distance-mode.js +17 -14
- package/dist/edit-modes/modify-mode.d.ts +1 -1
- package/dist/edit-modes/modify-mode.js +17 -14
- package/dist/edit-modes/resize-circle-mode.d.ts +2 -2
- package/dist/edit-modes/resize-circle-mode.js +3 -1
- package/dist/edit-modes/rotate-mode.d.ts +1 -1
- package/dist/edit-modes/rotate-mode.js +8 -5
- package/dist/edit-modes/scale-mode.d.ts +1 -1
- package/dist/edit-modes/scale-mode.js +8 -5
- package/dist/edit-modes/snappable-mode.d.ts +1 -1
- package/dist/edit-modes/snappable-mode.js +8 -5
- package/dist/edit-modes/split-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/split-polygon-mode.js +12 -9
- package/dist/edit-modes/three-click-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/three-click-polygon-mode.js +9 -6
- package/dist/edit-modes/transform-mode.d.ts +1 -1
- package/dist/edit-modes/transform-mode.js +4 -1
- package/dist/edit-modes/translate-mode.d.ts +1 -1
- package/dist/edit-modes/translate-mode.js +7 -4
- package/dist/edit-modes/two-click-polygon-mode.d.ts +1 -1
- package/dist/edit-modes/two-click-polygon-mode.js +9 -6
- package/dist/edit-modes/types.d.ts +1 -1
- package/dist/edit-modes/types.js +3 -0
- package/dist/edit-modes/utils.d.ts +1 -1
- package/dist/edit-modes/utils.js +21 -19
- package/dist/edit-modes/view-mode.js +3 -0
- package/dist/editable-layers/editable-geojson-layer.d.ts +4 -4
- package/dist/editable-layers/editable-geojson-layer.js +27 -26
- package/dist/editable-layers/editable-h3-cluster-layer.d.ts +2 -2
- package/dist/editable-layers/editable-h3-cluster-layer.js +6 -3
- package/dist/editable-layers/editable-layer.d.ts +5 -5
- package/dist/editable-layers/editable-layer.js +18 -15
- package/dist/editable-layers/editable-path-layer.d.ts +1 -1
- package/dist/editable-layers/editable-path-layer.js +10 -7
- package/dist/editable-layers/elevated-edit-handle-layer.d.ts +1 -1
- package/dist/editable-layers/elevated-edit-handle-layer.js +6 -3
- package/dist/editable-layers/junction-scatterplot-layer.d.ts +2 -2
- package/dist/editable-layers/junction-scatterplot-layer.js +10 -7
- package/dist/editable-layers/selection-layer.d.ts +1 -1
- package/dist/editable-layers/selection-layer.js +5 -2
- package/dist/index.cjs +65 -537
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +19 -20
- package/dist/index.js +20 -18
- package/dist/lib/constants.js +3 -0
- package/dist/lib/deck-renderer/deck-cache.d.ts +1 -1
- package/dist/lib/deck-renderer/deck-cache.js +1 -1
- package/dist/lib/deck-renderer/deck-drawer.d.ts +2 -3
- package/dist/lib/deck-renderer/deck-drawer.js +12 -12
- package/dist/lib/feature.d.ts +4 -4
- package/dist/lib/feature.js +4 -1
- package/dist/lib/layer-mouse-event.d.ts +2 -2
- package/dist/lib/layer-mouse-event.js +4 -1
- package/dist/lib/layers/junctions-layer.d.ts +4 -4
- package/dist/lib/layers/junctions-layer.js +10 -7
- package/dist/lib/layers/segments-layer.d.ts +4 -4
- package/dist/lib/layers/segments-layer.js +11 -8
- package/dist/lib/layers/texts-layer.d.ts +3 -3
- package/dist/lib/layers/texts-layer.js +8 -5
- package/dist/lib/math.d.ts +1 -1
- package/dist/lib/math.js +3 -0
- package/dist/lib/{nebula.d.ts → nebula-core.d.ts} +2 -2
- package/dist/lib/{nebula.js → nebula-core.js} +7 -4
- package/dist/lib/nebula-layer.d.ts +2 -2
- package/dist/lib/nebula-layer.js +4 -1
- package/dist/lib/style.js +5 -2
- package/dist/mode-handlers/composite-mode-handler.d.ts +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.js +13 -10
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +3 -0
- package/dist/mode-handlers/draw-circle-from-center-handler.js +3 -0
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +3 -0
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +5 -2
- package/dist/mode-handlers/draw-line-string-handler.js +7 -4
- package/dist/mode-handlers/draw-point-handler.js +4 -1
- package/dist/mode-handlers/draw-polygon-handler.d.ts +1 -1
- package/dist/mode-handlers/draw-polygon-handler.js +10 -7
- package/dist/mode-handlers/draw-rectangle-handler.js +3 -0
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +11 -8
- package/dist/mode-handlers/duplicate-handler.js +3 -0
- package/dist/mode-handlers/elevation-handler.d.ts +2 -2
- package/dist/mode-handlers/elevation-handler.js +8 -5
- package/dist/mode-handlers/extrude-handler.js +10 -7
- package/dist/mode-handlers/mode-handler.d.ts +1 -1
- package/dist/mode-handlers/mode-handler.js +17 -14
- package/dist/mode-handlers/modify-handler.d.ts +2 -2
- package/dist/mode-handlers/modify-handler.js +18 -15
- package/dist/mode-handlers/rotate-handler.d.ts +1 -1
- package/dist/mode-handlers/rotate-handler.js +4 -1
- package/dist/mode-handlers/scale-handler.d.ts +1 -1
- package/dist/mode-handlers/scale-handler.js +5 -2
- package/dist/mode-handlers/snappable-handler.d.ts +1 -1
- package/dist/mode-handlers/snappable-handler.js +6 -3
- package/dist/mode-handlers/split-polygon-handler.js +11 -8
- package/dist/mode-handlers/three-click-polygon-handler.js +3 -0
- package/dist/mode-handlers/translate-handler.d.ts +1 -1
- package/dist/mode-handlers/translate-handler.js +4 -1
- package/dist/mode-handlers/two-click-polygon-handler.js +3 -0
- package/dist/mode-handlers/view-handler.d.ts +1 -1
- package/dist/mode-handlers/view-handler.js +3 -0
- package/dist/shaderlib/color/color.d.ts +7 -6
- package/dist/shaderlib/color/color.js +7 -4
- package/dist/shaderlib/utils/utils.d.ts +2 -2
- package/dist/shaderlib/utils/utils.js +5 -2
- package/dist/{curve-utils.js → utils/curve-utils.js} +7 -4
- package/dist/{geojson-types.d.ts → utils/geojson-types.d.ts} +2 -25
- package/dist/utils/geojson-types.js +4 -0
- package/dist/{memoize.d.ts → utils/memoize.d.ts} +1 -1
- package/dist/{memoize.js → utils/memoize.js} +4 -1
- package/dist/{translateFromCenter.js → utils/translate-from-center.js} +4 -1
- package/dist/utils/types.js +4 -0
- package/dist/{utils.js → utils/utils.js} +8 -6
- package/package.json +10 -10
- package/src/constants.ts +5 -1
- package/src/edit-modes/composite-mode.ts +9 -5
- package/src/edit-modes/draw-90degree-polygon-mode.ts +38 -34
- package/src/edit-modes/draw-circle-by-diameter-mode.ts +16 -12
- package/src/edit-modes/draw-circle-from-center-mode.ts +15 -11
- package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +8 -4
- package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +9 -5
- package/src/edit-modes/draw-line-string-mode.ts +29 -25
- package/src/edit-modes/draw-point-mode.ts +13 -9
- package/src/edit-modes/draw-polygon-by-dragging-mode.ts +16 -16
- package/src/edit-modes/draw-polygon-mode.ts +28 -23
- package/src/edit-modes/draw-rectangle-from-center-mode.ts +6 -2
- package/src/edit-modes/draw-rectangle-mode.ts +6 -2
- package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +12 -8
- package/src/edit-modes/draw-square-from-center-mode.ts +7 -3
- package/src/edit-modes/draw-square-mode.ts +7 -3
- package/src/edit-modes/duplicate-mode.ts +7 -3
- package/src/edit-modes/edit-mode.ts +5 -1
- package/src/edit-modes/elevation-mode.ts +13 -9
- package/src/edit-modes/extend-line-string-mode.ts +16 -12
- package/src/edit-modes/extrude-mode.ts +22 -18
- package/src/edit-modes/geojson-edit-mode.ts +37 -33
- package/src/edit-modes/immutable-feature-collection.ts +28 -22
- package/src/edit-modes/measure-angle-mode.ts +66 -59
- package/src/edit-modes/measure-area-mode.ts +13 -10
- package/src/edit-modes/measure-distance-mode.ts +37 -33
- package/src/edit-modes/modify-mode.ts +36 -32
- package/src/edit-modes/resize-circle-mode.ts +8 -5
- package/src/edit-modes/rotate-mode.ts +22 -18
- package/src/edit-modes/scale-mode.ts +29 -23
- package/src/edit-modes/snappable-mode.ts +19 -15
- package/src/edit-modes/split-polygon-mode.ts +25 -21
- package/src/edit-modes/three-click-polygon-mode.ts +15 -11
- package/src/edit-modes/transform-mode.ts +15 -11
- package/src/edit-modes/translate-mode.ts +15 -11
- package/src/edit-modes/two-click-polygon-mode.ts +15 -11
- package/src/edit-modes/types.ts +5 -1
- package/src/edit-modes/utils.ts +33 -30
- package/src/edit-modes/view-mode.ts +5 -1
- package/src/editable-layers/editable-geojson-layer.ts +44 -41
- package/src/editable-layers/editable-h3-cluster-layer.ts +17 -14
- package/src/editable-layers/editable-layer.ts +42 -32
- package/src/editable-layers/editable-path-layer.ts +12 -8
- package/src/editable-layers/elevated-edit-handle-layer.ts +11 -7
- package/src/editable-layers/junction-scatterplot-layer.ts +15 -11
- package/src/editable-layers/selection-layer.ts +11 -7
- package/src/index.ts +68 -65
- package/src/lib/constants.ts +4 -0
- package/src/lib/deck-renderer/deck-cache.ts +1 -1
- package/src/lib/deck-renderer/deck-drawer.ts +28 -28
- package/src/lib/feature.ts +7 -3
- package/src/lib/layer-mouse-event.ts +7 -6
- package/src/lib/layers/junctions-layer.ts +14 -10
- package/src/lib/layers/segments-layer.ts +24 -20
- package/src/lib/layers/texts-layer.ts +18 -14
- package/src/lib/math.ts +5 -1
- package/src/lib/{nebula.ts → nebula-core.ts} +8 -4
- package/src/lib/nebula-layer.ts +9 -5
- package/src/lib/style.ts +6 -2
- package/src/mode-handlers/composite-mode-handler.ts +6 -6
- package/src/mode-handlers/draw-90degree-polygon-handler.ts +22 -18
- package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +10 -6
- package/src/mode-handlers/draw-circle-from-center-handler.ts +10 -6
- package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +9 -5
- package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +12 -8
- package/src/mode-handlers/draw-line-string-handler.ts +12 -8
- package/src/mode-handlers/draw-point-handler.ts +9 -5
- package/src/mode-handlers/draw-polygon-handler.ts +16 -12
- package/src/mode-handlers/draw-rectangle-handler.ts +8 -4
- package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +17 -13
- package/src/mode-handlers/duplicate-handler.ts +8 -4
- package/src/mode-handlers/elevation-handler.ts +14 -10
- package/src/mode-handlers/extrude-handler.ts +15 -11
- package/src/mode-handlers/mode-handler.ts +26 -28
- package/src/mode-handlers/modify-handler.ts +29 -25
- package/src/mode-handlers/rotate-handler.ts +13 -17
- package/src/mode-handlers/scale-handler.ts +13 -13
- package/src/mode-handlers/snappable-handler.ts +28 -24
- package/src/mode-handlers/split-polygon-handler.ts +22 -18
- package/src/mode-handlers/three-click-polygon-handler.ts +6 -2
- package/src/mode-handlers/translate-handler.ts +12 -8
- package/src/mode-handlers/two-click-polygon-handler.ts +6 -2
- package/src/mode-handlers/view-handler.ts +7 -3
- package/src/shaderlib/color/color.ts +10 -5
- package/src/shaderlib/utils/utils.ts +6 -2
- package/src/{curve-utils.ts → utils/curve-utils.ts} +11 -7
- package/src/{geojson-types.ts → utils/geojson-types.ts} +16 -31
- package/src/{memoize.ts → utils/memoize.ts} +5 -1
- package/src/{translateFromCenter.ts → utils/translate-from-center.ts} +8 -4
- package/src/{types.ts → utils/types.ts} +4 -0
- package/src/{utils.ts → utils/utils.ts} +14 -11
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.d.ts +0 -4
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.js +0 -55
- package/dist/editable-layers/path-marker-layer/create-path-markers.d.ts +0 -16
- package/dist/editable-layers/path-marker-layer/create-path-markers.js +0 -75
- package/dist/editable-layers/path-marker-layer/path-marker-layer.d.ts +0 -40
- package/dist/editable-layers/path-marker-layer/path-marker-layer.js +0 -121
- package/dist/editable-layers/path-marker-layer/polyline.d.ts +0 -18
- package/dist/editable-layers/path-marker-layer/polyline.js +0 -37
- package/dist/editable-layers/path-outline-layer/path-outline-layer.d.ts +0 -26
- package/dist/editable-layers/path-outline-layer/path-outline-layer.js +0 -106
- package/dist/geojson-types.js +0 -2
- package/dist/shaderlib/outline/outline.d.ts +0 -8
- package/dist/shaderlib/outline/outline.js +0 -97
- package/dist/types.js +0 -1
- package/src/editable-layers/path-marker-layer/arrow-2d-geometry.ts +0 -61
- package/src/editable-layers/path-marker-layer/create-path-markers.ts +0 -107
- package/src/editable-layers/path-marker-layer/path-marker-layer.ts +0 -179
- package/src/editable-layers/path-marker-layer/polyline.ts +0 -40
- package/src/editable-layers/path-outline-layer/path-outline-layer.ts +0 -147
- package/src/shaderlib/outline/outline.ts +0 -101
- /package/dist/{curve-utils.d.ts → utils/curve-utils.d.ts} +0 -0
- /package/dist/{translateFromCenter.d.ts → utils/translate-from-center.d.ts} +0 -0
- /package/dist/{types.d.ts → utils/types.d.ts} +0 -0
- /package/dist/{utils.d.ts → utils/utils.d.ts} +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { ModeHandler } from './mode-handler';
|
|
2
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
3
6
|
export class DrawLineStringHandler extends ModeHandler {
|
|
@@ -32,8 +35,8 @@ export class DrawLineStringHandler extends ModeHandler {
|
|
|
32
35
|
featureIndexes: [featureIndex],
|
|
33
36
|
editContext: {
|
|
34
37
|
positionIndexes,
|
|
35
|
-
position: event.mapCoords
|
|
36
|
-
}
|
|
38
|
+
position: event.mapCoords
|
|
39
|
+
}
|
|
37
40
|
};
|
|
38
41
|
this.resetClickSequence();
|
|
39
42
|
}
|
|
@@ -74,8 +77,8 @@ export class DrawLineStringHandler extends ModeHandler {
|
|
|
74
77
|
properties: {},
|
|
75
78
|
geometry: {
|
|
76
79
|
type: 'LineString',
|
|
77
|
-
coordinates: [startPosition, mapCoords]
|
|
78
|
-
}
|
|
80
|
+
coordinates: [startPosition, mapCoords]
|
|
81
|
+
}
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
84
|
return result;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { ModeHandler } from './mode-handler';
|
|
2
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
3
6
|
export class DrawPointHandler extends ModeHandler {
|
|
4
7
|
handleClick({ mapCoords }) {
|
|
5
8
|
const geometry = {
|
|
6
9
|
type: 'Point',
|
|
7
|
-
coordinates: mapCoords
|
|
10
|
+
coordinates: mapCoords
|
|
8
11
|
};
|
|
9
12
|
return this.getAddFeatureAction(geometry);
|
|
10
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Position } from '../geojson-types';
|
|
1
|
+
import { Position } from '../utils/geojson-types';
|
|
2
2
|
import { ClickEvent, PointerMoveEvent } from '../edit-modes/types';
|
|
3
3
|
import { EditAction, EditHandle, ModeHandler } from './mode-handler';
|
|
4
4
|
export declare class DrawPolygonHandler extends ModeHandler {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry } from './mode-handler';
|
|
2
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
3
6
|
export class DrawPolygonHandler extends ModeHandler {
|
|
4
7
|
getEditHandles(picks, mapCoords) {
|
|
@@ -39,7 +42,7 @@ export class DrawPolygonHandler extends ModeHandler {
|
|
|
39
42
|
// Remove the hovered position
|
|
40
43
|
const polygonToAdd = {
|
|
41
44
|
type: 'Polygon',
|
|
42
|
-
coordinates: [[...polygon.coordinates[0].slice(0, -2), polygon.coordinates[0][0]]]
|
|
45
|
+
coordinates: [[...polygon.coordinates[0].slice(0, -2), polygon.coordinates[0][0]]]
|
|
43
46
|
};
|
|
44
47
|
this.resetClickSequence();
|
|
45
48
|
this._setTentativeFeature(null);
|
|
@@ -55,7 +58,7 @@ export class DrawPolygonHandler extends ModeHandler {
|
|
|
55
58
|
pointerDownPicks: null,
|
|
56
59
|
pointerDownScreenCoords: null,
|
|
57
60
|
pointerDownMapCoords: null,
|
|
58
|
-
sourceEvent: null
|
|
61
|
+
sourceEvent: null
|
|
59
62
|
};
|
|
60
63
|
this.handlePointerMove(fakePointerMoveEvent);
|
|
61
64
|
return editAction;
|
|
@@ -73,8 +76,8 @@ export class DrawPolygonHandler extends ModeHandler {
|
|
|
73
76
|
type: 'Feature',
|
|
74
77
|
geometry: {
|
|
75
78
|
type: 'LineString',
|
|
76
|
-
coordinates: [...clickSequence, mapCoords]
|
|
77
|
-
}
|
|
79
|
+
coordinates: [...clickSequence, mapCoords]
|
|
80
|
+
}
|
|
78
81
|
});
|
|
79
82
|
}
|
|
80
83
|
else {
|
|
@@ -83,8 +86,8 @@ export class DrawPolygonHandler extends ModeHandler {
|
|
|
83
86
|
type: 'Feature',
|
|
84
87
|
geometry: {
|
|
85
88
|
type: 'Polygon',
|
|
86
|
-
coordinates: [[...clickSequence, mapCoords, clickSequence[0]]]
|
|
87
|
-
}
|
|
89
|
+
coordinates: [[...clickSequence, mapCoords, clickSequence[0]]]
|
|
90
|
+
}
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
93
|
return result;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
5
|
import { TwoClickPolygonHandler } from './two-click-polygon-handler';
|
|
3
6
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { generatePointsParallelToLinePoints } from '../utils/utils';
|
|
2
5
|
import { ThreeClickPolygonHandler } from './three-click-polygon-handler';
|
|
3
6
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
4
7
|
export class DrawRectangleUsingThreePointsHandler extends ThreeClickPolygonHandler {
|
|
@@ -15,14 +18,14 @@ export class DrawRectangleUsingThreePointsHandler extends ThreeClickPolygonHandl
|
|
|
15
18
|
type: 'Feature',
|
|
16
19
|
geometry: {
|
|
17
20
|
type: 'LineString',
|
|
18
|
-
coordinates: [clickSequence[0], mapCoords]
|
|
19
|
-
}
|
|
21
|
+
coordinates: [clickSequence[0], mapCoords]
|
|
22
|
+
}
|
|
20
23
|
});
|
|
21
24
|
}
|
|
22
25
|
else if (clickSequence.length === 2) {
|
|
23
26
|
const lineString = {
|
|
24
27
|
type: 'LineString',
|
|
25
|
-
coordinates: clickSequence
|
|
28
|
+
coordinates: clickSequence
|
|
26
29
|
};
|
|
27
30
|
const [p1, p2] = clickSequence;
|
|
28
31
|
const [p3, p4] = generatePointsParallelToLinePoints(p1, p2, mapCoords);
|
|
@@ -38,10 +41,10 @@ export class DrawRectangleUsingThreePointsHandler extends ThreeClickPolygonHandl
|
|
|
38
41
|
...lineString.coordinates,
|
|
39
42
|
p3,
|
|
40
43
|
p4,
|
|
41
|
-
p1
|
|
42
|
-
]
|
|
43
|
-
]
|
|
44
|
-
}
|
|
44
|
+
p1
|
|
45
|
+
]
|
|
46
|
+
]
|
|
47
|
+
}
|
|
45
48
|
});
|
|
46
49
|
}
|
|
47
50
|
return result;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { TranslateHandler } from './translate-handler';
|
|
2
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
3
6
|
export class DuplicateHandler extends TranslateHandler {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Position } from '../geojson-types';
|
|
1
|
+
import { Position } from '../utils/geojson-types';
|
|
2
2
|
import { PointerMoveEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
3
3
|
import { EditAction } from './mode-handler';
|
|
4
4
|
import { ModifyHandler } from './modify-handler';
|
|
@@ -12,7 +12,7 @@ export declare class ElevationHandler extends ModifyHandler {
|
|
|
12
12
|
getCursor(params: {
|
|
13
13
|
isDragging: boolean;
|
|
14
14
|
}): string;
|
|
15
|
-
static calculateElevationChangeWithViewport(viewport: any, { pointerDownScreenCoords, screenCoords
|
|
15
|
+
static calculateElevationChangeWithViewport(viewport: any, { pointerDownScreenCoords, screenCoords }: {
|
|
16
16
|
pointerDownScreenCoords: Position;
|
|
17
17
|
screenCoords: Position;
|
|
18
18
|
}): number;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { getPickedEditHandle } from './mode-handler';
|
|
2
5
|
import { ModifyHandler } from './modify-handler';
|
|
3
|
-
function defaultCalculateElevationChange({ pointerDownScreenCoords, screenCoords
|
|
6
|
+
function defaultCalculateElevationChange({ pointerDownScreenCoords, screenCoords }) {
|
|
4
7
|
return 10 * (pointerDownScreenCoords[1] - screenCoords[1]);
|
|
5
8
|
}
|
|
6
9
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
@@ -9,18 +12,18 @@ export class ElevationHandler extends ModifyHandler {
|
|
|
9
12
|
if (!event.pointerDownScreenCoords) {
|
|
10
13
|
return event;
|
|
11
14
|
}
|
|
12
|
-
const { minElevation = 0, maxElevation = 20000, calculateElevationChange = defaultCalculateElevationChange
|
|
15
|
+
const { minElevation = 0, maxElevation = 20000, calculateElevationChange = defaultCalculateElevationChange } = this._modeConfig || {};
|
|
13
16
|
// $FlowFixMe - really, I know it has something at index 2
|
|
14
17
|
let elevation = position.length === 3 ? position[2] : 0;
|
|
15
18
|
// calculateElevationChange is configurable becase (at this time) modes are not aware of the viewport
|
|
16
19
|
elevation += calculateElevationChange({
|
|
17
20
|
pointerDownScreenCoords: event.pointerDownScreenCoords,
|
|
18
|
-
screenCoords: event.screenCoords
|
|
21
|
+
screenCoords: event.screenCoords
|
|
19
22
|
});
|
|
20
23
|
elevation = Math.min(elevation, maxElevation);
|
|
21
24
|
elevation = Math.max(elevation, minElevation);
|
|
22
25
|
return Object.assign({}, event, {
|
|
23
|
-
mapCoords: [position[0], position[1], elevation]
|
|
26
|
+
mapCoords: [position[0], position[1], elevation]
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
handlePointerMove(event) {
|
|
@@ -40,7 +43,7 @@ export class ElevationHandler extends ModifyHandler {
|
|
|
40
43
|
}
|
|
41
44
|
return cursor;
|
|
42
45
|
}
|
|
43
|
-
static calculateElevationChangeWithViewport(viewport, { pointerDownScreenCoords, screenCoords
|
|
46
|
+
static calculateElevationChangeWithViewport(viewport, { pointerDownScreenCoords, screenCoords }) {
|
|
44
47
|
// Source: https://gis.stackexchange.com/a/127949/111804
|
|
45
48
|
const metersPerPixel = (156543.03392 * Math.cos((viewport.latitude * Math.PI) / 180)) / Math.pow(2, viewport.zoom);
|
|
46
49
|
return (metersPerPixel * (pointerDownScreenCoords[1] - screenCoords[1])) / 2;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import bearing from '@turf/bearing';
|
|
2
|
-
import { generatePointsParallelToLinePoints } from '../utils';
|
|
5
|
+
import { generatePointsParallelToLinePoints } from '../utils/utils';
|
|
3
6
|
import { getPickedEditHandle } from './mode-handler';
|
|
4
7
|
import { ModifyHandler } from './modify-handler';
|
|
5
8
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
@@ -30,8 +33,8 @@ export class ExtrudeHandler extends ModifyHandler {
|
|
|
30
33
|
featureIndexes: [editHandle.featureIndex],
|
|
31
34
|
editContext: {
|
|
32
35
|
positionIndexes: this.nextPositionIndexes(editHandle.positionIndexes, size),
|
|
33
|
-
position: p3
|
|
34
|
-
}
|
|
36
|
+
position: p3
|
|
37
|
+
}
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
}
|
|
@@ -63,8 +66,8 @@ export class ExtrudeHandler extends ModifyHandler {
|
|
|
63
66
|
featureIndexes: [editHandle.featureIndex],
|
|
64
67
|
editContext: {
|
|
65
68
|
positionIndexes: editHandle.positionIndexes,
|
|
66
|
-
position: p1
|
|
67
|
-
}
|
|
69
|
+
position: p1
|
|
70
|
+
}
|
|
68
71
|
};
|
|
69
72
|
}
|
|
70
73
|
}
|
|
@@ -95,8 +98,8 @@ export class ExtrudeHandler extends ModifyHandler {
|
|
|
95
98
|
featureIndexes: [editHandle.featureIndex],
|
|
96
99
|
editContext: {
|
|
97
100
|
positionIndexes: editHandle.positionIndexes,
|
|
98
|
-
position: p3
|
|
99
|
-
}
|
|
101
|
+
position: p3
|
|
102
|
+
}
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeatureCollection, Feature, Polygon, Geometry, Position } from '../geojson-types';
|
|
1
|
+
import { FeatureCollection, Feature, Polygon, Geometry, Position } from '../utils/geojson-types';
|
|
2
2
|
import { ClickEvent, Pick, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
3
3
|
import { ImmutableFeatureCollection } from '../edit-modes/immutable-feature-collection';
|
|
4
4
|
export type EditHandleType = 'existing' | 'intermediate' | 'snap';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
2
5
|
import turfUnion from '@turf/union';
|
|
3
6
|
import turfDifference from '@turf/difference';
|
|
@@ -39,7 +42,7 @@ export class ModeHandler {
|
|
|
39
42
|
const selectedFeatures = this.getSelectedFeatureIndexes().map((selectedIndex) => features[selectedIndex]);
|
|
40
43
|
return {
|
|
41
44
|
type: 'FeatureCollection',
|
|
42
|
-
features: selectedFeatures
|
|
45
|
+
features: selectedFeatures
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
48
|
setFeatureCollection(featureCollection) {
|
|
@@ -107,7 +110,7 @@ export class ModeHandler {
|
|
|
107
110
|
.addFeature({
|
|
108
111
|
type: 'Feature',
|
|
109
112
|
properties: {},
|
|
110
|
-
geometry: geometryAsAny
|
|
113
|
+
geometry: geometryAsAny
|
|
111
114
|
})
|
|
112
115
|
.getObject();
|
|
113
116
|
return {
|
|
@@ -115,8 +118,8 @@ export class ModeHandler {
|
|
|
115
118
|
editType: 'addFeature',
|
|
116
119
|
featureIndexes: [updatedData.features.length - 1],
|
|
117
120
|
editContext: {
|
|
118
|
-
featureIndexes: [updatedData.features.length - 1]
|
|
119
|
-
}
|
|
121
|
+
featureIndexes: [updatedData.features.length - 1]
|
|
122
|
+
}
|
|
120
123
|
};
|
|
121
124
|
}
|
|
122
125
|
getAddManyFeaturesAction(featureCollection) {
|
|
@@ -130,7 +133,7 @@ export class ModeHandler {
|
|
|
130
133
|
updatedData = updatedData.addFeature({
|
|
131
134
|
type: 'Feature',
|
|
132
135
|
properties,
|
|
133
|
-
geometry: geometryAsAny
|
|
136
|
+
geometry: geometryAsAny
|
|
134
137
|
});
|
|
135
138
|
updatedIndexes.push(initialIndex + updatedIndexes.length);
|
|
136
139
|
}
|
|
@@ -139,8 +142,8 @@ export class ModeHandler {
|
|
|
139
142
|
editType: 'addFeature',
|
|
140
143
|
featureIndexes: updatedIndexes,
|
|
141
144
|
editContext: {
|
|
142
|
-
featureIndexes: updatedIndexes
|
|
143
|
-
}
|
|
145
|
+
featureIndexes: updatedIndexes
|
|
146
|
+
}
|
|
144
147
|
};
|
|
145
148
|
}
|
|
146
149
|
getAddFeatureOrBooleanPolygonAction(geometry) {
|
|
@@ -156,7 +159,7 @@ export class ModeHandler {
|
|
|
156
159
|
}
|
|
157
160
|
const feature = {
|
|
158
161
|
type: 'Feature',
|
|
159
|
-
geometry
|
|
162
|
+
geometry
|
|
160
163
|
};
|
|
161
164
|
let updatedGeometry;
|
|
162
165
|
if (modeConfig.booleanOperation === 'union') {
|
|
@@ -190,8 +193,8 @@ export class ModeHandler {
|
|
|
190
193
|
editType: 'unionGeometry',
|
|
191
194
|
featureIndexes: [featureIndex],
|
|
192
195
|
editContext: {
|
|
193
|
-
featureIndexes: [featureIndex]
|
|
194
|
-
}
|
|
196
|
+
featureIndexes: [featureIndex]
|
|
197
|
+
}
|
|
195
198
|
};
|
|
196
199
|
return editAction;
|
|
197
200
|
}
|
|
@@ -221,7 +224,7 @@ export function getPickedEditHandle(picks) {
|
|
|
221
224
|
export function getIntermediatePosition(position1, position2) {
|
|
222
225
|
const intermediatePosition = [
|
|
223
226
|
(position1[0] + position2[0]) / 2.0,
|
|
224
|
-
(position1[1] + position2[1]) / 2.0
|
|
227
|
+
(position1[1] + position2[1]) / 2.0
|
|
225
228
|
];
|
|
226
229
|
return intermediatePosition;
|
|
227
230
|
}
|
|
@@ -235,8 +238,8 @@ export function getEditHandlesForGeometry(geometry, featureIndex, editHandleType
|
|
|
235
238
|
position: geometry.coordinates,
|
|
236
239
|
positionIndexes: [],
|
|
237
240
|
featureIndex,
|
|
238
|
-
type: editHandleType
|
|
239
|
-
}
|
|
241
|
+
type: editHandleType
|
|
242
|
+
}
|
|
240
243
|
];
|
|
241
244
|
break;
|
|
242
245
|
case 'MultiPoint':
|
|
@@ -279,7 +282,7 @@ function getEditHandlesForCoordinates(coordinates, positionIndexPrefix, featureI
|
|
|
279
282
|
position,
|
|
280
283
|
positionIndexes: [...positionIndexPrefix, i],
|
|
281
284
|
featureIndex,
|
|
282
|
-
type: editHandleType
|
|
285
|
+
type: editHandleType
|
|
283
286
|
});
|
|
284
287
|
}
|
|
285
288
|
return editHandles;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Position, FeatureOf, Point, LineString } from '../geojson-types';
|
|
2
|
-
import { NearestPointType } from '../utils';
|
|
1
|
+
import { Position, FeatureOf, Point, LineString } from '../utils/geojson-types';
|
|
2
|
+
import { NearestPointType } from '../utils/utils';
|
|
3
3
|
import { ClickEvent, PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
4
4
|
import { EditAction, EditHandle, ModeHandler } from './mode-handler';
|
|
5
5
|
export declare class ModifyHandler extends ModeHandler {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
2
5
|
import { point, lineString as toLineString } from '@turf/helpers';
|
|
3
|
-
import { recursivelyTraverseNestedArrays, nearestPointOnProjectedLine
|
|
4
|
-
import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry
|
|
6
|
+
import { recursivelyTraverseNestedArrays, nearestPointOnProjectedLine } from '../utils/utils';
|
|
7
|
+
import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry } from './mode-handler';
|
|
5
8
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
6
9
|
export class ModifyHandler extends ModeHandler {
|
|
7
10
|
_lastPointerMovePicks;
|
|
@@ -43,15 +46,15 @@ export class ModifyHandler extends ModeHandler {
|
|
|
43
46
|
});
|
|
44
47
|
// tack on the lone intermediate point to the set of handles
|
|
45
48
|
if (intermediatePoint) {
|
|
46
|
-
const { geometry: { coordinates: position }, properties: { index }
|
|
49
|
+
const { geometry: { coordinates: position }, properties: { index } } = intermediatePoint;
|
|
47
50
|
handles = [
|
|
48
51
|
...handles,
|
|
49
52
|
{
|
|
50
53
|
position,
|
|
51
54
|
positionIndexes: [...positionIndexPrefix, index + 1],
|
|
52
55
|
featureIndex: featureAsPick.index,
|
|
53
|
-
type: 'intermediate'
|
|
54
|
-
}
|
|
56
|
+
type: 'intermediate'
|
|
57
|
+
}
|
|
55
58
|
];
|
|
56
59
|
}
|
|
57
60
|
}
|
|
@@ -94,8 +97,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
94
97
|
featureIndexes: [clickedEditHandle.featureIndex],
|
|
95
98
|
editContext: {
|
|
96
99
|
positionIndexes: clickedEditHandle.positionIndexes,
|
|
97
|
-
position: clickedEditHandle.position
|
|
98
|
-
}
|
|
100
|
+
position: clickedEditHandle.position
|
|
101
|
+
}
|
|
99
102
|
};
|
|
100
103
|
}
|
|
101
104
|
}
|
|
@@ -110,8 +113,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
110
113
|
featureIndexes: [clickedEditHandle.featureIndex],
|
|
111
114
|
editContext: {
|
|
112
115
|
positionIndexes: clickedEditHandle.positionIndexes,
|
|
113
|
-
position: clickedEditHandle.position
|
|
114
|
-
}
|
|
116
|
+
position: clickedEditHandle.position
|
|
117
|
+
}
|
|
115
118
|
};
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -132,8 +135,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
132
135
|
featureIndexes: [editHandle.featureIndex],
|
|
133
136
|
editContext: {
|
|
134
137
|
positionIndexes: editHandle.positionIndexes,
|
|
135
|
-
position: event.mapCoords
|
|
136
|
-
}
|
|
138
|
+
position: event.mapCoords
|
|
139
|
+
}
|
|
137
140
|
};
|
|
138
141
|
}
|
|
139
142
|
// Cancel map panning if pointer went down on an edit handle
|
|
@@ -154,8 +157,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
154
157
|
featureIndexes: [editHandle.featureIndex],
|
|
155
158
|
editContext: {
|
|
156
159
|
positionIndexes: editHandle.positionIndexes,
|
|
157
|
-
position: event.mapCoords
|
|
158
|
-
}
|
|
160
|
+
position: event.mapCoords
|
|
161
|
+
}
|
|
159
162
|
};
|
|
160
163
|
}
|
|
161
164
|
return editAction;
|
|
@@ -174,8 +177,8 @@ export class ModifyHandler extends ModeHandler {
|
|
|
174
177
|
featureIndexes: [editHandle.featureIndex],
|
|
175
178
|
editContext: {
|
|
176
179
|
positionIndexes: editHandle.positionIndexes,
|
|
177
|
-
position: event.mapCoords
|
|
178
|
-
}
|
|
180
|
+
position: event.mapCoords
|
|
181
|
+
}
|
|
179
182
|
};
|
|
180
183
|
}
|
|
181
184
|
return editAction;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeatureCollection, Position } from '../geojson-types';
|
|
1
|
+
import { FeatureCollection, Position } from '../utils/geojson-types';
|
|
2
2
|
import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
3
3
|
import { EditAction, ModeHandler } from './mode-handler';
|
|
4
4
|
export declare class RotateHandler extends ModeHandler {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import turfCentroid from '@turf/centroid';
|
|
2
5
|
import turfBearing from '@turf/bearing';
|
|
3
6
|
import turfTransformRotate from '@turf/transform-rotate';
|
|
@@ -63,7 +66,7 @@ export class RotateHandler extends ModeHandler {
|
|
|
63
66
|
updatedData: updatedData.getObject(),
|
|
64
67
|
editType,
|
|
65
68
|
featureIndexes: selectedIndexes,
|
|
66
|
-
editContext: null
|
|
69
|
+
editContext: null
|
|
67
70
|
};
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeatureCollection, Position } from '../geojson-types';
|
|
1
|
+
import { FeatureCollection, Position } from '../utils/geojson-types';
|
|
2
2
|
import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
3
3
|
import { EditAction, ModeHandler } from './mode-handler';
|
|
4
4
|
export declare class ScaleHandler extends ModeHandler {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import turfCentroid from '@turf/centroid';
|
|
2
5
|
import turfDistance from '@turf/distance';
|
|
3
6
|
import turfTransformScale from '@turf/transform-scale';
|
|
@@ -52,7 +55,7 @@ export class ScaleHandler extends ModeHandler {
|
|
|
52
55
|
const scaledFeatures = turfTransformScale(
|
|
53
56
|
// @ts-expect-error turf type diff
|
|
54
57
|
this._geometryBeingScaled, factor, {
|
|
55
|
-
origin: centroid
|
|
58
|
+
origin: centroid
|
|
56
59
|
});
|
|
57
60
|
let updatedData = this.getImmutableFeatureCollection();
|
|
58
61
|
const selectedIndexes = this.getSelectedFeatureIndexes();
|
|
@@ -65,7 +68,7 @@ export class ScaleHandler extends ModeHandler {
|
|
|
65
68
|
updatedData: updatedData.getObject(),
|
|
66
69
|
editType,
|
|
67
70
|
featureIndexes: selectedIndexes,
|
|
68
|
-
editContext: null
|
|
71
|
+
editContext: null
|
|
69
72
|
};
|
|
70
73
|
}
|
|
71
74
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Feature, FeatureCollection, Position } from '../geojson-types';
|
|
1
|
+
import { Feature, FeatureCollection, Position } from '../utils/geojson-types';
|
|
2
2
|
import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
3
3
|
import { EditHandle, EditAction, ModeHandler } from './mode-handler';
|
|
4
4
|
type HandlePicks = {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import { ModeHandler, getPickedEditHandle, getEditHandlesForGeometry } from './mode-handler';
|
|
2
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
3
6
|
export class SnappableHandler extends ModeHandler {
|
|
4
7
|
_handler;
|
|
@@ -22,7 +25,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
22
25
|
// @ts-expect-error narrow event type
|
|
23
26
|
return Object.assign({}, event, {
|
|
24
27
|
mapCoords: snapPoint,
|
|
25
|
-
pointerDownMapCoords: this._startDragSnapHandlePosition
|
|
28
|
+
pointerDownMapCoords: this._startDragSnapHandlePosition
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
31
|
_getEditHandlePicks(event) {
|
|
@@ -59,7 +62,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
59
62
|
additionalSnapTargets = additionalSnapTargets || [];
|
|
60
63
|
const features = [
|
|
61
64
|
...this._handler.featureCollection.getObject().features,
|
|
62
|
-
...additionalSnapTargets
|
|
65
|
+
...additionalSnapTargets
|
|
63
66
|
];
|
|
64
67
|
return features;
|
|
65
68
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
|
|
2
5
|
import turfDifference from '@turf/difference';
|
|
3
6
|
import turfBuffer from '@turf/buffer';
|
|
@@ -8,7 +11,7 @@ import turfDistance from '@turf/distance';
|
|
|
8
11
|
import turfDestination from '@turf/destination';
|
|
9
12
|
import turfPolygonToLine from '@turf/polygon-to-line';
|
|
10
13
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
11
|
-
import { generatePointsParallelToLinePoints } from '../utils';
|
|
14
|
+
import { generatePointsParallelToLinePoints } from '../utils/utils';
|
|
12
15
|
import { ModeHandler } from './mode-handler';
|
|
13
16
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
14
17
|
export class SplitPolygonHandler extends ModeHandler {
|
|
@@ -40,7 +43,7 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
40
43
|
const lastBearing = turfBearing(firstPoint, closestPoint);
|
|
41
44
|
const currentDistance = turfDistance(firstPoint, mapCoords, { units: 'meters' });
|
|
42
45
|
return turfDestination(firstPoint, currentDistance, lastBearing, {
|
|
43
|
-
units: 'meters'
|
|
46
|
+
units: 'meters'
|
|
44
47
|
}).geometry.coordinates;
|
|
45
48
|
}
|
|
46
49
|
return mapCoords;
|
|
@@ -56,7 +59,7 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
56
59
|
handleClick(event) {
|
|
57
60
|
super.handleClick({
|
|
58
61
|
...event,
|
|
59
|
-
mapCoords: this.calculateMapCoords(this.getClickSequence(), event.mapCoords)
|
|
62
|
+
mapCoords: this.calculateMapCoords(this.getClickSequence(), event.mapCoords)
|
|
60
63
|
});
|
|
61
64
|
const editAction = null;
|
|
62
65
|
const tentativeFeature = this.getTentativeFeature();
|
|
@@ -70,7 +73,7 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
70
73
|
}
|
|
71
74
|
const pt = {
|
|
72
75
|
type: 'Point',
|
|
73
|
-
coordinates: clickSequence[clickSequence.length - 1]
|
|
76
|
+
coordinates: clickSequence[clickSequence.length - 1]
|
|
74
77
|
};
|
|
75
78
|
// @ts-expect-error turf type diff
|
|
76
79
|
const isPointInPolygon = booleanPointInPolygon(pt, selectedGeometry);
|
|
@@ -97,8 +100,8 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
97
100
|
type: 'Feature',
|
|
98
101
|
geometry: {
|
|
99
102
|
type: 'LineString',
|
|
100
|
-
coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords)]
|
|
101
|
-
}
|
|
103
|
+
coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords)]
|
|
104
|
+
}
|
|
102
105
|
});
|
|
103
106
|
return result;
|
|
104
107
|
}
|
|
@@ -141,13 +144,13 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
141
144
|
// Update the type to Mulitpolygon
|
|
142
145
|
const updatedData = this.getImmutableFeatureCollection().replaceGeometry(featureIndex, {
|
|
143
146
|
type: 'MultiPolygon',
|
|
144
|
-
coordinates: updatedCoordinates
|
|
147
|
+
coordinates: updatedCoordinates
|
|
145
148
|
});
|
|
146
149
|
const editAction = {
|
|
147
150
|
updatedData: updatedData.getObject(),
|
|
148
151
|
editType: 'split',
|
|
149
152
|
featureIndexes: [featureIndex],
|
|
150
|
-
editContext: null
|
|
153
|
+
editContext: null
|
|
151
154
|
};
|
|
152
155
|
return editAction;
|
|
153
156
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { ModeHandler } from './mode-handler';
|
|
2
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
3
6
|
export class ThreeClickPolygonHandler extends ModeHandler {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeatureCollection, Position } from '../geojson-types';
|
|
1
|
+
import { FeatureCollection, Position } from '../utils/geojson-types';
|
|
2
2
|
import { PointerMoveEvent, StartDraggingEvent, StopDraggingEvent } from '../edit-modes/types';
|
|
3
3
|
import { EditAction, ModeHandler } from './mode-handler';
|
|
4
4
|
export declare class TranslateHandler extends ModeHandler {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import turfBearing from '@turf/bearing';
|
|
2
5
|
import turfDistance from '@turf/distance';
|
|
3
6
|
import turfTransformTranslate from '@turf/transform-translate';
|
|
@@ -66,7 +69,7 @@ export class TranslateHandler extends ModeHandler {
|
|
|
66
69
|
updatedData: updatedData.getObject(),
|
|
67
70
|
editType,
|
|
68
71
|
featureIndexes: selectedIndexes,
|
|
69
|
-
editContext: null
|
|
72
|
+
editContext: null
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
75
|
}
|