@deck.gl-community/editable-layers 9.2.0-beta.5 → 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 +9 -5
- package/dist/edit-modes/draw-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.js +226 -81
- 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 +369 -995
- 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 -33
- 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 +304 -100
- 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
|
@@ -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
|
-
}
|
package/src/lib/math.ts
DELETED
|
@@ -1,30 +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 function toDegree(radian: number): number {
|
|
8
|
-
return (radian * 180) / Math.PI;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function toRadian(angle: number): number {
|
|
12
|
-
return (angle * Math.PI) / 180;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Converts an array of latitudes, longitudes in E7 format to a list of points in degrees.
|
|
17
|
-
*
|
|
18
|
-
* @param {[]} array: An E7 array [lat_e7, lng_e7, lat_e7, lng_e7, ...]
|
|
19
|
-
* @return {[]} An array of points in degrees
|
|
20
|
-
* [ [lng_degrees, lat_degrees], [lng_degrees, lat_degrees], ...]
|
|
21
|
-
*/
|
|
22
|
-
export function convertE7Array(array: number[]): Position[] {
|
|
23
|
-
const points: Position[] = [];
|
|
24
|
-
for (let i = 0; i < array.length; i += 2) {
|
|
25
|
-
const lat = array[i] * 1e-7;
|
|
26
|
-
const lng = array[i + 1] * 1e-7;
|
|
27
|
-
points.push([lng, lat]);
|
|
28
|
-
}
|
|
29
|
-
return points;
|
|
30
|
-
}
|