@deck.gl-community/editable-layers 9.2.0-beta.6 → 9.2.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts +2 -2
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.js.map +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +2 -2
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.js +0 -1
- package/dist/edit-modes/draw-circle-by-diameter-mode.js.map +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +2 -2
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-circle-from-center-mode.js +0 -1
- package/dist/edit-modes/draw-circle-from-center-mode.js.map +1 -1
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +2 -2
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +1 -2
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js.map +1 -1
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +2 -2
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +0 -2
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js.map +1 -1
- package/dist/edit-modes/draw-line-string-mode.d.ts +5 -5
- package/dist/edit-modes/draw-line-string-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-line-string-mode.js.map +1 -1
- package/dist/edit-modes/draw-point-mode.d.ts +2 -2
- package/dist/edit-modes/draw-point-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-point-mode.js.map +1 -1
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +8 -8
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-by-dragging-mode.js.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.d.ts +5 -5
- package/dist/edit-modes/draw-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.js.map +1 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +2 -2
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.js +0 -1
- package/dist/edit-modes/draw-rectangle-from-center-mode.js.map +1 -1
- package/dist/edit-modes/draw-rectangle-mode.d.ts +2 -2
- package/dist/edit-modes/draw-rectangle-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-rectangle-mode.js +0 -1
- package/dist/edit-modes/draw-rectangle-mode.js.map +1 -1
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +2 -2
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-from-center-mode.d.ts +2 -2
- package/dist/edit-modes/draw-square-from-center-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-from-center-mode.js +0 -1
- package/dist/edit-modes/draw-square-from-center-mode.js.map +1 -1
- package/dist/edit-modes/draw-square-mode.d.ts +2 -2
- package/dist/edit-modes/draw-square-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-mode.js +0 -1
- package/dist/edit-modes/draw-square-mode.js.map +1 -1
- package/dist/edit-modes/duplicate-mode.d.ts +2 -2
- package/dist/edit-modes/duplicate-mode.d.ts.map +1 -1
- package/dist/edit-modes/duplicate-mode.js.map +1 -1
- package/dist/edit-modes/extend-line-string-mode.d.ts +4 -4
- package/dist/edit-modes/extend-line-string-mode.d.ts.map +1 -1
- package/dist/edit-modes/extend-line-string-mode.js.map +1 -1
- package/dist/edit-modes/extrude-mode.d.ts +7 -7
- package/dist/edit-modes/extrude-mode.d.ts.map +1 -1
- package/dist/edit-modes/extrude-mode.js.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.d.ts +9 -9
- package/dist/edit-modes/geojson-edit-mode.d.ts.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.js +4 -7
- package/dist/edit-modes/geojson-edit-mode.js.map +1 -1
- package/dist/edit-modes/immutable-feature-collection.d.ts +7 -7
- package/dist/edit-modes/immutable-feature-collection.d.ts.map +1 -1
- package/dist/edit-modes/immutable-feature-collection.js.map +1 -1
- package/dist/edit-modes/measure-area-mode.d.ts +3 -3
- package/dist/edit-modes/measure-area-mode.d.ts.map +1 -1
- package/dist/edit-modes/measure-area-mode.js.map +1 -1
- package/dist/edit-modes/modify-mode.d.ts +8 -8
- package/dist/edit-modes/modify-mode.d.ts.map +1 -1
- package/dist/edit-modes/modify-mode.js +2 -4
- package/dist/edit-modes/modify-mode.js.map +1 -1
- package/dist/edit-modes/resize-circle-mode.d.ts +3 -3
- package/dist/edit-modes/resize-circle-mode.d.ts.map +1 -1
- package/dist/edit-modes/resize-circle-mode.js +1 -5
- package/dist/edit-modes/resize-circle-mode.js.map +1 -1
- package/dist/edit-modes/rotate-mode.d.ts +7 -7
- package/dist/edit-modes/rotate-mode.d.ts.map +1 -1
- package/dist/edit-modes/rotate-mode.js +2 -9
- package/dist/edit-modes/rotate-mode.js.map +1 -1
- package/dist/edit-modes/scale-mode.d.ts +11 -11
- package/dist/edit-modes/scale-mode.d.ts.map +1 -1
- package/dist/edit-modes/scale-mode.js +1 -6
- package/dist/edit-modes/scale-mode.js.map +1 -1
- package/dist/edit-modes/snappable-mode.d.ts +5 -5
- package/dist/edit-modes/snappable-mode.d.ts.map +1 -1
- package/dist/edit-modes/snappable-mode.js.map +1 -1
- package/dist/edit-modes/split-polygon-mode.d.ts +5 -5
- package/dist/edit-modes/split-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/split-polygon-mode.js +2 -5
- package/dist/edit-modes/split-polygon-mode.js.map +1 -1
- package/dist/edit-modes/three-click-polygon-mode.d.ts +3 -3
- package/dist/edit-modes/three-click-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/three-click-polygon-mode.js.map +1 -1
- package/dist/edit-modes/translate-mode.d.ts +6 -6
- package/dist/edit-modes/translate-mode.d.ts.map +1 -1
- package/dist/edit-modes/translate-mode.js +1 -2
- package/dist/edit-modes/translate-mode.js.map +1 -1
- package/dist/edit-modes/two-click-polygon-mode.d.ts +6 -6
- package/dist/edit-modes/two-click-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/two-click-polygon-mode.js.map +1 -1
- package/dist/edit-modes/types.d.ts +3 -3
- package/dist/edit-modes/types.d.ts.map +1 -1
- package/dist/edit-modes/utils.d.ts +7 -7
- package/dist/edit-modes/utils.d.ts.map +1 -1
- package/dist/edit-modes/utils.js +0 -3
- package/dist/edit-modes/utils.js.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.d.ts +5 -13
- package/dist/editable-layers/editable-geojson-layer.d.ts.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.js +4 -4
- package/dist/editable-layers/editable-geojson-layer.js.map +1 -1
- package/dist/editable-layers/selection-layer.d.ts +1 -2
- package/dist/editable-layers/selection-layer.d.ts.map +1 -1
- package/dist/editable-layers/selection-layer.js +2 -2
- package/dist/editable-layers/selection-layer.js.map +1 -1
- package/dist/index.cjs +192 -942
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +3 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -10
- package/dist/index.js.map +1 -1
- package/dist/mode-handlers/composite-mode-handler.d.ts +3 -3
- package/dist/mode-handlers/composite-mode-handler.d.ts.map +1 -1
- package/dist/mode-handlers/composite-mode-handler.js.map +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-90degree-polygon-handler.js +4 -2
- package/dist/mode-handlers/draw-90degree-polygon-handler.js.map +1 -1
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +0 -1
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js.map +1 -1
- package/dist/mode-handlers/draw-circle-from-center-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-circle-from-center-handler.js +0 -1
- package/dist/mode-handlers/draw-circle-from-center-handler.js.map +1 -1
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +1 -2
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js.map +1 -1
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +2 -2
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js.map +1 -1
- package/dist/mode-handlers/draw-point-handler.js.map +1 -1
- package/dist/mode-handlers/draw-polygon-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-polygon-handler.js +4 -2
- package/dist/mode-handlers/draw-polygon-handler.js.map +1 -1
- package/dist/mode-handlers/draw-rectangle-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-rectangle-handler.js +0 -1
- package/dist/mode-handlers/draw-rectangle-handler.js.map +1 -1
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.d.ts.map +1 -1
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +4 -2
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js.map +1 -1
- package/dist/mode-handlers/mode-handler.d.ts +12 -12
- package/dist/mode-handlers/mode-handler.d.ts.map +1 -1
- package/dist/mode-handlers/mode-handler.js +6 -7
- package/dist/mode-handlers/mode-handler.js.map +1 -1
- package/dist/mode-handlers/modify-handler.d.ts +2 -2
- package/dist/mode-handlers/modify-handler.d.ts.map +1 -1
- package/dist/mode-handlers/modify-handler.js +1 -4
- package/dist/mode-handlers/modify-handler.js.map +1 -1
- package/dist/mode-handlers/rotate-handler.d.ts +2 -2
- package/dist/mode-handlers/rotate-handler.d.ts.map +1 -1
- package/dist/mode-handlers/rotate-handler.js +2 -7
- package/dist/mode-handlers/rotate-handler.js.map +1 -1
- package/dist/mode-handlers/scale-handler.d.ts +2 -2
- package/dist/mode-handlers/scale-handler.d.ts.map +1 -1
- package/dist/mode-handlers/scale-handler.js +2 -7
- package/dist/mode-handlers/scale-handler.js.map +1 -1
- package/dist/mode-handlers/snappable-handler.d.ts +3 -3
- package/dist/mode-handlers/snappable-handler.d.ts.map +1 -1
- package/dist/mode-handlers/snappable-handler.js.map +1 -1
- package/dist/mode-handlers/split-polygon-handler.d.ts.map +1 -1
- package/dist/mode-handlers/split-polygon-handler.js +4 -5
- package/dist/mode-handlers/split-polygon-handler.js.map +1 -1
- package/dist/mode-handlers/translate-handler.d.ts +2 -2
- package/dist/mode-handlers/translate-handler.d.ts.map +1 -1
- package/dist/mode-handlers/translate-handler.js +1 -4
- package/dist/mode-handlers/translate-handler.js.map +1 -1
- package/dist/utils/geojson-types.d.ts +13 -34
- package/dist/utils/geojson-types.d.ts.map +1 -1
- package/dist/utils/translate-from-center.d.ts +2 -4
- package/dist/utils/translate-from-center.d.ts.map +1 -1
- package/dist/utils/translate-from-center.js.map +1 -1
- package/dist/utils/utils.d.ts +3 -3
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/package.json +33 -34
- package/src/edit-modes/draw-90degree-polygon-mode.ts +2 -2
- package/src/edit-modes/draw-circle-by-diameter-mode.ts +3 -3
- package/src/edit-modes/draw-circle-from-center-mode.ts +3 -3
- package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +4 -4
- package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +3 -4
- package/src/edit-modes/draw-line-string-mode.ts +5 -5
- package/src/edit-modes/draw-point-mode.ts +2 -2
- package/src/edit-modes/draw-polygon-by-dragging-mode.ts +8 -8
- package/src/edit-modes/draw-polygon-mode.ts +8 -8
- package/src/edit-modes/draw-rectangle-from-center-mode.ts +2 -3
- package/src/edit-modes/draw-rectangle-mode.ts +2 -3
- package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +2 -2
- package/src/edit-modes/draw-square-from-center-mode.ts +2 -3
- package/src/edit-modes/draw-square-mode.ts +3 -3
- package/src/edit-modes/duplicate-mode.ts +2 -2
- package/src/edit-modes/extend-line-string-mode.ts +4 -4
- package/src/edit-modes/extrude-mode.ts +7 -7
- package/src/edit-modes/geojson-edit-mode.ts +16 -19
- package/src/edit-modes/immutable-feature-collection.ts +10 -11
- package/src/edit-modes/measure-area-mode.ts +3 -3
- package/src/edit-modes/modify-mode.ts +13 -13
- package/src/edit-modes/resize-circle-mode.ts +6 -8
- package/src/edit-modes/rotate-mode.ts +9 -15
- package/src/edit-modes/scale-mode.ts +11 -15
- package/src/edit-modes/snappable-mode.ts +5 -5
- package/src/edit-modes/split-polygon-mode.ts +12 -16
- package/src/edit-modes/three-click-polygon-mode.ts +3 -3
- package/src/edit-modes/translate-mode.ts +10 -12
- package/src/edit-modes/two-click-polygon-mode.ts +7 -7
- package/src/edit-modes/types.ts +4 -4
- package/src/edit-modes/utils.ts +12 -16
- package/src/editable-layers/editable-geojson-layer.ts +19 -18
- package/src/editable-layers/selection-layer.ts +3 -3
- package/src/index.ts +8 -28
- package/src/mode-handlers/composite-mode-handler.ts +3 -3
- package/src/mode-handlers/draw-90degree-polygon-handler.ts +4 -2
- package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +0 -1
- package/src/mode-handlers/draw-circle-from-center-handler.ts +0 -1
- package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +1 -2
- package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +3 -2
- package/src/mode-handlers/draw-point-handler.ts +2 -2
- package/src/mode-handlers/draw-polygon-handler.ts +4 -2
- package/src/mode-handlers/draw-rectangle-handler.ts +0 -1
- package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +4 -2
- package/src/mode-handlers/mode-handler.ts +20 -21
- package/src/mode-handlers/modify-handler.ts +2 -4
- package/src/mode-handlers/rotate-handler.ts +4 -8
- package/src/mode-handlers/scale-handler.ts +4 -8
- package/src/mode-handlers/snappable-handler.ts +3 -3
- package/src/mode-handlers/split-polygon-handler.ts +6 -7
- package/src/mode-handlers/translate-handler.ts +3 -5
- package/src/utils/geojson-types.ts +15 -54
- package/src/utils/translate-from-center.ts +6 -11
- package/src/utils/utils.ts +4 -4
- package/dist/lib/constants.d.ts +0 -7
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/constants.js +0 -10
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/deck-renderer/deck-cache.d.ts +0 -15
- package/dist/lib/deck-renderer/deck-cache.d.ts.map +0 -1
- package/dist/lib/deck-renderer/deck-cache.js +0 -52
- package/dist/lib/deck-renderer/deck-cache.js.map +0 -1
- package/dist/lib/deck-renderer/deck-drawer.d.ts +0 -63
- package/dist/lib/deck-renderer/deck-drawer.d.ts.map +0 -1
- package/dist/lib/deck-renderer/deck-drawer.js +0 -233
- package/dist/lib/deck-renderer/deck-drawer.js.map +0 -1
- package/dist/lib/feature.d.ts +0 -11
- package/dist/lib/feature.d.ts.map +0 -1
- package/dist/lib/feature.js +0 -20
- package/dist/lib/feature.js.map +0 -1
- package/dist/lib/layer-mouse-event.d.ts +0 -12
- package/dist/lib/layer-mouse-event.d.ts.map +0 -1
- package/dist/lib/layer-mouse-event.js +0 -28
- package/dist/lib/layer-mouse-event.js.map +0 -1
- package/dist/lib/layers/junctions-layer.d.ts +0 -9
- package/dist/lib/layers/junctions-layer.d.ts.map +0 -1
- package/dist/lib/layers/junctions-layer.js +0 -37
- package/dist/lib/layers/junctions-layer.js.map +0 -1
- package/dist/lib/layers/segments-layer.d.ts +0 -19
- package/dist/lib/layers/segments-layer.d.ts.map +0 -1
- package/dist/lib/layers/segments-layer.js +0 -98
- package/dist/lib/layers/segments-layer.js.map +0 -1
- package/dist/lib/layers/texts-layer.d.ts +0 -9
- package/dist/lib/layers/texts-layer.d.ts.map +0 -1
- package/dist/lib/layers/texts-layer.js +0 -36
- package/dist/lib/layers/texts-layer.js.map +0 -1
- package/dist/lib/math.d.ts +0 -12
- package/dist/lib/math.d.ts.map +0 -1
- package/dist/lib/math.js +0 -26
- package/dist/lib/math.js.map +0 -1
- package/dist/lib/nebula-core.d.ts +0 -35
- package/dist/lib/nebula-core.d.ts.map +0 -1
- package/dist/lib/nebula-core.js +0 -258
- package/dist/lib/nebula-core.js.map +0 -1
- package/dist/lib/nebula-layer.d.ts +0 -14
- package/dist/lib/nebula-layer.d.ts.map +0 -1
- package/dist/lib/nebula-layer.js +0 -30
- package/dist/lib/nebula-layer.js.map +0 -1
- package/dist/lib/style.d.ts +0 -20
- package/dist/lib/style.d.ts.map +0 -1
- package/dist/lib/style.js +0 -24
- package/dist/lib/style.js.map +0 -1
- package/dist/utils/curve-utils.d.ts +0 -3
- package/dist/utils/curve-utils.d.ts.map +0 -1
- package/dist/utils/curve-utils.js +0 -65
- package/dist/utils/curve-utils.js.map +0 -1
- package/src/lib/constants.ts +0 -10
- package/src/lib/deck-renderer/deck-cache.ts +0 -61
- package/src/lib/deck-renderer/deck-drawer.ts +0 -263
- package/src/lib/feature.ts +0 -31
- package/src/lib/layer-mouse-event.ts +0 -33
- package/src/lib/layers/junctions-layer.ts +0 -44
- package/src/lib/layers/segments-layer.ts +0 -112
- package/src/lib/layers/texts-layer.ts +0 -47
- package/src/lib/math.ts +0 -30
- package/src/lib/nebula-core.ts +0 -327
- package/src/lib/nebula-layer.ts +0 -37
- package/src/lib/style.ts +0 -26
- package/src/utils/curve-utils.ts +0 -81
|
@@ -32,7 +32,8 @@ export class DrawEllipseUsingThreePointsHandler extends ThreeClickPolygonHandler
|
|
|
32
32
|
geometry: {
|
|
33
33
|
type: 'LineString',
|
|
34
34
|
coordinates: [clickSequence[0], mapCoords]
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
properties: {}
|
|
36
37
|
});
|
|
37
38
|
} else if (clickSequence.length === 2) {
|
|
38
39
|
const [p1, p2] = clickSequence;
|
|
@@ -41,7 +42,7 @@ export class DrawEllipseUsingThreePointsHandler extends ThreeClickPolygonHandler
|
|
|
41
42
|
const xSemiAxis = Math.max(distance(centerCoordinates, point(mapCoords)), 0.001);
|
|
42
43
|
const ySemiAxis = Math.max(distance(p1, p2), 0.001) / 2;
|
|
43
44
|
const options = {angle: bearing(p1, p2)};
|
|
44
|
-
|
|
45
|
+
|
|
45
46
|
this._setTentativeFeature(ellipse(centerCoordinates, xSemiAxis, ySemiAxis, options));
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {SimpleGeometry} from '../utils/geojson-types';
|
|
6
6
|
import {ClickEvent} from '../edit-modes/types';
|
|
7
7
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
8
8
|
|
|
9
9
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
10
10
|
export class DrawPointHandler extends ModeHandler {
|
|
11
11
|
handleClick({mapCoords}: ClickEvent): EditAction | null | undefined {
|
|
12
|
-
const geometry:
|
|
12
|
+
const geometry: SimpleGeometry = {
|
|
13
13
|
type: 'Point',
|
|
14
14
|
coordinates: mapCoords
|
|
15
15
|
};
|
|
@@ -107,7 +107,8 @@ export class DrawPolygonHandler extends ModeHandler {
|
|
|
107
107
|
geometry: {
|
|
108
108
|
type: 'LineString',
|
|
109
109
|
coordinates: [...clickSequence, mapCoords]
|
|
110
|
-
}
|
|
110
|
+
},
|
|
111
|
+
properties: {}
|
|
111
112
|
});
|
|
112
113
|
} else {
|
|
113
114
|
// Draw a Polygon connecting all the clicked points with the hovered point
|
|
@@ -116,7 +117,8 @@ export class DrawPolygonHandler extends ModeHandler {
|
|
|
116
117
|
geometry: {
|
|
117
118
|
type: 'Polygon',
|
|
118
119
|
coordinates: [[...clickSequence, mapCoords, clickSequence[0]]]
|
|
119
|
-
}
|
|
120
|
+
},
|
|
121
|
+
properties: {}
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
|
|
@@ -24,7 +24,6 @@ export class DrawRectangleHandler extends TwoClickPolygonHandler {
|
|
|
24
24
|
const corner1 = clickSequence[0];
|
|
25
25
|
const corner2 = event.mapCoords;
|
|
26
26
|
|
|
27
|
-
// @ts-expect-error turf type diff
|
|
28
27
|
this._setTentativeFeature(bboxPolygon([corner1[0], corner1[1], corner2[0], corner2[1]]));
|
|
29
28
|
|
|
30
29
|
return result;
|
|
@@ -30,7 +30,8 @@ export class DrawRectangleUsingThreePointsHandler extends ThreeClickPolygonHandl
|
|
|
30
30
|
geometry: {
|
|
31
31
|
type: 'LineString',
|
|
32
32
|
coordinates: [clickSequence[0], mapCoords]
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
properties: {}
|
|
34
35
|
});
|
|
35
36
|
} else if (clickSequence.length === 2) {
|
|
36
37
|
const lineString: LineString = {
|
|
@@ -55,7 +56,8 @@ export class DrawRectangleUsingThreePointsHandler extends ThreeClickPolygonHandl
|
|
|
55
56
|
p1
|
|
56
57
|
]
|
|
57
58
|
]
|
|
58
|
-
}
|
|
59
|
+
},
|
|
60
|
+
properties: {}
|
|
59
61
|
});
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
6
6
|
|
|
7
|
+
import {featureCollection as turfFeatureCollection} from '@turf/helpers';
|
|
7
8
|
import turfUnion from '@turf/union';
|
|
8
9
|
import turfDifference from '@turf/difference';
|
|
9
10
|
import turfIntersect from '@turf/intersect';
|
|
10
11
|
|
|
11
|
-
import {FeatureCollection, Feature, Polygon,
|
|
12
|
+
import {FeatureCollection, Feature, Polygon, SimpleGeometry, Position, PolygonGeometry, SimpleFeatureCollection, SimpleFeature} from '../utils/geojson-types';
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
ClickEvent,
|
|
@@ -29,7 +30,7 @@ export type EditHandle = {
|
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export type EditAction = {
|
|
32
|
-
updatedData:
|
|
33
|
+
updatedData: SimpleFeatureCollection;
|
|
33
34
|
editType: string;
|
|
34
35
|
featureIndexes: number[];
|
|
35
36
|
editContext: any;
|
|
@@ -38,12 +39,12 @@ export type EditAction = {
|
|
|
38
39
|
export class ModeHandler {
|
|
39
40
|
// TODO: add underscore
|
|
40
41
|
featureCollection: ImmutableFeatureCollection = undefined!;
|
|
41
|
-
_tentativeFeature:
|
|
42
|
+
_tentativeFeature: SimpleFeature | null | undefined;
|
|
42
43
|
_modeConfig: any = null;
|
|
43
44
|
_selectedFeatureIndexes: number[] = [];
|
|
44
45
|
_clickSequence: Position[] = [];
|
|
45
46
|
|
|
46
|
-
constructor(featureCollection?:
|
|
47
|
+
constructor(featureCollection?: SimpleFeatureCollection) {
|
|
47
48
|
if (featureCollection) {
|
|
48
49
|
this.setFeatureCollection(featureCollection);
|
|
49
50
|
}
|
|
@@ -57,14 +58,14 @@ export class ModeHandler {
|
|
|
57
58
|
return this.featureCollection;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
getSelectedFeature():
|
|
61
|
+
getSelectedFeature(): SimpleFeature | null | undefined {
|
|
61
62
|
if (this._selectedFeatureIndexes.length === 1) {
|
|
62
63
|
return this.featureCollection.getObject().features[this._selectedFeatureIndexes[0]];
|
|
63
64
|
}
|
|
64
65
|
return null;
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
getSelectedGeometry():
|
|
68
|
+
getSelectedGeometry(): SimpleGeometry | null | undefined {
|
|
68
69
|
const feature = this.getSelectedFeature();
|
|
69
70
|
if (feature) {
|
|
70
71
|
return feature.geometry;
|
|
@@ -72,8 +73,8 @@ export class ModeHandler {
|
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
getSelectedFeaturesAsFeatureCollection():
|
|
76
|
-
const {features} = this.featureCollection.getObject();
|
|
76
|
+
getSelectedFeaturesAsFeatureCollection(): SimpleFeatureCollection {
|
|
77
|
+
const { features } = this.featureCollection.getObject();
|
|
77
78
|
const selectedFeatures = this.getSelectedFeatureIndexes().map(
|
|
78
79
|
(selectedIndex) => features[selectedIndex]
|
|
79
80
|
);
|
|
@@ -83,7 +84,7 @@ export class ModeHandler {
|
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
setFeatureCollection(featureCollection:
|
|
87
|
+
setFeatureCollection(featureCollection: SimpleFeatureCollection): void {
|
|
87
88
|
this.featureCollection = new ImmutableFeatureCollection(featureCollection);
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -121,12 +122,12 @@ export class ModeHandler {
|
|
|
121
122
|
this._clickSequence = [];
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
getTentativeFeature():
|
|
125
|
+
getTentativeFeature(): SimpleFeature | null | undefined {
|
|
125
126
|
return this._tentativeFeature;
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
// TODO: remove the underscore
|
|
129
|
-
_setTentativeFeature(tentativeFeature:
|
|
130
|
+
_setTentativeFeature(tentativeFeature: SimpleFeature | null | undefined): void {
|
|
130
131
|
this._tentativeFeature = tentativeFeature;
|
|
131
132
|
if (!tentativeFeature) {
|
|
132
133
|
// Reset the click sequence
|
|
@@ -154,7 +155,7 @@ export class ModeHandler {
|
|
|
154
155
|
return selectedFeatureIndexes.some((index) => pickedIndexes.includes(index));
|
|
155
156
|
}
|
|
156
157
|
|
|
157
|
-
getAddFeatureAction(geometry:
|
|
158
|
+
getAddFeatureAction(geometry: SimpleGeometry): EditAction {
|
|
158
159
|
// Unsure why flow can't deal with Geometry type, but there I fixed it
|
|
159
160
|
const geometryAsAny: any = geometry;
|
|
160
161
|
|
|
@@ -218,21 +219,19 @@ export class ModeHandler {
|
|
|
218
219
|
return null;
|
|
219
220
|
}
|
|
220
221
|
|
|
221
|
-
const feature = {
|
|
222
|
+
const feature: Feature<Polygon> = {
|
|
222
223
|
type: 'Feature',
|
|
223
|
-
geometry
|
|
224
|
+
geometry,
|
|
225
|
+
properties: {},
|
|
224
226
|
};
|
|
225
227
|
|
|
226
228
|
let updatedGeometry;
|
|
227
229
|
if (modeConfig.booleanOperation === 'union') {
|
|
228
|
-
|
|
229
|
-
updatedGeometry = turfUnion(selectedFeature, feature);
|
|
230
|
+
updatedGeometry = turfUnion(turfFeatureCollection([selectedFeature as Feature<PolygonGeometry>, feature]));
|
|
230
231
|
} else if (modeConfig.booleanOperation === 'difference') {
|
|
231
|
-
|
|
232
|
-
updatedGeometry = turfDifference(selectedFeature, feature);
|
|
232
|
+
updatedGeometry = turfDifference(turfFeatureCollection([selectedFeature as Feature<PolygonGeometry>, feature]));
|
|
233
233
|
} else if (modeConfig.booleanOperation === 'intersection') {
|
|
234
|
-
|
|
235
|
-
updatedGeometry = turfIntersect(selectedFeature, feature);
|
|
234
|
+
updatedGeometry = turfIntersect(turfFeatureCollection([selectedFeature as Feature<PolygonGeometry>, feature]));
|
|
236
235
|
} else {
|
|
237
236
|
// eslint-disable-next-line no-console,no-undef
|
|
238
237
|
console.warn(`Invalid booleanOperation ${modeConfig.booleanOperation}`);
|
|
@@ -307,7 +306,7 @@ export function getIntermediatePosition(position1: Position, position2: Position
|
|
|
307
306
|
}
|
|
308
307
|
|
|
309
308
|
export function getEditHandlesForGeometry(
|
|
310
|
-
geometry:
|
|
309
|
+
geometry: SimpleGeometry,
|
|
311
310
|
featureIndex: number,
|
|
312
311
|
editHandleType: EditHandleType = 'existing'
|
|
313
312
|
): EditHandle[] {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
6
6
|
import {point, lineString as toLineString} from '@turf/helpers';
|
|
7
|
-
import {Position,
|
|
7
|
+
import {Position, Feature, Point, LineString} from '../utils/geojson-types';
|
|
8
8
|
import {
|
|
9
9
|
recursivelyTraverseNestedArrays,
|
|
10
10
|
nearestPointOnProjectedLine,
|
|
@@ -66,7 +66,6 @@ export class ModifyHandler extends ModeHandler {
|
|
|
66
66
|
const lineStringFeature = toLineString(lineString);
|
|
67
67
|
|
|
68
68
|
const candidateIntermediatePoint = this.nearestPointOnLine(
|
|
69
|
-
// @ts-expect-error turf type diff
|
|
70
69
|
lineStringFeature,
|
|
71
70
|
referencePoint
|
|
72
71
|
);
|
|
@@ -102,7 +101,7 @@ export class ModifyHandler extends ModeHandler {
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
// turf.js does not support elevation for nearestPointOnLine
|
|
105
|
-
nearestPointOnLine(line:
|
|
104
|
+
nearestPointOnLine(line: Feature<LineString>, inPoint: Feature<Point>): NearestPointType {
|
|
106
105
|
const {coordinates} = line.geometry;
|
|
107
106
|
if (coordinates.some((coord) => coord.length > 2)) {
|
|
108
107
|
const modeConfig = this.getModeConfig();
|
|
@@ -115,7 +114,6 @@ export class ModifyHandler extends ModeHandler {
|
|
|
115
114
|
'Editing 3D point but modeConfig.viewport not provided. Falling back to 2D logic.'
|
|
116
115
|
);
|
|
117
116
|
}
|
|
118
|
-
// @ts-expect-error geojson types diff
|
|
119
117
|
return nearestPointOnLine(line, inPoint);
|
|
120
118
|
}
|
|
121
119
|
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import turfCentroid from '@turf/centroid';
|
|
6
6
|
import turfBearing from '@turf/bearing';
|
|
7
7
|
import turfTransformRotate from '@turf/transform-rotate';
|
|
8
|
-
import {
|
|
8
|
+
import {SimpleFeatureCollection, Position} from '../utils/geojson-types';
|
|
9
9
|
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
10
10
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
11
11
|
|
|
12
12
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
13
13
|
export class RotateHandler extends ModeHandler {
|
|
14
14
|
_isRotatable: boolean = undefined!;
|
|
15
|
-
_geometryBeingRotated:
|
|
15
|
+
_geometryBeingRotated: SimpleFeatureCollection | null | undefined;
|
|
16
16
|
|
|
17
17
|
handlePointerMove(event: PointerMoveEvent): {
|
|
18
18
|
editAction: EditAction | null | undefined;
|
|
@@ -66,14 +66,10 @@ export class RotateHandler extends ModeHandler {
|
|
|
66
66
|
|
|
67
67
|
getRotateAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction {
|
|
68
68
|
const startPosition = startDragPoint;
|
|
69
|
-
// @ts-expect-error turf types diff
|
|
70
69
|
const centroid = turfCentroid(this._geometryBeingRotated);
|
|
71
|
-
|
|
72
|
-
const angle = getRotationAngle(centroid, startPosition, currentPoint);
|
|
70
|
+
const angle = getRotationAngle(centroid.geometry.coordinates, startPosition, currentPoint);
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
const rotatedFeatures: FeatureCollection = turfTransformRotate(
|
|
76
|
-
// @ts-expect-error turf type diff
|
|
72
|
+
const rotatedFeatures = turfTransformRotate(
|
|
77
73
|
this._geometryBeingRotated,
|
|
78
74
|
angle
|
|
79
75
|
);
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import turfCentroid from '@turf/centroid';
|
|
6
6
|
import turfDistance from '@turf/distance';
|
|
7
7
|
import turfTransformScale from '@turf/transform-scale';
|
|
8
|
-
import {
|
|
8
|
+
import {SimpleFeatureCollection, Position, SimpleGeometry} from '../utils/geojson-types';
|
|
9
9
|
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
10
10
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
11
11
|
|
|
12
12
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
13
13
|
export class ScaleHandler extends ModeHandler {
|
|
14
14
|
_isScalable: boolean = undefined!;
|
|
15
|
-
_geometryBeingScaled:
|
|
15
|
+
_geometryBeingScaled: SimpleFeatureCollection | null | undefined;
|
|
16
16
|
|
|
17
17
|
handlePointerMove(event: PointerMoveEvent): {
|
|
18
18
|
editAction: EditAction | null | undefined;
|
|
@@ -66,13 +66,9 @@ export class ScaleHandler extends ModeHandler {
|
|
|
66
66
|
|
|
67
67
|
getScaleAction(startDragPoint: Position, currentPoint: Position, editType: string): EditAction {
|
|
68
68
|
const startPosition = startDragPoint;
|
|
69
|
-
// @ts-expect-error turf types diff
|
|
70
69
|
const centroid = turfCentroid(this._geometryBeingScaled);
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
// @ts-expect-error turf type diff
|
|
74
|
-
const scaledFeatures: FeatureCollection = turfTransformScale(
|
|
75
|
-
// @ts-expect-error turf type diff
|
|
70
|
+
const factor = getScaleFactor(centroid.geometry.coordinates, startPosition, currentPoint);
|
|
71
|
+
const scaledFeatures = turfTransformScale(
|
|
76
72
|
this._geometryBeingScaled,
|
|
77
73
|
factor,
|
|
78
74
|
{
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {SimpleFeature, SimpleFeatureCollection, Position} from '../utils/geojson-types';
|
|
6
6
|
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
7
7
|
import {
|
|
8
8
|
EditHandle,
|
|
@@ -25,7 +25,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
25
25
|
this._handler = handler;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
setFeatureCollection(featureCollection:
|
|
28
|
+
setFeatureCollection(featureCollection: SimpleFeatureCollection): void {
|
|
29
29
|
this._handler.setFeatureCollection(featureCollection);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -88,7 +88,7 @@ export class SnappableHandler extends ModeHandler {
|
|
|
88
88
|
// method will return those features along with the features
|
|
89
89
|
// that live in the current layer. Otherwise, this method will simply return the
|
|
90
90
|
// features from the current layer
|
|
91
|
-
_getSnapTargets():
|
|
91
|
+
_getSnapTargets(): SimpleFeature[] {
|
|
92
92
|
let {additionalSnapTargets} = this.getModeConfig() || {};
|
|
93
93
|
additionalSnapTargets = additionalSnapTargets || [];
|
|
94
94
|
|
|
@@ -6,16 +6,16 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
|
|
|
6
6
|
import turfDifference from '@turf/difference';
|
|
7
7
|
import turfBuffer from '@turf/buffer';
|
|
8
8
|
import lineIntersect from '@turf/line-intersect';
|
|
9
|
-
import {lineString} from '@turf/helpers';
|
|
9
|
+
import {feature as turfFeature, featureCollection, lineString} from '@turf/helpers';
|
|
10
10
|
import turfBearing from '@turf/bearing';
|
|
11
11
|
import turfDistance from '@turf/distance';
|
|
12
12
|
import turfDestination from '@turf/destination';
|
|
13
13
|
import turfPolygonToLine from '@turf/polygon-to-line';
|
|
14
|
-
import type {NearestPointOnLine} from '@turf/nearest-point-on-line';
|
|
15
14
|
import nearestPointOnLine from '@turf/nearest-point-on-line';
|
|
16
15
|
import {generatePointsParallelToLinePoints} from '../utils/utils';
|
|
17
16
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
18
17
|
import {ClickEvent, PointerMoveEvent} from '../edit-modes/types';
|
|
18
|
+
import {PolygonGeometry} from '../utils/geojson-types';
|
|
19
19
|
|
|
20
20
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
21
21
|
export class SplitPolygonHandler extends ModeHandler {
|
|
@@ -33,7 +33,7 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
33
33
|
|
|
34
34
|
const lines = feature.type === 'FeatureCollection' ? feature.features : [feature];
|
|
35
35
|
let minDistance = Number.MAX_SAFE_INTEGER;
|
|
36
|
-
let closestPoint:
|
|
36
|
+
let closestPoint: ReturnType<typeof nearestPointOnLine> | null = null;
|
|
37
37
|
// If Multipolygon, then we should find nearest polygon line and stick split to it.
|
|
38
38
|
lines.forEach((line) => {
|
|
39
39
|
const snapPoint = nearestPointOnLine(line, firstPoint);
|
|
@@ -120,7 +120,8 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
120
120
|
geometry: {
|
|
121
121
|
type: 'LineString',
|
|
122
122
|
coordinates: [...clickSequence, this.calculateMapCoords(clickSequence, mapCoords)]
|
|
123
|
-
}
|
|
123
|
+
},
|
|
124
|
+
properties: {}
|
|
124
125
|
});
|
|
125
126
|
|
|
126
127
|
return result;
|
|
@@ -138,10 +139,8 @@ export class SplitPolygonHandler extends ModeHandler {
|
|
|
138
139
|
gap = 0.1;
|
|
139
140
|
units = 'centimeters';
|
|
140
141
|
}
|
|
141
|
-
// @ts-expect-error turf type diff
|
|
142
142
|
const buffer = turfBuffer(tentativeFeature, gap, {units});
|
|
143
|
-
|
|
144
|
-
const updatedGeometry = turfDifference(selectedGeometry, buffer);
|
|
143
|
+
const updatedGeometry = turfDifference(featureCollection([turfFeature(selectedGeometry as PolygonGeometry), buffer]));
|
|
145
144
|
this._setTentativeFeature(null);
|
|
146
145
|
if (!updatedGeometry) {
|
|
147
146
|
// eslint-disable-next-line no-console,no-undef
|
|
@@ -6,13 +6,13 @@ import turfBearing from '@turf/bearing';
|
|
|
6
6
|
import turfDistance from '@turf/distance';
|
|
7
7
|
import turfTransformTranslate from '@turf/transform-translate';
|
|
8
8
|
import {point} from '@turf/helpers';
|
|
9
|
-
import {
|
|
9
|
+
import {SimpleFeatureCollection, Position} from '../utils/geojson-types';
|
|
10
10
|
import {PointerMoveEvent, StartDraggingEvent, StopDraggingEvent} from '../edit-modes/types';
|
|
11
11
|
import {EditAction, ModeHandler} from './mode-handler';
|
|
12
12
|
|
|
13
13
|
// TODO edit-modes: delete handlers once EditMode fully implemented
|
|
14
14
|
export class TranslateHandler extends ModeHandler {
|
|
15
|
-
_geometryBeforeTranslate:
|
|
15
|
+
_geometryBeforeTranslate: SimpleFeatureCollection | null | undefined;
|
|
16
16
|
_isTranslatable: boolean = undefined!;
|
|
17
17
|
|
|
18
18
|
handlePointerMove(event: PointerMoveEvent): {
|
|
@@ -87,9 +87,7 @@ export class TranslateHandler extends ModeHandler {
|
|
|
87
87
|
const distanceMoved = turfDistance(p1, p2);
|
|
88
88
|
const direction = turfBearing(p1, p2);
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
const movedFeatures: FeatureCollection = turfTransformTranslate(
|
|
92
|
-
// @ts-expect-error turf type diff
|
|
90
|
+
const movedFeatures: SimpleFeatureCollection = turfTransformTranslate(
|
|
93
91
|
this._geometryBeforeTranslate,
|
|
94
92
|
distanceMoved,
|
|
95
93
|
direction
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
// Geometry types
|
|
6
|
-
|
|
7
5
|
import type {
|
|
8
6
|
Point,
|
|
9
7
|
LineString,
|
|
@@ -11,64 +9,27 @@ import type {
|
|
|
11
9
|
MultiPoint,
|
|
12
10
|
MultiLineString,
|
|
13
11
|
MultiPolygon,
|
|
14
|
-
Position
|
|
12
|
+
Position,
|
|
13
|
+
Feature,
|
|
14
|
+
FeatureCollection,
|
|
15
15
|
} from 'geojson';
|
|
16
16
|
|
|
17
|
-
export {Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Position};
|
|
18
|
-
|
|
19
|
-
export type PointCoordinates = Position;
|
|
20
|
-
export type LineStringCoordinates = Position[];
|
|
21
|
-
export type PolygonCoordinates = Position[][];
|
|
22
|
-
export type MultiPointCoordinates = Position[];
|
|
23
|
-
export type MultiLineStringCoordinates = Position[][];
|
|
24
|
-
export type MultiPolygonCoordinates = Position[][][];
|
|
25
|
-
|
|
26
|
-
export type AnyCoordinates =
|
|
27
|
-
| PointCoordinates
|
|
28
|
-
| LineStringCoordinates
|
|
29
|
-
| PolygonCoordinates
|
|
30
|
-
| MultiPointCoordinates
|
|
31
|
-
| MultiLineStringCoordinates
|
|
32
|
-
| MultiPolygonCoordinates;
|
|
33
|
-
|
|
34
|
-
export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
35
|
-
|
|
36
|
-
export type Polygonal = Polygon | MultiPolygon;
|
|
37
|
-
|
|
38
|
-
// Feature types
|
|
17
|
+
export { Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, Position, Feature, FeatureCollection };
|
|
39
18
|
|
|
40
|
-
|
|
19
|
+
/** Simple geometries (excludes GeometryCollection) */
|
|
20
|
+
export type SimpleGeometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
41
21
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
geometry: T;
|
|
45
|
-
properties?: {
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
};
|
|
48
|
-
id?: string | number;
|
|
49
|
-
bbox?: BoundingBoxArray;
|
|
50
|
-
};
|
|
22
|
+
/** Feature with any geometry except GeometryCollection */
|
|
23
|
+
export type SimpleFeature = Feature<SimpleGeometry>
|
|
51
24
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
geometry: T;
|
|
55
|
-
properties: P;
|
|
56
|
-
};
|
|
25
|
+
/** FeatureCollection with any geometries except GeometryCollection */
|
|
26
|
+
export type SimpleFeatureCollection = FeatureCollection<SimpleGeometry>
|
|
57
27
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| FeatureOf<LineString>
|
|
61
|
-
| FeatureOf<Polygon>
|
|
62
|
-
| FeatureOf<MultiPoint>
|
|
63
|
-
| FeatureOf<MultiLineString>
|
|
64
|
-
| FeatureOf<MultiPolygon>;
|
|
28
|
+
/** Coordinates of any geometry except GeometryCollection */
|
|
29
|
+
export type SimpleGeometryCoordinates = SimpleGeometry['coordinates']
|
|
65
30
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
features: Feature[];
|
|
69
|
-
properties?: {};
|
|
70
|
-
id?: string | number;
|
|
71
|
-
bbox?: BoundingBoxArray;
|
|
72
|
-
};
|
|
31
|
+
/** Polygon and MultiPolygon geometries */
|
|
32
|
+
export type PolygonGeometry = Polygon | MultiPolygon;
|
|
73
33
|
|
|
34
|
+
/** A Feature or FeatureCollection */
|
|
74
35
|
export type AnyGeoJson = Feature | FeatureCollection;
|
|
@@ -6,35 +6,30 @@ import turfCenter from '@turf/center';
|
|
|
6
6
|
import turfRhumbBearing from '@turf/rhumb-bearing';
|
|
7
7
|
import turfRhumbDistance from '@turf/rhumb-distance';
|
|
8
8
|
import turfRhumbDestination from '@turf/rhumb-destination';
|
|
9
|
-
import type {
|
|
10
|
-
Position as TurfPosition,
|
|
11
|
-
Feature as TurfFeature,
|
|
12
|
-
Geometry as TurfGeometry
|
|
13
|
-
} from '@turf/helpers';
|
|
14
9
|
import {mapCoords} from '../edit-modes/utils';
|
|
15
|
-
import type {
|
|
10
|
+
import type {SimpleFeature} from './geojson-types';
|
|
16
11
|
|
|
17
12
|
// This function takes feature's center, moves it,
|
|
18
13
|
// and builds new feature around it keeping the proportions
|
|
19
14
|
export function translateFromCenter(
|
|
20
|
-
feature:
|
|
15
|
+
feature: SimpleFeature,
|
|
21
16
|
distance: number,
|
|
22
17
|
direction: number
|
|
23
18
|
) {
|
|
24
|
-
const initialCenterPoint = turfCenter(feature
|
|
19
|
+
const initialCenterPoint = turfCenter(feature);
|
|
25
20
|
|
|
26
21
|
const movedCenterPoint = turfRhumbDestination(initialCenterPoint, distance, direction);
|
|
27
22
|
|
|
28
23
|
const movedCoordinates = mapCoords(
|
|
29
|
-
feature.geometry.coordinates
|
|
24
|
+
feature.geometry.coordinates,
|
|
30
25
|
(coordinate) => {
|
|
31
26
|
const rhumbDistance = turfRhumbDistance(
|
|
32
27
|
initialCenterPoint.geometry.coordinates,
|
|
33
|
-
coordinate
|
|
28
|
+
coordinate
|
|
34
29
|
);
|
|
35
30
|
const rhumbDirection = turfRhumbBearing(
|
|
36
31
|
initialCenterPoint.geometry.coordinates,
|
|
37
|
-
coordinate
|
|
32
|
+
coordinate
|
|
38
33
|
);
|
|
39
34
|
|
|
40
35
|
const movedPosition = turfRhumbDestination(
|
package/src/utils/utils.ts
CHANGED
|
@@ -7,12 +7,12 @@ import bearing from '@turf/bearing';
|
|
|
7
7
|
import pointToLineDistance from '@turf/point-to-line-distance';
|
|
8
8
|
import {point} from '@turf/helpers';
|
|
9
9
|
import {WebMercatorViewport} from 'viewport-mercator-project';
|
|
10
|
-
import {
|
|
10
|
+
import {Feature, LineString, Point, Position} from './geojson-types';
|
|
11
11
|
import {Viewport} from './types';
|
|
12
12
|
|
|
13
13
|
// TODO edit-modes: delete and use edit-modes/utils instead
|
|
14
14
|
|
|
15
|
-
export type NearestPointType =
|
|
15
|
+
export type NearestPointType = Feature<Point, {dist: number; index: number}>;
|
|
16
16
|
|
|
17
17
|
export function toDeckColor(
|
|
18
18
|
color?: [number, number, number, number] | number,
|
|
@@ -106,8 +106,8 @@ export function mix(a: number, b: number, ratio: number): number {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export function nearestPointOnProjectedLine(
|
|
109
|
-
line:
|
|
110
|
-
inPoint:
|
|
109
|
+
line: Feature<LineString>,
|
|
110
|
+
inPoint: Feature<Point>,
|
|
111
111
|
viewport: Viewport
|
|
112
112
|
): NearestPointType {
|
|
113
113
|
const wmViewport = new WebMercatorViewport(viewport);
|
package/dist/lib/constants.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.
|
|
3
|
-
* Required in order to maintain the same appearance after upgrading to deck.gl v8.5.
|
|
4
|
-
* https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md
|
|
5
|
-
*/
|
|
6
|
-
export declare const PROJECTED_PIXEL_SIZE_MULTIPLIER: number;
|
|
7
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,QAAQ,CAAC"}
|
package/dist/lib/constants.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
/**
|
|
5
|
-
* A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.
|
|
6
|
-
* Required in order to maintain the same appearance after upgrading to deck.gl v8.5.
|
|
7
|
-
* https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md
|
|
8
|
-
*/
|
|
9
|
-
export const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;
|
|
10
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class DeckCache<TORIG, TCONV> {
|
|
2
|
-
objects: TCONV[];
|
|
3
|
-
originals: TORIG[];
|
|
4
|
-
updateTrigger: number;
|
|
5
|
-
_idToPosition: Map<string, number>;
|
|
6
|
-
_getData: () => TORIG[];
|
|
7
|
-
_convert: (arg0: TORIG) => TCONV;
|
|
8
|
-
constructor(getData: () => TORIG[], convert: (arg0: TORIG) => TCONV);
|
|
9
|
-
updateAllDeckObjects(): void;
|
|
10
|
-
updateDeckObjectsByIds(ids: string[]): void;
|
|
11
|
-
triggerUpdate(): void;
|
|
12
|
-
getDeckObjectById(id: string): TCONV | null | undefined;
|
|
13
|
-
getOriginalById(id: string): TORIG | null | undefined;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=deck-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deck-cache.d.ts","sourceRoot":"","sources":["../../../src/lib/deck-renderer/deck-cache.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS,CAAC,KAAK,EAAE,KAAK;IACjC,OAAO,EAAE,KAAK,EAAE,CAAC;IACjB,SAAS,EAAE,KAAK,EAAE,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,KAAK,CAAC;gBAErB,OAAO,EAAE,MAAM,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,KAAK;IAUnE,oBAAoB;IAgBpB,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE;IAapC,aAAa;IAIb,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;IAKvD,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS;CAItD"}
|