@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,121 @@
|
|
|
1
|
+
import { CompositeLayer, COORDINATE_SYSTEM } from '@deck.gl/core';
|
|
2
|
+
import { ScatterplotLayer } from '@deck.gl/layers';
|
|
3
|
+
import { SimpleMeshLayer } from '@deck.gl/mesh-layers';
|
|
4
|
+
import PathOutlineLayer from '../path-outline-layer/path-outline-layer';
|
|
5
|
+
import Arrow2DGeometry from './arrow-2d-geometry';
|
|
6
|
+
import createPathMarkers from './create-path-markers';
|
|
7
|
+
import { getClosestPointOnPolyline } from './polyline';
|
|
8
|
+
const DISTANCE_FOR_MULTI_ARROWS = 0.1;
|
|
9
|
+
const ARROW_HEAD_SIZE = 0.2;
|
|
10
|
+
const ARROW_TAIL_WIDTH = 0.05;
|
|
11
|
+
// const ARROW_CENTER_ADJUST = -0.8;
|
|
12
|
+
const DEFAULT_MARKER_LAYER = SimpleMeshLayer;
|
|
13
|
+
const DEFAULT_MARKER_LAYER_PROPS = {
|
|
14
|
+
mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH })
|
|
15
|
+
};
|
|
16
|
+
const defaultProps = Object.assign({}, PathOutlineLayer.defaultProps, {
|
|
17
|
+
MarkerLayer: DEFAULT_MARKER_LAYER,
|
|
18
|
+
markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,
|
|
19
|
+
sizeScale: 100,
|
|
20
|
+
fp64: false,
|
|
21
|
+
highlightIndex: -1,
|
|
22
|
+
highlightPoint: null,
|
|
23
|
+
getPath: (x) => x.path,
|
|
24
|
+
getColor: (x) => x.color,
|
|
25
|
+
getMarkerColor: (x) => [0, 0, 0, 255],
|
|
26
|
+
getDirection: (x) => x.direction,
|
|
27
|
+
getMarkerPercentages: (object, { lineLength }) => lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]
|
|
28
|
+
});
|
|
29
|
+
export default class PathMarkerLayer extends CompositeLayer {
|
|
30
|
+
static layerName = 'PathMarkerLayer';
|
|
31
|
+
static defaultProps = defaultProps;
|
|
32
|
+
state = undefined;
|
|
33
|
+
initializeState() {
|
|
34
|
+
this.state = {
|
|
35
|
+
markers: [],
|
|
36
|
+
mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH }),
|
|
37
|
+
closestPoint: null,
|
|
38
|
+
closestPoints: []
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {
|
|
42
|
+
if (coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
43
|
+
const [dx, dy] = viewport.metersToLngLatDelta(xyz);
|
|
44
|
+
const [x, y] = coordinateOrigin;
|
|
45
|
+
return viewport.projectFlat([x + dx, dy + y]);
|
|
46
|
+
}
|
|
47
|
+
else if (coordinateSystem === COORDINATE_SYSTEM.LNGLAT_OFFSETS) {
|
|
48
|
+
const [dx, dy] = xyz;
|
|
49
|
+
const [x, y] = coordinateOrigin;
|
|
50
|
+
return viewport.projectFlat([x + dx, dy + y]);
|
|
51
|
+
}
|
|
52
|
+
return viewport.projectFlat(xyz);
|
|
53
|
+
}
|
|
54
|
+
updateState({ props, oldProps, changeFlags }) {
|
|
55
|
+
if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {
|
|
56
|
+
const { data, getPath, getDirection, getMarkerColor, getMarkerPercentages, coordinateSystem, coordinateOrigin } = this.props;
|
|
57
|
+
const { viewport } = this.context;
|
|
58
|
+
const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);
|
|
59
|
+
this.state.markers = createPathMarkers({
|
|
60
|
+
data,
|
|
61
|
+
getPath,
|
|
62
|
+
getDirection,
|
|
63
|
+
getColor: getMarkerColor,
|
|
64
|
+
getMarkerPercentages,
|
|
65
|
+
projectFlat
|
|
66
|
+
});
|
|
67
|
+
this._recalculateClosestPoint();
|
|
68
|
+
}
|
|
69
|
+
if (changeFlags.propsChanged) {
|
|
70
|
+
if (props.point !== oldProps.point) {
|
|
71
|
+
this._recalculateClosestPoint();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
_recalculateClosestPoint() {
|
|
76
|
+
const { highlightPoint, highlightIndex } = this.props;
|
|
77
|
+
if (highlightPoint && highlightIndex >= 0) {
|
|
78
|
+
const object = this.props.data[highlightIndex];
|
|
79
|
+
const points = this.props.getPath(object, null);
|
|
80
|
+
const { point } = getClosestPointOnPolyline({ points, p: highlightPoint });
|
|
81
|
+
this.state.closestPoints = [{ position: point }];
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.state.closestPoints = [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
getPickingInfo({ info }) {
|
|
88
|
+
return Object.assign(info, {
|
|
89
|
+
// override object with picked feature
|
|
90
|
+
object: (info.object && info.object.path) || info.object
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
renderLayers() {
|
|
94
|
+
return [
|
|
95
|
+
new PathOutlineLayer(this.props, this.getSubLayerProps({
|
|
96
|
+
id: 'paths',
|
|
97
|
+
// Note: data has to be passed explicitly like this to avoid being empty
|
|
98
|
+
data: this.props.data
|
|
99
|
+
})),
|
|
100
|
+
new this.props.MarkerLayer(this.getSubLayerProps(Object.assign({}, this.props.markerLayerProps, {
|
|
101
|
+
id: 'markers',
|
|
102
|
+
data: this.state.markers,
|
|
103
|
+
getOrientation: (x) => [0, -x.angle, 0],
|
|
104
|
+
getColor: (x) => x.color,
|
|
105
|
+
sizeScale: this.props.sizeScale,
|
|
106
|
+
fp64: this.props.fp64,
|
|
107
|
+
pickable: false,
|
|
108
|
+
parameters: {
|
|
109
|
+
blend: false,
|
|
110
|
+
depthTest: false
|
|
111
|
+
}
|
|
112
|
+
}))),
|
|
113
|
+
this.state.closestPoints &&
|
|
114
|
+
new ScatterplotLayer({
|
|
115
|
+
id: `${this.props.id}-highlight`,
|
|
116
|
+
data: this.state.closestPoints,
|
|
117
|
+
fp64: this.props.fp64
|
|
118
|
+
})
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vector3 } from '@math.gl/core';
|
|
2
|
+
export declare function getClosestPointOnLine({ p, p1, p2, clampToLine }: {
|
|
3
|
+
p: any;
|
|
4
|
+
p1: any;
|
|
5
|
+
p2: any;
|
|
6
|
+
clampToLine?: boolean;
|
|
7
|
+
}): Vector3;
|
|
8
|
+
export declare function getClosestPointOnPolyline({ p, points }: {
|
|
9
|
+
p: any;
|
|
10
|
+
points: any;
|
|
11
|
+
}): {
|
|
12
|
+
point: Vector3;
|
|
13
|
+
index: number;
|
|
14
|
+
p1: any;
|
|
15
|
+
p2: any;
|
|
16
|
+
distanceSquared: number;
|
|
17
|
+
distance: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Vector3, clamp } from '@math.gl/core';
|
|
2
|
+
// Return the closest point on a line segment
|
|
3
|
+
export function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
|
|
4
|
+
const lineVector = new Vector3(p2).subtract(p1);
|
|
5
|
+
const pointVector = new Vector3(p).subtract(p1);
|
|
6
|
+
let dotProduct = lineVector.dot(pointVector);
|
|
7
|
+
if (clampToLine) {
|
|
8
|
+
dotProduct = clamp(dotProduct, 0, 1);
|
|
9
|
+
}
|
|
10
|
+
return lineVector.lerp(p1, p2, dotProduct);
|
|
11
|
+
}
|
|
12
|
+
// Return the closest point on a line segment
|
|
13
|
+
export function getClosestPointOnPolyline({ p, points }) {
|
|
14
|
+
p = new Vector3(p);
|
|
15
|
+
let pClosest = null;
|
|
16
|
+
let distanceSquared = Infinity;
|
|
17
|
+
let index = -1;
|
|
18
|
+
for (let i = 0; i < points.length - 1; ++i) {
|
|
19
|
+
const p1 = points[i];
|
|
20
|
+
const p2 = points[i + 1];
|
|
21
|
+
const pClosestOnLine = getClosestPointOnLine({ p, p1, p2 });
|
|
22
|
+
const distanceToLineSquared = p.distanceSquared(pClosestOnLine);
|
|
23
|
+
if (distanceToLineSquared < distanceSquared) {
|
|
24
|
+
distanceSquared = distanceToLineSquared;
|
|
25
|
+
pClosest = pClosestOnLine;
|
|
26
|
+
index = i;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
point: pClosest,
|
|
31
|
+
index,
|
|
32
|
+
p1: points[index],
|
|
33
|
+
p2: points[index + 1],
|
|
34
|
+
distanceSquared,
|
|
35
|
+
distance: Math.sqrt(distanceSquared),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PathLayer, PathLayerProps } from '@deck.gl/layers';
|
|
2
|
+
import type { DefaultProps, LayerContext } from '@deck.gl/core';
|
|
3
|
+
import { Framebuffer, Texture } from '@luma.gl/core';
|
|
4
|
+
export type PathOutlineLayerProps<DataT> = PathLayerProps<DataT> & {
|
|
5
|
+
dashJustified?: boolean;
|
|
6
|
+
getDashArray?: [number, number] | ((d: DataT) => [number, number] | null);
|
|
7
|
+
getZLevel?: (d: DataT, index: number) => number;
|
|
8
|
+
};
|
|
9
|
+
export default class PathOutlineLayer<DataT = any, ExtraPropsT = Record<string, unknown>> extends PathLayer<DataT, ExtraPropsT & Required<PathOutlineLayerProps<DataT>>> {
|
|
10
|
+
static layerName: string;
|
|
11
|
+
static defaultProps: DefaultProps<PathOutlineLayerProps<any>>;
|
|
12
|
+
state: {
|
|
13
|
+
model?: any;
|
|
14
|
+
pathTesselator: any;
|
|
15
|
+
outlineFramebuffer: Framebuffer;
|
|
16
|
+
dummyTexture: Texture;
|
|
17
|
+
};
|
|
18
|
+
getShaders(): any;
|
|
19
|
+
initializeState(context: LayerContext): void;
|
|
20
|
+
draw({ moduleParameters, parameters, uniforms, context }: {
|
|
21
|
+
moduleParameters?: {};
|
|
22
|
+
parameters: any;
|
|
23
|
+
uniforms: any;
|
|
24
|
+
context: any;
|
|
25
|
+
}): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { PathLayer } from '@deck.gl/layers';
|
|
2
|
+
import { GL } from '@luma.gl/constants';
|
|
3
|
+
import outline from '../../shaderlib/outline/outline';
|
|
4
|
+
import { UNIT } from '../../constants';
|
|
5
|
+
// TODO - this should be built into assembleShaders
|
|
6
|
+
function injectShaderCode({ source, code = '' }) {
|
|
7
|
+
const INJECT_CODE = /}[^{}]*$/;
|
|
8
|
+
return source.replace(INJECT_CODE, code.concat('\n}\n'));
|
|
9
|
+
}
|
|
10
|
+
const VS_CODE = `\
|
|
11
|
+
outline_setUV(gl_Position);
|
|
12
|
+
outline_setZLevel(instanceZLevel);
|
|
13
|
+
`;
|
|
14
|
+
const FS_CODE = `\
|
|
15
|
+
fragColor = outline_filterColor(fragColor);
|
|
16
|
+
`;
|
|
17
|
+
const defaultProps = {
|
|
18
|
+
getZLevel: () => 0,
|
|
19
|
+
};
|
|
20
|
+
export default class PathOutlineLayer extends PathLayer {
|
|
21
|
+
static layerName = 'PathOutlineLayer';
|
|
22
|
+
static defaultProps = defaultProps;
|
|
23
|
+
state = undefined;
|
|
24
|
+
// Override getShaders to inject the outline module
|
|
25
|
+
getShaders() {
|
|
26
|
+
const shaders = super.getShaders();
|
|
27
|
+
return Object.assign({}, shaders, {
|
|
28
|
+
modules: shaders.modules.concat([outline]),
|
|
29
|
+
vs: injectShaderCode({ source: shaders.vs, code: VS_CODE }),
|
|
30
|
+
fs: injectShaderCode({ source: shaders.fs, code: FS_CODE }),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// @ts-expect-error PathLayer is missing LayerContext arg
|
|
34
|
+
initializeState(context) {
|
|
35
|
+
super.initializeState();
|
|
36
|
+
// Create an outline "shadow" map
|
|
37
|
+
// TODO - we should create a single outlineMap for all layers
|
|
38
|
+
this.setState({
|
|
39
|
+
outlineFramebuffer: context.device.createFramebuffer({}),
|
|
40
|
+
dummyTexture: context.device.createTexture({}),
|
|
41
|
+
});
|
|
42
|
+
// Create an attribute manager
|
|
43
|
+
// @ts-expect-error check whether this.getAttributeManager works here
|
|
44
|
+
this.state.attributeManager.addInstanced({
|
|
45
|
+
instanceZLevel: {
|
|
46
|
+
size: 1,
|
|
47
|
+
type: GL.UNSIGNED_BYTE,
|
|
48
|
+
accessor: 'getZLevel',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Override draw to add render module
|
|
53
|
+
draw({ moduleParameters = {}, parameters, uniforms, context }) {
|
|
54
|
+
// Need to calculate same uniforms as base layer
|
|
55
|
+
const { jointRounded, capRounded, billboard, miterLimit, widthUnits, widthScale, widthMinPixels, widthMaxPixels, } = this.props;
|
|
56
|
+
uniforms = Object.assign({}, uniforms, {
|
|
57
|
+
jointType: Number(jointRounded),
|
|
58
|
+
capType: Number(capRounded),
|
|
59
|
+
billboard,
|
|
60
|
+
widthUnits: UNIT[widthUnits],
|
|
61
|
+
widthScale,
|
|
62
|
+
miterLimit,
|
|
63
|
+
widthMinPixels,
|
|
64
|
+
widthMaxPixels,
|
|
65
|
+
});
|
|
66
|
+
// Render the outline shadowmap (based on segment z orders)
|
|
67
|
+
const { outlineFramebuffer, dummyTexture } = this.state;
|
|
68
|
+
// TODO(v9): resize, see 'sf' example.
|
|
69
|
+
// outlineFramebuffer.resize();
|
|
70
|
+
// TODO(v9) clear FBO
|
|
71
|
+
// outlineFramebuffer.clear({ color: true, depth: true, stencil: true });
|
|
72
|
+
this.state.model.updateModuleSettings({
|
|
73
|
+
outlineEnabled: true,
|
|
74
|
+
outlineRenderShadowmap: true,
|
|
75
|
+
outlineShadowmap: dummyTexture,
|
|
76
|
+
});
|
|
77
|
+
this.state.model.draw({
|
|
78
|
+
uniforms: Object.assign({}, uniforms, {
|
|
79
|
+
jointType: 0,
|
|
80
|
+
widthScale: this.props.widthScale * 1.3,
|
|
81
|
+
}),
|
|
82
|
+
parameters: {
|
|
83
|
+
depthTest: false,
|
|
84
|
+
// Biggest value needs to go into buffer
|
|
85
|
+
blendEquation: GL.MAX,
|
|
86
|
+
},
|
|
87
|
+
framebuffer: outlineFramebuffer,
|
|
88
|
+
});
|
|
89
|
+
// Now use the outline shadowmap to render the lines (with outlines)
|
|
90
|
+
this.state.model.updateModuleSettings({
|
|
91
|
+
outlineEnabled: true,
|
|
92
|
+
outlineRenderShadowmap: false,
|
|
93
|
+
outlineShadowmap: outlineFramebuffer,
|
|
94
|
+
});
|
|
95
|
+
this.state.model.draw({
|
|
96
|
+
uniforms: Object.assign({}, uniforms, {
|
|
97
|
+
jointType: Number(jointRounded),
|
|
98
|
+
capType: Number(capRounded),
|
|
99
|
+
widthScale: this.props.widthScale,
|
|
100
|
+
}),
|
|
101
|
+
parameters: {
|
|
102
|
+
depthTest: false,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CompositeLayer, CompositeLayerProps, DefaultProps } from '@deck.gl/core';
|
|
2
|
+
import turfDifference from '@turf/difference';
|
|
3
|
+
export declare const SELECTION_TYPE: {
|
|
4
|
+
NONE: any;
|
|
5
|
+
RECTANGLE: string;
|
|
6
|
+
POLYGON: string;
|
|
7
|
+
};
|
|
8
|
+
interface SelectionLayerProps<DataT> extends CompositeLayerProps {
|
|
9
|
+
layerIds: any[];
|
|
10
|
+
onSelect: (info: any) => any;
|
|
11
|
+
selectionType: string | null;
|
|
12
|
+
}
|
|
13
|
+
export default class SelectionLayer<DataT, ExtraPropsT> extends CompositeLayer<ExtraPropsT & Required<SelectionLayerProps<DataT>>> {
|
|
14
|
+
static layerName: string;
|
|
15
|
+
static defaultProps: DefaultProps<SelectionLayerProps<any>>;
|
|
16
|
+
state: {
|
|
17
|
+
pendingPolygonSelection: {
|
|
18
|
+
bigPolygon: ReturnType<typeof turfDifference>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
_selectRectangleObjects(coordinates: any): void;
|
|
22
|
+
_selectPolygonObjects(coordinates: any): void;
|
|
23
|
+
renderLayers(): any[];
|
|
24
|
+
shouldUpdateState({ changeFlags: { stateChanged, propsOrDataChanged } }: Record<string, any>): any;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
import { CompositeLayer } from '@deck.gl/core';
|
|
3
|
+
import { PolygonLayer } from '@deck.gl/layers';
|
|
4
|
+
import { polygon } from '@turf/helpers';
|
|
5
|
+
import turfBuffer from '@turf/buffer';
|
|
6
|
+
import turfDifference from '@turf/difference';
|
|
7
|
+
import EditableGeoJsonLayer from './editable-geojson-layer';
|
|
8
|
+
import { DrawRectangleMode } from '../edit-modes/draw-rectangle-mode';
|
|
9
|
+
import { DrawPolygonMode } from '../edit-modes/draw-polygon-mode';
|
|
10
|
+
import { ViewMode } from '../edit-modes/view-mode';
|
|
11
|
+
export const SELECTION_TYPE = {
|
|
12
|
+
NONE: null,
|
|
13
|
+
RECTANGLE: 'rectangle',
|
|
14
|
+
POLYGON: 'polygon'
|
|
15
|
+
};
|
|
16
|
+
const MODE_MAP = {
|
|
17
|
+
[SELECTION_TYPE.RECTANGLE]: DrawRectangleMode,
|
|
18
|
+
[SELECTION_TYPE.POLYGON]: DrawPolygonMode
|
|
19
|
+
};
|
|
20
|
+
const MODE_CONFIG_MAP = {
|
|
21
|
+
[SELECTION_TYPE.RECTANGLE]: { dragToDraw: true }
|
|
22
|
+
};
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
selectionType: SELECTION_TYPE.RECTANGLE,
|
|
25
|
+
layerIds: [],
|
|
26
|
+
onSelect: () => { }
|
|
27
|
+
};
|
|
28
|
+
const EMPTY_DATA = {
|
|
29
|
+
type: 'FeatureCollection',
|
|
30
|
+
features: []
|
|
31
|
+
};
|
|
32
|
+
const EXPANSION_KM = 50;
|
|
33
|
+
const LAYER_ID_GEOJSON = 'selection-geojson';
|
|
34
|
+
const LAYER_ID_BLOCKER = 'selection-blocker';
|
|
35
|
+
const PASS_THROUGH_PROPS = [
|
|
36
|
+
'lineWidthScale',
|
|
37
|
+
'lineWidthMinPixels',
|
|
38
|
+
'lineWidthMaxPixels',
|
|
39
|
+
'lineWidthUnits',
|
|
40
|
+
'lineJointRounded',
|
|
41
|
+
'lineCapRounded',
|
|
42
|
+
'lineMiterLimit',
|
|
43
|
+
'pointRadiusScale',
|
|
44
|
+
'pointRadiusMinPixels',
|
|
45
|
+
'pointRadiusMaxPixels',
|
|
46
|
+
'lineDashJustified',
|
|
47
|
+
'getLineColor',
|
|
48
|
+
'getFillColor',
|
|
49
|
+
'getRadius',
|
|
50
|
+
'getLineWidth',
|
|
51
|
+
'getLineDashArray',
|
|
52
|
+
'getTentativeLineDashArray',
|
|
53
|
+
'getTentativeLineColor',
|
|
54
|
+
'getTentativeFillColor',
|
|
55
|
+
'getTentativeLineWidth'
|
|
56
|
+
];
|
|
57
|
+
export default class SelectionLayer extends CompositeLayer {
|
|
58
|
+
static layerName = 'SelectionLayer';
|
|
59
|
+
static defaultProps = defaultProps;
|
|
60
|
+
state = undefined;
|
|
61
|
+
_selectRectangleObjects(coordinates) {
|
|
62
|
+
const { layerIds, onSelect } = this.props;
|
|
63
|
+
const [x1, y1] = this.context.viewport.project(coordinates[0][0]);
|
|
64
|
+
const [x2, y2] = this.context.viewport.project(coordinates[0][2]);
|
|
65
|
+
const pickingInfos = this.context.deck.pickObjects({
|
|
66
|
+
x: Math.min(x1, x2),
|
|
67
|
+
y: Math.min(y1, y2),
|
|
68
|
+
width: Math.abs(x2 - x1),
|
|
69
|
+
height: Math.abs(y2 - y1),
|
|
70
|
+
layerIds
|
|
71
|
+
});
|
|
72
|
+
onSelect({ pickingInfos });
|
|
73
|
+
}
|
|
74
|
+
_selectPolygonObjects(coordinates) {
|
|
75
|
+
const { layerIds, onSelect } = this.props;
|
|
76
|
+
const mousePoints = coordinates[0].map((c) => this.context.viewport.project(c));
|
|
77
|
+
const allX = mousePoints.map((mousePoint) => mousePoint[0]);
|
|
78
|
+
const allY = mousePoints.map((mousePoint) => mousePoint[1]);
|
|
79
|
+
const x = Math.min(...allX);
|
|
80
|
+
const y = Math.min(...allY);
|
|
81
|
+
const maxX = Math.max(...allX);
|
|
82
|
+
const maxY = Math.max(...allY);
|
|
83
|
+
// Use a polygon to hide the outside, because pickObjects()
|
|
84
|
+
// does not support polygons
|
|
85
|
+
const landPointsPoly = polygon(coordinates);
|
|
86
|
+
const bigBuffer = turfBuffer(landPointsPoly, EXPANSION_KM);
|
|
87
|
+
let bigPolygon;
|
|
88
|
+
try {
|
|
89
|
+
// turfDifference throws an exception if the polygon
|
|
90
|
+
// intersects with itself (TODO: check if true in all versions)
|
|
91
|
+
bigPolygon = turfDifference(bigBuffer, landPointsPoly);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
// invalid selection polygon
|
|
95
|
+
console.log('turfDifference() error', e); // eslint-disable-line
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.setState({
|
|
99
|
+
pendingPolygonSelection: {
|
|
100
|
+
bigPolygon
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const blockerId = `${this.props.id}-${LAYER_ID_BLOCKER}`;
|
|
104
|
+
// HACK, find a better way
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
const pickingInfos = this.context.deck.pickObjects({
|
|
107
|
+
x,
|
|
108
|
+
y,
|
|
109
|
+
width: maxX - x,
|
|
110
|
+
height: maxY - y,
|
|
111
|
+
layerIds: [blockerId, ...layerIds]
|
|
112
|
+
});
|
|
113
|
+
onSelect({
|
|
114
|
+
pickingInfos: pickingInfos.filter((item) => item.layer.id !== this.props.id)
|
|
115
|
+
});
|
|
116
|
+
}, 250);
|
|
117
|
+
}
|
|
118
|
+
renderLayers() {
|
|
119
|
+
const { pendingPolygonSelection } = this.state;
|
|
120
|
+
const mode = MODE_MAP[this.props.selectionType] || ViewMode;
|
|
121
|
+
const modeConfig = MODE_CONFIG_MAP[this.props.selectionType];
|
|
122
|
+
const inheritedProps = {};
|
|
123
|
+
PASS_THROUGH_PROPS.forEach((p) => {
|
|
124
|
+
if (this.props[p] !== undefined)
|
|
125
|
+
inheritedProps[p] = this.props[p];
|
|
126
|
+
});
|
|
127
|
+
const layers = [
|
|
128
|
+
new EditableGeoJsonLayer(this.getSubLayerProps({
|
|
129
|
+
id: LAYER_ID_GEOJSON,
|
|
130
|
+
pickable: true,
|
|
131
|
+
mode,
|
|
132
|
+
modeConfig,
|
|
133
|
+
selectedFeatureIndexes: [],
|
|
134
|
+
data: EMPTY_DATA,
|
|
135
|
+
onEdit: ({ updatedData, editType }) => {
|
|
136
|
+
if (editType === 'addFeature') {
|
|
137
|
+
const { coordinates } = updatedData.features[0].geometry;
|
|
138
|
+
if (this.props.selectionType === SELECTION_TYPE.RECTANGLE) {
|
|
139
|
+
this._selectRectangleObjects(coordinates);
|
|
140
|
+
}
|
|
141
|
+
else if (this.props.selectionType === SELECTION_TYPE.POLYGON) {
|
|
142
|
+
this._selectPolygonObjects(coordinates);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
...inheritedProps
|
|
147
|
+
}))
|
|
148
|
+
];
|
|
149
|
+
if (pendingPolygonSelection) {
|
|
150
|
+
const { bigPolygon } = pendingPolygonSelection;
|
|
151
|
+
layers.push(new PolygonLayer(this.getSubLayerProps({
|
|
152
|
+
id: LAYER_ID_BLOCKER,
|
|
153
|
+
pickable: true,
|
|
154
|
+
stroked: false,
|
|
155
|
+
opacity: 1.0,
|
|
156
|
+
data: [bigPolygon],
|
|
157
|
+
getLineColor: (obj) => [0, 0, 0, 1],
|
|
158
|
+
getFillColor: (obj) => [0, 0, 0, 1],
|
|
159
|
+
getPolygon: (o) => o.geometry.coordinates
|
|
160
|
+
})));
|
|
161
|
+
}
|
|
162
|
+
return layers;
|
|
163
|
+
}
|
|
164
|
+
shouldUpdateState({ changeFlags: { stateChanged, propsOrDataChanged } }) {
|
|
165
|
+
return stateChanged || propsOrDataChanged;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export type Position = [number, number] | [number, number, number];
|
|
2
|
+
export type PointCoordinates = Position;
|
|
3
|
+
export type LineStringCoordinates = Position[];
|
|
4
|
+
export type PolygonCoordinates = Position[][];
|
|
5
|
+
export type MultiPointCoordinates = Position[];
|
|
6
|
+
export type MultiLineStringCoordinates = Position[][];
|
|
7
|
+
export type MultiPolygonCoordinates = Position[][][];
|
|
8
|
+
export type AnyCoordinates = PointCoordinates | LineStringCoordinates | PolygonCoordinates | MultiPointCoordinates | MultiLineStringCoordinates | MultiPolygonCoordinates;
|
|
9
|
+
export type Point = {
|
|
10
|
+
type: 'Point';
|
|
11
|
+
coordinates: PointCoordinates;
|
|
12
|
+
};
|
|
13
|
+
export type LineString = {
|
|
14
|
+
type: 'LineString';
|
|
15
|
+
coordinates: LineStringCoordinates;
|
|
16
|
+
};
|
|
17
|
+
export type Polygon = {
|
|
18
|
+
type: 'Polygon';
|
|
19
|
+
coordinates: PolygonCoordinates;
|
|
20
|
+
};
|
|
21
|
+
export type MultiPoint = {
|
|
22
|
+
type: 'MultiPoint';
|
|
23
|
+
coordinates: MultiPointCoordinates;
|
|
24
|
+
};
|
|
25
|
+
export type MultiLineString = {
|
|
26
|
+
type: 'MultiLineString';
|
|
27
|
+
coordinates: MultiLineStringCoordinates;
|
|
28
|
+
};
|
|
29
|
+
export type MultiPolygon = {
|
|
30
|
+
type: 'MultiPolygon';
|
|
31
|
+
coordinates: MultiPolygonCoordinates;
|
|
32
|
+
};
|
|
33
|
+
export type Geometry = Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon;
|
|
34
|
+
export type Polygonal = Polygon | MultiPolygon;
|
|
35
|
+
export type BoundingBoxArray = [number, number, number, number];
|
|
36
|
+
export type FeatureOf<T extends Geometry> = {
|
|
37
|
+
type: 'Feature';
|
|
38
|
+
geometry: T;
|
|
39
|
+
properties?: {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
};
|
|
42
|
+
id?: string | number;
|
|
43
|
+
bbox?: BoundingBoxArray;
|
|
44
|
+
};
|
|
45
|
+
export type FeatureWithProps<T extends Geometry, P> = {
|
|
46
|
+
type: 'Feature';
|
|
47
|
+
geometry: T;
|
|
48
|
+
properties: P;
|
|
49
|
+
};
|
|
50
|
+
export type Feature = FeatureOf<Point> | FeatureOf<LineString> | FeatureOf<Polygon> | FeatureOf<MultiPoint> | FeatureOf<MultiLineString> | FeatureOf<MultiPolygon>;
|
|
51
|
+
export type FeatureCollection = {
|
|
52
|
+
type: 'FeatureCollection';
|
|
53
|
+
features: Feature[];
|
|
54
|
+
properties?: {};
|
|
55
|
+
id?: string | number;
|
|
56
|
+
bbox?: BoundingBoxArray;
|
|
57
|
+
};
|
|
58
|
+
export type AnyGeoJson = Feature | FeatureCollection;
|