@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,10 +1,14 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
6
|
import distance from '@turf/distance';
|
|
3
7
|
import ellipse from '@turf/ellipse';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
+
import {point} from '@turf/helpers';
|
|
9
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
10
|
+
import {getIntermediatePosition} from './geojson-edit-mode';
|
|
11
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
8
12
|
|
|
9
13
|
export class DrawEllipseByBoundingBoxMode extends TwoClickPolygonMode {
|
|
10
14
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import distance from '@turf/distance';
|
|
2
6
|
import ellipse from '@turf/ellipse';
|
|
3
7
|
import bearing from '@turf/bearing';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
+
import {point} from '@turf/helpers';
|
|
9
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
10
|
+
import {getIntermediatePosition} from './geojson-edit-mode';
|
|
11
|
+
import {ThreeClickPolygonMode} from './three-click-polygon-mode';
|
|
8
12
|
|
|
9
13
|
export class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
10
14
|
getThreeClickPolygon(
|
|
@@ -16,7 +20,7 @@ export class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
|
16
20
|
const centerCoordinates = getIntermediatePosition(coord1, coord2);
|
|
17
21
|
const xSemiAxis = Math.max(distance(centerCoordinates, point(coord3)), 0.001);
|
|
18
22
|
const ySemiAxis = Math.max(distance(coord1, coord2), 0.001) / 2;
|
|
19
|
-
const options = {
|
|
23
|
+
const options = {angle: bearing(coord1, coord2)};
|
|
20
24
|
// @ts-expect-error fix return types
|
|
21
25
|
return ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options);
|
|
22
26
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import distance from '@turf/distance';
|
|
2
|
-
import memoize from '../memoize';
|
|
3
|
-
import {
|
|
6
|
+
import {memoize} from '../utils/memoize';
|
|
7
|
+
import {LineString, FeatureCollection, Position} from '../utils/geojson-types';
|
|
4
8
|
import {
|
|
5
9
|
ClickEvent,
|
|
6
10
|
PointerMoveEvent,
|
|
7
11
|
ModeProps,
|
|
8
12
|
GuideFeatureCollection,
|
|
9
13
|
GuideFeature,
|
|
10
|
-
Tooltip
|
|
14
|
+
Tooltip
|
|
11
15
|
} from './types';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
16
|
+
import {getPickedEditHandle} from './utils';
|
|
17
|
+
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
14
18
|
|
|
15
19
|
export class DrawLineStringMode extends GeoJsonEditMode {
|
|
16
20
|
// declaration of variables for the calculation of the distance of linestring
|
|
@@ -18,7 +22,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
18
22
|
position: Position = null!;
|
|
19
23
|
elems: Position[] = [];
|
|
20
24
|
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
|
|
21
|
-
const {
|
|
25
|
+
const {picks} = event;
|
|
22
26
|
const clickedEditHandle = getPickedEditHandle(picks);
|
|
23
27
|
|
|
24
28
|
let positionAdded = false;
|
|
@@ -45,7 +49,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
45
49
|
this.dist = 0;
|
|
46
50
|
const lineStringToAdd: LineString = {
|
|
47
51
|
type: 'LineString',
|
|
48
|
-
coordinates: [...clickSequence]
|
|
52
|
+
coordinates: [...clickSequence]
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
this.resetClickSequence();
|
|
@@ -61,20 +65,20 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
61
65
|
updatedData: props.data,
|
|
62
66
|
editType: 'addTentativePosition',
|
|
63
67
|
editContext: {
|
|
64
|
-
position: event.mapCoords
|
|
65
|
-
}
|
|
68
|
+
position: event.mapCoords
|
|
69
|
+
}
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {
|
|
71
|
-
const {
|
|
75
|
+
const {key} = event;
|
|
72
76
|
if (key === 'Enter') {
|
|
73
77
|
const clickSequence = this.getClickSequence();
|
|
74
78
|
if (clickSequence.length > 1) {
|
|
75
79
|
const lineStringToAdd: LineString = {
|
|
76
80
|
type: 'LineString',
|
|
77
|
-
coordinates: [...clickSequence]
|
|
81
|
+
coordinates: [...clickSequence]
|
|
78
82
|
};
|
|
79
83
|
this.resetClickSequence();
|
|
80
84
|
const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);
|
|
@@ -88,20 +92,20 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
88
92
|
// Because the new drawing feature is dropped, so the data will keep as the same.
|
|
89
93
|
updatedData: props.data,
|
|
90
94
|
editType: 'cancelFeature',
|
|
91
|
-
editContext: {}
|
|
95
|
+
editContext: {}
|
|
92
96
|
});
|
|
93
97
|
}
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {
|
|
97
|
-
const {
|
|
101
|
+
const {lastPointerMoveEvent} = props;
|
|
98
102
|
const clickSequence = this.getClickSequence();
|
|
99
103
|
|
|
100
104
|
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
|
|
101
105
|
|
|
102
106
|
const guides: GuideFeatureCollection = {
|
|
103
107
|
type: 'FeatureCollection',
|
|
104
|
-
features: []
|
|
108
|
+
features: []
|
|
105
109
|
};
|
|
106
110
|
|
|
107
111
|
let tentativeFeature;
|
|
@@ -109,12 +113,12 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
109
113
|
tentativeFeature = {
|
|
110
114
|
type: 'Feature',
|
|
111
115
|
properties: {
|
|
112
|
-
guideType: 'tentative'
|
|
116
|
+
guideType: 'tentative'
|
|
113
117
|
},
|
|
114
118
|
geometry: {
|
|
115
119
|
type: 'LineString',
|
|
116
|
-
coordinates: [...clickSequence, ...lastCoords]
|
|
117
|
-
}
|
|
120
|
+
coordinates: [...clickSequence, ...lastCoords]
|
|
121
|
+
}
|
|
118
122
|
};
|
|
119
123
|
}
|
|
120
124
|
|
|
@@ -128,12 +132,12 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
128
132
|
guideType: 'editHandle',
|
|
129
133
|
editHandleType: 'existing',
|
|
130
134
|
featureIndex: -1,
|
|
131
|
-
positionIndexes: [index]
|
|
135
|
+
positionIndexes: [index]
|
|
132
136
|
},
|
|
133
137
|
geometry: {
|
|
134
138
|
type: 'Point',
|
|
135
|
-
coordinates: clickedCoord
|
|
136
|
-
}
|
|
139
|
+
coordinates: clickedCoord
|
|
140
|
+
}
|
|
137
141
|
}));
|
|
138
142
|
|
|
139
143
|
guides.features.push(...editHandles);
|
|
@@ -152,7 +156,7 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
152
156
|
getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {
|
|
153
157
|
return this._getTooltips({
|
|
154
158
|
modeConfig: props.modeConfig,
|
|
155
|
-
dist: this.dist
|
|
159
|
+
dist: this.dist
|
|
156
160
|
});
|
|
157
161
|
}
|
|
158
162
|
|
|
@@ -176,9 +180,9 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
176
180
|
* @param modeConfig
|
|
177
181
|
* @param dist
|
|
178
182
|
*/
|
|
179
|
-
_getTooltips = memoize(({
|
|
183
|
+
_getTooltips = memoize(({modeConfig, dist}) => {
|
|
180
184
|
let tooltips: Tooltip[] = [];
|
|
181
|
-
const {
|
|
185
|
+
const {formatTooltip} = modeConfig || {};
|
|
182
186
|
let text;
|
|
183
187
|
if (dist) {
|
|
184
188
|
if (formatTooltip) {
|
|
@@ -191,8 +195,8 @@ export class DrawLineStringMode extends GeoJsonEditMode {
|
|
|
191
195
|
tooltips = [
|
|
192
196
|
{
|
|
193
197
|
position: this.position,
|
|
194
|
-
text
|
|
195
|
-
}
|
|
198
|
+
text
|
|
199
|
+
}
|
|
196
200
|
];
|
|
197
201
|
}
|
|
198
202
|
return tooltips;
|
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {ClickEvent, PointerMoveEvent, ModeProps, TentativeFeature} from './types';
|
|
6
|
+
import {FeatureCollection, Point} from '../utils/geojson-types';
|
|
7
|
+
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
4
8
|
|
|
5
9
|
export class DrawPointMode extends GeoJsonEditMode {
|
|
6
10
|
createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {
|
|
7
|
-
const {
|
|
11
|
+
const {lastPointerMoveEvent} = props;
|
|
8
12
|
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
|
|
9
13
|
|
|
10
14
|
return {
|
|
11
15
|
type: 'Feature',
|
|
12
16
|
properties: {
|
|
13
|
-
guideType: 'tentative'
|
|
17
|
+
guideType: 'tentative'
|
|
14
18
|
},
|
|
15
19
|
geometry: {
|
|
16
20
|
type: 'Point',
|
|
17
|
-
coordinates: lastCoords[0]
|
|
18
|
-
}
|
|
21
|
+
coordinates: lastCoords[0]
|
|
22
|
+
}
|
|
19
23
|
};
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
handleClick({
|
|
26
|
+
handleClick({mapCoords}: ClickEvent, props: ModeProps<FeatureCollection>): void {
|
|
23
27
|
const geometry: Point = {
|
|
24
28
|
type: 'Point',
|
|
25
|
-
coordinates: mapCoords
|
|
29
|
+
coordinates: mapCoords
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
props.onEdit(this.getAddFeatureAction(geometry, props.data));
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import throttle from 'lodash.throttle';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
DraggingEvent,
|
|
7
|
-
ModeProps,
|
|
8
|
-
} from './types';
|
|
9
|
-
import { Polygon, FeatureCollection } from '../geojson-types';
|
|
10
|
-
import { getPickedEditHandle } from './utils';
|
|
11
|
-
import { DrawPolygonMode } from './draw-polygon-mode';
|
|
6
|
+
import {ClickEvent, StartDraggingEvent, StopDraggingEvent, DraggingEvent, ModeProps} from './types';
|
|
7
|
+
import {Polygon, FeatureCollection} from '../utils/geojson-types';
|
|
8
|
+
import {getPickedEditHandle} from './utils';
|
|
9
|
+
import {DrawPolygonMode} from './draw-polygon-mode';
|
|
12
10
|
|
|
13
11
|
type DraggingHandler = (event: DraggingEvent, props: ModeProps<FeatureCollection>) => void;
|
|
14
12
|
|
|
@@ -22,8 +20,10 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
22
20
|
handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
23
21
|
event.cancelPan();
|
|
24
22
|
if (props.modeConfig && props.modeConfig.throttleMs) {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
25
24
|
this.handleDraggingThrottled = throttle(this.handleDraggingAux, props.modeConfig.throttleMs);
|
|
26
25
|
} else {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
27
27
|
this.handleDraggingThrottled = this.handleDraggingAux;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -41,7 +41,7 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
41
41
|
// Complete the polygon.
|
|
42
42
|
const polygonToAdd: Polygon = {
|
|
43
43
|
type: 'Polygon',
|
|
44
|
-
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
44
|
+
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);
|
|
@@ -53,7 +53,7 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
handleDraggingAux(event: DraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
56
|
-
const {
|
|
56
|
+
const {picks} = event;
|
|
57
57
|
const clickedEditHandle = getPickedEditHandle(picks);
|
|
58
58
|
|
|
59
59
|
if (!clickedEditHandle) {
|
|
@@ -63,8 +63,8 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
63
63
|
updatedData: props.data,
|
|
64
64
|
editType: 'addTentativePosition',
|
|
65
65
|
editContext: {
|
|
66
|
-
position: event.mapCoords
|
|
67
|
-
}
|
|
66
|
+
position: event.mapCoords
|
|
67
|
+
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
}
|
|
@@ -81,7 +81,7 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
81
81
|
if (clickSequence.length > 2) {
|
|
82
82
|
const polygonToAdd: Polygon = {
|
|
83
83
|
type: 'Polygon',
|
|
84
|
-
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
84
|
+
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
85
85
|
};
|
|
86
86
|
this.resetClickSequence();
|
|
87
87
|
|
|
@@ -99,7 +99,7 @@ export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
|
99
99
|
// Because the new drawing feature is dropped, so the data will keep as the same.
|
|
100
100
|
updatedData: props.data,
|
|
101
101
|
editType: 'cancelFeature',
|
|
102
|
-
editContext: {}
|
|
102
|
+
editContext: {}
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import lineIntersect from '@turf/line-intersect';
|
|
2
|
-
import {
|
|
6
|
+
import {lineString as turfLineString} from '@turf/helpers';
|
|
3
7
|
import {
|
|
4
8
|
ClickEvent,
|
|
5
9
|
PointerMoveEvent,
|
|
6
10
|
ModeProps,
|
|
7
11
|
GuideFeatureCollection,
|
|
8
12
|
TentativeFeature,
|
|
9
|
-
GuideFeature
|
|
13
|
+
GuideFeature
|
|
10
14
|
} from './types';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
15
|
+
import {Polygon, FeatureCollection} from '../utils/geojson-types';
|
|
16
|
+
import {getPickedEditHandle} from './utils';
|
|
17
|
+
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
14
18
|
|
|
15
19
|
export class DrawPolygonMode extends GeoJsonEditMode {
|
|
16
20
|
createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {
|
|
17
|
-
const {
|
|
21
|
+
const {lastPointerMoveEvent} = props;
|
|
18
22
|
const clickSequence = this.getClickSequence();
|
|
19
23
|
|
|
20
24
|
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
|
|
@@ -24,23 +28,23 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
24
28
|
tentativeFeature = {
|
|
25
29
|
type: 'Feature',
|
|
26
30
|
properties: {
|
|
27
|
-
guideType: 'tentative'
|
|
31
|
+
guideType: 'tentative'
|
|
28
32
|
},
|
|
29
33
|
geometry: {
|
|
30
34
|
type: 'LineString',
|
|
31
|
-
coordinates: [...clickSequence, ...lastCoords]
|
|
32
|
-
}
|
|
35
|
+
coordinates: [...clickSequence, ...lastCoords]
|
|
36
|
+
}
|
|
33
37
|
};
|
|
34
38
|
} else if (clickSequence.length > 2) {
|
|
35
39
|
tentativeFeature = {
|
|
36
40
|
type: 'Feature',
|
|
37
41
|
properties: {
|
|
38
|
-
guideType: 'tentative'
|
|
42
|
+
guideType: 'tentative'
|
|
39
43
|
},
|
|
40
44
|
geometry: {
|
|
41
45
|
type: 'Polygon',
|
|
42
|
-
coordinates: [[...clickSequence, ...lastCoords, clickSequence[0]]]
|
|
43
|
-
}
|
|
46
|
+
coordinates: [[...clickSequence, ...lastCoords, clickSequence[0]]]
|
|
47
|
+
}
|
|
44
48
|
};
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -52,7 +56,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
52
56
|
|
|
53
57
|
const guides: GuideFeatureCollection = {
|
|
54
58
|
type: 'FeatureCollection',
|
|
55
|
-
features: []
|
|
59
|
+
features: []
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
const tentativeFeature = this.createTentativeFeature(props);
|
|
@@ -66,12 +70,12 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
66
70
|
guideType: 'editHandle',
|
|
67
71
|
editHandleType: 'existing',
|
|
68
72
|
featureIndex: -1,
|
|
69
|
-
positionIndexes: [index]
|
|
73
|
+
positionIndexes: [index]
|
|
70
74
|
},
|
|
71
75
|
geometry: {
|
|
72
76
|
type: 'Point',
|
|
73
|
-
coordinates: clickedCoord
|
|
74
|
-
}
|
|
77
|
+
coordinates: clickedCoord
|
|
78
|
+
}
|
|
75
79
|
}));
|
|
76
80
|
|
|
77
81
|
guides.features.push(...editHandles);
|
|
@@ -79,8 +83,9 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
79
83
|
return guides;
|
|
80
84
|
}
|
|
81
85
|
|
|
86
|
+
// eslint-disable-next-line complexity
|
|
82
87
|
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
|
|
83
|
-
const {
|
|
88
|
+
const {picks} = event;
|
|
84
89
|
const clickedEditHandle = getPickedEditHandle(picks);
|
|
85
90
|
const clickSequence = this.getClickSequence();
|
|
86
91
|
|
|
@@ -88,7 +93,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
88
93
|
if (clickSequence.length > 2 && props.modeConfig && props.modeConfig.preventOverlappingLines) {
|
|
89
94
|
const currentLine = turfLineString([
|
|
90
95
|
clickSequence[clickSequence.length - 1],
|
|
91
|
-
event.mapCoords
|
|
96
|
+
event.mapCoords
|
|
92
97
|
]);
|
|
93
98
|
const otherLines = turfLineString([...clickSequence.slice(0, clickSequence.length - 1)]);
|
|
94
99
|
const intersectingPoints = lineIntersect(currentLine, otherLines);
|
|
@@ -116,7 +121,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
116
121
|
// Remove the hovered position
|
|
117
122
|
const polygonToAdd: Polygon = {
|
|
118
123
|
type: 'Polygon',
|
|
119
|
-
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
124
|
+
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
120
125
|
};
|
|
121
126
|
|
|
122
127
|
this.resetClickSequence();
|
|
@@ -132,8 +137,8 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
132
137
|
updatedData: props.data,
|
|
133
138
|
editType: 'addTentativePosition',
|
|
134
139
|
editContext: {
|
|
135
|
-
position: event.mapCoords
|
|
136
|
-
}
|
|
140
|
+
position: event.mapCoords
|
|
141
|
+
}
|
|
137
142
|
});
|
|
138
143
|
}
|
|
139
144
|
}
|
|
@@ -144,7 +149,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
144
149
|
if (clickSequence.length > 2) {
|
|
145
150
|
const polygonToAdd: Polygon = {
|
|
146
151
|
type: 'Polygon',
|
|
147
|
-
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
152
|
+
coordinates: [[...clickSequence, clickSequence[0]]]
|
|
148
153
|
};
|
|
149
154
|
this.resetClickSequence();
|
|
150
155
|
|
|
@@ -159,7 +164,7 @@ export class DrawPolygonMode extends GeoJsonEditMode {
|
|
|
159
164
|
// Because the new drawing feature is dropped, so the data will keep as the same.
|
|
160
165
|
updatedData: props.data,
|
|
161
166
|
editType: 'cancelFeature',
|
|
162
|
-
editContext: {}
|
|
167
|
+
editContext: {}
|
|
163
168
|
});
|
|
164
169
|
}
|
|
165
170
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
6
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
7
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
4
8
|
|
|
5
9
|
export class DrawRectangleFromCenterMode extends TwoClickPolygonMode {
|
|
6
10
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
6
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
7
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
4
8
|
|
|
5
9
|
export class DrawRectangleMode extends TwoClickPolygonMode {
|
|
6
10
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {generatePointsParallelToLinePoints} from './utils';
|
|
6
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
7
|
+
import {ThreeClickPolygonMode} from './three-click-polygon-mode';
|
|
4
8
|
|
|
5
9
|
export class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
6
10
|
getThreeClickPolygon(
|
|
@@ -14,7 +18,7 @@ export class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
|
14
18
|
return {
|
|
15
19
|
type: 'Feature',
|
|
16
20
|
properties: {
|
|
17
|
-
shape: 'Rectangle'
|
|
21
|
+
shape: 'Rectangle'
|
|
18
22
|
},
|
|
19
23
|
geometry: {
|
|
20
24
|
type: 'Polygon',
|
|
@@ -27,10 +31,10 @@ export class DrawRectangleUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
|
27
31
|
coord2,
|
|
28
32
|
p3,
|
|
29
33
|
p4,
|
|
30
|
-
coord1
|
|
31
|
-
]
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
+
coord1
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
}
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
6
|
import turfDistance from '@turf/distance';
|
|
3
7
|
import turfAlong from '@turf/along';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import {point, lineString as turfLineString} from '@turf/helpers';
|
|
9
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
10
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
7
11
|
|
|
8
12
|
export class DrawSquareFromCenterMode extends TwoClickPolygonMode {
|
|
9
13
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
6
|
import turfDistance from '@turf/distance';
|
|
3
7
|
import turfAlong from '@turf/along';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
8
|
+
import {point, lineString as turfLineString} from '@turf/helpers';
|
|
9
|
+
import {Position, Polygon, FeatureOf} from '../utils/geojson-types';
|
|
10
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
7
11
|
|
|
8
12
|
export class DrawSquareMode extends TwoClickPolygonMode {
|
|
9
13
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {StartDraggingEvent, ModeProps} from './types';
|
|
6
|
+
import {FeatureCollection} from '../utils/geojson-types';
|
|
7
|
+
import {TranslateMode} from './translate-mode';
|
|
4
8
|
|
|
5
9
|
export class DuplicateMode extends TranslateMode {
|
|
6
10
|
handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
/* istanbul ignore file */
|
|
2
6
|
|
|
3
7
|
import {
|
|
@@ -7,7 +11,7 @@ import {
|
|
|
7
11
|
StopDraggingEvent,
|
|
8
12
|
DraggingEvent,
|
|
9
13
|
Tooltip,
|
|
10
|
-
ModeProps
|
|
14
|
+
ModeProps
|
|
11
15
|
} from './types';
|
|
12
16
|
|
|
13
17
|
export interface EditMode<TData, TGuides> {
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {ModeProps, PointerMoveEvent, StopDraggingEvent} from './types';
|
|
6
|
+
import {Position, FeatureCollection} from '../utils/geojson-types';
|
|
7
|
+
import {getPickedEditHandle} from './utils';
|
|
8
|
+
import {ModifyMode} from './modify-mode';
|
|
5
9
|
|
|
6
10
|
function defaultCalculateElevationChange({
|
|
7
11
|
pointerDownScreenCoords,
|
|
8
|
-
screenCoords
|
|
12
|
+
screenCoords
|
|
9
13
|
}: {
|
|
10
14
|
pointerDownScreenCoords: Position;
|
|
11
15
|
screenCoords: Position;
|
|
@@ -22,7 +26,7 @@ export class ElevationMode extends ModifyMode {
|
|
|
22
26
|
const {
|
|
23
27
|
minElevation = 0,
|
|
24
28
|
maxElevation = 20000,
|
|
25
|
-
calculateElevationChange = defaultCalculateElevationChange
|
|
29
|
+
calculateElevationChange = defaultCalculateElevationChange
|
|
26
30
|
} = props.modeConfig || {};
|
|
27
31
|
|
|
28
32
|
if (!event.pointerDownScreenCoords) {
|
|
@@ -35,13 +39,13 @@ export class ElevationMode extends ModifyMode {
|
|
|
35
39
|
// calculateElevationChange is configurable because (at this time) modes are not aware of the viewport
|
|
36
40
|
elevation += calculateElevationChange({
|
|
37
41
|
pointerDownScreenCoords: event.pointerDownScreenCoords,
|
|
38
|
-
screenCoords: event.screenCoords
|
|
42
|
+
screenCoords: event.screenCoords
|
|
39
43
|
});
|
|
40
44
|
elevation = Math.min(elevation, maxElevation);
|
|
41
45
|
elevation = Math.max(elevation, minElevation);
|
|
42
46
|
|
|
43
47
|
return Object.assign({}, event, {
|
|
44
|
-
mapCoords: [position[0], position[1], elevation]
|
|
48
|
+
mapCoords: [position[0], position[1], elevation]
|
|
45
49
|
});
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -71,7 +75,7 @@ export class ElevationMode extends ModifyMode {
|
|
|
71
75
|
viewport: any,
|
|
72
76
|
{
|
|
73
77
|
pointerDownScreenCoords,
|
|
74
|
-
screenCoords
|
|
78
|
+
screenCoords
|
|
75
79
|
}: {
|
|
76
80
|
pointerDownScreenCoords: Position;
|
|
77
81
|
screenCoords: Position;
|