@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 TwoClickPolygonHandler extends ModeHandler {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
declare function getUniforms(opts?: Record<string, number>): Record<string, number>;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/** Shader module that implements desaturation. @note still WIP */
|
|
3
|
+
export declare const color: {
|
|
4
|
+
readonly name: "color";
|
|
5
|
+
readonly vs: "in vec4 color_vColor;\n\ncolor_setColor(vec4 color) {\n color_vColor = color;\n}\n";
|
|
6
|
+
readonly fs: "uniform float color_uOpacity;\nuniform float color_uDesaturate;\nuniform float color_uBrightness;\n\nin vec4 color_vColor;\n\nout vec4 fragColor;\n\nvec4 color_getColor() {\n return color_vColor;\n}\n\nvec4 color_filterColor(vec4 color) {\n // apply desaturation and brightness\n if (color_uDesaturate > 0.01) {\n float luminance = (color.r + color.g + color.b) * 0.333333333 + color_uBrightness;\n color = vec4(mix(color.rgb, vec3(luminance), color_uDesaturate), color.a);\n\n // Apply opacity\n color = vec4(color.rgb, color.a * color_uOpacity);\n return color;\n}\n";
|
|
7
|
+
readonly getUniforms: typeof getUniforms;
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
+
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
//
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
2
4
|
/* eslint-disable camelcase */
|
|
3
5
|
const INITIAL_STATE = {
|
|
4
6
|
color_uOpacity: 1.0,
|
|
5
7
|
color_uDesaturate: 0.0,
|
|
6
|
-
color_uBrightness: 1.0
|
|
8
|
+
color_uBrightness: 1.0
|
|
7
9
|
};
|
|
8
10
|
function getUniforms(opts = INITIAL_STATE) {
|
|
9
11
|
const uniforms = {};
|
|
@@ -43,9 +45,10 @@ vec4 color_filterColor(vec4 color) {
|
|
|
43
45
|
return color;
|
|
44
46
|
}
|
|
45
47
|
`;
|
|
46
|
-
|
|
48
|
+
/** Shader module that implements desaturation. @note still WIP */
|
|
49
|
+
export const color = {
|
|
47
50
|
name: 'color',
|
|
48
51
|
vs,
|
|
49
52
|
fs,
|
|
50
|
-
getUniforms
|
|
53
|
+
getUniforms
|
|
51
54
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
// TODO - this module is a WIP
|
|
2
5
|
/* eslint-disable camelcase */
|
|
3
6
|
const INITIAL_STATE = {};
|
|
@@ -20,9 +23,9 @@ vec2 project_clipspace_to_projective_uv(vec4 position) {
|
|
|
20
23
|
}
|
|
21
24
|
`;
|
|
22
25
|
const fs = vs;
|
|
23
|
-
export
|
|
26
|
+
export const utils = {
|
|
24
27
|
name: 'outline',
|
|
25
28
|
vs,
|
|
26
29
|
fs,
|
|
27
|
-
getUniforms
|
|
30
|
+
getUniforms
|
|
28
31
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import hermite from 'cubic-hermite-spline';
|
|
2
5
|
import turfDistance from '@turf/distance';
|
|
3
6
|
import { lineString } from '@turf/helpers';
|
|
@@ -27,13 +30,13 @@ export function generateCurveFromControlPoints(line) {
|
|
|
27
30
|
// calculate tangents
|
|
28
31
|
const tangents = [];
|
|
29
32
|
// first tangent
|
|
30
|
-
// @ts-
|
|
33
|
+
// @ts-expect-error TODO
|
|
31
34
|
tangents.push(calculateSingleTangent(coords[0], coords[1], knots[1] - knots[0]));
|
|
32
35
|
// second to before last
|
|
33
36
|
for (let i = 1; i < coords.length - 1; i++) {
|
|
34
|
-
// @ts-
|
|
37
|
+
// @ts-expect-error TODO
|
|
35
38
|
const A = calculateSingleTangent(coords[i], coords[i + 1], knots[i + 1] - knots[i]);
|
|
36
|
-
// @ts-
|
|
39
|
+
// @ts-expect-error TODO
|
|
37
40
|
const B = calculateSingleTangent(coords[i - 1], coords[i], knots[i] - knots[i - 1]);
|
|
38
41
|
const x = (A[0] + B[0]) / 2.0;
|
|
39
42
|
const y = (A[1] + B[1]) / 2.0;
|
|
@@ -42,7 +45,7 @@ export function generateCurveFromControlPoints(line) {
|
|
|
42
45
|
// last tangent
|
|
43
46
|
const last = coords.length - 1;
|
|
44
47
|
tangents.push(
|
|
45
|
-
// @ts-
|
|
48
|
+
// @ts-expect-error TODO
|
|
46
49
|
calculateSingleTangent(coords[last - 1], coords[last], knots[last] - knots[last - 1]));
|
|
47
50
|
// generate curve
|
|
48
51
|
const result = [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Position } from 'geojson';
|
|
2
|
+
export { Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Position };
|
|
2
3
|
export type PointCoordinates = Position;
|
|
3
4
|
export type LineStringCoordinates = Position[];
|
|
4
5
|
export type PolygonCoordinates = Position[][];
|
|
@@ -6,30 +7,6 @@ export type MultiPointCoordinates = Position[];
|
|
|
6
7
|
export type MultiLineStringCoordinates = Position[][];
|
|
7
8
|
export type MultiPolygonCoordinates = Position[][][];
|
|
8
9
|
export type AnyCoordinates = PointCoordinates | LineStringCoordinates | PolygonCoordinates | MultiPointCoordinates | MultiLineStringCoordinates | MultiPolygonCoordinates;
|
|
9
|
-
export type Point = {
|
|
10
|
-
type: 'Point';
|
|
11
|
-
coordinates: PointCoordinates;
|
|
12
|
-
};
|
|
13
|
-
export type LineString = {
|
|
14
|
-
type: 'LineString';
|
|
15
|
-
coordinates: LineStringCoordinates;
|
|
16
|
-
};
|
|
17
|
-
export type Polygon = {
|
|
18
|
-
type: 'Polygon';
|
|
19
|
-
coordinates: PolygonCoordinates;
|
|
20
|
-
};
|
|
21
|
-
export type MultiPoint = {
|
|
22
|
-
type: 'MultiPoint';
|
|
23
|
-
coordinates: MultiPointCoordinates;
|
|
24
|
-
};
|
|
25
|
-
export type MultiLineString = {
|
|
26
|
-
type: 'MultiLineString';
|
|
27
|
-
coordinates: MultiLineStringCoordinates;
|
|
28
|
-
};
|
|
29
|
-
export type MultiPolygon = {
|
|
30
|
-
type: 'MultiPolygon';
|
|
31
|
-
coordinates: MultiPolygonCoordinates;
|
|
32
|
-
};
|
|
33
10
|
export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
34
11
|
export type Polygonal = Polygon | MultiPolygon;
|
|
35
12
|
export type BoundingBoxArray = [number, number, number, number];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
// port from @deck.gl/core
|
|
2
5
|
function isEqual(a, b) {
|
|
3
6
|
if (a === b) {
|
|
@@ -24,7 +27,7 @@ function isEqual(a, b) {
|
|
|
24
27
|
* https://en.wikipedia.org/wiki/Memoization
|
|
25
28
|
* @param {function} compute - the function to be memoized
|
|
26
29
|
*/
|
|
27
|
-
export
|
|
30
|
+
export function memoize(compute) {
|
|
28
31
|
let cachedArgs = {};
|
|
29
32
|
let cachedResult;
|
|
30
33
|
return (args) => {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import turfCenter from '@turf/center';
|
|
2
5
|
import turfRhumbBearing from '@turf/rhumb-bearing';
|
|
3
6
|
import turfRhumbDistance from '@turf/rhumb-distance';
|
|
4
7
|
import turfRhumbDestination from '@turf/rhumb-destination';
|
|
5
|
-
import { mapCoords } from '
|
|
8
|
+
import { mapCoords } from '../edit-modes/utils';
|
|
6
9
|
// This function takes feature's center, moves it,
|
|
7
10
|
// and builds new feature around it keeping the proportions
|
|
8
11
|
export function translateFromCenter(feature, distance, direction) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import destination from '@turf/destination';
|
|
2
5
|
import bearing from '@turf/bearing';
|
|
3
6
|
import pointToLineDistance from '@turf/point-to-line-distance';
|
|
@@ -49,7 +52,7 @@ export function recursivelyTraverseNestedArrays(array, prefix, fn) {
|
|
|
49
52
|
export function generatePointsParallelToLinePoints(p1, p2, mapCoords) {
|
|
50
53
|
const lineString = {
|
|
51
54
|
type: 'LineString',
|
|
52
|
-
coordinates: [p1, p2]
|
|
55
|
+
coordinates: [p1, p2]
|
|
53
56
|
};
|
|
54
57
|
const pt = point(mapCoords);
|
|
55
58
|
const ddistance = pointToLineDistance(pt, lineString);
|
|
@@ -102,7 +105,7 @@ export function nearestPointOnProjectedLine(line, inPoint, viewport) {
|
|
|
102
105
|
minPointInfo = {
|
|
103
106
|
index,
|
|
104
107
|
x0: (B * (B * x - A * y) - A * C) / div,
|
|
105
|
-
y0: (A * (-B * x + A * y) - B * C) / div
|
|
108
|
+
y0: (A * (-B * x + A * y) - B * C) / div
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
});
|
|
@@ -118,14 +121,13 @@ export function nearestPointOnProjectedLine(line, inPoint, viewport) {
|
|
|
118
121
|
type: 'Feature',
|
|
119
122
|
geometry: {
|
|
120
123
|
type: 'Point',
|
|
121
|
-
|
|
122
|
-
coordinates: wmViewport.unproject([x0, y0, z0]),
|
|
124
|
+
coordinates: wmViewport.unproject([x0, y0, z0])
|
|
123
125
|
},
|
|
124
126
|
properties: {
|
|
125
127
|
// TODO: calculate the distance in proper units
|
|
126
128
|
dist: minDistance,
|
|
127
|
-
index: index - 1
|
|
128
|
-
}
|
|
129
|
+
index: index - 1
|
|
130
|
+
}
|
|
129
131
|
};
|
|
130
132
|
}
|
|
131
133
|
/**
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl-community/editable-layers",
|
|
3
3
|
"description": "A suite of 3D-enabled data editing overlays, suitable for deck.gl",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "9.0.
|
|
5
|
+
"version": "9.0.2",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/visgl/deck.gl-community"
|
|
@@ -62,23 +62,23 @@
|
|
|
62
62
|
"@turf/transform-scale": "^6.5.0",
|
|
63
63
|
"@turf/transform-translate": "^6.5.0",
|
|
64
64
|
"@turf/union": "^6.5.0",
|
|
65
|
+
"@types/geojson": "^7946.0.14",
|
|
65
66
|
"cubic-hermite-spline": "^1.0.1",
|
|
66
67
|
"eventemitter3": "^5.0.0",
|
|
67
|
-
"geojson-types": "^2.0.1",
|
|
68
68
|
"lodash.throttle": "^4.1.1",
|
|
69
69
|
"uuid": "9.0.0",
|
|
70
70
|
"viewport-mercator-project": ">=6.2.3"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@deck.gl/core": "
|
|
74
|
-
"@deck.gl/extensions": "
|
|
75
|
-
"@deck.gl/geo-layers": "
|
|
76
|
-
"@deck.gl/layers": "
|
|
73
|
+
"@deck.gl/core": "^9.0.12",
|
|
74
|
+
"@deck.gl/extensions": "^9.0.12",
|
|
75
|
+
"@deck.gl/geo-layers": "^9.0.12",
|
|
76
|
+
"@deck.gl/layers": "^9.0.12",
|
|
77
77
|
"@deck.gl/mesh-layers": ">=9.0.6",
|
|
78
|
-
"@luma.gl/constants": ">=9.0.
|
|
79
|
-
"@luma.gl/core": ">=9.0.
|
|
80
|
-
"@luma.gl/engine": ">=9.0.
|
|
78
|
+
"@luma.gl/constants": ">=9.0.12",
|
|
79
|
+
"@luma.gl/core": ">=9.0.12",
|
|
80
|
+
"@luma.gl/engine": ">=9.0.12",
|
|
81
81
|
"@math.gl/core": ">=4.0.1"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "646f8328d27d67d596f05c9154072051ec5cf4f0"
|
|
84
84
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.
|
|
3
7
|
* Required in order to maintain the same appearance after upgrading to deck.gl v8.5.
|
|
@@ -11,5 +15,5 @@ export const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;
|
|
|
11
15
|
export const UNIT = {
|
|
12
16
|
common: 0,
|
|
13
17
|
meters: 1,
|
|
14
|
-
pixels: 2
|
|
18
|
+
pixels: 2
|
|
15
19
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {FeatureCollection} from '../utils/geojson-types';
|
|
2
6
|
import {
|
|
3
7
|
ModeProps,
|
|
4
8
|
ClickEvent,
|
|
@@ -7,9 +11,9 @@ import {
|
|
|
7
11
|
StopDraggingEvent,
|
|
8
12
|
DraggingEvent,
|
|
9
13
|
GuideFeatureCollection,
|
|
10
|
-
GuideFeature
|
|
14
|
+
GuideFeature
|
|
11
15
|
} from './types';
|
|
12
|
-
import {
|
|
16
|
+
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
13
17
|
|
|
14
18
|
export class CompositeMode extends GeoJsonEditMode {
|
|
15
19
|
_modes: Array<GeoJsonEditMode>;
|
|
@@ -33,7 +37,7 @@ export class CompositeMode extends GeoJsonEditMode {
|
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
return result
|
|
40
|
+
return result;
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>): void {
|
|
@@ -68,7 +72,7 @@ export class CompositeMode extends GeoJsonEditMode {
|
|
|
68
72
|
|
|
69
73
|
return {
|
|
70
74
|
type: 'FeatureCollection',
|
|
71
|
-
features: allGuides
|
|
75
|
+
features: allGuides
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
78
|
}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import destination from '@turf/destination';
|
|
2
6
|
import bearing from '@turf/bearing';
|
|
3
7
|
import lineIntersect from '@turf/line-intersect';
|
|
4
8
|
import turfDistance from '@turf/distance';
|
|
5
|
-
import {
|
|
9
|
+
import {point, lineString as turfLineString} from '@turf/helpers';
|
|
6
10
|
import {
|
|
7
11
|
generatePointsParallelToLinePoints,
|
|
8
12
|
getPickedEditHandle,
|
|
9
|
-
getEditHandlesForGeometry
|
|
13
|
+
getEditHandlesForGeometry
|
|
10
14
|
} from './utils';
|
|
11
15
|
import {
|
|
12
16
|
ClickEvent,
|
|
13
17
|
PointerMoveEvent,
|
|
14
18
|
ModeProps,
|
|
15
19
|
GuideFeatureCollection,
|
|
16
|
-
TentativeFeature
|
|
20
|
+
TentativeFeature
|
|
17
21
|
} from './types';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
22
|
+
import {Polygon, LineString, Position, FeatureCollection} from '../utils/geojson-types';
|
|
23
|
+
import {GeoJsonEditMode} from './geojson-edit-mode';
|
|
20
24
|
|
|
21
25
|
export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
22
26
|
createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {
|
|
23
27
|
const clickSequence = this.getClickSequence();
|
|
24
28
|
|
|
25
|
-
const {
|
|
29
|
+
const {mapCoords} = props.lastPointerMoveEvent;
|
|
26
30
|
|
|
27
31
|
let p3;
|
|
28
|
-
if (clickSequence.length
|
|
32
|
+
if (clickSequence.length <= 1) {
|
|
29
33
|
p3 = mapCoords;
|
|
30
34
|
} else {
|
|
31
35
|
const p1 = clickSequence[clickSequence.length - 2];
|
|
@@ -40,24 +44,24 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
40
44
|
tentativeFeature = {
|
|
41
45
|
type: 'Feature',
|
|
42
46
|
properties: {
|
|
43
|
-
guideType: 'tentative'
|
|
47
|
+
guideType: 'tentative'
|
|
44
48
|
},
|
|
45
49
|
geometry: {
|
|
46
50
|
type: 'LineString',
|
|
47
|
-
coordinates: [...clickSequence, p3]
|
|
48
|
-
}
|
|
51
|
+
coordinates: [...clickSequence, p3]
|
|
52
|
+
}
|
|
49
53
|
};
|
|
50
54
|
} else {
|
|
51
55
|
// Draw a Polygon connecting all the clicked points with the hovered point
|
|
52
56
|
tentativeFeature = {
|
|
53
57
|
type: 'Feature',
|
|
54
58
|
properties: {
|
|
55
|
-
guideType: 'tentative'
|
|
59
|
+
guideType: 'tentative'
|
|
56
60
|
},
|
|
57
61
|
geometry: {
|
|
58
62
|
type: 'Polygon',
|
|
59
|
-
coordinates: [[...clickSequence, p3, clickSequence[0]]]
|
|
60
|
-
}
|
|
63
|
+
coordinates: [[...clickSequence, p3, clickSequence[0]]]
|
|
64
|
+
}
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
67
|
|
|
@@ -67,7 +71,7 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
67
71
|
getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {
|
|
68
72
|
const guides: GuideFeatureCollection = {
|
|
69
73
|
type: 'FeatureCollection',
|
|
70
|
-
features: []
|
|
74
|
+
features: []
|
|
71
75
|
};
|
|
72
76
|
|
|
73
77
|
const clickSequence = this.getClickSequence();
|
|
@@ -95,7 +99,7 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
|
|
98
|
-
const {
|
|
102
|
+
const {picks} = event;
|
|
99
103
|
const tentativeFeature = this.getTentativeGuide(props);
|
|
100
104
|
this.addClickSequence(event);
|
|
101
105
|
const clickSequence = this.getClickSequence();
|
|
@@ -129,7 +133,7 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
129
133
|
// They clicked the first or last point (or double-clicked), so complete the polygon
|
|
130
134
|
const polygonToAdd: Polygon = {
|
|
131
135
|
type: 'Polygon',
|
|
132
|
-
coordinates: this.finalizedCoordinates([...polygon.coordinates[0]])
|
|
136
|
+
coordinates: this.finalizedCoordinates([...polygon.coordinates[0]])
|
|
133
137
|
};
|
|
134
138
|
|
|
135
139
|
this.resetClickSequence();
|
|
@@ -139,21 +143,21 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
139
143
|
props.onEdit(editAction);
|
|
140
144
|
}
|
|
141
145
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
};
|
|
146
|
+
} else {
|
|
147
|
+
// Trigger pointer move right away in order for it to update edit handles (to support double-click)
|
|
148
|
+
const fakePointerMoveEvent: PointerMoveEvent = {
|
|
149
|
+
screenCoords: [-1, -1],
|
|
150
|
+
mapCoords: event.mapCoords,
|
|
151
|
+
picks: [],
|
|
152
|
+
pointerDownPicks: null,
|
|
153
|
+
pointerDownScreenCoords: null,
|
|
154
|
+
pointerDownMapCoords: null,
|
|
155
|
+
cancelPan: () => {},
|
|
156
|
+
sourceEvent: null
|
|
157
|
+
};
|
|
155
158
|
|
|
156
|
-
|
|
159
|
+
this.handlePointerMove(fakePointerMoveEvent, props);
|
|
160
|
+
}
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
finalizedCoordinates(coords: Position[]) {
|
|
@@ -184,7 +188,7 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
184
188
|
const p4 = coordinates[coordinates.length - 4];
|
|
185
189
|
const angle2 = bearing(p3, p4);
|
|
186
190
|
|
|
187
|
-
const angles = {
|
|
191
|
+
const angles = {first: [] as number[], second: [] as number[]};
|
|
188
192
|
// calculate 3 right angle points for first and last points in lineString
|
|
189
193
|
[1, 2, 3].forEach((factor) => {
|
|
190
194
|
const newAngle1 = angle1 + factor * 90;
|
|
@@ -200,17 +204,17 @@ export class Draw90DegreePolygonMode extends GeoJsonEditMode {
|
|
|
200
204
|
[0, 1, 2].forEach((indexFirst) => {
|
|
201
205
|
const line1 = turfLineString([
|
|
202
206
|
p1,
|
|
203
|
-
destination(p1, distance, angles.first[indexFirst]).geometry.coordinates
|
|
207
|
+
destination(p1, distance, angles.first[indexFirst]).geometry.coordinates
|
|
204
208
|
]);
|
|
205
209
|
[0, 1, 2].forEach((indexSecond) => {
|
|
206
210
|
const line2 = turfLineString([
|
|
207
211
|
p3,
|
|
208
|
-
destination(p3, distance, angles.second[indexSecond]).geometry.coordinates
|
|
212
|
+
destination(p3, distance, angles.second[indexSecond]).geometry.coordinates
|
|
209
213
|
]);
|
|
210
214
|
const fc = lineIntersect(line1, line2);
|
|
211
215
|
if (fc && fc.features.length) {
|
|
212
216
|
// found the intersect point
|
|
213
|
-
pt = fc.features[0].geometry.coordinates
|
|
217
|
+
pt = fc.features[0].geometry.coordinates;
|
|
214
218
|
}
|
|
215
219
|
});
|
|
216
220
|
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import circle from '@turf/circle';
|
|
2
6
|
import distance from '@turf/distance';
|
|
3
7
|
import area from '@turf/area';
|
|
4
|
-
import memoize from '../memoize';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
8
|
+
import {memoize} from '../utils/memoize';
|
|
9
|
+
import {ModeProps, Tooltip} from './types';
|
|
10
|
+
import {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';
|
|
11
|
+
import {getIntermediatePosition} from './geojson-edit-mode';
|
|
12
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
9
13
|
|
|
10
14
|
export class DrawCircleByDiameterMode extends TwoClickPolygonMode {
|
|
11
15
|
radius: number | null | undefined = null;
|
|
@@ -14,8 +18,8 @@ export class DrawCircleByDiameterMode extends TwoClickPolygonMode {
|
|
|
14
18
|
diameter: number | null | undefined = null;
|
|
15
19
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
16
20
|
// Default turf value for circle is 64
|
|
17
|
-
const {
|
|
18
|
-
const options = {
|
|
21
|
+
const {steps = 64} = modeConfig || {};
|
|
22
|
+
const options = {steps};
|
|
19
23
|
|
|
20
24
|
if (steps < 4) {
|
|
21
25
|
console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef
|
|
@@ -50,7 +54,7 @@ export class DrawCircleByDiameterMode extends TwoClickPolygonMode {
|
|
|
50
54
|
modeConfig: props.modeConfig,
|
|
51
55
|
radius: this.radius,
|
|
52
56
|
areaCircle: this.areaCircle,
|
|
53
|
-
diameter: this.diameter
|
|
57
|
+
diameter: this.diameter
|
|
54
58
|
});
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -61,9 +65,9 @@ export class DrawCircleByDiameterMode extends TwoClickPolygonMode {
|
|
|
61
65
|
* @param areaCircle
|
|
62
66
|
* @param diameter
|
|
63
67
|
*/
|
|
64
|
-
_getTooltips = memoize(({
|
|
68
|
+
_getTooltips = memoize(({modeConfig, radius, areaCircle, diameter}) => {
|
|
65
69
|
let tooltips: Tooltip[] = [];
|
|
66
|
-
const {
|
|
70
|
+
const {formatTooltip} = modeConfig || {};
|
|
67
71
|
let text;
|
|
68
72
|
if (radius && areaCircle) {
|
|
69
73
|
if (formatTooltip) {
|
|
@@ -78,8 +82,8 @@ export class DrawCircleByDiameterMode extends TwoClickPolygonMode {
|
|
|
78
82
|
tooltips = [
|
|
79
83
|
{
|
|
80
84
|
position: this.position,
|
|
81
|
-
text
|
|
82
|
-
}
|
|
85
|
+
text
|
|
86
|
+
}
|
|
83
87
|
];
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import circle from '@turf/circle';
|
|
2
6
|
import distance from '@turf/distance';
|
|
3
7
|
import area from '@turf/area';
|
|
4
|
-
import memoize from '../memoize';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
+
import {memoize} from '../utils/memoize';
|
|
9
|
+
import {ModeProps, Tooltip} from './types';
|
|
10
|
+
import {Position, Polygon, FeatureOf, FeatureCollection} from '../utils/geojson-types';
|
|
11
|
+
import {TwoClickPolygonMode} from './two-click-polygon-mode';
|
|
8
12
|
|
|
9
13
|
export class DrawCircleFromCenterMode extends TwoClickPolygonMode {
|
|
10
14
|
radius: number | null | undefined = null;
|
|
@@ -12,8 +16,8 @@ export class DrawCircleFromCenterMode extends TwoClickPolygonMode {
|
|
|
12
16
|
areaCircle: number | null | undefined = null;
|
|
13
17
|
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
14
18
|
// Default turf value for circle is 64
|
|
15
|
-
const {
|
|
16
|
-
const options = {
|
|
19
|
+
const {steps = 64} = modeConfig || {};
|
|
20
|
+
const options = {steps};
|
|
17
21
|
// setting with position of center of circle
|
|
18
22
|
this.position = coord2;
|
|
19
23
|
|
|
@@ -43,7 +47,7 @@ export class DrawCircleFromCenterMode extends TwoClickPolygonMode {
|
|
|
43
47
|
return this._getTooltips({
|
|
44
48
|
modeConfig: props?.modeConfig,
|
|
45
49
|
radius: this.radius,
|
|
46
|
-
areaCircle: this.areaCircle
|
|
50
|
+
areaCircle: this.areaCircle
|
|
47
51
|
});
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -53,9 +57,9 @@ export class DrawCircleFromCenterMode extends TwoClickPolygonMode {
|
|
|
53
57
|
* @param radius
|
|
54
58
|
* @param areaCircle
|
|
55
59
|
*/
|
|
56
|
-
_getTooltips = memoize(({
|
|
60
|
+
_getTooltips = memoize(({modeConfig, radius, areaCircle}) => {
|
|
57
61
|
let tooltips: Tooltip[] = [];
|
|
58
|
-
const {
|
|
62
|
+
const {formatTooltip} = modeConfig || {};
|
|
59
63
|
let text: string;
|
|
60
64
|
if (radius && areaCircle) {
|
|
61
65
|
if (formatTooltip) {
|
|
@@ -69,8 +73,8 @@ export class DrawCircleFromCenterMode extends TwoClickPolygonMode {
|
|
|
69
73
|
tooltips = [
|
|
70
74
|
{
|
|
71
75
|
position: this.position,
|
|
72
|
-
text
|
|
73
|
-
}
|
|
76
|
+
text
|
|
77
|
+
}
|
|
74
78
|
];
|
|
75
79
|
}
|
|
76
80
|
|