@deck.gl-community/editable-layers 9.2.0-beta.6 → 9.2.5
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 +48 -52
- 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 +25 -23
- 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 +14 -18
- 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 +1 -4
- 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 +20 -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 +430 -989
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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 +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.d.ts +1 -0
- package/dist/widgets/edit-mode-tray-widget.d.ts.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.js +1 -0
- package/dist/widgets/edit-mode-tray-widget.js.map +1 -1
- package/dist/widgets/editor-toolbar-widget.d.ts +40 -0
- package/dist/widgets/editor-toolbar-widget.d.ts.map +1 -0
- package/dist/widgets/editor-toolbar-widget.js +170 -0
- package/dist/widgets/editor-toolbar-widget.js.map +1 -0
- package/package.json +47 -44
- package/src/edit-modes/draw-90degree-polygon-mode.ts +8 -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 +10 -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 +103 -124
- 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 +2 -3
- package/src/edit-modes/duplicate-mode.ts +2 -2
- package/src/edit-modes/extend-line-string-mode.ts +11 -4
- package/src/edit-modes/extrude-mode.ts +7 -7
- package/src/edit-modes/geojson-edit-mode.ts +28 -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 +42 -30
- package/src/edit-modes/resize-circle-mode.ts +10 -7
- package/src/edit-modes/rotate-mode.ts +11 -22
- package/src/edit-modes/scale-mode.ts +14 -19
- package/src/edit-modes/snappable-mode.ts +10 -5
- package/src/edit-modes/split-polygon-mode.ts +17 -15
- package/src/edit-modes/three-click-polygon-mode.ts +30 -33
- package/src/edit-modes/translate-mode.ts +15 -12
- package/src/edit-modes/two-click-polygon-mode.ts +13 -7
- package/src/edit-modes/types.ts +4 -4
- package/src/edit-modes/utils.ts +13 -17
- package/src/editable-layers/editable-geojson-layer.ts +35 -18
- package/src/editable-layers/selection-layer.ts +3 -3
- package/src/index.ts +11 -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 +34 -20
- package/src/mode-handlers/modify-handler.ts +2 -4
- package/src/mode-handlers/rotate-handler.ts +5 -12
- package/src/mode-handlers/scale-handler.ts +6 -14
- package/src/mode-handlers/snappable-handler.ts +3 -3
- package/src/mode-handlers/split-polygon-handler.ts +8 -7
- package/src/mode-handlers/translate-handler.ts +3 -5
- package/src/utils/geojson-types.ts +31 -54
- package/src/utils/translate-from-center.ts +13 -31
- package/src/utils/utils.ts +5 -5
- package/src/widgets/edit-mode-tray-widget.tsx +2 -6
- package/src/widgets/editor-toolbar-widget.tsx +348 -0
- 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
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import hermite from 'cubic-hermite-spline';
|
|
5
|
-
import turfDistance from '@turf/distance';
|
|
6
|
-
import { lineString } from '@turf/helpers';
|
|
7
|
-
const INTERPOLATION_INTERVAL = 0.005;
|
|
8
|
-
const INTERPOLATION_THRESHOLD = 0.001;
|
|
9
|
-
function calculateSingleTangent(p0, p1, d) {
|
|
10
|
-
const x = (p1[0] - p0[0]) / d;
|
|
11
|
-
const y = (p1[1] - p0[1]) / d;
|
|
12
|
-
return [x, y];
|
|
13
|
-
}
|
|
14
|
-
// eslint-disable-next-line max-statements
|
|
15
|
-
export function generateCurveFromControlPoints(line) {
|
|
16
|
-
// calculate knots
|
|
17
|
-
const knots = [0];
|
|
18
|
-
let prev = null;
|
|
19
|
-
let totalDistance = 0;
|
|
20
|
-
const { coordinates: coords } = line.geometry;
|
|
21
|
-
for (let i = 0; i < coords.length; i++) {
|
|
22
|
-
const cur = coords[i];
|
|
23
|
-
if (prev !== null) {
|
|
24
|
-
// @ts-expect-error turf types diff
|
|
25
|
-
totalDistance += turfDistance(prev, cur);
|
|
26
|
-
knots.push(totalDistance);
|
|
27
|
-
}
|
|
28
|
-
prev = cur;
|
|
29
|
-
}
|
|
30
|
-
// calculate tangents
|
|
31
|
-
const tangents = [];
|
|
32
|
-
// first tangent
|
|
33
|
-
// @ts-expect-error TODO
|
|
34
|
-
tangents.push(calculateSingleTangent(coords[0], coords[1], knots[1] - knots[0]));
|
|
35
|
-
// second to before last
|
|
36
|
-
for (let i = 1; i < coords.length - 1; i++) {
|
|
37
|
-
// @ts-expect-error TODO
|
|
38
|
-
const A = calculateSingleTangent(coords[i], coords[i + 1], knots[i + 1] - knots[i]);
|
|
39
|
-
// @ts-expect-error TODO
|
|
40
|
-
const B = calculateSingleTangent(coords[i - 1], coords[i], knots[i] - knots[i - 1]);
|
|
41
|
-
const x = (A[0] + B[0]) / 2.0;
|
|
42
|
-
const y = (A[1] + B[1]) / 2.0;
|
|
43
|
-
tangents.push([x, y]);
|
|
44
|
-
}
|
|
45
|
-
// last tangent
|
|
46
|
-
const last = coords.length - 1;
|
|
47
|
-
tangents.push(
|
|
48
|
-
// @ts-expect-error TODO
|
|
49
|
-
calculateSingleTangent(coords[last - 1], coords[last], knots[last] - knots[last - 1]));
|
|
50
|
-
// generate curve
|
|
51
|
-
const result = [];
|
|
52
|
-
for (let i = 0; i < coords.length; i++) {
|
|
53
|
-
// add control point
|
|
54
|
-
result.push(coords[i]);
|
|
55
|
-
// add interpolated values
|
|
56
|
-
for (let t = knots[i] + INTERPOLATION_INTERVAL; t < knots[i + 1]; t += INTERPOLATION_INTERVAL) {
|
|
57
|
-
if (knots[i + 1] - t > INTERPOLATION_THRESHOLD) {
|
|
58
|
-
// Only add if not too close to a control point (knot = control point)
|
|
59
|
-
result.push(hermite(t, coords, tangents, knots));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return lineString(result);
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=curve-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"curve-utils.js","sourceRoot":"","sources":["../../src/utils/curve-utils.ts"],"names":[],"mappings":"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"}
|
package/src/lib/constants.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A multiplier for screen-space width/scale for Arc, Line, Icon and Text layers.
|
|
7
|
-
* Required in order to maintain the same appearance after upgrading to deck.gl v8.5.
|
|
8
|
-
* https://github.com/visgl/deck.gl/blob/master/docs/upgrade-guide.md
|
|
9
|
-
*/
|
|
10
|
-
export const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export 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
|
-
|
|
9
|
-
constructor(getData: () => TORIG[], convert: (arg0: TORIG) => TCONV) {
|
|
10
|
-
this.objects = [];
|
|
11
|
-
this.originals = [];
|
|
12
|
-
this.updateTrigger = 0;
|
|
13
|
-
|
|
14
|
-
this._idToPosition = new Map();
|
|
15
|
-
this._getData = getData;
|
|
16
|
-
this._convert = convert;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
updateAllDeckObjects() {
|
|
20
|
-
if (!this._getData || !this._convert) return;
|
|
21
|
-
|
|
22
|
-
this.originals.length = 0;
|
|
23
|
-
this.objects.length = 0;
|
|
24
|
-
this._idToPosition.clear();
|
|
25
|
-
|
|
26
|
-
this._getData().forEach((d) => {
|
|
27
|
-
this._idToPosition.set((d as any).id, this.objects.length);
|
|
28
|
-
this.originals.push(d);
|
|
29
|
-
this.objects.push(this._convert(d));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
this.triggerUpdate();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
updateDeckObjectsByIds(ids: string[]) {
|
|
36
|
-
if (!this._getData || !this._convert) return;
|
|
37
|
-
|
|
38
|
-
ids.forEach((id) => {
|
|
39
|
-
const p = this._idToPosition.get(id);
|
|
40
|
-
if (p !== undefined) {
|
|
41
|
-
this.objects[p] = this._convert(this.originals[p]);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
this.triggerUpdate();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
triggerUpdate() {
|
|
49
|
-
this.updateTrigger++;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getDeckObjectById(id: string): TCONV | null | undefined {
|
|
53
|
-
const p = this._idToPosition.get(id);
|
|
54
|
-
return p !== undefined ? this.objects[p] : null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
getOriginalById(id: string): TORIG | null | undefined {
|
|
58
|
-
const p = this._idToPosition.get(id);
|
|
59
|
-
return p !== undefined ? this.originals[p] : null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import {PolygonLayer} from '@deck.gl/layers';
|
|
2
|
-
import {point, polygon} from '@turf/helpers';
|
|
3
|
-
import turfBbox from '@turf/bbox';
|
|
4
|
-
import turfBboxPolygon from '@turf/bbox-polygon';
|
|
5
|
-
import turfBuffer from '@turf/buffer';
|
|
6
|
-
import turfDifference from '@turf/difference';
|
|
7
|
-
import turfDistance from '@turf/distance';
|
|
8
|
-
|
|
9
|
-
import {Color} from '../../utils/types';
|
|
10
|
-
|
|
11
|
-
const POLYGON_LINE_COLOR = [0, 255, 0, 255];
|
|
12
|
-
const POLYGON_FILL_COLOR = [255, 255, 255, 90];
|
|
13
|
-
const POLYGON_LINE_WIDTH = 2;
|
|
14
|
-
// const POLYGON_DASHES = [20, 20];
|
|
15
|
-
const POLYGON_THRESHOLD = 0.01;
|
|
16
|
-
const EXPANSION_KM = 10;
|
|
17
|
-
const LAYER_ID_VIEW = 'DeckDrawerView';
|
|
18
|
-
const LAYER_ID_PICK = 'DeckDrawerPick';
|
|
19
|
-
|
|
20
|
-
export const SELECTION_TYPE = {
|
|
21
|
-
NONE: null,
|
|
22
|
-
RECTANGLE: 'rectangle',
|
|
23
|
-
POLYGON: 'polygon'
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export class DeckDrawer {
|
|
27
|
-
nebula: Record<string, any>;
|
|
28
|
-
usePolygon: boolean;
|
|
29
|
-
validPolygon: boolean;
|
|
30
|
-
landPoints: [number, number][];
|
|
31
|
-
mousePoints: [number, number][];
|
|
32
|
-
|
|
33
|
-
constructor(nebula: Record<string, any>) {
|
|
34
|
-
this.nebula = nebula;
|
|
35
|
-
this.usePolygon = false;
|
|
36
|
-
this.validPolygon = true;
|
|
37
|
-
this.landPoints = [];
|
|
38
|
-
this.mousePoints = [];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_getLayerIds() {
|
|
42
|
-
// TODO: sort by mouse priority
|
|
43
|
-
return this.nebula.deckgl.props.layers
|
|
44
|
-
.filter((l) => l && l.props && l.props.nebulaLayer && l.props.nebulaLayer.enableSelection)
|
|
45
|
-
.map((l) => l.id);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
_selectFromPickingInfos(pickingInfos: Record<string, any>[]) {
|
|
49
|
-
const objects = pickingInfos.map(
|
|
50
|
-
({layer, index, object}) =>
|
|
51
|
-
object.original || layer.props.nebulaLayer.deckCache.originals[index]
|
|
52
|
-
);
|
|
53
|
-
this.nebula.props.onSelection(objects);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
_getBoundingBox(): Record<string, any> {
|
|
57
|
-
const {mousePoints} = this;
|
|
58
|
-
const allX = mousePoints.map((mousePoint) => mousePoint[0]);
|
|
59
|
-
const allY = mousePoints.map((mousePoint) => mousePoint[1]);
|
|
60
|
-
const x = Math.min(...allX);
|
|
61
|
-
const y = Math.min(...allY);
|
|
62
|
-
const maxX = Math.max(...allX);
|
|
63
|
-
const maxY = Math.max(...allY);
|
|
64
|
-
|
|
65
|
-
return {x, y, width: maxX - x, height: maxY - y};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
_selectRectangleObjects() {
|
|
69
|
-
if (this.landPoints.length !== 2) return;
|
|
70
|
-
|
|
71
|
-
const [x1, y1] = this.mousePoints[0];
|
|
72
|
-
const [x2, y2] = this.mousePoints[1];
|
|
73
|
-
const pickingInfos = this.nebula.deckgl.pickObjects({
|
|
74
|
-
x: Math.min(x1, x2),
|
|
75
|
-
y: Math.min(y1, y2),
|
|
76
|
-
width: Math.abs(x2 - x1),
|
|
77
|
-
height: Math.abs(y2 - y1),
|
|
78
|
-
layerIds: this._getLayerIds()
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
this._selectFromPickingInfos(pickingInfos);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
_selectPolygonObjects() {
|
|
85
|
-
const pickingInfos = this.nebula.deckgl.pickObjects({
|
|
86
|
-
...this._getBoundingBox(),
|
|
87
|
-
layerIds: [LAYER_ID_PICK, ...this._getLayerIds()]
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this._selectFromPickingInfos(pickingInfos.filter((item) => item.layer.id !== LAYER_ID_PICK));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
_getMousePosFromEvent(event: Record<string, any>): [number, number] {
|
|
94
|
-
const {offsetX, offsetY} = event;
|
|
95
|
-
return [offsetX, offsetY];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// eslint-disable-next-line max-statements, complexity
|
|
99
|
-
handleEvent(
|
|
100
|
-
event: Record<string, any>,
|
|
101
|
-
lngLat: [number, number],
|
|
102
|
-
selectionType: number
|
|
103
|
-
): {redraw: boolean; deactivate: boolean} {
|
|
104
|
-
// capture all events (mouse-up is needed to prevent us stuck in moving map)
|
|
105
|
-
if (event.type !== 'mouseup') event.stopPropagation();
|
|
106
|
-
|
|
107
|
-
// @ts-expect-error revisit selectionType type
|
|
108
|
-
this.usePolygon = selectionType === SELECTION_TYPE.POLYGON;
|
|
109
|
-
|
|
110
|
-
let redraw = false;
|
|
111
|
-
let deactivate = false;
|
|
112
|
-
|
|
113
|
-
const {usePolygon, landPoints, mousePoints} = this;
|
|
114
|
-
|
|
115
|
-
if (event.type === 'mousedown') {
|
|
116
|
-
if (usePolygon && landPoints.length) {
|
|
117
|
-
// if landPoints.length is zero we want to insert two points (so we let it run the else)
|
|
118
|
-
// also don't insert if polygon is invalid
|
|
119
|
-
if (this.landPoints.length < 3 || this.validPolygon) {
|
|
120
|
-
landPoints.push(lngLat);
|
|
121
|
-
mousePoints.push(this._getMousePosFromEvent(event));
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
this.landPoints = [lngLat, lngLat];
|
|
125
|
-
const m = this._getMousePosFromEvent(event);
|
|
126
|
-
this.mousePoints = [m, m];
|
|
127
|
-
}
|
|
128
|
-
redraw = true;
|
|
129
|
-
} else if (event.type === 'mousemove' && landPoints.length) {
|
|
130
|
-
// update last point
|
|
131
|
-
landPoints[landPoints.length - 1] = lngLat;
|
|
132
|
-
mousePoints[mousePoints.length - 1] = this._getMousePosFromEvent(event);
|
|
133
|
-
redraw = true;
|
|
134
|
-
} else if (event.type === 'mouseup') {
|
|
135
|
-
if (usePolygon) {
|
|
136
|
-
// check to see if completed
|
|
137
|
-
// TODO: Maybe double-click to finish?
|
|
138
|
-
if (
|
|
139
|
-
landPoints.length > 4 &&
|
|
140
|
-
turfDistance(landPoints[0], landPoints[landPoints.length - 1]) < POLYGON_THRESHOLD &&
|
|
141
|
-
this.validPolygon
|
|
142
|
-
) {
|
|
143
|
-
this._selectPolygonObjects();
|
|
144
|
-
this.reset();
|
|
145
|
-
redraw = true;
|
|
146
|
-
deactivate = true;
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
this._selectRectangleObjects();
|
|
150
|
-
this.reset();
|
|
151
|
-
redraw = true;
|
|
152
|
-
deactivate = true;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return {redraw, deactivate};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
reset() {
|
|
160
|
-
this.landPoints = [];
|
|
161
|
-
this.mousePoints = [];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
_makeStartPointHighlight(center: [number, number]): number[] {
|
|
165
|
-
const buffer = turfBuffer(point(center), POLYGON_THRESHOLD / 4.0);
|
|
166
|
-
// @ts-expect-error revisit return type
|
|
167
|
-
return turfBboxPolygon(turfBbox(buffer)).geometry.coordinates;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
render() {
|
|
171
|
-
const data: any[] = [];
|
|
172
|
-
const dataPick: any[] = [];
|
|
173
|
-
|
|
174
|
-
if (!this.usePolygon && this.landPoints.length === 2) {
|
|
175
|
-
// Use mouse points instead of land points so we get the right shape
|
|
176
|
-
// no matter what bearing is.
|
|
177
|
-
const [[x1, y1], [x2, y2]] = this.mousePoints;
|
|
178
|
-
const selPolygon = [
|
|
179
|
-
[x1, y1],
|
|
180
|
-
[x1, y2],
|
|
181
|
-
[x2, y2],
|
|
182
|
-
[x2, y1],
|
|
183
|
-
[x1, y1]
|
|
184
|
-
].map((mousePos) => this.nebula.unprojectMousePosition(mousePos));
|
|
185
|
-
data.push({
|
|
186
|
-
polygon: selPolygon,
|
|
187
|
-
lineColor: POLYGON_LINE_COLOR,
|
|
188
|
-
fillColor: POLYGON_FILL_COLOR
|
|
189
|
-
});
|
|
190
|
-
} else if (this.usePolygon && this.landPoints.length) {
|
|
191
|
-
data.push({
|
|
192
|
-
polygon: this.landPoints,
|
|
193
|
-
lineColor: POLYGON_LINE_COLOR,
|
|
194
|
-
fillColor: POLYGON_FILL_COLOR
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Hack: use a polygon to hide the outside, because pickObjects()
|
|
198
|
-
// does not support polygons
|
|
199
|
-
if (this.landPoints.length >= 3) {
|
|
200
|
-
const landPointsPoly = polygon([[...this.landPoints, this.landPoints[0]]]);
|
|
201
|
-
const bigBuffer = turfBuffer(point(this.landPoints[0]), EXPANSION_KM);
|
|
202
|
-
let bigPolygon;
|
|
203
|
-
try {
|
|
204
|
-
// turfDifference throws an exception if the polygon
|
|
205
|
-
// intersects with itself
|
|
206
|
-
bigPolygon = turfDifference(bigBuffer, landPointsPoly);
|
|
207
|
-
dataPick.push({
|
|
208
|
-
polygon: bigPolygon.geometry.coordinates,
|
|
209
|
-
fillColor: [0, 0, 0, 1]
|
|
210
|
-
});
|
|
211
|
-
this.validPolygon = true;
|
|
212
|
-
} catch (e) {
|
|
213
|
-
// invalid selection polygon
|
|
214
|
-
this.validPolygon = false;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
if (this.landPoints.length) {
|
|
220
|
-
// highlight start point
|
|
221
|
-
data.push({
|
|
222
|
-
polygon: this._makeStartPointHighlight(this.landPoints[0]),
|
|
223
|
-
lineColor: [0, 0, 0, 0],
|
|
224
|
-
fillColor: POLYGON_LINE_COLOR
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Hack to make the PolygonLayer() stay active,
|
|
229
|
-
// otherwise it takes 3 seconds (!) to init!
|
|
230
|
-
// TODO: fix this
|
|
231
|
-
data.push({polygon: [[0, 0]]});
|
|
232
|
-
dataPick.push({polygon: [[0, 0]]});
|
|
233
|
-
|
|
234
|
-
return [
|
|
235
|
-
new PolygonLayer({
|
|
236
|
-
id: LAYER_ID_VIEW,
|
|
237
|
-
data,
|
|
238
|
-
fp64: false,
|
|
239
|
-
opacity: 1.0,
|
|
240
|
-
pickable: false,
|
|
241
|
-
lineWidthMinPixels: POLYGON_LINE_WIDTH,
|
|
242
|
-
lineWidthMaxPixels: POLYGON_LINE_WIDTH,
|
|
243
|
-
lineDashJustified: true,
|
|
244
|
-
// TODO(v9) Add extension
|
|
245
|
-
// getLineDashArray: (x) => POLYGON_DASHES,
|
|
246
|
-
getLineColor: (obj: {lineColor?: Color}) => obj.lineColor || [0, 0, 0, 255],
|
|
247
|
-
getFillColor: (obj: {fillColor?: Color}) => obj.fillColor || [0, 0, 0, 255],
|
|
248
|
-
getPolygon: (o: {polygon?: any}) => o.polygon
|
|
249
|
-
}),
|
|
250
|
-
new PolygonLayer({
|
|
251
|
-
id: LAYER_ID_PICK,
|
|
252
|
-
data: dataPick,
|
|
253
|
-
getLineColor: (obj: {lineColor?: Color}) => obj.lineColor || [0, 0, 0, 255],
|
|
254
|
-
getFillColor: (obj: {fillColor?: Color}) => obj.fillColor || [0, 0, 0, 255],
|
|
255
|
-
fp64: false,
|
|
256
|
-
opacity: 1.0,
|
|
257
|
-
stroked: false,
|
|
258
|
-
pickable: true,
|
|
259
|
-
getPolygon: (o: {polygon?: any}) => o.polygon
|
|
260
|
-
})
|
|
261
|
-
];
|
|
262
|
-
}
|
|
263
|
-
}
|
package/src/lib/feature.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {Feature as GeoJson} from '../utils/geojson-types';
|
|
6
|
-
|
|
7
|
-
import {Style} from '../utils/types';
|
|
8
|
-
|
|
9
|
-
export class Feature {
|
|
10
|
-
// geo json coordinates
|
|
11
|
-
geoJson: GeoJson;
|
|
12
|
-
style: Style;
|
|
13
|
-
original: any | null | undefined;
|
|
14
|
-
metadata: Record<string, any>;
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
geoJson: GeoJson,
|
|
18
|
-
style: Style,
|
|
19
|
-
original: any | null | undefined = null,
|
|
20
|
-
metadata: Record<string, any> = {}
|
|
21
|
-
) {
|
|
22
|
-
this.geoJson = geoJson;
|
|
23
|
-
this.style = style;
|
|
24
|
-
this.original = original;
|
|
25
|
-
this.metadata = metadata;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
getCoords() {
|
|
29
|
-
return this.geoJson.geometry.coordinates;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {Position} from '../utils/geojson-types';
|
|
6
|
-
|
|
7
|
-
export class LayerMouseEvent {
|
|
8
|
-
canceled: boolean = false;
|
|
9
|
-
// original item that this event is related to
|
|
10
|
-
data: Record<string, any>;
|
|
11
|
-
// internal nebula info about the object
|
|
12
|
-
metadata: Record<string, any>;
|
|
13
|
-
// the mouse [lng,lat] raycasted onto the ground
|
|
14
|
-
groundPoint: Position;
|
|
15
|
-
// browser event
|
|
16
|
-
nativeEvent: MouseEvent;
|
|
17
|
-
// reference to nebula
|
|
18
|
-
nebula: Record<string, any>;
|
|
19
|
-
|
|
20
|
-
constructor(nativeEvent: MouseEvent, {data, groundPoint, nebula, metadata}: Record<string, any>) {
|
|
21
|
-
this.nativeEvent = nativeEvent;
|
|
22
|
-
|
|
23
|
-
this.data = data;
|
|
24
|
-
this.groundPoint = groundPoint;
|
|
25
|
-
this.nebula = nebula;
|
|
26
|
-
this.metadata = metadata;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
stopPropagation() {
|
|
30
|
-
this.nativeEvent.stopPropagation();
|
|
31
|
-
this.canceled = true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {NebulaLayer} from '../nebula-layer';
|
|
6
|
-
import {toDeckColor} from '../../utils/utils';
|
|
7
|
-
import {DeckCache} from '../deck-renderer/deck-cache';
|
|
8
|
-
import {JunctionScatterplotLayer} from '../../editable-layers/junction-scatterplot-layer';
|
|
9
|
-
|
|
10
|
-
export class JunctionsLayer extends NebulaLayer {
|
|
11
|
-
deckCache: DeckCache<any, any>;
|
|
12
|
-
|
|
13
|
-
constructor(config: Record<string, any>) {
|
|
14
|
-
super(config);
|
|
15
|
-
this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));
|
|
16
|
-
this.enablePicking = true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
render({nebula}: Record<string, any>) {
|
|
20
|
-
const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];
|
|
21
|
-
const {objects, updateTrigger} = this.deckCache;
|
|
22
|
-
|
|
23
|
-
return new JunctionScatterplotLayer({
|
|
24
|
-
id: `junctions-${this.id}`,
|
|
25
|
-
data: objects,
|
|
26
|
-
opacity: 1,
|
|
27
|
-
pickable: true,
|
|
28
|
-
getPosition: (nf: any) => nf.geoJson.geometry.coordinates,
|
|
29
|
-
getFillColor: (nf: any) => toDeckColor(nf.style.fillColor) || defaultColor,
|
|
30
|
-
getStrokeColor: (nf: any) =>
|
|
31
|
-
toDeckColor(nf.style.outlineColor) || toDeckColor(nf.style.fillColor) || defaultColor,
|
|
32
|
-
getRadius: (nf: any) => nf.style.pointRadiusMeters + nf.style.outlineRadiusMeters || 1,
|
|
33
|
-
getInnerRadius: (nf: any) => nf.style.pointRadiusMeters || 0.5,
|
|
34
|
-
parameters: {
|
|
35
|
-
depthCompare: 'always'
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
updateTriggers: {all: updateTrigger},
|
|
39
|
-
|
|
40
|
-
// @ts-expect-error TODO
|
|
41
|
-
nebulaLayer: this
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {ArrowStyles, DEFAULT_STYLE, MAX_ARROWS} from '../style';
|
|
6
|
-
import {NebulaLayer} from '../nebula-layer';
|
|
7
|
-
import {toDeckColor} from '../../utils/utils';
|
|
8
|
-
import {DeckCache} from '../deck-renderer/deck-cache';
|
|
9
|
-
import {PathMarkerLayer} from '@deck.gl-community/layers';
|
|
10
|
-
|
|
11
|
-
const NEBULA_TO_DECK_DIRECTIONS = {
|
|
12
|
-
[ArrowStyles.NONE]: {forward: false, backward: false},
|
|
13
|
-
[ArrowStyles.FORWARD]: {forward: true, backward: false},
|
|
14
|
-
[ArrowStyles.BACKWARD]: {forward: false, backward: true},
|
|
15
|
-
[ArrowStyles.BOTH]: {forward: true, backward: true}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export class SegmentsLayer extends NebulaLayer {
|
|
19
|
-
deckCache: DeckCache<any, any>;
|
|
20
|
-
noBlend: boolean;
|
|
21
|
-
highlightColor: [number, number, number, number];
|
|
22
|
-
arrowSize: number;
|
|
23
|
-
jointRounded: boolean;
|
|
24
|
-
capRounded: boolean;
|
|
25
|
-
dashed: boolean;
|
|
26
|
-
markerLayerProps: Record<string, any> | null | undefined;
|
|
27
|
-
|
|
28
|
-
constructor(config: Record<string, any>) {
|
|
29
|
-
super(config);
|
|
30
|
-
this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));
|
|
31
|
-
this.enableSelection = true;
|
|
32
|
-
this.enablePicking = config.enablePicking ?? true;
|
|
33
|
-
this.noBlend = config.noBlend ?? false;
|
|
34
|
-
this.jointRounded = config.jointRounded ?? true;
|
|
35
|
-
this.capRounded = config.capRounded ?? true;
|
|
36
|
-
this.dashed = config.dashed ?? false;
|
|
37
|
-
this.markerLayerProps = config.markerLayerProps ?? null;
|
|
38
|
-
this.highlightColor = [1, 1, 1, 1];
|
|
39
|
-
this.arrowSize = 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getMouseOverSegment(): any {
|
|
43
|
-
// TODO: remove references
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_calcMarkerPercentages(nf: Record<string, any>): number[] {
|
|
48
|
-
const {arrowPercentages} = nf.style;
|
|
49
|
-
if (arrowPercentages) {
|
|
50
|
-
return arrowPercentages;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const arrowStyle = nf.style.arrowStyle || DEFAULT_STYLE.arrowStyle;
|
|
54
|
-
if (arrowStyle === ArrowStyles.NONE) return [];
|
|
55
|
-
|
|
56
|
-
const arrowCount = Math.min(nf.style.arrowCount || DEFAULT_STYLE.arrowCount, MAX_ARROWS);
|
|
57
|
-
return [[0.5], [0.33, 0.66], [0.25, 0.5, 0.75]][arrowCount - 1];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_getHighlightedObjectIndex({nebula}: Record<string, any>): number {
|
|
61
|
-
const {deckglMouseOverInfo} = nebula;
|
|
62
|
-
if (deckglMouseOverInfo) {
|
|
63
|
-
const {originalLayer, index} = deckglMouseOverInfo;
|
|
64
|
-
if (originalLayer === this) {
|
|
65
|
-
return index;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// no object
|
|
70
|
-
return -1;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
render({nebula}: Record<string, any>) {
|
|
74
|
-
const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];
|
|
75
|
-
const {objects, updateTrigger} = this.deckCache;
|
|
76
|
-
|
|
77
|
-
return new PathMarkerLayer<any>({
|
|
78
|
-
id: `segments-${this.id}`,
|
|
79
|
-
data: objects,
|
|
80
|
-
opacity: 1,
|
|
81
|
-
fp64: false,
|
|
82
|
-
jointRounded: this.jointRounded,
|
|
83
|
-
capRounded: this.capRounded,
|
|
84
|
-
pickable: true,
|
|
85
|
-
sizeScale: this.arrowSize || 6,
|
|
86
|
-
parameters: {
|
|
87
|
-
depthCompare: 'always',
|
|
88
|
-
blendColorOperation: this.noBlend ? undefined : 'max'
|
|
89
|
-
},
|
|
90
|
-
getPath: (nf: any) => nf.geoJson.geometry.coordinates,
|
|
91
|
-
getColor: (nf: any) => toDeckColor(nf.style.lineColor, defaultColor),
|
|
92
|
-
getWidth: (nf: any) => nf.style.lineWidthMeters || 1,
|
|
93
|
-
getZLevel: (nf: any) => nf.style.zLevel * 255,
|
|
94
|
-
getDirection: (nf: any) => NEBULA_TO_DECK_DIRECTIONS[nf.style.arrowStyle],
|
|
95
|
-
getMarkerColor: (nf: any) => toDeckColor(nf.style.arrowColor, defaultColor),
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
97
|
-
getMarkerPercentages: this._calcMarkerPercentages,
|
|
98
|
-
updateTriggers: {all: updateTrigger},
|
|
99
|
-
|
|
100
|
-
highlightedObjectIndex: this._getHighlightedObjectIndex({nebula}),
|
|
101
|
-
highlightColor: toDeckColor(this.highlightColor),
|
|
102
|
-
|
|
103
|
-
dashJustified: this.dashed,
|
|
104
|
-
getDashArray: this.dashed ? (nf) => nf.style.dashArray : undefined,
|
|
105
|
-
markerLayerProps:
|
|
106
|
-
this.markerLayerProps ||
|
|
107
|
-
(PathMarkerLayer as Record<string, any>).defaultProps.markerLayerProps,
|
|
108
|
-
|
|
109
|
-
nebulaLayer: this
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {TextLayer} from '@deck.gl/layers';
|
|
6
|
-
import {NebulaLayer} from '../nebula-layer';
|
|
7
|
-
import {toDeckColor} from '../../utils/utils';
|
|
8
|
-
import {PROJECTED_PIXEL_SIZE_MULTIPLIER} from '../constants';
|
|
9
|
-
import {DeckCache} from '../deck-renderer/deck-cache';
|
|
10
|
-
import {Color} from '../../utils/types';
|
|
11
|
-
|
|
12
|
-
export class TextsLayer extends NebulaLayer {
|
|
13
|
-
deckCache: DeckCache<any, any>;
|
|
14
|
-
|
|
15
|
-
constructor(config: Record<string, any>) {
|
|
16
|
-
super(config);
|
|
17
|
-
this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
render({nebula}: Record<string, any>): TextLayer {
|
|
21
|
-
const defaultColor: Color = [0x0, 0x0, 0x0, 0xff];
|
|
22
|
-
const {objects, updateTrigger} = this.deckCache;
|
|
23
|
-
|
|
24
|
-
const {zoom} = nebula.props.viewport;
|
|
25
|
-
|
|
26
|
-
return new TextLayer({
|
|
27
|
-
id: `texts-${this.id}`,
|
|
28
|
-
data: objects,
|
|
29
|
-
opacity: 1,
|
|
30
|
-
fp64: false,
|
|
31
|
-
pickable: false,
|
|
32
|
-
|
|
33
|
-
getText: (nf: any) => nf.style.text,
|
|
34
|
-
getPosition: (nf: any) => nf.geoJson.geometry.coordinates,
|
|
35
|
-
getColor: (nf: {style: {fillColor: Color}}) =>
|
|
36
|
-
toDeckColor(nf.style.fillColor) || defaultColor,
|
|
37
|
-
|
|
38
|
-
// TODO: layer should offer option to scale with zoom
|
|
39
|
-
sizeScale: 1 / Math.pow(2, 20 - zoom),
|
|
40
|
-
getSize: PROJECTED_PIXEL_SIZE_MULTIPLIER,
|
|
41
|
-
|
|
42
|
-
updateTriggers: {all: updateTrigger},
|
|
43
|
-
|
|
44
|
-
nebulaLayer: this
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|