@deck.gl-community/editable-layers 9.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -0
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +14 -0
- package/dist/curve-utils.d.ts +2 -0
- package/dist/curve-utils.js +61 -0
- package/dist/edit-modes/composite-mode.d.ts +14 -0
- package/dist/edit-modes/composite-mode.js +47 -0
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts +11 -0
- package/dist/edit-modes/draw-90degree-polygon-mode.js +179 -0
- package/dist/edit-modes/draw-circle-by-diameter-mode.d.ts +24 -0
- package/dist/edit-modes/draw-circle-by-diameter-mode.js +78 -0
- package/dist/edit-modes/draw-circle-from-center-mode.d.ts +22 -0
- package/dist/edit-modes/draw-circle-from-center-mode.js +70 -0
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.d.ts +5 -0
- package/dist/edit-modes/draw-ellipse-by-bounding-box-mode.js +20 -0
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.d.ts +5 -0
- package/dist/edit-modes/draw-ellipse-using-three-points-mode.js +16 -0
- package/dist/edit-modes/draw-line-string-mode.d.ts +25 -0
- package/dist/edit-modes/draw-line-string-mode.js +170 -0
- package/dist/edit-modes/draw-point-mode.d.ts +8 -0
- package/dist/edit-modes/draw-point-mode.js +28 -0
- package/dist/edit-modes/draw-polygon-by-dragging-mode.d.ts +14 -0
- package/dist/edit-modes/draw-polygon-by-dragging-mode.js +87 -0
- package/dist/edit-modes/draw-polygon-mode.d.ts +10 -0
- package/dist/edit-modes/draw-polygon-mode.js +143 -0
- package/dist/edit-modes/draw-rectangle-from-center-mode.d.ts +5 -0
- package/dist/edit-modes/draw-rectangle-from-center-mode.js +17 -0
- package/dist/edit-modes/draw-rectangle-mode.d.ts +5 -0
- package/dist/edit-modes/draw-rectangle-mode.js +11 -0
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.d.ts +5 -0
- package/dist/edit-modes/draw-rectangle-using-three-points-mode.js +28 -0
- package/dist/edit-modes/draw-square-from-center-mode.d.ts +5 -0
- package/dist/edit-modes/draw-square-from-center-mode.js +35 -0
- package/dist/edit-modes/draw-square-mode.d.ts +5 -0
- package/dist/edit-modes/draw-square-mode.js +28 -0
- package/dist/edit-modes/duplicate-mode.d.ts +7 -0
- package/dist/edit-modes/duplicate-mode.js +17 -0
- package/dist/edit-modes/edit-mode.d.ts +11 -0
- package/dist/edit-modes/edit-mode.js +2 -0
- package/dist/edit-modes/elevation-mode.d.ts +13 -0
- package/dist/edit-modes/elevation-mode.js +49 -0
- package/dist/edit-modes/extend-line-string-mode.d.ts +9 -0
- package/dist/edit-modes/extend-line-string-mode.js +72 -0
- package/dist/edit-modes/extrude-mode.d.ts +15 -0
- package/dist/edit-modes/extrude-mode.js +186 -0
- package/dist/edit-modes/geojson-edit-mode.d.ts +33 -0
- package/dist/edit-modes/geojson-edit-mode.js +208 -0
- package/dist/edit-modes/immutable-feature-collection.d.ts +43 -0
- package/dist/edit-modes/immutable-feature-collection.js +300 -0
- package/dist/edit-modes/measure-angle-mode.d.ts +11 -0
- package/dist/edit-modes/measure-angle-mode.js +99 -0
- package/dist/edit-modes/measure-area-mode.d.ts +8 -0
- package/dist/edit-modes/measure-area-mode.js +50 -0
- package/dist/edit-modes/measure-distance-mode.d.ts +19 -0
- package/dist/edit-modes/measure-distance-mode.js +171 -0
- package/dist/edit-modes/modify-mode.d.ts +15 -0
- package/dist/edit-modes/modify-mode.js +203 -0
- package/dist/edit-modes/resize-circle-mode.d.ts +16 -0
- package/dist/edit-modes/resize-circle-mode.js +142 -0
- package/dist/edit-modes/rotate-mode.d.ts +17 -0
- package/dist/edit-modes/rotate-mode.js +151 -0
- package/dist/edit-modes/scale-mode.d.ts +27 -0
- package/dist/edit-modes/scale-mode.js +173 -0
- package/dist/edit-modes/snappable-mode.d.ts +21 -0
- package/dist/edit-modes/snappable-mode.js +109 -0
- package/dist/edit-modes/split-polygon-mode.d.ts +10 -0
- package/dist/edit-modes/split-polygon-mode.js +164 -0
- package/dist/edit-modes/three-click-polygon-mode.d.ts +10 -0
- package/dist/edit-modes/three-click-polygon-mode.js +72 -0
- package/dist/edit-modes/transform-mode.d.ts +9 -0
- package/dist/edit-modes/transform-mode.js +63 -0
- package/dist/edit-modes/translate-mode.d.ts +13 -0
- package/dist/edit-modes/translate-mode.js +113 -0
- package/dist/edit-modes/two-click-polygon-mode.d.ts +13 -0
- package/dist/edit-modes/two-click-polygon-mode.js +93 -0
- package/dist/edit-modes/types.d.ts +86 -0
- package/dist/edit-modes/types.js +1 -0
- package/dist/edit-modes/utils.d.ts +36 -0
- package/dist/edit-modes/utils.js +381 -0
- package/dist/edit-modes/view-mode.d.ts +3 -0
- package/dist/edit-modes/view-mode.js +3 -0
- package/dist/editable-layers/editable-geojson-layer.d.ts +98 -0
- package/dist/editable-layers/editable-geojson-layer.js +450 -0
- package/dist/editable-layers/editable-h3-cluster-layer.d.ts +34 -0
- package/dist/editable-layers/editable-h3-cluster-layer.js +164 -0
- package/dist/editable-layers/editable-layer.d.ts +49 -0
- package/dist/editable-layers/editable-layer.js +195 -0
- package/dist/editable-layers/editable-path-layer.d.ts +9 -0
- package/dist/editable-layers/editable-path-layer.js +34 -0
- package/dist/editable-layers/elevated-edit-handle-layer.d.ts +7 -0
- package/dist/editable-layers/elevated-edit-handle-layer.js +24 -0
- package/dist/editable-layers/junction-scatterplot-layer.d.ts +14 -0
- package/dist/editable-layers/junction-scatterplot-layer.js +41 -0
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.d.ts +4 -0
- package/dist/editable-layers/path-marker-layer/arrow-2d-geometry.js +55 -0
- package/dist/editable-layers/path-marker-layer/create-path-markers.d.ts +16 -0
- package/dist/editable-layers/path-marker-layer/create-path-markers.js +75 -0
- package/dist/editable-layers/path-marker-layer/path-marker-layer.d.ts +40 -0
- package/dist/editable-layers/path-marker-layer/path-marker-layer.js +121 -0
- package/dist/editable-layers/path-marker-layer/polyline.d.ts +18 -0
- package/dist/editable-layers/path-marker-layer/polyline.js +37 -0
- package/dist/editable-layers/path-outline-layer/path-outline-layer.d.ts +26 -0
- package/dist/editable-layers/path-outline-layer/path-outline-layer.js +106 -0
- package/dist/editable-layers/selection-layer.d.ts +26 -0
- package/dist/editable-layers/selection-layer.js +167 -0
- package/dist/geojson-types.d.ts +58 -0
- package/dist/geojson-types.js +2 -0
- package/dist/index.cjs +5825 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +62 -0
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +6 -0
- package/dist/lib/deck-renderer/deck-cache.d.ts +14 -0
- package/dist/lib/deck-renderer/deck-cache.js +51 -0
- package/dist/lib/deck-renderer/deck-drawer.d.ts +63 -0
- package/dist/lib/deck-renderer/deck-drawer.js +232 -0
- package/dist/lib/feature.d.ts +10 -0
- package/dist/lib/feature.js +16 -0
- package/dist/lib/layer-mouse-event.d.ts +11 -0
- package/dist/lib/layer-mouse-event.js +24 -0
- package/dist/lib/layers/junctions-layer.d.ts +8 -0
- package/dist/lib/layers/junctions-layer.js +33 -0
- package/dist/lib/layers/segments-layer.d.ts +18 -0
- package/dist/lib/layers/segments-layer.js +94 -0
- package/dist/lib/layers/texts-layer.d.ts +8 -0
- package/dist/lib/layers/texts-layer.js +32 -0
- package/dist/lib/math.d.ts +11 -0
- package/dist/lib/math.js +22 -0
- package/dist/lib/nebula-layer.d.ts +13 -0
- package/dist/lib/nebula-layer.js +26 -0
- package/dist/lib/nebula.d.ts +34 -0
- package/dist/lib/nebula.js +254 -0
- package/dist/lib/style.d.ts +19 -0
- package/dist/lib/style.js +20 -0
- package/dist/memoize.d.ts +6 -0
- package/dist/memoize.js +40 -0
- package/dist/mode-handlers/composite-mode-handler.d.ts +24 -0
- package/dist/mode-handlers/composite-mode-handler.js +55 -0
- package/dist/mode-handlers/draw-90degree-polygon-handler.d.ts +13 -0
- package/dist/mode-handlers/draw-90degree-polygon-handler.js +169 -0
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-circle-by-bounding-box-handler.js +29 -0
- package/dist/mode-handlers/draw-circle-from-center-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-circle-from-center-handler.js +27 -0
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-ellipse-by-bounding-box-handler.js +30 -0
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-ellipse-using-three-points-handler.js +37 -0
- package/dist/mode-handlers/draw-line-string-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-line-string-handler.js +83 -0
- package/dist/mode-handlers/draw-point-handler.d.ts +5 -0
- package/dist/mode-handlers/draw-point-handler.js +11 -0
- package/dist/mode-handlers/draw-polygon-handler.d.ts +11 -0
- package/dist/mode-handlers/draw-polygon-handler.js +92 -0
- package/dist/mode-handlers/draw-rectangle-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-rectangle-handler.js +18 -0
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.d.ts +9 -0
- package/dist/mode-handlers/draw-rectangle-using-three-points-handler.js +49 -0
- package/dist/mode-handlers/duplicate-handler.d.ts +9 -0
- package/dist/mode-handlers/duplicate-handler.js +19 -0
- package/dist/mode-handlers/elevation-handler.d.ts +19 -0
- package/dist/mode-handlers/elevation-handler.js +48 -0
- package/dist/mode-handlers/extrude-handler.d.ts +18 -0
- package/dist/mode-handlers/extrude-handler.js +176 -0
- package/dist/mode-handlers/mode-handler.d.ts +61 -0
- package/dist/mode-handlers/mode-handler.js +286 -0
- package/dist/mode-handlers/modify-handler.d.ts +19 -0
- package/dist/mode-handlers/modify-handler.js +193 -0
- package/dist/mode-handlers/rotate-handler.d.ts +17 -0
- package/dist/mode-handlers/rotate-handler.js +74 -0
- package/dist/mode-handlers/scale-handler.d.ts +17 -0
- package/dist/mode-handlers/scale-handler.js +76 -0
- package/dist/mode-handlers/snappable-handler.d.ts +33 -0
- package/dist/mode-handlers/snappable-handler.js +133 -0
- package/dist/mode-handlers/split-polygon-handler.d.ts +11 -0
- package/dist/mode-handlers/split-polygon-handler.js +154 -0
- package/dist/mode-handlers/three-click-polygon-handler.d.ts +5 -0
- package/dist/mode-handlers/three-click-polygon-handler.js +18 -0
- package/dist/mode-handlers/translate-handler.d.ts +17 -0
- package/dist/mode-handlers/translate-handler.js +72 -0
- package/dist/mode-handlers/two-click-polygon-handler.d.ts +5 -0
- package/dist/mode-handlers/two-click-polygon-handler.js +18 -0
- package/dist/mode-handlers/view-handler.d.ts +8 -0
- package/dist/mode-handlers/view-handler.js +10 -0
- package/dist/shaderlib/color/color.d.ts +8 -0
- package/dist/shaderlib/color/color.js +51 -0
- package/dist/shaderlib/outline/outline.d.ts +8 -0
- package/dist/shaderlib/outline/outline.js +97 -0
- package/dist/shaderlib/utils/utils.d.ts +8 -0
- package/dist/shaderlib/utils/utils.js +28 -0
- package/dist/translateFromCenter.d.ts +4 -0
- package/dist/translateFromCenter.js +19 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +144 -0
- package/package.json +84 -0
- package/src/constants.ts +15 -0
- package/src/curve-utils.ts +77 -0
- package/src/edit-modes/composite-mode.ts +74 -0
- package/src/edit-modes/draw-90degree-polygon-mode.ts +220 -0
- package/src/edit-modes/draw-circle-by-diameter-mode.ts +88 -0
- package/src/edit-modes/draw-circle-from-center-mode.ts +79 -0
- package/src/edit-modes/draw-ellipse-by-bounding-box-mode.ts +25 -0
- package/src/edit-modes/draw-ellipse-using-three-points-mode.ts +23 -0
- package/src/edit-modes/draw-line-string-mode.ts +200 -0
- package/src/edit-modes/draw-point-mode.ts +35 -0
- package/src/edit-modes/draw-polygon-by-dragging-mode.ts +106 -0
- package/src/edit-modes/draw-polygon-mode.ts +171 -0
- package/src/edit-modes/draw-rectangle-from-center-mode.ts +23 -0
- package/src/edit-modes/draw-rectangle-mode.ts +14 -0
- package/src/edit-modes/draw-rectangle-using-three-points-mode.ts +36 -0
- package/src/edit-modes/draw-square-from-center-mode.ts +46 -0
- package/src/edit-modes/draw-square-mode.ts +36 -0
- package/src/edit-modes/duplicate-mode.ts +21 -0
- package/src/edit-modes/edit-mode.ts +30 -0
- package/src/edit-modes/elevation-mode.ts +86 -0
- package/src/edit-modes/extend-line-string-mode.ts +87 -0
- package/src/edit-modes/extrude-mode.ts +254 -0
- package/src/edit-modes/geojson-edit-mode.ts +283 -0
- package/src/edit-modes/immutable-feature-collection.ts +417 -0
- package/src/edit-modes/measure-angle-mode.ts +127 -0
- package/src/edit-modes/measure-area-mode.ts +62 -0
- package/src/edit-modes/measure-distance-mode.ts +215 -0
- package/src/edit-modes/modify-mode.ts +293 -0
- package/src/edit-modes/resize-circle-mode.ts +202 -0
- package/src/edit-modes/rotate-mode.ts +208 -0
- package/src/edit-modes/scale-mode.ts +231 -0
- package/src/edit-modes/snappable-mode.ts +174 -0
- package/src/edit-modes/split-polygon-mode.ts +201 -0
- package/src/edit-modes/three-click-polygon-mode.ts +111 -0
- package/src/edit-modes/transform-mode.ts +75 -0
- package/src/edit-modes/translate-mode.ts +161 -0
- package/src/edit-modes/two-click-polygon-mode.ts +132 -0
- package/src/edit-modes/types.ts +135 -0
- package/src/edit-modes/utils.ts +513 -0
- package/src/edit-modes/view-mode.ts +3 -0
- package/src/editable-layers/editable-geojson-layer.ts +603 -0
- package/src/editable-layers/editable-h3-cluster-layer.ts +226 -0
- package/src/editable-layers/editable-layer.ts +252 -0
- package/src/editable-layers/editable-path-layer.ts +51 -0
- package/src/editable-layers/elevated-edit-handle-layer.ts +33 -0
- package/src/editable-layers/junction-scatterplot-layer.ts +53 -0
- package/src/editable-layers/path-marker-layer/arrow-2d-geometry.ts +61 -0
- package/src/editable-layers/path-marker-layer/create-path-markers.ts +107 -0
- package/src/editable-layers/path-marker-layer/path-marker-layer.ts +179 -0
- package/src/editable-layers/path-marker-layer/polyline.ts +40 -0
- package/src/editable-layers/path-outline-layer/path-outline-layer.ts +147 -0
- package/src/editable-layers/selection-layer.ts +209 -0
- package/src/geojson-types.ts +89 -0
- package/src/index.ts +125 -0
- package/src/lib/constants.ts +6 -0
- package/src/lib/deck-renderer/deck-cache.ts +61 -0
- package/src/lib/deck-renderer/deck-drawer.ts +263 -0
- package/src/lib/feature.ts +27 -0
- package/src/lib/layer-mouse-event.ts +32 -0
- package/src/lib/layers/junctions-layer.ts +40 -0
- package/src/lib/layers/segments-layer.ts +108 -0
- package/src/lib/layers/texts-layer.ts +43 -0
- package/src/lib/math.ts +26 -0
- package/src/lib/nebula-layer.ts +33 -0
- package/src/lib/nebula.ts +323 -0
- package/src/lib/style.ts +22 -0
- package/src/memoize.ts +43 -0
- package/src/mode-handlers/composite-mode-handler.ts +89 -0
- package/src/mode-handlers/draw-90degree-polygon-handler.ts +201 -0
- package/src/mode-handlers/draw-circle-by-bounding-box-handler.ts +39 -0
- package/src/mode-handlers/draw-circle-from-center-handler.ts +38 -0
- package/src/mode-handlers/draw-ellipse-by-bounding-box-handler.ts +41 -0
- package/src/mode-handlers/draw-ellipse-using-three-points-handler.ts +46 -0
- package/src/mode-handlers/draw-line-string-handler.ts +108 -0
- package/src/mode-handlers/draw-point-handler.ts +15 -0
- package/src/mode-handlers/draw-polygon-handler.ts +121 -0
- package/src/mode-handlers/draw-rectangle-handler.ts +28 -0
- package/src/mode-handlers/draw-rectangle-using-three-points-handler.ts +60 -0
- package/src/mode-handlers/duplicate-handler.ts +25 -0
- package/src/mode-handlers/elevation-handler.ts +88 -0
- package/src/mode-handlers/extrude-handler.ts +245 -0
- package/src/mode-handlers/mode-handler.ts +394 -0
- package/src/mode-handlers/modify-handler.ts +263 -0
- package/src/mode-handlers/rotate-handler.ts +107 -0
- package/src/mode-handlers/scale-handler.ts +105 -0
- package/src/mode-handlers/snappable-handler.ts +184 -0
- package/src/mode-handlers/split-polygon-handler.ts +177 -0
- package/src/mode-handlers/three-click-polygon-handler.ts +25 -0
- package/src/mode-handlers/translate-handler.ts +110 -0
- package/src/mode-handlers/two-click-polygon-handler.ts +25 -0
- package/src/mode-handlers/view-handler.ts +13 -0
- package/src/shaderlib/color/color.ts +56 -0
- package/src/shaderlib/outline/outline.ts +101 -0
- package/src/shaderlib/utils/utils.ts +33 -0
- package/src/translateFromCenter.ts +48 -0
- package/src/types.ts +39 -0
- package/src/utils.ts +185 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Geometry types
|
|
2
|
+
|
|
3
|
+
export type Position = [number, number] | [number, number, number];
|
|
4
|
+
export type PointCoordinates = Position;
|
|
5
|
+
export type LineStringCoordinates = Position[];
|
|
6
|
+
export type PolygonCoordinates = Position[][];
|
|
7
|
+
export type MultiPointCoordinates = Position[];
|
|
8
|
+
export type MultiLineStringCoordinates = Position[][];
|
|
9
|
+
export type MultiPolygonCoordinates = Position[][][];
|
|
10
|
+
|
|
11
|
+
export type AnyCoordinates =
|
|
12
|
+
| PointCoordinates
|
|
13
|
+
| LineStringCoordinates
|
|
14
|
+
| PolygonCoordinates
|
|
15
|
+
| MultiPointCoordinates
|
|
16
|
+
| MultiLineStringCoordinates
|
|
17
|
+
| MultiPolygonCoordinates;
|
|
18
|
+
|
|
19
|
+
export type Point = {
|
|
20
|
+
type: 'Point';
|
|
21
|
+
coordinates: PointCoordinates;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type LineString = {
|
|
25
|
+
type: 'LineString';
|
|
26
|
+
coordinates: LineStringCoordinates;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type Polygon = {
|
|
30
|
+
type: 'Polygon';
|
|
31
|
+
coordinates: PolygonCoordinates;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type MultiPoint = {
|
|
35
|
+
type: 'MultiPoint';
|
|
36
|
+
coordinates: MultiPointCoordinates;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type MultiLineString = {
|
|
40
|
+
type: 'MultiLineString';
|
|
41
|
+
coordinates: MultiLineStringCoordinates;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type MultiPolygon = {
|
|
45
|
+
type: 'MultiPolygon';
|
|
46
|
+
coordinates: MultiPolygonCoordinates;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
50
|
+
|
|
51
|
+
export type Polygonal = Polygon | MultiPolygon;
|
|
52
|
+
|
|
53
|
+
// Feature types
|
|
54
|
+
|
|
55
|
+
export type BoundingBoxArray = [number, number, number, number];
|
|
56
|
+
|
|
57
|
+
export type FeatureOf<T extends Geometry> = {
|
|
58
|
+
type: 'Feature';
|
|
59
|
+
geometry: T;
|
|
60
|
+
properties?: {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
};
|
|
63
|
+
id?: string | number;
|
|
64
|
+
bbox?: BoundingBoxArray;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type FeatureWithProps<T extends Geometry, P> = {
|
|
68
|
+
type: 'Feature';
|
|
69
|
+
geometry: T;
|
|
70
|
+
properties: P;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type Feature =
|
|
74
|
+
| FeatureOf<Point>
|
|
75
|
+
| FeatureOf<LineString>
|
|
76
|
+
| FeatureOf<Polygon>
|
|
77
|
+
| FeatureOf<MultiPoint>
|
|
78
|
+
| FeatureOf<MultiLineString>
|
|
79
|
+
| FeatureOf<MultiPolygon>;
|
|
80
|
+
|
|
81
|
+
export type FeatureCollection = {
|
|
82
|
+
type: 'FeatureCollection';
|
|
83
|
+
features: Feature[];
|
|
84
|
+
properties?: {};
|
|
85
|
+
id?: string | number;
|
|
86
|
+
bbox?: BoundingBoxArray;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type AnyGeoJson = Feature | FeatureCollection;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export { ArrowStyles, DEFAULT_ARROWS, MAX_ARROWS } from './lib/style';
|
|
2
|
+
export { SELECTION_TYPE } from './lib/deck-renderer/deck-drawer';
|
|
3
|
+
|
|
4
|
+
export { default as Feature } from './lib/feature';
|
|
5
|
+
export { default as LayerMouseEvent } from './lib/layer-mouse-event';
|
|
6
|
+
|
|
7
|
+
export { default as NebulaLayer } from './lib/nebula-layer';
|
|
8
|
+
export { default as JunctionsLayer } from './lib/layers/junctions-layer';
|
|
9
|
+
export { default as TextsLayer } from './lib/layers/texts-layer';
|
|
10
|
+
export { default as SegmentsLayer } from './lib/layers/segments-layer';
|
|
11
|
+
|
|
12
|
+
export { default as NebulaCore } from './lib/nebula';
|
|
13
|
+
|
|
14
|
+
export { PROJECTED_PIXEL_SIZE_MULTIPLIER } from './lib/constants';
|
|
15
|
+
|
|
16
|
+
// Utils
|
|
17
|
+
export { toDeckColor } from './utils';
|
|
18
|
+
|
|
19
|
+
// Types
|
|
20
|
+
export type { Color, Style, Viewport } from './types';
|
|
21
|
+
|
|
22
|
+
// Layers
|
|
23
|
+
export { default as EditableGeoJsonLayer } from './editable-layers/editable-geojson-layer';
|
|
24
|
+
export { default as EditableH3ClusterLayer } from './editable-layers/editable-h3-cluster-layer';
|
|
25
|
+
export { default as SelectionLayer } from './editable-layers/selection-layer';
|
|
26
|
+
export { default as ElevatedEditHandleLayer } from './editable-layers/elevated-edit-handle-layer';
|
|
27
|
+
|
|
28
|
+
// Layers moved from deck.gl
|
|
29
|
+
export { default as PathOutlineLayer } from './editable-layers/path-outline-layer/path-outline-layer';
|
|
30
|
+
export { default as PathMarkerLayer } from './editable-layers/path-marker-layer/path-marker-layer';
|
|
31
|
+
export { default as JunctionScatterplotLayer } from './editable-layers/junction-scatterplot-layer';
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// Types
|
|
35
|
+
|
|
36
|
+
import * as utils from './utils';
|
|
37
|
+
|
|
38
|
+
export { utils };
|
|
39
|
+
|
|
40
|
+
export type { EditMode } from './edit-modes/edit-mode';
|
|
41
|
+
export type { GeoJsonEditModeType } from './edit-modes/geojson-edit-mode';
|
|
42
|
+
export type { GeoJsonEditModeConstructor } from './edit-modes/geojson-edit-mode';
|
|
43
|
+
|
|
44
|
+
export { GeoJsonEditMode } from './edit-modes/geojson-edit-mode';
|
|
45
|
+
|
|
46
|
+
// Alter modes
|
|
47
|
+
export { ModifyMode } from './edit-modes/modify-mode';
|
|
48
|
+
export { ResizeCircleMode } from './edit-modes/resize-circle-mode';
|
|
49
|
+
export { TranslateMode } from './edit-modes/translate-mode';
|
|
50
|
+
export { ScaleMode } from './edit-modes/scale-mode';
|
|
51
|
+
export { RotateMode } from './edit-modes/rotate-mode';
|
|
52
|
+
export { DuplicateMode } from './edit-modes/duplicate-mode';
|
|
53
|
+
export { ExtendLineStringMode } from './edit-modes/extend-line-string-mode';
|
|
54
|
+
export { SplitPolygonMode } from './edit-modes/split-polygon-mode';
|
|
55
|
+
export { ExtrudeMode } from './edit-modes/extrude-mode';
|
|
56
|
+
export { ElevationMode } from './edit-modes/elevation-mode';
|
|
57
|
+
export { TransformMode } from './edit-modes/transform-mode';
|
|
58
|
+
|
|
59
|
+
// Draw modes
|
|
60
|
+
export { DrawPointMode } from './edit-modes/draw-point-mode';
|
|
61
|
+
export { DrawLineStringMode } from './edit-modes/draw-line-string-mode';
|
|
62
|
+
export { DrawPolygonMode } from './edit-modes/draw-polygon-mode';
|
|
63
|
+
export { DrawRectangleMode } from './edit-modes/draw-rectangle-mode';
|
|
64
|
+
export { DrawSquareMode } from './edit-modes/draw-square-mode';
|
|
65
|
+
export { DrawRectangleFromCenterMode } from './edit-modes/draw-rectangle-from-center-mode';
|
|
66
|
+
export { DrawSquareFromCenterMode } from './edit-modes/draw-square-from-center-mode';
|
|
67
|
+
export { DrawCircleByDiameterMode } from './edit-modes/draw-circle-by-diameter-mode';
|
|
68
|
+
export { DrawCircleFromCenterMode } from './edit-modes/draw-circle-from-center-mode';
|
|
69
|
+
export { DrawEllipseByBoundingBoxMode } from './edit-modes/draw-ellipse-by-bounding-box-mode';
|
|
70
|
+
export { DrawEllipseUsingThreePointsMode } from './edit-modes/draw-ellipse-using-three-points-mode';
|
|
71
|
+
export { DrawRectangleUsingThreePointsMode } from './edit-modes/draw-rectangle-using-three-points-mode';
|
|
72
|
+
export { Draw90DegreePolygonMode } from './edit-modes/draw-90degree-polygon-mode';
|
|
73
|
+
export { DrawPolygonByDraggingMode } from './edit-modes/draw-polygon-by-dragging-mode';
|
|
74
|
+
export { ImmutableFeatureCollection } from './edit-modes/immutable-feature-collection';
|
|
75
|
+
|
|
76
|
+
// Other modes
|
|
77
|
+
export { ViewMode } from './edit-modes/view-mode';
|
|
78
|
+
export { MeasureDistanceMode } from './edit-modes/measure-distance-mode';
|
|
79
|
+
export { MeasureAreaMode } from './edit-modes/measure-area-mode';
|
|
80
|
+
export { MeasureAngleMode } from './edit-modes/measure-angle-mode';
|
|
81
|
+
export { CompositeMode } from './edit-modes/composite-mode';
|
|
82
|
+
export { SnappableMode } from './edit-modes/snappable-mode';
|
|
83
|
+
|
|
84
|
+
// Experimental
|
|
85
|
+
export { default as _memoize } from './memoize';
|
|
86
|
+
|
|
87
|
+
export type {
|
|
88
|
+
ScreenCoordinates,
|
|
89
|
+
EditAction,
|
|
90
|
+
Pick,
|
|
91
|
+
ClickEvent,
|
|
92
|
+
PointerMoveEvent,
|
|
93
|
+
StartDraggingEvent,
|
|
94
|
+
StopDraggingEvent,
|
|
95
|
+
DraggingEvent,
|
|
96
|
+
ModeProps,
|
|
97
|
+
GuideFeatureCollection,
|
|
98
|
+
// Viewport,
|
|
99
|
+
Tooltip,
|
|
100
|
+
} from './edit-modes/types';
|
|
101
|
+
|
|
102
|
+
export type {
|
|
103
|
+
Position,
|
|
104
|
+
PointCoordinates,
|
|
105
|
+
LineStringCoordinates,
|
|
106
|
+
PolygonCoordinates,
|
|
107
|
+
MultiPointCoordinates,
|
|
108
|
+
MultiLineStringCoordinates,
|
|
109
|
+
MultiPolygonCoordinates,
|
|
110
|
+
AnyCoordinates,
|
|
111
|
+
Point,
|
|
112
|
+
LineString,
|
|
113
|
+
Polygon,
|
|
114
|
+
MultiPoint,
|
|
115
|
+
MultiLineString,
|
|
116
|
+
MultiPolygon,
|
|
117
|
+
Geometry,
|
|
118
|
+
Polygonal,
|
|
119
|
+
BoundingBoxArray,
|
|
120
|
+
FeatureOf,
|
|
121
|
+
FeatureWithProps,
|
|
122
|
+
// Feature,
|
|
123
|
+
FeatureCollection,
|
|
124
|
+
AnyGeoJson,
|
|
125
|
+
} from './geojson-types';
|
|
@@ -0,0 +1,6 @@
|
|
|
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 const PROJECTED_PIXEL_SIZE_MULTIPLIER = 2 / 3;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export default 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
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
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 '../../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 default 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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Feature as GeoJson } from '../geojson-types';
|
|
2
|
+
|
|
3
|
+
import { Style } from '../types';
|
|
4
|
+
|
|
5
|
+
export default class Feature {
|
|
6
|
+
// geo json coordinates
|
|
7
|
+
geoJson: GeoJson;
|
|
8
|
+
style: Style;
|
|
9
|
+
original: any | null | undefined;
|
|
10
|
+
metadata: Record<string, any>;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
geoJson: GeoJson,
|
|
14
|
+
style: Style,
|
|
15
|
+
original: any | null | undefined = null,
|
|
16
|
+
metadata: Record<string, any> = {}
|
|
17
|
+
) {
|
|
18
|
+
this.geoJson = geoJson;
|
|
19
|
+
this.style = style;
|
|
20
|
+
this.original = original;
|
|
21
|
+
this.metadata = metadata;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getCoords() {
|
|
25
|
+
return this.geoJson.geometry.coordinates;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Position } from '../geojson-types';
|
|
2
|
+
|
|
3
|
+
export default class LayerMouseEvent {
|
|
4
|
+
canceled: boolean = false;
|
|
5
|
+
// original item that this event is related to
|
|
6
|
+
data: Record<string, any>;
|
|
7
|
+
// internal nebula info about the object
|
|
8
|
+
metadata: Record<string, any>;
|
|
9
|
+
// the mouse [lng,lat] raycasted onto the ground
|
|
10
|
+
groundPoint: Position;
|
|
11
|
+
// browser event
|
|
12
|
+
nativeEvent: MouseEvent;
|
|
13
|
+
// reference to nebula
|
|
14
|
+
nebula: Record<string, any>;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
nativeEvent: MouseEvent,
|
|
18
|
+
{ data, groundPoint, nebula, metadata }: Record<string, any>
|
|
19
|
+
) {
|
|
20
|
+
this.nativeEvent = nativeEvent;
|
|
21
|
+
|
|
22
|
+
this.data = data;
|
|
23
|
+
this.groundPoint = groundPoint;
|
|
24
|
+
this.nebula = nebula;
|
|
25
|
+
this.metadata = metadata;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
stopPropagation() {
|
|
29
|
+
this.nativeEvent.stopPropagation();
|
|
30
|
+
this.canceled = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import NebulaLayer from '../nebula-layer';
|
|
2
|
+
import { toDeckColor } from '../../utils';
|
|
3
|
+
import DeckCache from '../deck-renderer/deck-cache';
|
|
4
|
+
import JunctionScatterplotLayer from '../../editable-layers/junction-scatterplot-layer';
|
|
5
|
+
|
|
6
|
+
export default class JunctionsLayer extends NebulaLayer {
|
|
7
|
+
deckCache: DeckCache<any, any>;
|
|
8
|
+
|
|
9
|
+
constructor(config: Record<string, any>) {
|
|
10
|
+
super(config);
|
|
11
|
+
this.deckCache = new DeckCache(config.getData, (data) => config.toNebulaFeature(data));
|
|
12
|
+
this.enablePicking = true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
render({ nebula }: Record<string, any>) {
|
|
16
|
+
const defaultColor: [number, number, number, number] = [0x0, 0x0, 0x0, 0xff];
|
|
17
|
+
const { objects, updateTrigger } = this.deckCache;
|
|
18
|
+
|
|
19
|
+
return new JunctionScatterplotLayer({
|
|
20
|
+
id: `junctions-${this.id}`,
|
|
21
|
+
data: objects,
|
|
22
|
+
opacity: 1,
|
|
23
|
+
pickable: true,
|
|
24
|
+
getPosition: (nf: any) => nf.geoJson.geometry.coordinates,
|
|
25
|
+
getFillColor: (nf: any) => toDeckColor(nf.style.fillColor) || defaultColor,
|
|
26
|
+
getStrokeColor: (nf: any) =>
|
|
27
|
+
toDeckColor(nf.style.outlineColor) || toDeckColor(nf.style.fillColor) || defaultColor,
|
|
28
|
+
getRadius: (nf: any) => nf.style.pointRadiusMeters + nf.style.outlineRadiusMeters || 1,
|
|
29
|
+
getInnerRadius: (nf: any) => nf.style.pointRadiusMeters || 0.5,
|
|
30
|
+
parameters: {
|
|
31
|
+
depthCompare: 'always'
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
updateTriggers: { all: updateTrigger },
|
|
35
|
+
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
nebulaLayer: this,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|