@deck.gl-community/editable-layers 9.2.0-beta.8 → 9.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edit-modes/draw-90degree-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-90degree-polygon-mode.js.map +1 -1
- 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-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-polygon-mode.js +48 -52
- package/dist/edit-modes/draw-polygon-mode.js.map +1 -1
- package/dist/edit-modes/draw-square-mode.d.ts.map +1 -1
- package/dist/edit-modes/draw-square-mode.js.map +1 -1
- 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/geojson-edit-mode.d.ts.map +1 -1
- package/dist/edit-modes/geojson-edit-mode.js.map +1 -1
- package/dist/edit-modes/modify-mode.d.ts.map +1 -1
- package/dist/edit-modes/modify-mode.js +23 -19
- package/dist/edit-modes/modify-mode.js.map +1 -1
- package/dist/edit-modes/resize-circle-mode.d.ts.map +1 -1
- package/dist/edit-modes/resize-circle-mode.js.map +1 -1
- package/dist/edit-modes/rotate-mode.d.ts.map +1 -1
- package/dist/edit-modes/rotate-mode.js.map +1 -1
- package/dist/edit-modes/scale-mode.d.ts.map +1 -1
- package/dist/edit-modes/scale-mode.js.map +1 -1
- 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.map +1 -1
- package/dist/edit-modes/split-polygon-mode.js.map +1 -1
- package/dist/edit-modes/three-click-polygon-mode.d.ts.map +1 -1
- package/dist/edit-modes/three-click-polygon-mode.js +14 -18
- package/dist/edit-modes/three-click-polygon-mode.js.map +1 -1
- package/dist/edit-modes/translate-mode.d.ts.map +1 -1
- package/dist/edit-modes/translate-mode.js +2 -2
- package/dist/edit-modes/translate-mode.js.map +1 -1
- 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/utils.js +1 -1
- package/dist/edit-modes/utils.js.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.d.ts.map +1 -1
- package/dist/editable-layers/editable-geojson-layer.js +20 -4
- package/dist/editable-layers/editable-geojson-layer.js.map +1 -1
- package/dist/index.cjs +246 -55
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mode-handlers/mode-handler.d.ts.map +1 -1
- package/dist/mode-handlers/mode-handler.js +1 -1
- package/dist/mode-handlers/mode-handler.js.map +1 -1
- package/dist/mode-handlers/rotate-handler.d.ts.map +1 -1
- package/dist/mode-handlers/rotate-handler.js.map +1 -1
- package/dist/mode-handlers/scale-handler.d.ts.map +1 -1
- package/dist/mode-handlers/scale-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.map +1 -1
- package/dist/utils/geojson-types.d.ts.map +1 -1
- 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.js +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.d.ts +1 -0
- package/dist/widgets/edit-mode-tray-widget.d.ts.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.js +1 -0
- package/dist/widgets/edit-mode-tray-widget.js.map +1 -1
- package/dist/widgets/editor-toolbar-widget.d.ts +40 -0
- package/dist/widgets/editor-toolbar-widget.d.ts.map +1 -0
- package/dist/widgets/editor-toolbar-widget.js +170 -0
- package/dist/widgets/editor-toolbar-widget.js.map +1 -0
- package/package.json +16 -12
- package/src/edit-modes/draw-90degree-polygon-mode.ts +7 -1
- package/src/edit-modes/draw-line-string-mode.ts +6 -1
- package/src/edit-modes/draw-polygon-mode.ts +96 -117
- package/src/edit-modes/draw-square-mode.ts +0 -1
- package/src/edit-modes/extend-line-string-mode.ts +9 -2
- package/src/edit-modes/geojson-edit-mode.ts +15 -3
- package/src/edit-modes/immutable-feature-collection.ts +1 -1
- package/src/edit-modes/modify-mode.ts +33 -21
- package/src/edit-modes/resize-circle-mode.ts +8 -3
- package/src/edit-modes/rotate-mode.ts +3 -8
- package/src/edit-modes/scale-mode.ts +5 -6
- package/src/edit-modes/snappable-mode.ts +6 -1
- package/src/edit-modes/split-polygon-mode.ts +9 -3
- package/src/edit-modes/three-click-polygon-mode.ts +28 -31
- package/src/edit-modes/translate-mode.ts +8 -3
- package/src/edit-modes/two-click-polygon-mode.ts +7 -1
- package/src/edit-modes/utils.ts +1 -1
- package/src/editable-layers/editable-geojson-layer.ts +20 -4
- package/src/index.ts +3 -0
- package/src/mode-handlers/mode-handler.ts +21 -6
- package/src/mode-handlers/rotate-handler.ts +1 -4
- package/src/mode-handlers/scale-handler.ts +3 -7
- package/src/mode-handlers/split-polygon-handler.ts +3 -1
- package/src/utils/geojson-types.ts +22 -6
- package/src/utils/translate-from-center.ts +11 -24
- package/src/utils/utils.ts +1 -1
- package/src/widgets/edit-mode-tray-widget.tsx +2 -6
- package/src/widgets/editor-toolbar-widget.tsx +348 -0
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,7 @@ __export(dist_exports, {
|
|
|
54
54
|
EditModeTrayWidget: () => EditModeTrayWidget,
|
|
55
55
|
EditableGeoJsonLayer: () => EditableGeoJsonLayer,
|
|
56
56
|
EditableH3ClusterLayer: () => EditableH3ClusterLayer,
|
|
57
|
+
EditorToolbarWidget: () => EditorToolbarWidget,
|
|
57
58
|
ElevatedEditHandleLayer: () => ElevatedEditHandleLayer,
|
|
58
59
|
ElevationMode: () => ElevationMode,
|
|
59
60
|
ExtendLineStringMode: () => ExtendLineStringMode,
|
|
@@ -97,7 +98,7 @@ var import_destination = __toESM(require("@turf/destination"), 1);
|
|
|
97
98
|
var import_bearing = __toESM(require("@turf/bearing"), 1);
|
|
98
99
|
var import_point_to_line_distance = __toESM(require("@turf/point-to-line-distance"), 1);
|
|
99
100
|
var import_helpers = require("@turf/helpers");
|
|
100
|
-
var
|
|
101
|
+
var import_web_mercator = require("@math.gl/web-mercator");
|
|
101
102
|
function toDeckColor(color, defaultColor = [255, 0, 0, 255]) {
|
|
102
103
|
if (!Array.isArray(color)) {
|
|
103
104
|
return defaultColor;
|
|
@@ -139,7 +140,7 @@ function mix(a, b, ratio) {
|
|
|
139
140
|
return b * ratio + a * (1 - ratio);
|
|
140
141
|
}
|
|
141
142
|
function nearestPointOnProjectedLine(line, inPoint, viewport) {
|
|
142
|
-
const wmViewport = new
|
|
143
|
+
const wmViewport = new import_web_mercator.WebMercatorViewport(viewport);
|
|
143
144
|
const coordinates = line.geometry.coordinates;
|
|
144
145
|
const projectedCoords = coordinates.map(([x3, y3, z = 0]) => wmViewport.project([x3, y3, z]));
|
|
145
146
|
const [x, y] = wmViewport.project(inPoint.geometry.coordinates);
|
|
@@ -209,7 +210,7 @@ var import_point_to_line_distance2 = __toESM(require("@turf/point-to-line-distan
|
|
|
209
210
|
var import_meta = require("@turf/meta");
|
|
210
211
|
var import_helpers2 = require("@turf/helpers");
|
|
211
212
|
var import_invariant = require("@turf/invariant");
|
|
212
|
-
var
|
|
213
|
+
var import_web_mercator2 = require("@math.gl/web-mercator");
|
|
213
214
|
function recursivelyTraverseNestedArrays2(array, prefix, fn) {
|
|
214
215
|
if (!Array.isArray(array[0])) {
|
|
215
216
|
return true;
|
|
@@ -245,7 +246,7 @@ function mix2(a, b, ratio) {
|
|
|
245
246
|
return b * ratio + a * (1 - ratio);
|
|
246
247
|
}
|
|
247
248
|
function nearestPointOnProjectedLine2(line, inPoint, viewport) {
|
|
248
|
-
const wmViewport = new
|
|
249
|
+
const wmViewport = new import_web_mercator2.WebMercatorViewport(viewport);
|
|
249
250
|
const coordinates = line.geometry.coordinates;
|
|
250
251
|
const projectedCoords = coordinates.map(([x3, y3, z = 0]) => wmViewport.project([x3, y3, z]));
|
|
251
252
|
const [x, y] = wmViewport.project(inPoint.geometry.coordinates);
|
|
@@ -294,7 +295,7 @@ function nearestPointOnLine(lines, inPoint, viewport) {
|
|
|
294
295
|
var _a, _b;
|
|
295
296
|
let mercator;
|
|
296
297
|
if (viewport) {
|
|
297
|
-
mercator = new
|
|
298
|
+
mercator = new import_web_mercator2.WebMercatorViewport(viewport);
|
|
298
299
|
}
|
|
299
300
|
let closestPoint = (0, import_helpers2.point)([Infinity, Infinity], {
|
|
300
301
|
dist: Infinity
|
|
@@ -974,7 +975,7 @@ var import_bearing3 = __toESM(require("@turf/bearing"), 1);
|
|
|
974
975
|
var import_distance = __toESM(require("@turf/distance"), 1);
|
|
975
976
|
var import_clone = __toESM(require("@turf/clone"), 1);
|
|
976
977
|
var import_helpers4 = require("@turf/helpers");
|
|
977
|
-
var
|
|
978
|
+
var import_web_mercator3 = require("@math.gl/web-mercator");
|
|
978
979
|
|
|
979
980
|
// dist/utils/translate-from-center.js
|
|
980
981
|
var import_center = __toESM(require("@turf/center"), 1);
|
|
@@ -1046,7 +1047,7 @@ var TranslateMode = class extends GeoJsonEditMode {
|
|
|
1046
1047
|
const selectedIndexes = props.selectedIndexes;
|
|
1047
1048
|
const { viewport: viewportDesc, screenSpace } = props.modeConfig || {};
|
|
1048
1049
|
if (viewportDesc && screenSpace) {
|
|
1049
|
-
const viewport = viewportDesc.project ? viewportDesc : new
|
|
1050
|
+
const viewport = viewportDesc.project ? viewportDesc : new import_web_mercator3.WebMercatorViewport(viewportDesc);
|
|
1050
1051
|
const from = viewport.project(startDragPoint);
|
|
1051
1052
|
const to = viewport.project(currentPoint);
|
|
1052
1053
|
const dx = to[0] - from[0];
|
|
@@ -1162,31 +1163,35 @@ var ModifyMode = class extends GeoJsonEditMode {
|
|
|
1162
1163
|
return nearestPointOnLine(line, inPoint, viewport);
|
|
1163
1164
|
}
|
|
1164
1165
|
handleClick(event, props) {
|
|
1165
|
-
var _a;
|
|
1166
|
+
var _a, _b;
|
|
1166
1167
|
const pickedExistingHandle = getPickedExistingEditHandle(event.picks);
|
|
1167
1168
|
const pickedIntermediateHandle = getPickedIntermediateEditHandle(event.picks);
|
|
1168
1169
|
if (pickedExistingHandle) {
|
|
1169
1170
|
const { featureIndex, positionIndexes } = pickedExistingHandle.properties;
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1171
|
+
const feature = props.data.features[featureIndex];
|
|
1172
|
+
const canRemovePosition = !(((_a = props.modeConfig) == null ? void 0 : _a.lockRectangles) && (feature == null ? void 0 : feature.properties.shape) === "Rectangle");
|
|
1173
|
+
if (canRemovePosition) {
|
|
1174
|
+
let updatedData;
|
|
1175
|
+
try {
|
|
1176
|
+
updatedData = new ImmutableFeatureCollection(props.data).removePosition(featureIndex, positionIndexes).getObject();
|
|
1177
|
+
} catch (ignored) {
|
|
1178
|
+
}
|
|
1179
|
+
if (updatedData) {
|
|
1180
|
+
props.onEdit({
|
|
1181
|
+
updatedData,
|
|
1182
|
+
editType: "removePosition",
|
|
1183
|
+
editContext: {
|
|
1184
|
+
featureIndexes: [featureIndex],
|
|
1185
|
+
positionIndexes,
|
|
1186
|
+
position: pickedExistingHandle.geometry.coordinates
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1185
1190
|
}
|
|
1186
1191
|
} else if (pickedIntermediateHandle) {
|
|
1187
1192
|
const { featureIndex, positionIndexes } = pickedIntermediateHandle.properties;
|
|
1188
1193
|
const feature = props.data.features[featureIndex];
|
|
1189
|
-
const canAddPosition = !(((
|
|
1194
|
+
const canAddPosition = !(((_b = props.modeConfig) == null ? void 0 : _b.lockRectangles) && (feature == null ? void 0 : feature.properties.shape) === "Rectangle");
|
|
1190
1195
|
if (canAddPosition) {
|
|
1191
1196
|
const updatedData = new ImmutableFeatureCollection(props.data).addPosition(featureIndex, positionIndexes, pickedIntermediateHandle.geometry.coordinates).getObject();
|
|
1192
1197
|
if (updatedData) {
|
|
@@ -2148,9 +2153,10 @@ var DrawLineStringMode = class extends GeoJsonEditMode {
|
|
|
2148
2153
|
};
|
|
2149
2154
|
|
|
2150
2155
|
// dist/edit-modes/draw-polygon-mode.js
|
|
2151
|
-
var import_line_intersect2 =
|
|
2156
|
+
var import_line_intersect2 = require("@turf/line-intersect");
|
|
2152
2157
|
var import_helpers9 = require("@turf/helpers");
|
|
2153
|
-
var import_boolean_within =
|
|
2158
|
+
var import_boolean_within = require("@turf/boolean-within");
|
|
2159
|
+
var import_kinks = require("@turf/kinks");
|
|
2154
2160
|
var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
2155
2161
|
holeSequence = [];
|
|
2156
2162
|
isDrawingHole = false;
|
|
@@ -2296,7 +2302,7 @@ var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
|
2296
2302
|
const canAddHole = canAddHoleToPolygon(props);
|
|
2297
2303
|
const canOverlap = canPolygonOverlap(props);
|
|
2298
2304
|
if (!canOverlap) {
|
|
2299
|
-
const overlapping = (0,
|
|
2305
|
+
const overlapping = (0, import_kinks.kinks)(newPolygon).features;
|
|
2300
2306
|
if (overlapping.length > 0) {
|
|
2301
2307
|
props.onEdit({
|
|
2302
2308
|
updatedData: props.data,
|
|
@@ -2338,7 +2344,7 @@ var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
|
2338
2344
|
const outer = (0, import_helpers9.polygon)(feature.geometry.coordinates);
|
|
2339
2345
|
for (let i = 1; i < feature.geometry.coordinates.length; i++) {
|
|
2340
2346
|
const hole = (0, import_helpers9.polygon)([feature.geometry.coordinates[i]]);
|
|
2341
|
-
const intersection = (0, import_line_intersect2.
|
|
2347
|
+
const intersection = (0, import_line_intersect2.lineIntersect)(hole, newPolygon);
|
|
2342
2348
|
if (intersection.features.length > 0) {
|
|
2343
2349
|
props.onEdit({
|
|
2344
2350
|
updatedData: props.data,
|
|
@@ -2347,7 +2353,7 @@ var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
|
2347
2353
|
});
|
|
2348
2354
|
return { handled: true };
|
|
2349
2355
|
}
|
|
2350
|
-
if ((0, import_boolean_within.
|
|
2356
|
+
if ((0, import_boolean_within.booleanWithin)(hole, newPolygon) || (0, import_boolean_within.booleanWithin)(newPolygon, hole)) {
|
|
2351
2357
|
props.onEdit({
|
|
2352
2358
|
updatedData: props.data,
|
|
2353
2359
|
editType: "invalidHole",
|
|
@@ -2356,7 +2362,7 @@ var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
|
2356
2362
|
return { handled: true };
|
|
2357
2363
|
}
|
|
2358
2364
|
}
|
|
2359
|
-
const intersectionWithOuter = (0, import_line_intersect2.
|
|
2365
|
+
const intersectionWithOuter = (0, import_line_intersect2.lineIntersect)(outer, newPolygon);
|
|
2360
2366
|
if (intersectionWithOuter.features.length > 0) {
|
|
2361
2367
|
props.onEdit({
|
|
2362
2368
|
updatedData: props.data,
|
|
@@ -2365,7 +2371,7 @@ var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
|
2365
2371
|
});
|
|
2366
2372
|
return { handled: true };
|
|
2367
2373
|
}
|
|
2368
|
-
if ((0, import_boolean_within.
|
|
2374
|
+
if ((0, import_boolean_within.booleanWithin)(outer, newPolygon)) {
|
|
2369
2375
|
props.onEdit({
|
|
2370
2376
|
updatedData: props.data,
|
|
2371
2377
|
editType: "invalidPolygon",
|
|
@@ -2373,7 +2379,7 @@ var DrawPolygonMode = class extends GeoJsonEditMode {
|
|
|
2373
2379
|
});
|
|
2374
2380
|
return { handled: true };
|
|
2375
2381
|
}
|
|
2376
|
-
if ((0, import_boolean_within.
|
|
2382
|
+
if ((0, import_boolean_within.booleanWithin)(newPolygon, outer)) {
|
|
2377
2383
|
const updatedData = new ImmutableFeatureCollection(props.data).replaceGeometry(featureIndex, {
|
|
2378
2384
|
...feature.geometry,
|
|
2379
2385
|
coordinates: [...feature.geometry.coordinates, polygon2]
|
|
@@ -2734,14 +2740,14 @@ var DrawEllipseByBoundingBoxMode = class extends TwoClickPolygonMode {
|
|
|
2734
2740
|
};
|
|
2735
2741
|
|
|
2736
2742
|
// dist/edit-modes/three-click-polygon-mode.js
|
|
2737
|
-
var import_lodash2 = __toESM(require("lodash.omit"), 1);
|
|
2738
2743
|
var ThreeClickPolygonMode = class extends GeoJsonEditMode {
|
|
2739
2744
|
handleClick(event, props) {
|
|
2740
2745
|
this.addClickSequence(event);
|
|
2746
|
+
const { modeConfig } = props;
|
|
2741
2747
|
const clickSequence = this.getClickSequence();
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
const editAction = this.getAddFeatureOrBooleanPolygonAction(
|
|
2748
|
+
if (clickSequence.length > 2) {
|
|
2749
|
+
const { geometry, properties } = this.getThreeClickPolygon(clickSequence[0], clickSequence[1], clickSequence[2], modeConfig);
|
|
2750
|
+
const editAction = this.getAddFeatureOrBooleanPolygonAction(geometry, props, properties);
|
|
2745
2751
|
this.resetClickSequence();
|
|
2746
2752
|
if (editAction) {
|
|
2747
2753
|
props.onEdit(editAction);
|
|
@@ -2755,11 +2761,11 @@ var ThreeClickPolygonMode = class extends GeoJsonEditMode {
|
|
|
2755
2761
|
type: "FeatureCollection",
|
|
2756
2762
|
features: []
|
|
2757
2763
|
};
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
if (
|
|
2764
|
+
const coords = [
|
|
2765
|
+
...clickSequence,
|
|
2766
|
+
...lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : []
|
|
2767
|
+
];
|
|
2768
|
+
if (coords.length === 2) {
|
|
2763
2769
|
guides.features.push({
|
|
2764
2770
|
type: "Feature",
|
|
2765
2771
|
properties: {
|
|
@@ -2767,19 +2773,18 @@ var ThreeClickPolygonMode = class extends GeoJsonEditMode {
|
|
|
2767
2773
|
},
|
|
2768
2774
|
geometry: {
|
|
2769
2775
|
type: "LineString",
|
|
2770
|
-
coordinates: [
|
|
2776
|
+
coordinates: [coords[0], coords[1]]
|
|
2771
2777
|
}
|
|
2772
2778
|
});
|
|
2773
|
-
} else {
|
|
2774
|
-
const polygon2 = this.getThreeClickPolygon(
|
|
2779
|
+
} else if (coords.length > 2) {
|
|
2780
|
+
const polygon2 = this.getThreeClickPolygon(coords[0], coords[1], coords[2], modeConfig);
|
|
2775
2781
|
if (polygon2) {
|
|
2776
2782
|
guides.features.push({
|
|
2777
|
-
|
|
2783
|
+
...polygon2,
|
|
2778
2784
|
properties: {
|
|
2779
2785
|
...polygon2.properties,
|
|
2780
2786
|
guideType: "tentative"
|
|
2781
|
-
}
|
|
2782
|
-
geometry: polygon2.geometry
|
|
2787
|
+
}
|
|
2783
2788
|
});
|
|
2784
2789
|
}
|
|
2785
2790
|
}
|
|
@@ -3012,7 +3017,7 @@ var Draw90DegreePolygonMode = class extends GeoJsonEditMode {
|
|
|
3012
3017
|
};
|
|
3013
3018
|
|
|
3014
3019
|
// dist/edit-modes/draw-polygon-by-dragging-mode.js
|
|
3015
|
-
var
|
|
3020
|
+
var import_lodash2 = __toESM(require("lodash.throttle"), 1);
|
|
3016
3021
|
var DrawPolygonByDraggingMode = class extends DrawPolygonMode {
|
|
3017
3022
|
handleDraggingThrottled = null;
|
|
3018
3023
|
handleClick(event, props) {
|
|
@@ -3020,7 +3025,7 @@ var DrawPolygonByDraggingMode = class extends DrawPolygonMode {
|
|
|
3020
3025
|
handleStartDragging(event, props) {
|
|
3021
3026
|
event.cancelPan();
|
|
3022
3027
|
if (props.modeConfig && props.modeConfig.throttleMs) {
|
|
3023
|
-
this.handleDraggingThrottled = (0,
|
|
3028
|
+
this.handleDraggingThrottled = (0, import_lodash2.default)(this.handleDraggingAux, props.modeConfig.throttleMs);
|
|
3024
3029
|
} else {
|
|
3025
3030
|
this.handleDraggingThrottled = this.handleDraggingAux;
|
|
3026
3031
|
}
|
|
@@ -3739,10 +3744,26 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
3739
3744
|
}
|
|
3740
3745
|
},
|
|
3741
3746
|
updateTriggers: {
|
|
3742
|
-
getLineColor: [
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3747
|
+
getLineColor: [
|
|
3748
|
+
this.props.updateTriggers.getLineColor,
|
|
3749
|
+
this.props.selectedFeatureIndexes,
|
|
3750
|
+
this.props.mode
|
|
3751
|
+
],
|
|
3752
|
+
getFillColor: [
|
|
3753
|
+
this.props.updateTriggers.getFillColor,
|
|
3754
|
+
this.props.selectedFeatureIndexes,
|
|
3755
|
+
this.props.mode
|
|
3756
|
+
],
|
|
3757
|
+
getPointRadius: [
|
|
3758
|
+
this.props.updateTriggers.getPointRadius,
|
|
3759
|
+
this.props.selectedFeatureIndexes,
|
|
3760
|
+
this.props.mode
|
|
3761
|
+
],
|
|
3762
|
+
getLineWidth: [
|
|
3763
|
+
this.props.updateTriggers.getLineWidth,
|
|
3764
|
+
this.props.selectedFeatureIndexes,
|
|
3765
|
+
this.props.mode
|
|
3766
|
+
]
|
|
3746
3767
|
}
|
|
3747
3768
|
});
|
|
3748
3769
|
let layers = [new import_layers2.GeoJsonLayer(subLayerProps)];
|
|
@@ -4500,6 +4521,7 @@ var _EditModeTrayWidget = class extends import_core4.Widget {
|
|
|
4500
4521
|
var EditModeTrayWidget = _EditModeTrayWidget;
|
|
4501
4522
|
__publicField(EditModeTrayWidget, "defaultProps", {
|
|
4502
4523
|
id: "edit-mode-tray",
|
|
4524
|
+
_container: null,
|
|
4503
4525
|
placement: "top-left",
|
|
4504
4526
|
layout: "vertical",
|
|
4505
4527
|
modes: [],
|
|
@@ -4507,10 +4529,179 @@ __publicField(EditModeTrayWidget, "defaultProps", {
|
|
|
4507
4529
|
className: ""
|
|
4508
4530
|
});
|
|
4509
4531
|
|
|
4510
|
-
// dist/
|
|
4532
|
+
// dist/widgets/editor-toolbar-widget.js
|
|
4533
|
+
var import_jsx_runtime2 = require("preact/jsx-runtime");
|
|
4534
|
+
var import_preact2 = require("preact");
|
|
4511
4535
|
var import_core5 = require("@deck.gl/core");
|
|
4536
|
+
var ROOT_STYLE2 = {
|
|
4537
|
+
position: "absolute",
|
|
4538
|
+
display: "flex",
|
|
4539
|
+
flexDirection: "column",
|
|
4540
|
+
gap: "6px",
|
|
4541
|
+
pointerEvents: "auto",
|
|
4542
|
+
userSelect: "none",
|
|
4543
|
+
zIndex: "99"
|
|
4544
|
+
};
|
|
4545
|
+
var TRAY_STYLE = {
|
|
4546
|
+
display: "flex",
|
|
4547
|
+
gap: "4px",
|
|
4548
|
+
background: "rgba(36, 40, 41, 0.88)",
|
|
4549
|
+
borderRadius: "999px",
|
|
4550
|
+
padding: "5px 8px",
|
|
4551
|
+
alignItems: "center",
|
|
4552
|
+
justifyContent: "center",
|
|
4553
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.25)"
|
|
4554
|
+
};
|
|
4555
|
+
var BUTTON_STYLE = {
|
|
4556
|
+
appearance: "none",
|
|
4557
|
+
background: "transparent",
|
|
4558
|
+
border: "none",
|
|
4559
|
+
color: "#f0f0f0",
|
|
4560
|
+
height: "30px",
|
|
4561
|
+
padding: "0 8px",
|
|
4562
|
+
display: "flex",
|
|
4563
|
+
alignItems: "center",
|
|
4564
|
+
justifyContent: "center",
|
|
4565
|
+
gap: "4px",
|
|
4566
|
+
borderRadius: "15px",
|
|
4567
|
+
cursor: "pointer",
|
|
4568
|
+
fontSize: "11px",
|
|
4569
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
4570
|
+
fontWeight: "500",
|
|
4571
|
+
transition: "background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease",
|
|
4572
|
+
whiteSpace: "nowrap"
|
|
4573
|
+
};
|
|
4574
|
+
var BUTTON_ACTIVE_STYLE2 = {
|
|
4575
|
+
background: "#0071e3",
|
|
4576
|
+
color: "#ffffff",
|
|
4577
|
+
boxShadow: "0 0 0 2px rgba(255, 255, 255, 0.35)"
|
|
4578
|
+
};
|
|
4579
|
+
var DIVIDER_STYLE = {
|
|
4580
|
+
width: "1px",
|
|
4581
|
+
height: "20px",
|
|
4582
|
+
background: "rgba(255, 255, 255, 0.2)",
|
|
4583
|
+
margin: "0 2px",
|
|
4584
|
+
flexShrink: "0"
|
|
4585
|
+
};
|
|
4586
|
+
var BADGE_STYLE = {
|
|
4587
|
+
color: "rgba(255, 255, 255, 0.6)",
|
|
4588
|
+
fontSize: "11px",
|
|
4589
|
+
padding: "0 6px",
|
|
4590
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
4591
|
+
whiteSpace: "nowrap"
|
|
4592
|
+
};
|
|
4593
|
+
function PencilIcon() {
|
|
4594
|
+
return (0, import_jsx_runtime2.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: (0, import_jsx_runtime2.jsx)("path", { d: "M10 1.5l2.5 2.5L4.5 12H2v-2.5z" }) });
|
|
4595
|
+
}
|
|
4596
|
+
function SubtractIcon() {
|
|
4597
|
+
return (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.1", children: [(0, import_jsx_runtime2.jsx)("rect", { x: "1", y: "1", width: "8", height: "8", rx: "1.5" }), (0, import_jsx_runtime2.jsx)("rect", { x: "5", y: "5", width: "8", height: "8", rx: "1.5", fill: "rgba(36,40,41,0.88)" })] });
|
|
4598
|
+
}
|
|
4599
|
+
function UnionIcon() {
|
|
4600
|
+
return (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.1", children: [(0, import_jsx_runtime2.jsx)("rect", { x: "1", y: "1", width: "8", height: "8", rx: "1.5" }), (0, import_jsx_runtime2.jsx)("rect", { x: "5", y: "5", width: "8", height: "8", rx: "1.5" })] });
|
|
4601
|
+
}
|
|
4602
|
+
function IntersectIcon() {
|
|
4603
|
+
return (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", strokeWidth: "1.1", children: [(0, import_jsx_runtime2.jsx)("rect", { x: "1", y: "1", width: "8", height: "8", rx: "1.5", stroke: "currentColor", opacity: "0.4" }), (0, import_jsx_runtime2.jsx)("rect", { x: "5", y: "5", width: "8", height: "8", rx: "1.5", stroke: "currentColor", opacity: "0.4" }), (0, import_jsx_runtime2.jsx)("rect", { x: "5", y: "5", width: "4", height: "4", fill: "currentColor", opacity: "0.6" })] });
|
|
4604
|
+
}
|
|
4605
|
+
function TrashIcon() {
|
|
4606
|
+
return (0, import_jsx_runtime2.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round", children: (0, import_jsx_runtime2.jsx)("path", { d: "M2.5 4h9M5.5 4V2.5h3V4M3.5 4l.5 8h6l.5-8" }) });
|
|
4607
|
+
}
|
|
4608
|
+
function DownloadIcon() {
|
|
4609
|
+
return (0, import_jsx_runtime2.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round", strokeLinejoin: "round", children: (0, import_jsx_runtime2.jsx)("path", { d: "M7 2v7M4.5 6.5L7 9l2.5-2.5M2.5 11.5h9" }) });
|
|
4610
|
+
}
|
|
4611
|
+
var BOOLEAN_OPS = [
|
|
4612
|
+
{ op: null, icon: PencilIcon, label: "Edit", title: "Draw new features" },
|
|
4613
|
+
{ op: "difference", icon: SubtractIcon, label: "Sub", title: "Subtract from selection" },
|
|
4614
|
+
{ op: "union", icon: UnionIcon, label: "Union", title: "Union with selection" },
|
|
4615
|
+
{ op: "intersection", icon: IntersectIcon, label: "Sect", title: "Intersect with selection" }
|
|
4616
|
+
];
|
|
4617
|
+
var _EditorToolbarWidget = class extends import_core5.Widget {
|
|
4618
|
+
placement = "bottom-left";
|
|
4619
|
+
className = "deck-widget-editor-toolbar";
|
|
4620
|
+
deck = null;
|
|
4621
|
+
appliedCustomClassName = null;
|
|
4622
|
+
constructor(props = {}) {
|
|
4623
|
+
super({ ..._EditorToolbarWidget.defaultProps, ...props });
|
|
4624
|
+
this.placement = props.placement ?? _EditorToolbarWidget.defaultProps.placement;
|
|
4625
|
+
}
|
|
4626
|
+
setProps(props) {
|
|
4627
|
+
if (props.placement !== void 0) {
|
|
4628
|
+
this.placement = props.placement;
|
|
4629
|
+
}
|
|
4630
|
+
super.setProps(props);
|
|
4631
|
+
this.renderToolbar();
|
|
4632
|
+
}
|
|
4633
|
+
onAdd({ deck }) {
|
|
4634
|
+
this.deck = deck;
|
|
4635
|
+
}
|
|
4636
|
+
onRemove() {
|
|
4637
|
+
this.deck = null;
|
|
4638
|
+
const root = this.rootElement;
|
|
4639
|
+
if (root) {
|
|
4640
|
+
(0, import_preact2.render)(null, root);
|
|
4641
|
+
}
|
|
4642
|
+
this.rootElement = null;
|
|
4643
|
+
}
|
|
4644
|
+
onRenderHTML(rootElement) {
|
|
4645
|
+
const style = { ...ROOT_STYLE2, ...this.props.style };
|
|
4646
|
+
Object.assign(rootElement.style, style);
|
|
4647
|
+
if (this.appliedCustomClassName && this.appliedCustomClassName !== this.props.className) {
|
|
4648
|
+
rootElement.classList.remove(this.appliedCustomClassName);
|
|
4649
|
+
this.appliedCustomClassName = null;
|
|
4650
|
+
}
|
|
4651
|
+
if (this.props.className) {
|
|
4652
|
+
rootElement.classList.add(this.props.className);
|
|
4653
|
+
this.appliedCustomClassName = this.props.className;
|
|
4654
|
+
}
|
|
4655
|
+
rootElement.classList.add(this.className);
|
|
4656
|
+
this.renderToolbar();
|
|
4657
|
+
}
|
|
4658
|
+
renderToolbar() {
|
|
4659
|
+
const root = this.rootElement;
|
|
4660
|
+
if (!root) {
|
|
4661
|
+
return;
|
|
4662
|
+
}
|
|
4663
|
+
const booleanOp = this.props.booleanOperation ?? null;
|
|
4664
|
+
const featureCount = this.props.featureCount ?? 0;
|
|
4665
|
+
const stopEvent = (event) => {
|
|
4666
|
+
event.stopPropagation();
|
|
4667
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
4668
|
+
event.stopImmediatePropagation();
|
|
4669
|
+
}
|
|
4670
|
+
};
|
|
4671
|
+
const ui = (0, import_jsx_runtime2.jsxs)("div", { style: TRAY_STYLE, onPointerDown: stopEvent, onPointerMove: stopEvent, onPointerUp: stopEvent, onMouseDown: stopEvent, onMouseMove: stopEvent, onMouseUp: stopEvent, onTouchStart: stopEvent, onTouchMove: stopEvent, onTouchEnd: stopEvent, children: [BOOLEAN_OPS.map(({ op, icon: Icon, label, title }) => {
|
|
4672
|
+
const active = booleanOp === op;
|
|
4673
|
+
return (0, import_jsx_runtime2.jsxs)("button", { type: "button", title, "aria-pressed": active, style: { ...BUTTON_STYLE, ...active ? BUTTON_ACTIVE_STYLE2 : {} }, onClick: (event) => {
|
|
4674
|
+
var _a, _b;
|
|
4675
|
+
stopEvent(event);
|
|
4676
|
+
(_b = (_a = this.props).onSetBooleanOperation) == null ? void 0 : _b.call(_a, op);
|
|
4677
|
+
}, children: [(0, import_jsx_runtime2.jsx)(Icon, {}), (0, import_jsx_runtime2.jsx)("span", { children: label })] }, label);
|
|
4678
|
+
}), (0, import_jsx_runtime2.jsx)("div", { style: DIVIDER_STYLE }), (0, import_jsx_runtime2.jsx)("button", { type: "button", title: "Clear all features", style: BUTTON_STYLE, onClick: (event) => {
|
|
4679
|
+
var _a, _b;
|
|
4680
|
+
stopEvent(event);
|
|
4681
|
+
(_b = (_a = this.props).onClear) == null ? void 0 : _b.call(_a);
|
|
4682
|
+
}, children: (0, import_jsx_runtime2.jsx)(TrashIcon, {}) }), (0, import_jsx_runtime2.jsx)("button", { type: "button", title: "Download as GeoJSON", style: BUTTON_STYLE, onClick: (event) => {
|
|
4683
|
+
var _a, _b;
|
|
4684
|
+
stopEvent(event);
|
|
4685
|
+
(_b = (_a = this.props).onExport) == null ? void 0 : _b.call(_a);
|
|
4686
|
+
}, children: (0, import_jsx_runtime2.jsx)(DownloadIcon, {}) }), (0, import_jsx_runtime2.jsx)("div", { style: DIVIDER_STYLE }), (0, import_jsx_runtime2.jsxs)("span", { style: BADGE_STYLE, children: [featureCount, " feature", featureCount !== 1 ? "s" : ""] })] });
|
|
4687
|
+
(0, import_preact2.render)(ui, root);
|
|
4688
|
+
}
|
|
4689
|
+
};
|
|
4690
|
+
var EditorToolbarWidget = _EditorToolbarWidget;
|
|
4691
|
+
__publicField(EditorToolbarWidget, "defaultProps", {
|
|
4692
|
+
id: "editor-toolbar",
|
|
4693
|
+
_container: null,
|
|
4694
|
+
placement: "bottom-left",
|
|
4695
|
+
booleanOperation: null,
|
|
4696
|
+
featureCount: 0,
|
|
4697
|
+
style: {},
|
|
4698
|
+
className: ""
|
|
4699
|
+
});
|
|
4700
|
+
|
|
4701
|
+
// dist/editable-layers/junction-scatterplot-layer.js
|
|
4702
|
+
var import_core6 = require("@deck.gl/core");
|
|
4512
4703
|
var import_layers5 = require("@deck.gl/layers");
|
|
4513
|
-
var JunctionScatterplotLayer = class extends
|
|
4704
|
+
var JunctionScatterplotLayer = class extends import_core6.CompositeLayer {
|
|
4514
4705
|
renderLayers() {
|
|
4515
4706
|
const { id, getFillColor, getStrokeColor, getInnerRadius, updateTriggers } = this.props;
|
|
4516
4707
|
return [
|