@deck.gl-community/editable-layers 9.0.0-alpha.1
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/README.md +82 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +14 -0
- package/dist/curve-utils.d.ts +2 -0
- package/dist/curve-utils.js +61 -0
- package/dist/edit-modes/composite-mode.d.ts +14 -0
- package/dist/edit-modes/composite-mode.js +47 -0
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts +11 -0
- package/dist/edit-modes/draw-90degree-polygon-mode.js +179 -0
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +24 -0
- package/dist/edit-modes/draw-circle-by-diameter-mode.js +78 -0
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +22 -0
- package/dist/edit-modes/draw-circle-from-center-mode.js +70 -0
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +5 -0
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +20 -0
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +5 -0
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +16 -0
- package/dist/edit-modes/draw-line-string-mode.d.ts +25 -0
- package/dist/edit-modes/draw-line-string-mode.js +170 -0
- package/dist/edit-modes/draw-point-mode.d.ts +8 -0
- package/dist/edit-modes/draw-point-mode.js +28 -0
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +14 -0
- package/dist/edit-modes/draw-polygon-by-dragging-mode.js +87 -0
- package/dist/edit-modes/draw-polygon-mode.d.ts +10 -0
- package/dist/edit-modes/draw-polygon-mode.js +143 -0
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +5 -0
- package/dist/edit-modes/draw-rectangle-from-center-mode.js +17 -0
- package/dist/edit-modes/draw-rectangle-mode.d.ts +5 -0
- package/dist/edit-modes/draw-rectangle-mode.js +11 -0
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +5 -0
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.js +28 -0
- package/dist/edit-modes/draw-square-from-center-mode.d.ts +5 -0
- package/dist/edit-modes/draw-square-from-center-mode.js +35 -0
- package/dist/edit-modes/draw-square-mode.d.ts +5 -0
- package/dist/edit-modes/draw-square-mode.js +28 -0
- package/dist/edit-modes/duplicate-mode.d.ts +7 -0
- package/dist/edit-modes/duplicate-mode.js +17 -0
- package/dist/edit-modes/edit-mode.d.ts +11 -0
- package/dist/edit-modes/edit-mode.js +2 -0
- package/dist/edit-modes/elevation-mode.d.ts +13 -0
- package/dist/edit-modes/elevation-mode.js +49 -0
- package/dist/edit-modes/extend-line-string-mode.d.ts +9 -0
- package/dist/edit-modes/extend-line-string-mode.js +72 -0
- package/dist/edit-modes/extrude-mode.d.ts +15 -0
- package/dist/edit-modes/extrude-mode.js +186 -0
- package/dist/edit-modes/geojson-edit-mode.d.ts +33 -0
- package/dist/edit-modes/geojson-edit-mode.js +208 -0
- package/dist/edit-modes/immutable-feature-collection.d.ts +43 -0
- package/dist/edit-modes/immutable-feature-collection.js +300 -0
- package/dist/edit-modes/measure-angle-mode.d.ts +11 -0
- package/dist/edit-modes/measure-angle-mode.js +99 -0
- package/dist/edit-modes/measure-area-mode.d.ts +8 -0
- package/dist/edit-modes/measure-area-mode.js +50 -0
- package/dist/edit-modes/measure-distance-mode.d.ts +19 -0
- package/dist/edit-modes/measure-distance-mode.js +171 -0
- package/dist/edit-modes/modify-mode.d.ts +15 -0
- package/dist/edit-modes/modify-mode.js +203 -0
- package/dist/edit-modes/resize-circle-mode.d.ts +16 -0
- package/dist/edit-modes/resize-circle-mode.js +142 -0
- package/dist/edit-modes/rotate-mode.d.ts +17 -0
- package/dist/edit-modes/rotate-mode.js +151 -0
- package/dist/edit-modes/scale-mode.d.ts +27 -0
- package/dist/edit-modes/scale-mode.js +173 -0
- package/dist/edit-modes/snappable-mode.d.ts +21 -0
- package/dist/edit-modes/snappable-mode.js +109 -0
- package/dist/edit-modes/split-polygon-mode.d.ts +10 -0
- package/dist/edit-modes/split-polygon-mode.js +164 -0
- package/dist/edit-modes/three-click-polygon-mode.d.ts +10 -0
- package/dist/edit-modes/three-click-polygon-mode.js +72 -0
- package/dist/edit-modes/transform-mode.d.ts +9 -0
- package/dist/edit-modes/transform-mode.js +63 -0
- package/dist/edit-modes/translate-mode.d.ts +13 -0
- package/dist/edit-modes/translate-mode.js +113 -0
- package/dist/edit-modes/two-click-polygon-mode.d.ts +13 -0
- package/dist/edit-modes/two-click-polygon-mode.js +93 -0
- package/dist/edit-modes/types.d.ts +86 -0
- package/dist/edit-modes/types.js +1 -0
- package/dist/edit-modes/utils.d.ts +36 -0
- package/dist/edit-modes/utils.js +381 -0
- package/dist/edit-modes/view-mode.d.ts +3 -0
- package/dist/edit-modes/view-mode.js +3 -0
- package/dist/editable-layers/editable-geojson-layer.d.ts +98 -0
- package/dist/editable-layers/editable-geojson-layer.js +450 -0
- package/dist/editable-layers/editable-h3-cluster-layer.d.ts +34 -0
- package/dist/editable-layers/editable-h3-cluster-layer.js +164 -0
- package/dist/editable-layers/editable-layer.d.ts +49 -0
- package/dist/editable-layers/editable-layer.js +195 -0
- package/dist/editable-layers/editable-path-layer.d.ts +9 -0
- package/dist/editable-layers/editable-path-layer.js +34 -0
- package/dist/editable-layers/elevated-edit-handle-layer.d.ts +7 -0
- package/dist/editable-layers/elevated-edit-handle-layer.js +24 -0
- package/dist/editable-layers/junction-scatterplot-layer.d.ts +14 -0
- package/dist/editable-layers/junction-scatterplot-layer.js +41 -0
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.d.ts +4 -0
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.js +55 -0
- package/dist/editable-layers/path-marker-layer/create-path-markers.d.ts +16 -0
- package/dist/editable-layers/path-marker-layer/create-path-markers.js +75 -0
- package/dist/editable-layers/path-marker-layer/path-marker-layer.d.ts +40 -0
- package/dist/editable-layers/path-marker-layer/path-marker-layer.js +121 -0
- package/dist/editable-layers/path-marker-layer/polyline.d.ts +18 -0
- package/dist/editable-layers/path-marker-layer/polyline.js +37 -0
- package/dist/editable-layers/path-outline-layer/path-outline-layer.d.ts +26 -0
- package/dist/editable-layers/path-outline-layer/path-outline-layer.js +106 -0
- package/dist/editable-layers/selection-layer.d.ts +26 -0
- package/dist/editable-layers/selection-layer.js +167 -0
- package/dist/geojson-types.d.ts +58 -0
- package/dist/geojson-types.js +2 -0
- package/dist/index.cjs +5825 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +62 -0
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +6 -0
- package/dist/lib/deck-renderer/deck-cache.d.ts +14 -0
- package/dist/lib/deck-renderer/deck-cache.js +51 -0
- package/dist/lib/deck-renderer/deck-drawer.d.ts +63 -0
- package/dist/lib/deck-renderer/deck-drawer.js +232 -0
- package/dist/lib/feature.d.ts +10 -0
- package/dist/lib/feature.js +16 -0
- package/dist/lib/layer-mouse-event.d.ts +11 -0
- package/dist/lib/layer-mouse-event.js +24 -0
- package/dist/lib/layers/junctions-layer.d.ts +8 -0
- package/dist/lib/layers/junctions-layer.js +33 -0
- package/dist/lib/layers/segments-layer.d.ts +18 -0
- package/dist/lib/layers/segments-layer.js +94 -0
- package/dist/lib/layers/texts-layer.d.ts +8 -0
- package/dist/lib/layers/texts-layer.js +32 -0
- package/dist/lib/math.d.ts +11 -0
- package/dist/lib/math.js +22 -0
- package/dist/lib/nebula-layer.d.ts +13 -0
- package/dist/lib/nebula-layer.js +26 -0
- package/dist/lib/nebula.d.ts +34 -0
- package/dist/lib/nebula.js +254 -0
- package/dist/lib/style.d.ts +19 -0
- package/dist/lib/style.js +20 -0
- package/dist/memoize.d.ts +6 -0
- package/dist/memoize.js +40 -0
- package/dist/mode-handlers/composite-mode-handler.d.ts +24 -0
- package/dist/mode-handlers/composite-mode-handler.js +55 -0
- package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts +13 -0
- package/dist/mode-handlers/draw-90degree-polygon-handler.js +169 -0
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +29 -0
- package/dist/mode-handlers/draw-circle-from-center-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-circle-from-center-handler.js +27 -0
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +30 -0
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +37 -0
- package/dist/mode-handlers/draw-line-string-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-line-string-handler.js +83 -0
- package/dist/mode-handlers/draw-point-handler.d.ts +5 -0
- package/dist/mode-handlers/draw-point-handler.js +11 -0
- package/dist/mode-handlers/draw-polygon-handler.d.ts +11 -0
- package/dist/mode-handlers/draw-polygon-handler.js +92 -0
- package/dist/mode-handlers/draw-rectangle-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-rectangle-handler.js +18 -0
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +49 -0
- package/dist/mode-handlers/duplicate-handler.d.ts +9 -0
- package/dist/mode-handlers/duplicate-handler.js +19 -0
- package/dist/mode-handlers/elevation-handler.d.ts +19 -0
- package/dist/mode-handlers/elevation-handler.js +48 -0
- package/dist/mode-handlers/extrude-handler.d.ts +18 -0
- package/dist/mode-handlers/extrude-handler.js +176 -0
- package/dist/mode-handlers/mode-handler.d.ts +61 -0
- package/dist/mode-handlers/mode-handler.js +286 -0
- package/dist/mode-handlers/modify-handler.d.ts +19 -0
- package/dist/mode-handlers/modify-handler.js +193 -0
- package/dist/mode-handlers/rotate-handler.d.ts +17 -0
- package/dist/mode-handlers/rotate-handler.js +74 -0
- package/dist/mode-handlers/scale-handler.d.ts +17 -0
- package/dist/mode-handlers/scale-handler.js +76 -0
- package/dist/mode-handlers/snappable-handler.d.ts +33 -0
- package/dist/mode-handlers/snappable-handler.js +133 -0
- package/dist/mode-handlers/split-polygon-handler.d.ts +11 -0
- package/dist/mode-handlers/split-polygon-handler.js +154 -0
- package/dist/mode-handlers/three-click-polygon-handler.d.ts +5 -0
- package/dist/mode-handlers/three-click-polygon-handler.js +18 -0
- package/dist/mode-handlers/translate-handler.d.ts +17 -0
- package/dist/mode-handlers/translate-handler.js +72 -0
- package/dist/mode-handlers/two-click-polygon-handler.d.ts +5 -0
- package/dist/mode-handlers/two-click-polygon-handler.js +18 -0
- package/dist/mode-handlers/view-handler.d.ts +8 -0
- package/dist/mode-handlers/view-handler.js +10 -0
- package/dist/shaderlib/color/color.d.ts +8 -0
- package/dist/shaderlib/color/color.js +51 -0
- package/dist/shaderlib/outline/outline.d.ts +8 -0
- package/dist/shaderlib/outline/outline.js +97 -0
- package/dist/shaderlib/utils/utils.d.ts +8 -0
- package/dist/shaderlib/utils/utils.js +28 -0
- package/dist/translateFromCenter.d.ts +4 -0
- package/dist/translateFromCenter.js +19 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +144 -0
- package/package.json +84 -0
- package/src/constants.ts +15 -0
- package/src/curve-utils.ts +77 -0
- package/src/edit-modes/composite-mode.ts +74 -0
- package/src/edit-modes/draw-90degree-polygon-mode.ts +220 -0
- package/src/edit-modes/draw-circle-by-diameter-mode.ts +88 -0
- package/src/edit-modes/draw-circle-from-center-mode.ts +79 -0
- package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +25 -0
- package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +23 -0
- package/src/edit-modes/draw-line-string-mode.ts +200 -0
- package/src/edit-modes/draw-point-mode.ts +35 -0
- package/src/edit-modes/draw-polygon-by-dragging-mode.ts +106 -0
- package/src/edit-modes/draw-polygon-mode.ts +171 -0
- package/src/edit-modes/draw-rectangle-from-center-mode.ts +23 -0
- package/src/edit-modes/draw-rectangle-mode.ts +14 -0
- package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +36 -0
- package/src/edit-modes/draw-square-from-center-mode.ts +46 -0
- package/src/edit-modes/draw-square-mode.ts +36 -0
- package/src/edit-modes/duplicate-mode.ts +21 -0
- package/src/edit-modes/edit-mode.ts +30 -0
- package/src/edit-modes/elevation-mode.ts +86 -0
- package/src/edit-modes/extend-line-string-mode.ts +87 -0
- package/src/edit-modes/extrude-mode.ts +254 -0
- package/src/edit-modes/geojson-edit-mode.ts +283 -0
- package/src/edit-modes/immutable-feature-collection.ts +417 -0
- package/src/edit-modes/measure-angle-mode.ts +127 -0
- package/src/edit-modes/measure-area-mode.ts +62 -0
- package/src/edit-modes/measure-distance-mode.ts +215 -0
- package/src/edit-modes/modify-mode.ts +293 -0
- package/src/edit-modes/resize-circle-mode.ts +202 -0
- package/src/edit-modes/rotate-mode.ts +208 -0
- package/src/edit-modes/scale-mode.ts +231 -0
- package/src/edit-modes/snappable-mode.ts +174 -0
- package/src/edit-modes/split-polygon-mode.ts +201 -0
- package/src/edit-modes/three-click-polygon-mode.ts +111 -0
- package/src/edit-modes/transform-mode.ts +75 -0
- package/src/edit-modes/translate-mode.ts +161 -0
- package/src/edit-modes/two-click-polygon-mode.ts +132 -0
- package/src/edit-modes/types.ts +135 -0
- package/src/edit-modes/utils.ts +513 -0
- package/src/edit-modes/view-mode.ts +3 -0
- package/src/editable-layers/editable-geojson-layer.ts +603 -0
- package/src/editable-layers/editable-h3-cluster-layer.ts +226 -0
- package/src/editable-layers/editable-layer.ts +252 -0
- package/src/editable-layers/editable-path-layer.ts +51 -0
- package/src/editable-layers/elevated-edit-handle-layer.ts +33 -0
- package/src/editable-layers/junction-scatterplot-layer.ts +53 -0
- package/src/editable-layers/path-marker-layer/arrow-2d-geometry.ts +61 -0
- package/src/editable-layers/path-marker-layer/create-path-markers.ts +107 -0
- package/src/editable-layers/path-marker-layer/path-marker-layer.ts +179 -0
- package/src/editable-layers/path-marker-layer/polyline.ts +40 -0
- package/src/editable-layers/path-outline-layer/path-outline-layer.ts +147 -0
- package/src/editable-layers/selection-layer.ts +209 -0
- package/src/geojson-types.ts +89 -0
- package/src/index.ts +125 -0
- package/src/lib/constants.ts +6 -0
- package/src/lib/deck-renderer/deck-cache.ts +61 -0
- package/src/lib/deck-renderer/deck-drawer.ts +263 -0
- package/src/lib/feature.ts +27 -0
- package/src/lib/layer-mouse-event.ts +32 -0
- package/src/lib/layers/junctions-layer.ts +40 -0
- package/src/lib/layers/segments-layer.ts +108 -0
- package/src/lib/layers/texts-layer.ts +43 -0
- package/src/lib/math.ts +26 -0
- package/src/lib/nebula-layer.ts +33 -0
- package/src/lib/nebula.ts +323 -0
- package/src/lib/style.ts +22 -0
- package/src/memoize.ts +43 -0
- package/src/mode-handlers/composite-mode-handler.ts +89 -0
- package/src/mode-handlers/draw-90degree-polygon-handler.ts +201 -0
- package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +39 -0
- package/src/mode-handlers/draw-circle-from-center-handler.ts +38 -0
- package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +41 -0
- package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +46 -0
- package/src/mode-handlers/draw-line-string-handler.ts +108 -0
- package/src/mode-handlers/draw-point-handler.ts +15 -0
- package/src/mode-handlers/draw-polygon-handler.ts +121 -0
- package/src/mode-handlers/draw-rectangle-handler.ts +28 -0
- package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +60 -0
- package/src/mode-handlers/duplicate-handler.ts +25 -0
- package/src/mode-handlers/elevation-handler.ts +88 -0
- package/src/mode-handlers/extrude-handler.ts +245 -0
- package/src/mode-handlers/mode-handler.ts +394 -0
- package/src/mode-handlers/modify-handler.ts +263 -0
- package/src/mode-handlers/rotate-handler.ts +107 -0
- package/src/mode-handlers/scale-handler.ts +105 -0
- package/src/mode-handlers/snappable-handler.ts +184 -0
- package/src/mode-handlers/split-polygon-handler.ts +177 -0
- package/src/mode-handlers/three-click-polygon-handler.ts +25 -0
- package/src/mode-handlers/translate-handler.ts +110 -0
- package/src/mode-handlers/two-click-polygon-handler.ts +25 -0
- package/src/mode-handlers/view-handler.ts +13 -0
- package/src/shaderlib/color/color.ts +56 -0
- package/src/shaderlib/outline/outline.ts +101 -0
- package/src/shaderlib/utils/utils.ts +33 -0
- package/src/translateFromCenter.ts +48 -0
- package/src/types.ts +39 -0
- package/src/utils.ts +185 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import circle from '@turf/circle';
|
|
2
|
+
import distance from '@turf/distance';
|
|
3
|
+
import area from '@turf/area';
|
|
4
|
+
import memoize from '../memoize';
|
|
5
|
+
import { ModeProps, Tooltip } from './types';
|
|
6
|
+
import { Position, Polygon, FeatureOf, FeatureCollection } from '../geojson-types';
|
|
7
|
+
import { getIntermediatePosition } from './geojson-edit-mode';
|
|
8
|
+
import { TwoClickPolygonMode } from './two-click-polygon-mode';
|
|
9
|
+
|
|
10
|
+
export class DrawCircleByDiameterMode extends TwoClickPolygonMode {
|
|
11
|
+
radius: number | null | undefined = null;
|
|
12
|
+
position: Position = null!;
|
|
13
|
+
areaCircle: number | null | undefined = null;
|
|
14
|
+
diameter: number | null | undefined = null;
|
|
15
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
16
|
+
// Default turf value for circle is 64
|
|
17
|
+
const { steps = 64 } = modeConfig || {};
|
|
18
|
+
const options = { steps };
|
|
19
|
+
|
|
20
|
+
if (steps < 4) {
|
|
21
|
+
console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef
|
|
22
|
+
options.steps = 4;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const centerCoordinates = getIntermediatePosition(coord1, coord2);
|
|
26
|
+
// setting value of radius as distance of center and other point
|
|
27
|
+
this.radius = Math.max(distance(coord1, centerCoordinates), 0.001);
|
|
28
|
+
// setting value of diameter as distance of points
|
|
29
|
+
this.diameter = Math.max(distance(coord1, coord2), 0.001);
|
|
30
|
+
// setting position tooltip as center of circle
|
|
31
|
+
this.position = centerCoordinates;
|
|
32
|
+
|
|
33
|
+
const geometry = circle(centerCoordinates, this.radius, options);
|
|
34
|
+
|
|
35
|
+
geometry.properties = geometry.properties || {};
|
|
36
|
+
geometry.properties.shape = 'Circle';
|
|
37
|
+
// calculate area of circle with turf function
|
|
38
|
+
this.areaCircle = area(geometry);
|
|
39
|
+
// @ts-expect-error turf types diff
|
|
40
|
+
return geometry;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* define the default function to display the tooltip for
|
|
45
|
+
* nebula geometry mode type
|
|
46
|
+
* @param props properties of geometry nebula mode
|
|
47
|
+
*/
|
|
48
|
+
getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {
|
|
49
|
+
return this._getTooltips({
|
|
50
|
+
modeConfig: props.modeConfig,
|
|
51
|
+
radius: this.radius,
|
|
52
|
+
areaCircle: this.areaCircle,
|
|
53
|
+
diameter: this.diameter,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* redefine the tooltip of geometry
|
|
59
|
+
* @param modeConfig
|
|
60
|
+
* @param radius
|
|
61
|
+
* @param areaCircle
|
|
62
|
+
* @param diameter
|
|
63
|
+
*/
|
|
64
|
+
_getTooltips = memoize(({ modeConfig, radius, areaCircle, diameter }) => {
|
|
65
|
+
let tooltips: Tooltip[] = [];
|
|
66
|
+
const { formatTooltip } = modeConfig || {};
|
|
67
|
+
let text;
|
|
68
|
+
if (radius && areaCircle) {
|
|
69
|
+
if (formatTooltip) {
|
|
70
|
+
text = formatTooltip(radius);
|
|
71
|
+
} else {
|
|
72
|
+
// By default, round to 2 decimal places and append units
|
|
73
|
+
text = `Radius: ${parseFloat(radius).toFixed(2)} kilometers
|
|
74
|
+
\n Area: ${parseFloat(areaCircle).toFixed(2)}
|
|
75
|
+
\n Diameter: ${parseFloat(diameter).toFixed(2)} kilometers`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
tooltips = [
|
|
79
|
+
{
|
|
80
|
+
position: this.position,
|
|
81
|
+
text,
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return tooltips;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import circle from '@turf/circle';
|
|
2
|
+
import distance from '@turf/distance';
|
|
3
|
+
import area from '@turf/area';
|
|
4
|
+
import memoize from '../memoize';
|
|
5
|
+
import { ModeProps, Tooltip } from './types';
|
|
6
|
+
import { Position, Polygon, FeatureOf, FeatureCollection } from '../geojson-types';
|
|
7
|
+
import { TwoClickPolygonMode } from './two-click-polygon-mode';
|
|
8
|
+
|
|
9
|
+
export class DrawCircleFromCenterMode extends TwoClickPolygonMode {
|
|
10
|
+
radius: number | null | undefined = null;
|
|
11
|
+
position: Position = null!;
|
|
12
|
+
areaCircle: number | null | undefined = null;
|
|
13
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
14
|
+
// Default turf value for circle is 64
|
|
15
|
+
const { steps = 64 } = modeConfig || {};
|
|
16
|
+
const options = { steps };
|
|
17
|
+
// setting with position of center of circle
|
|
18
|
+
this.position = coord2;
|
|
19
|
+
|
|
20
|
+
if (steps < 4) {
|
|
21
|
+
console.warn('Minimum steps to draw a circle is 4 '); // eslint-disable-line no-console,no-undef
|
|
22
|
+
options.steps = 4;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// setting value of radius as distance of center and other point
|
|
26
|
+
this.radius = Math.max(distance(coord1, coord2), 0.001);
|
|
27
|
+
const geometry = circle(coord1, this.radius, options);
|
|
28
|
+
|
|
29
|
+
geometry.properties = geometry.properties || {};
|
|
30
|
+
geometry.properties.shape = 'Circle';
|
|
31
|
+
// calculate area of circle with turf function
|
|
32
|
+
this.areaCircle = area(geometry);
|
|
33
|
+
// @ts-expect-error turf types diff
|
|
34
|
+
return geometry;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* define the default function to display the tooltip for
|
|
39
|
+
* nebula geometry mode type
|
|
40
|
+
* @param props properties of geometry nebula mode
|
|
41
|
+
*/
|
|
42
|
+
getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {
|
|
43
|
+
return this._getTooltips({
|
|
44
|
+
modeConfig: props?.modeConfig,
|
|
45
|
+
radius: this.radius,
|
|
46
|
+
areaCircle: this.areaCircle,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* redefine the tooltip of geometry
|
|
52
|
+
* @param modeConfig
|
|
53
|
+
* @param radius
|
|
54
|
+
* @param areaCircle
|
|
55
|
+
*/
|
|
56
|
+
_getTooltips = memoize(({ modeConfig, radius, areaCircle }) => {
|
|
57
|
+
let tooltips: Tooltip[] = [];
|
|
58
|
+
const { formatTooltip } = modeConfig || {};
|
|
59
|
+
let text: string;
|
|
60
|
+
if (radius && areaCircle) {
|
|
61
|
+
if (formatTooltip) {
|
|
62
|
+
text = formatTooltip(radius);
|
|
63
|
+
} else {
|
|
64
|
+
// By default, round to 2 decimal places and append units
|
|
65
|
+
text = `Radius: ${parseFloat(radius).toFixed(2)} kilometers
|
|
66
|
+
\n Area: ${parseFloat(areaCircle).toFixed(2)}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
tooltips = [
|
|
70
|
+
{
|
|
71
|
+
position: this.position,
|
|
72
|
+
text,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return tooltips;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import bboxPolygon from '@turf/bbox-polygon';
|
|
2
|
+
import distance from '@turf/distance';
|
|
3
|
+
import ellipse from '@turf/ellipse';
|
|
4
|
+
import { point } from '@turf/helpers';
|
|
5
|
+
import { Position, Polygon, FeatureOf } from '../geojson-types';
|
|
6
|
+
import { getIntermediatePosition } from './geojson-edit-mode';
|
|
7
|
+
import { TwoClickPolygonMode } from './two-click-polygon-mode';
|
|
8
|
+
|
|
9
|
+
export class DrawEllipseByBoundingBoxMode extends TwoClickPolygonMode {
|
|
10
|
+
getTwoClickPolygon(coord1: Position, coord2: Position, modeConfig: any): FeatureOf<Polygon> {
|
|
11
|
+
const minX = Math.min(coord1[0], coord2[0]);
|
|
12
|
+
const minY = Math.min(coord1[1], coord2[1]);
|
|
13
|
+
const maxX = Math.max(coord1[0], coord2[0]);
|
|
14
|
+
const maxY = Math.max(coord1[1], coord2[1]);
|
|
15
|
+
|
|
16
|
+
const polygonPoints = bboxPolygon([minX, minY, maxX, maxY]).geometry.coordinates[0];
|
|
17
|
+
const centerCoordinates = getIntermediatePosition(coord1, coord2);
|
|
18
|
+
|
|
19
|
+
const xSemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[1])), 0.001);
|
|
20
|
+
const ySemiAxis = Math.max(distance(point(polygonPoints[0]), point(polygonPoints[3])), 0.001);
|
|
21
|
+
|
|
22
|
+
// @ts-expect-error fix return types
|
|
23
|
+
return ellipse(centerCoordinates, xSemiAxis, ySemiAxis);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import distance from '@turf/distance';
|
|
2
|
+
import ellipse from '@turf/ellipse';
|
|
3
|
+
import bearing from '@turf/bearing';
|
|
4
|
+
import { point } from '@turf/helpers';
|
|
5
|
+
import { Position, Polygon, FeatureOf } from '../geojson-types';
|
|
6
|
+
import { getIntermediatePosition } from './geojson-edit-mode';
|
|
7
|
+
import { ThreeClickPolygonMode } from './three-click-polygon-mode';
|
|
8
|
+
|
|
9
|
+
export class DrawEllipseUsingThreePointsMode extends ThreeClickPolygonMode {
|
|
10
|
+
getThreeClickPolygon(
|
|
11
|
+
coord1: Position,
|
|
12
|
+
coord2: Position,
|
|
13
|
+
coord3: Position,
|
|
14
|
+
modeConfig: any
|
|
15
|
+
): FeatureOf<Polygon> | null | undefined {
|
|
16
|
+
const centerCoordinates = getIntermediatePosition(coord1, coord2);
|
|
17
|
+
const xSemiAxis = Math.max(distance(centerCoordinates, point(coord3)), 0.001);
|
|
18
|
+
const ySemiAxis = Math.max(distance(coord1, coord2), 0.001) / 2;
|
|
19
|
+
const options = { angle: bearing(coord1, coord2) };
|
|
20
|
+
// @ts-expect-error fix return types
|
|
21
|
+
return ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import distance from '@turf/distance';
|
|
2
|
+
import memoize from '../memoize';
|
|
3
|
+
import { LineString, FeatureCollection, Position } from '../geojson-types';
|
|
4
|
+
import {
|
|
5
|
+
ClickEvent,
|
|
6
|
+
PointerMoveEvent,
|
|
7
|
+
ModeProps,
|
|
8
|
+
GuideFeatureCollection,
|
|
9
|
+
GuideFeature,
|
|
10
|
+
Tooltip,
|
|
11
|
+
} from './types';
|
|
12
|
+
import { getPickedEditHandle } from './utils';
|
|
13
|
+
import { GeoJsonEditMode } from './geojson-edit-mode';
|
|
14
|
+
|
|
15
|
+
export class DrawLineStringMode extends GeoJsonEditMode {
|
|
16
|
+
// declaration of variables for the calculation of the distance of linestring
|
|
17
|
+
dist = 0;
|
|
18
|
+
position: Position = null!;
|
|
19
|
+
elems: Position[] = [];
|
|
20
|
+
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
|
|
21
|
+
const { picks } = event;
|
|
22
|
+
const clickedEditHandle = getPickedEditHandle(picks);
|
|
23
|
+
|
|
24
|
+
let positionAdded = false;
|
|
25
|
+
if (!clickedEditHandle) {
|
|
26
|
+
// Don't add another point right next to an existing one
|
|
27
|
+
this.addClickSequence(event);
|
|
28
|
+
positionAdded = true;
|
|
29
|
+
}
|
|
30
|
+
const clickSequence = this.getClickSequence();
|
|
31
|
+
|
|
32
|
+
// check if the pointer is on editable state calculate the distance of new point
|
|
33
|
+
if (!clickedEditHandle) {
|
|
34
|
+
this.calculateInfoDraw(clickSequence);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
clickSequence.length > 1 &&
|
|
39
|
+
clickedEditHandle &&
|
|
40
|
+
Array.isArray(clickedEditHandle.properties.positionIndexes) &&
|
|
41
|
+
clickedEditHandle.properties.positionIndexes[0] === clickSequence.length - 1
|
|
42
|
+
) {
|
|
43
|
+
// They clicked the last point (or double-clicked), so add the LineString
|
|
44
|
+
// reset distance to new calculate
|
|
45
|
+
this.dist = 0;
|
|
46
|
+
const lineStringToAdd: LineString = {
|
|
47
|
+
type: 'LineString',
|
|
48
|
+
coordinates: [...clickSequence],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
this.resetClickSequence();
|
|
52
|
+
|
|
53
|
+
const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);
|
|
54
|
+
if (editAction) {
|
|
55
|
+
props.onEdit(editAction);
|
|
56
|
+
}
|
|
57
|
+
} else if (positionAdded) {
|
|
58
|
+
// new tentative point
|
|
59
|
+
props.onEdit({
|
|
60
|
+
// data is the same
|
|
61
|
+
updatedData: props.data,
|
|
62
|
+
editType: 'addTentativePosition',
|
|
63
|
+
editContext: {
|
|
64
|
+
position: event.mapCoords,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {
|
|
71
|
+
const { key } = event;
|
|
72
|
+
if (key === 'Enter') {
|
|
73
|
+
const clickSequence = this.getClickSequence();
|
|
74
|
+
if (clickSequence.length > 1) {
|
|
75
|
+
const lineStringToAdd: LineString = {
|
|
76
|
+
type: 'LineString',
|
|
77
|
+
coordinates: [...clickSequence],
|
|
78
|
+
};
|
|
79
|
+
this.resetClickSequence();
|
|
80
|
+
const editAction = this.getAddFeatureAction(lineStringToAdd, props.data);
|
|
81
|
+
if (editAction) {
|
|
82
|
+
props.onEdit(editAction);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} else if (key === 'Escape') {
|
|
86
|
+
this.resetClickSequence();
|
|
87
|
+
props.onEdit({
|
|
88
|
+
// Because the new drawing feature is dropped, so the data will keep as the same.
|
|
89
|
+
updatedData: props.data,
|
|
90
|
+
editType: 'cancelFeature',
|
|
91
|
+
editContext: {},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getGuides(props: ModeProps<FeatureCollection>): GuideFeatureCollection {
|
|
97
|
+
const { lastPointerMoveEvent } = props;
|
|
98
|
+
const clickSequence = this.getClickSequence();
|
|
99
|
+
|
|
100
|
+
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
|
|
101
|
+
|
|
102
|
+
const guides: GuideFeatureCollection = {
|
|
103
|
+
type: 'FeatureCollection',
|
|
104
|
+
features: [],
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
let tentativeFeature;
|
|
108
|
+
if (clickSequence.length > 0) {
|
|
109
|
+
tentativeFeature = {
|
|
110
|
+
type: 'Feature',
|
|
111
|
+
properties: {
|
|
112
|
+
guideType: 'tentative',
|
|
113
|
+
},
|
|
114
|
+
geometry: {
|
|
115
|
+
type: 'LineString',
|
|
116
|
+
coordinates: [...clickSequence, ...lastCoords],
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (tentativeFeature) {
|
|
122
|
+
guides.features.push(tentativeFeature);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const editHandles: GuideFeature[] = clickSequence.map((clickedCoord, index) => ({
|
|
126
|
+
type: 'Feature',
|
|
127
|
+
properties: {
|
|
128
|
+
guideType: 'editHandle',
|
|
129
|
+
editHandleType: 'existing',
|
|
130
|
+
featureIndex: -1,
|
|
131
|
+
positionIndexes: [index],
|
|
132
|
+
},
|
|
133
|
+
geometry: {
|
|
134
|
+
type: 'Point',
|
|
135
|
+
coordinates: clickedCoord,
|
|
136
|
+
},
|
|
137
|
+
}));
|
|
138
|
+
|
|
139
|
+
guides.features.push(...editHandles);
|
|
140
|
+
return guides;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {
|
|
144
|
+
props.onUpdateCursor('cell');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* define the default function to display the tooltip for
|
|
149
|
+
* nebula geometry mode type
|
|
150
|
+
* @param props properties of geometry nebula mode
|
|
151
|
+
*/
|
|
152
|
+
getTooltips(props: ModeProps<FeatureCollection>): Tooltip[] {
|
|
153
|
+
return this._getTooltips({
|
|
154
|
+
modeConfig: props.modeConfig,
|
|
155
|
+
dist: this.dist,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// utility function
|
|
160
|
+
calculateInfoDraw(clickSequence) {
|
|
161
|
+
// check if the selected points are at least 2
|
|
162
|
+
if (clickSequence.length > 1) {
|
|
163
|
+
// setting the last point
|
|
164
|
+
this.position = clickSequence[clickSequence.length - 1];
|
|
165
|
+
// calculate the new distance by adding the
|
|
166
|
+
// distance of the new drawn linestring
|
|
167
|
+
this.dist += distance(
|
|
168
|
+
clickSequence[clickSequence.length - 2],
|
|
169
|
+
clickSequence[clickSequence.length - 1]
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* redefine the tooltip of geometry
|
|
176
|
+
* @param modeConfig
|
|
177
|
+
* @param dist
|
|
178
|
+
*/
|
|
179
|
+
_getTooltips = memoize(({ modeConfig, dist }) => {
|
|
180
|
+
let tooltips: Tooltip[] = [];
|
|
181
|
+
const { formatTooltip } = modeConfig || {};
|
|
182
|
+
let text;
|
|
183
|
+
if (dist) {
|
|
184
|
+
if (formatTooltip) {
|
|
185
|
+
text = formatTooltip(dist);
|
|
186
|
+
} else {
|
|
187
|
+
// By default, round to 2 decimal places and append units
|
|
188
|
+
text = `Distance: ${parseFloat(dist).toFixed(2)} kilometers`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
tooltips = [
|
|
192
|
+
{
|
|
193
|
+
position: this.position,
|
|
194
|
+
text,
|
|
195
|
+
},
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
return tooltips;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ClickEvent, PointerMoveEvent, ModeProps, TentativeFeature } from './types';
|
|
2
|
+
import { FeatureCollection, Point } from '../geojson-types';
|
|
3
|
+
import { GeoJsonEditMode } from './geojson-edit-mode';
|
|
4
|
+
|
|
5
|
+
export class DrawPointMode extends GeoJsonEditMode {
|
|
6
|
+
createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {
|
|
7
|
+
const { lastPointerMoveEvent } = props;
|
|
8
|
+
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
type: 'Feature',
|
|
12
|
+
properties: {
|
|
13
|
+
guideType: 'tentative',
|
|
14
|
+
},
|
|
15
|
+
geometry: {
|
|
16
|
+
type: 'Point',
|
|
17
|
+
coordinates: lastCoords[0],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
handleClick({ mapCoords }: ClickEvent, props: ModeProps<FeatureCollection>): void {
|
|
23
|
+
const geometry: Point = {
|
|
24
|
+
type: 'Point',
|
|
25
|
+
coordinates: mapCoords,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
props.onEdit(this.getAddFeatureAction(geometry, props.data));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {
|
|
32
|
+
props.onUpdateCursor('cell');
|
|
33
|
+
super.handlePointerMove(event, props);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import throttle from 'lodash.throttle';
|
|
2
|
+
import {
|
|
3
|
+
ClickEvent,
|
|
4
|
+
StartDraggingEvent,
|
|
5
|
+
StopDraggingEvent,
|
|
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';
|
|
12
|
+
|
|
13
|
+
type DraggingHandler = (event: DraggingEvent, props: ModeProps<FeatureCollection>) => void;
|
|
14
|
+
|
|
15
|
+
export class DrawPolygonByDraggingMode extends DrawPolygonMode {
|
|
16
|
+
handleDraggingThrottled: DraggingHandler | null | undefined = null;
|
|
17
|
+
|
|
18
|
+
handleClick(event: ClickEvent, props: ModeProps<FeatureCollection>) {
|
|
19
|
+
// No-op
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
handleStartDragging(event: StartDraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
23
|
+
event.cancelPan();
|
|
24
|
+
if (props.modeConfig && props.modeConfig.throttleMs) {
|
|
25
|
+
this.handleDraggingThrottled = throttle(this.handleDraggingAux, props.modeConfig.throttleMs);
|
|
26
|
+
} else {
|
|
27
|
+
this.handleDraggingThrottled = this.handleDraggingAux;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
handleStopDragging(event: StopDraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
32
|
+
this.addClickSequence(event);
|
|
33
|
+
const clickSequence = this.getClickSequence();
|
|
34
|
+
// @ts-expect-error cancel() not typed
|
|
35
|
+
if (this.handleDraggingThrottled && this.handleDraggingThrottled.cancel) {
|
|
36
|
+
// @ts-expect-error cancel() not typed
|
|
37
|
+
this.handleDraggingThrottled.cancel();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (clickSequence.length > 2) {
|
|
41
|
+
// Complete the polygon.
|
|
42
|
+
const polygonToAdd: Polygon = {
|
|
43
|
+
type: 'Polygon',
|
|
44
|
+
coordinates: [[...clickSequence, clickSequence[0]]],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);
|
|
48
|
+
if (editAction) {
|
|
49
|
+
props.onEdit(editAction);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this.resetClickSequence();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
handleDraggingAux(event: DraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
56
|
+
const { picks } = event;
|
|
57
|
+
const clickedEditHandle = getPickedEditHandle(picks);
|
|
58
|
+
|
|
59
|
+
if (!clickedEditHandle) {
|
|
60
|
+
// Don't add another point right next to an existing one.
|
|
61
|
+
this.addClickSequence(event);
|
|
62
|
+
props.onEdit({
|
|
63
|
+
updatedData: props.data,
|
|
64
|
+
editType: 'addTentativePosition',
|
|
65
|
+
editContext: {
|
|
66
|
+
position: event.mapCoords,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
handleDragging(event: DraggingEvent, props: ModeProps<FeatureCollection>) {
|
|
73
|
+
if (this.handleDraggingThrottled) {
|
|
74
|
+
this.handleDraggingThrottled(event, props);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
handleKeyUp(event: KeyboardEvent, props: ModeProps<FeatureCollection>) {
|
|
79
|
+
if (event.key === 'Enter') {
|
|
80
|
+
const clickSequence = this.getClickSequence();
|
|
81
|
+
if (clickSequence.length > 2) {
|
|
82
|
+
const polygonToAdd: Polygon = {
|
|
83
|
+
type: 'Polygon',
|
|
84
|
+
coordinates: [[...clickSequence, clickSequence[0]]],
|
|
85
|
+
};
|
|
86
|
+
this.resetClickSequence();
|
|
87
|
+
|
|
88
|
+
const editAction = this.getAddFeatureOrBooleanPolygonAction(polygonToAdd, props);
|
|
89
|
+
if (editAction) {
|
|
90
|
+
props.onEdit(editAction);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
} else if (event.key === 'Escape') {
|
|
94
|
+
this.resetClickSequence();
|
|
95
|
+
if (this.handleDraggingThrottled) {
|
|
96
|
+
this.handleDraggingThrottled = null;
|
|
97
|
+
}
|
|
98
|
+
props.onEdit({
|
|
99
|
+
// Because the new drawing feature is dropped, so the data will keep as the same.
|
|
100
|
+
updatedData: props.data,
|
|
101
|
+
editType: 'cancelFeature',
|
|
102
|
+
editContext: {},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|