@octostar/map-component 0.2.11 → 0.2.12
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/index.cjs +358 -194
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +358 -194
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/lib/deep-clone.d.ts +22 -0
- package/dist/types/lib/deep-clone.d.ts.map +1 -0
- package/dist/types/lib/geometry-equals.d.ts +15 -0
- package/dist/types/lib/geometry-equals.d.ts.map +1 -0
- package/dist/types/lib/raf-coalescer.d.ts +29 -0
- package/dist/types/lib/raf-coalescer.d.ts.map +1 -0
- package/dist/types/lib/selection-diff.d.ts +68 -0
- package/dist/types/lib/selection-diff.d.ts.map +1 -0
- package/dist/types/lib/selection-hit-test.d.ts +44 -0
- package/dist/types/lib/selection-hit-test.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5407,6 +5407,224 @@ function countFeaturesInBounds(featureGroups, bounds, options) {
|
|
|
5407
5407
|
}
|
|
5408
5408
|
return count;
|
|
5409
5409
|
}
|
|
5410
|
+
const rafScheduler = {
|
|
5411
|
+
request: (cb) => requestAnimationFrame(() => cb()),
|
|
5412
|
+
cancel: (handle) => cancelAnimationFrame(handle)
|
|
5413
|
+
};
|
|
5414
|
+
function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
5415
|
+
let reasons = /* @__PURE__ */ new Set();
|
|
5416
|
+
let handle = null;
|
|
5417
|
+
let running = false;
|
|
5418
|
+
const fire = () => {
|
|
5419
|
+
handle = null;
|
|
5420
|
+
const snapshot = reasons;
|
|
5421
|
+
reasons = /* @__PURE__ */ new Set();
|
|
5422
|
+
running = true;
|
|
5423
|
+
try {
|
|
5424
|
+
run(snapshot);
|
|
5425
|
+
} finally {
|
|
5426
|
+
running = false;
|
|
5427
|
+
}
|
|
5428
|
+
};
|
|
5429
|
+
return {
|
|
5430
|
+
schedule(reason) {
|
|
5431
|
+
reasons.add(reason);
|
|
5432
|
+
if (handle === null) {
|
|
5433
|
+
handle = scheduler.request(fire);
|
|
5434
|
+
}
|
|
5435
|
+
},
|
|
5436
|
+
isPending() {
|
|
5437
|
+
return handle !== null;
|
|
5438
|
+
},
|
|
5439
|
+
flush() {
|
|
5440
|
+
if (running || handle === null) return;
|
|
5441
|
+
scheduler.cancel(handle);
|
|
5442
|
+
fire();
|
|
5443
|
+
},
|
|
5444
|
+
cancel() {
|
|
5445
|
+
if (handle !== null) {
|
|
5446
|
+
scheduler.cancel(handle);
|
|
5447
|
+
handle = null;
|
|
5448
|
+
}
|
|
5449
|
+
reasons.clear();
|
|
5450
|
+
}
|
|
5451
|
+
};
|
|
5452
|
+
}
|
|
5453
|
+
const DEFAULT_LABEL_PRIORITY = 100;
|
|
5454
|
+
function createSelectionPaintCache() {
|
|
5455
|
+
return {
|
|
5456
|
+
presentIds: /* @__PURE__ */ new Set(),
|
|
5457
|
+
appliedSelectedIds: /* @__PURE__ */ new Set(),
|
|
5458
|
+
basePriorityById: /* @__PURE__ */ new Map(),
|
|
5459
|
+
updatable: true
|
|
5460
|
+
};
|
|
5461
|
+
}
|
|
5462
|
+
function recordPaintedFeature(cache, featureId, basePriority, isSelected) {
|
|
5463
|
+
if (cache.presentIds.has(featureId)) {
|
|
5464
|
+
cache.updatable = false;
|
|
5465
|
+
} else {
|
|
5466
|
+
cache.presentIds.add(featureId);
|
|
5467
|
+
}
|
|
5468
|
+
cache.basePriorityById.set(featureId, basePriority);
|
|
5469
|
+
if (isSelected) cache.appliedSelectedIds.add(featureId);
|
|
5470
|
+
}
|
|
5471
|
+
function applySelectionFastPath(cache, nextSelectedIds, source) {
|
|
5472
|
+
if (!cache || !cache.updatable || !source) return false;
|
|
5473
|
+
const diff = buildSelectionDiff(cache, nextSelectedIds);
|
|
5474
|
+
if (diff) {
|
|
5475
|
+
try {
|
|
5476
|
+
source.updateData(diff);
|
|
5477
|
+
} catch {
|
|
5478
|
+
return false;
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
const applied = /* @__PURE__ */ new Set();
|
|
5482
|
+
nextSelectedIds.forEach((id) => {
|
|
5483
|
+
if (cache.presentIds.has(id)) applied.add(id);
|
|
5484
|
+
});
|
|
5485
|
+
cache.appliedSelectedIds = applied;
|
|
5486
|
+
return true;
|
|
5487
|
+
}
|
|
5488
|
+
function needsDrawSelectionUpdate(input) {
|
|
5489
|
+
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
5490
|
+
}
|
|
5491
|
+
function buildSelectionDiff(cache, nextSelectedIds) {
|
|
5492
|
+
const update = [];
|
|
5493
|
+
cache.appliedSelectedIds.forEach((id) => {
|
|
5494
|
+
if (!nextSelectedIds.has(id) && cache.presentIds.has(id)) {
|
|
5495
|
+
update.push({
|
|
5496
|
+
id,
|
|
5497
|
+
addOrUpdateProperties: [
|
|
5498
|
+
{ key: "isSelected", value: 0 },
|
|
5499
|
+
{ key: "_labelPriority", value: cache.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
|
|
5500
|
+
]
|
|
5501
|
+
});
|
|
5502
|
+
}
|
|
5503
|
+
});
|
|
5504
|
+
nextSelectedIds.forEach((id) => {
|
|
5505
|
+
if (!cache.appliedSelectedIds.has(id) && cache.presentIds.has(id)) {
|
|
5506
|
+
update.push({
|
|
5507
|
+
id,
|
|
5508
|
+
addOrUpdateProperties: [
|
|
5509
|
+
{ key: "isSelected", value: 1 },
|
|
5510
|
+
{ key: "_labelPriority", value: 0 }
|
|
5511
|
+
]
|
|
5512
|
+
});
|
|
5513
|
+
}
|
|
5514
|
+
});
|
|
5515
|
+
return update.length > 0 ? { update } : null;
|
|
5516
|
+
}
|
|
5517
|
+
function deepClone(value) {
|
|
5518
|
+
try {
|
|
5519
|
+
return structuredClone(value);
|
|
5520
|
+
} catch {
|
|
5521
|
+
return JSON.parse(JSON.stringify(value));
|
|
5522
|
+
}
|
|
5523
|
+
}
|
|
5524
|
+
function cloneFeatures(features) {
|
|
5525
|
+
try {
|
|
5526
|
+
return structuredClone(features);
|
|
5527
|
+
} catch {
|
|
5528
|
+
return features.map((f) => deepClone(f));
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
function numberEquals(a, b) {
|
|
5532
|
+
return a === b || !Number.isFinite(a) && !Number.isFinite(b);
|
|
5533
|
+
}
|
|
5534
|
+
function coordinatesEqual(a, b) {
|
|
5535
|
+
if (typeof a === "number" || typeof b === "number") {
|
|
5536
|
+
return typeof a === "number" && typeof b === "number" && numberEquals(a, b);
|
|
5537
|
+
}
|
|
5538
|
+
if (a.length !== b.length) return false;
|
|
5539
|
+
for (let i = 0; i < a.length; i++) {
|
|
5540
|
+
if (!coordinatesEqual(a[i], b[i])) return false;
|
|
5541
|
+
}
|
|
5542
|
+
return true;
|
|
5543
|
+
}
|
|
5544
|
+
function bboxEqual(a, b) {
|
|
5545
|
+
if (a === void 0 || b === void 0) return a === b;
|
|
5546
|
+
if (a.length !== b.length) return false;
|
|
5547
|
+
for (let i = 0; i < a.length; i++) {
|
|
5548
|
+
if (!numberEquals(a[i], b[i])) return false;
|
|
5549
|
+
}
|
|
5550
|
+
return true;
|
|
5551
|
+
}
|
|
5552
|
+
function geometryEquals(a, b) {
|
|
5553
|
+
if (a == null || b == null) return a === b;
|
|
5554
|
+
if (a.type !== b.type) return false;
|
|
5555
|
+
if (!bboxEqual(a.bbox, b.bbox)) return false;
|
|
5556
|
+
if (a.type === "GeometryCollection") {
|
|
5557
|
+
const bGeometries = b.geometries;
|
|
5558
|
+
if (a.geometries.length !== bGeometries.length) return false;
|
|
5559
|
+
for (let i = 0; i < a.geometries.length; i++) {
|
|
5560
|
+
if (!geometryEquals(a.geometries[i], bGeometries[i])) return false;
|
|
5561
|
+
}
|
|
5562
|
+
return true;
|
|
5563
|
+
}
|
|
5564
|
+
return coordinatesEqual(
|
|
5565
|
+
a.coordinates,
|
|
5566
|
+
b.coordinates
|
|
5567
|
+
);
|
|
5568
|
+
}
|
|
5569
|
+
function collectVisibleFeatureGroups(drawFeatures, readOnlyByLayer, layers) {
|
|
5570
|
+
const groups = [];
|
|
5571
|
+
if (drawFeatures) groups.push(drawFeatures);
|
|
5572
|
+
const layerById = new Map(layers.map((l) => [l.id, l]));
|
|
5573
|
+
readOnlyByLayer.forEach((features, layerId) => {
|
|
5574
|
+
var _a;
|
|
5575
|
+
if ((_a = layerById.get(layerId)) == null ? void 0 : _a.visible) groups.push(features);
|
|
5576
|
+
});
|
|
5577
|
+
return groups;
|
|
5578
|
+
}
|
|
5579
|
+
function extendBounds(bounds, coords) {
|
|
5580
|
+
if (!Array.isArray(coords) || coords.length === 0) return;
|
|
5581
|
+
if (typeof coords[0] === "number") {
|
|
5582
|
+
const lng = coords[0];
|
|
5583
|
+
const lat = coords[1];
|
|
5584
|
+
if (lng < bounds.minLng) bounds.minLng = lng;
|
|
5585
|
+
if (lng > bounds.maxLng) bounds.maxLng = lng;
|
|
5586
|
+
if (lat < bounds.minLat) bounds.minLat = lat;
|
|
5587
|
+
if (lat > bounds.maxLat) bounds.maxLat = lat;
|
|
5588
|
+
return;
|
|
5589
|
+
}
|
|
5590
|
+
for (const nested of coords) extendBounds(bounds, nested);
|
|
5591
|
+
}
|
|
5592
|
+
function computeBounds(coords) {
|
|
5593
|
+
const bounds = { minLng: Infinity, minLat: Infinity, maxLng: -Infinity, maxLat: -Infinity };
|
|
5594
|
+
extendBounds(bounds, coords);
|
|
5595
|
+
return bounds;
|
|
5596
|
+
}
|
|
5597
|
+
function boundsDisjoint(a, b) {
|
|
5598
|
+
return a.maxLng < b.minLng || a.minLng > b.maxLng || a.maxLat < b.minLat || a.minLat > b.maxLat;
|
|
5599
|
+
}
|
|
5600
|
+
function pointInBounds(lng, lat, b) {
|
|
5601
|
+
return lng >= b.minLng && lng <= b.maxLng && lat >= b.minLat && lat <= b.maxLat;
|
|
5602
|
+
}
|
|
5603
|
+
function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
5604
|
+
const selectionBounds = computeBounds(selectionPolygon.geometry.coordinates);
|
|
5605
|
+
const rectExactForPoints = (options == null ? void 0 : options.axisAlignedRectangle) === true;
|
|
5606
|
+
const selectedIds = [];
|
|
5607
|
+
for (const features of featureGroups) {
|
|
5608
|
+
for (const feature of features) {
|
|
5609
|
+
try {
|
|
5610
|
+
const geom = feature.geometry;
|
|
5611
|
+
let isInside = false;
|
|
5612
|
+
if ((geom == null ? void 0 : geom.type) === "Point") {
|
|
5613
|
+
const lng = geom.coordinates[0];
|
|
5614
|
+
const lat = geom.coordinates[1];
|
|
5615
|
+
isInside = typeof lng === "number" && typeof lat === "number" && pointInBounds(lng, lat, selectionBounds) && (rectExactForPoints || turf__namespace.booleanPointInPolygon(geom.coordinates, selectionPolygon));
|
|
5616
|
+
} else if ((geom == null ? void 0 : geom.type) === "LineString" || (geom == null ? void 0 : geom.type) === "Polygon" || (geom == null ? void 0 : geom.type) === "MultiPoint" || (geom == null ? void 0 : geom.type) === "MultiLineString" || (geom == null ? void 0 : geom.type) === "MultiPolygon") {
|
|
5617
|
+
isInside = !boundsDisjoint(computeBounds(geom.coordinates), selectionBounds) && turf__namespace.booleanIntersects(feature, selectionPolygon);
|
|
5618
|
+
}
|
|
5619
|
+
if (isInside && feature.id) {
|
|
5620
|
+
selectedIds.push(String(feature.id));
|
|
5621
|
+
}
|
|
5622
|
+
} catch {
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
return selectedIds;
|
|
5627
|
+
}
|
|
5410
5628
|
const OTHER_BUCKET_KEY = "__other__";
|
|
5411
5629
|
const OTHER_BUCKET_LABEL = "Other";
|
|
5412
5630
|
const OTHER_BUCKET_COLOR = "#9ca3af";
|
|
@@ -6390,14 +6608,22 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6390
6608
|
return false;
|
|
6391
6609
|
}
|
|
6392
6610
|
});
|
|
6393
|
-
|
|
6611
|
+
const needsDrawCall = needsDrawSelectionUpdate({
|
|
6612
|
+
editableSelectionCount: visibleEditableIds.length,
|
|
6613
|
+
drawSelectedCount: draw.current.getSelectedIds().length,
|
|
6614
|
+
currentMode: draw.current.getMode(),
|
|
6615
|
+
targetMode: mode
|
|
6616
|
+
});
|
|
6617
|
+
if (needsDrawCall) {
|
|
6618
|
+
draw.current.changeMode(mode, { featureIds: visibleEditableIds });
|
|
6619
|
+
}
|
|
6394
6620
|
setSelectedFeatureIds(nextIds);
|
|
6395
6621
|
selectedFeatureIdsRef.current = nextIds;
|
|
6396
6622
|
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
|
|
6397
6623
|
if (onFeatureSelect) {
|
|
6398
6624
|
onFeatureSelect(nextIds.map((id) => getFeatureById(id)).filter(Boolean));
|
|
6399
6625
|
}
|
|
6400
|
-
|
|
6626
|
+
scheduleSync("selection");
|
|
6401
6627
|
if (readOnlyIds.length > 0) {
|
|
6402
6628
|
queueMicrotask(() => {
|
|
6403
6629
|
isSelectingReadOnlyRef.current = false;
|
|
@@ -6420,9 +6646,26 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6420
6646
|
setFeatureCount(drawFeatureCount + hiddenCount + readOnlyCount);
|
|
6421
6647
|
}, []);
|
|
6422
6648
|
const timelineVisibleIdsRef = react.useRef(null);
|
|
6423
|
-
const timelineSyncRafRef = react.useRef(null);
|
|
6424
6649
|
const syncRef = react.useRef(() => {
|
|
6425
6650
|
});
|
|
6651
|
+
const trySelectionFastPathRef = react.useRef(null);
|
|
6652
|
+
const syncCoalescerRef = react.useRef(null);
|
|
6653
|
+
if (syncCoalescerRef.current === null) {
|
|
6654
|
+
syncCoalescerRef.current = createRafCoalescer((reasons) => {
|
|
6655
|
+
var _a;
|
|
6656
|
+
if (reasons.size === 1 && reasons.has("selection") && ((_a = trySelectionFastPathRef.current) == null ? void 0 : _a.call(trySelectionFastPathRef))) {
|
|
6657
|
+
return;
|
|
6658
|
+
}
|
|
6659
|
+
syncRef.current();
|
|
6660
|
+
});
|
|
6661
|
+
}
|
|
6662
|
+
const scheduleSync = react.useCallback((reason = "full") => {
|
|
6663
|
+
var _a;
|
|
6664
|
+
(_a = syncCoalescerRef.current) == null ? void 0 : _a.schedule(reason);
|
|
6665
|
+
}, []);
|
|
6666
|
+
react.useEffect(() => {
|
|
6667
|
+
scheduleSync();
|
|
6668
|
+
}, [layers, scheduleSync]);
|
|
6426
6669
|
const hashStringToColor$1 = react.useCallback((str) => hashStringToColor(str), []);
|
|
6427
6670
|
const selectedFeatureColors = react.useMemo(() => {
|
|
6428
6671
|
if (selectedFeatureIds.length === 0) return /* @__PURE__ */ new Map();
|
|
@@ -6508,6 +6751,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6508
6751
|
);
|
|
6509
6752
|
}, []);
|
|
6510
6753
|
const isSyncingRef = react.useRef(false);
|
|
6754
|
+
const selectionPaintCacheRef = react.useRef(null);
|
|
6511
6755
|
const syncFeaturesToCustomLayers = react.useCallback(() => {
|
|
6512
6756
|
if (!map.current) return;
|
|
6513
6757
|
if (isSyncingRef.current) return;
|
|
@@ -6518,7 +6762,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6518
6762
|
const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
|
|
6519
6763
|
const drawSelectedIds = draw.current ? draw.current.getSelectedIds() : [];
|
|
6520
6764
|
const componentSelectedIds = selectedFeatureIdsRef.current;
|
|
6521
|
-
const
|
|
6765
|
+
const selectedIdSet = /* @__PURE__ */ new Set();
|
|
6766
|
+
drawSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
6767
|
+
componentSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
6522
6768
|
const visibleSet = timelineVisibleIdsRef.current;
|
|
6523
6769
|
const currentLayers = layersRef.current;
|
|
6524
6770
|
const isLayerVisible = (layer) => {
|
|
@@ -6623,6 +6869,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6623
6869
|
}
|
|
6624
6870
|
});
|
|
6625
6871
|
});
|
|
6872
|
+
const paintCache = createSelectionPaintCache();
|
|
6626
6873
|
const sourceData = {
|
|
6627
6874
|
type: "FeatureCollection",
|
|
6628
6875
|
features: allFeatures.map((f) => {
|
|
@@ -6700,7 +6947,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6700
6947
|
const isPoint = f.geometry.type === "Point";
|
|
6701
6948
|
const hideByHeatmap = isPoint && ((_i = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _i.enabled) === true;
|
|
6702
6949
|
const hideByCluster = isPoint && ((_j = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _j.enabled) === true && !((_k = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _k.showPointDots);
|
|
6703
|
-
const isSelected = selectedIds.includes(featureId);
|
|
6704
6950
|
const hideByTrace = false;
|
|
6705
6951
|
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
6706
6952
|
const hideFlatFor3DOnly = isLine && (layer == null ? void 0 : layer.hasAltitudeData) && (layer == null ? void 0 : layer.altitudeDisplayMode) === "3d";
|
|
@@ -6718,14 +6964,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6718
6964
|
}
|
|
6719
6965
|
});
|
|
6720
6966
|
}
|
|
6721
|
-
const isFeatureSelected = (enableSelectionRef.current || enableDrawingRef.current) &&
|
|
6722
|
-
let
|
|
6723
|
-
if (
|
|
6724
|
-
|
|
6725
|
-
} else if (traceLabel) {
|
|
6726
|
-
labelPriority = 5;
|
|
6967
|
+
const isFeatureSelected = (enableSelectionRef.current || enableDrawingRef.current) && selectedIdSet.has(featureId) ? 1 : 0;
|
|
6968
|
+
let basePriority = DEFAULT_LABEL_PRIORITY;
|
|
6969
|
+
if (traceLabel) {
|
|
6970
|
+
basePriority = 5;
|
|
6727
6971
|
} else if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
6728
|
-
|
|
6972
|
+
basePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
6729
6973
|
} else {
|
|
6730
6974
|
const idStr = String(featureId);
|
|
6731
6975
|
let h = 0;
|
|
@@ -6733,8 +6977,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6733
6977
|
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
6734
6978
|
h |= 0;
|
|
6735
6979
|
}
|
|
6736
|
-
|
|
6980
|
+
basePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
6737
6981
|
}
|
|
6982
|
+
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
6983
|
+
recordPaintedFeature(paintCache, featureId, basePriority, isFeatureSelected === 1);
|
|
6738
6984
|
return {
|
|
6739
6985
|
type: "Feature",
|
|
6740
6986
|
id: featureId,
|
|
@@ -6767,6 +7013,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
6767
7013
|
})
|
|
6768
7014
|
};
|
|
6769
7015
|
source.setData(sourceData);
|
|
7016
|
+
selectionPaintCacheRef.current = paintCache;
|
|
6770
7017
|
const traceSource = map.current.getSource("trace-features");
|
|
6771
7018
|
if (traceSource) {
|
|
6772
7019
|
const traceSegments = [];
|
|
@@ -7285,13 +7532,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
7285
7532
|
layerTemporalCacheRef.current.clear();
|
|
7286
7533
|
updateFeatureCount();
|
|
7287
7534
|
scheduleTimelineUpdate();
|
|
7288
|
-
|
|
7535
|
+
scheduleSync();
|
|
7289
7536
|
setFeatureUpdateCounter((c) => c + 1);
|
|
7290
7537
|
queueMicrotask(() => {
|
|
7291
7538
|
isSelectingReadOnlyRef.current = false;
|
|
7292
7539
|
});
|
|
7293
7540
|
},
|
|
7294
|
-
[cleanupOrphanLayerSources, updateFeatureCount, scheduleTimelineUpdate,
|
|
7541
|
+
[cleanupOrphanLayerSources, updateFeatureCount, scheduleTimelineUpdate, scheduleSync]
|
|
7295
7542
|
);
|
|
7296
7543
|
const buildDiffCommand = react.useCallback(
|
|
7297
7544
|
(label, coalesceKey, before, after, beforeLayers, afterLayers, beforeSelectedIds, afterSelectedIds) => {
|
|
@@ -8403,7 +8650,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8403
8650
|
saveStateForUndo("draw feature", {
|
|
8404
8651
|
excludeDrawIds: new Set(newFeatures.map((f) => String(f.id)))
|
|
8405
8652
|
});
|
|
8406
|
-
|
|
8653
|
+
scheduleSync();
|
|
8407
8654
|
setTimeout(() => {
|
|
8408
8655
|
setActiveMode("simple_select");
|
|
8409
8656
|
if (drawInstance.getMode() !== "simple_select") {
|
|
@@ -8415,7 +8662,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8415
8662
|
});
|
|
8416
8663
|
});
|
|
8417
8664
|
mapInstance.on("draw.render", () => {
|
|
8418
|
-
|
|
8665
|
+
scheduleSync();
|
|
8419
8666
|
});
|
|
8420
8667
|
mapInstance.on("draw.update", (e) => {
|
|
8421
8668
|
const activeLayerId = activeEditingLayerIdRef.current;
|
|
@@ -8445,9 +8692,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8445
8692
|
}
|
|
8446
8693
|
} else {
|
|
8447
8694
|
const previousGeometry = originalGeometriesRef.current.get(fid);
|
|
8448
|
-
const geometryChanged = !previousGeometry ||
|
|
8695
|
+
const geometryChanged = !previousGeometry || !geometryEquals(previousGeometry, feature.geometry);
|
|
8449
8696
|
if (geometryChanged) {
|
|
8450
|
-
originalGeometriesRef.current.set(fid,
|
|
8697
|
+
originalGeometriesRef.current.set(fid, deepClone(feature.geometry));
|
|
8451
8698
|
if (!externalPersistence) {
|
|
8452
8699
|
drawInstance.setFeatureProperty(fid, "_unsaved", true);
|
|
8453
8700
|
}
|
|
@@ -8456,7 +8703,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8456
8703
|
}
|
|
8457
8704
|
}
|
|
8458
8705
|
});
|
|
8459
|
-
|
|
8706
|
+
scheduleSync();
|
|
8460
8707
|
if (e.action === "change_coordinates" && !hasRevertedFeatures) {
|
|
8461
8708
|
scheduleTimelineUpdate();
|
|
8462
8709
|
recordMoveFromPreDrag();
|
|
@@ -8476,7 +8723,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8476
8723
|
updateFeatureCount();
|
|
8477
8724
|
scheduleTimelineUpdate();
|
|
8478
8725
|
saveStateForUndo("delete feature", { addDrawFeatures: e.features });
|
|
8479
|
-
|
|
8726
|
+
scheduleSync();
|
|
8480
8727
|
onFeatureDelete == null ? void 0 : onFeatureDelete(deletedIds);
|
|
8481
8728
|
});
|
|
8482
8729
|
mapInstance.on("draw.selectionchange", (e) => {
|
|
@@ -8492,7 +8739,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8492
8739
|
e.features.forEach((feature) => {
|
|
8493
8740
|
const fid = feature.id;
|
|
8494
8741
|
if (!originalGeometriesRef.current.has(fid)) {
|
|
8495
|
-
originalGeometriesRef.current.set(fid,
|
|
8742
|
+
originalGeometriesRef.current.set(fid, deepClone(feature.geometry));
|
|
8496
8743
|
}
|
|
8497
8744
|
});
|
|
8498
8745
|
}
|
|
@@ -8509,11 +8756,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8509
8756
|
if (enableProperties && (autoOpenProperties || !wasJustCreated)) {
|
|
8510
8757
|
setShowProperties(ids.length > 0);
|
|
8511
8758
|
}
|
|
8512
|
-
|
|
8759
|
+
scheduleSync("selection");
|
|
8513
8760
|
onFeatureSelect == null ? void 0 : onFeatureSelect(e.features);
|
|
8514
8761
|
});
|
|
8515
8762
|
mapInstance.on("draw.modechange", () => {
|
|
8516
|
-
|
|
8763
|
+
scheduleSync();
|
|
8517
8764
|
});
|
|
8518
8765
|
mapInstance.on("click", (e) => {
|
|
8519
8766
|
var _a;
|
|
@@ -8561,7 +8808,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8561
8808
|
setSelectedFeatureIds(nextIds);
|
|
8562
8809
|
selectedFeatureIdsRef.current = nextIds;
|
|
8563
8810
|
if (enableProperties) setShowProperties(nextIds.length > 0);
|
|
8564
|
-
|
|
8811
|
+
scheduleSync("selection");
|
|
8565
8812
|
const selectedFeatures2 = [];
|
|
8566
8813
|
for (const id of nextIds) {
|
|
8567
8814
|
readOnlyFeatures.current.forEach((layerFeatures) => {
|
|
@@ -8594,7 +8841,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8594
8841
|
setMapError(error instanceof Error ? error.message : "Failed to initialize map");
|
|
8595
8842
|
}
|
|
8596
8843
|
return () => {
|
|
8844
|
+
var _a;
|
|
8597
8845
|
if (timelineUpdateTimerRef.current) clearTimeout(timelineUpdateTimerRef.current);
|
|
8846
|
+
(_a = syncCoalescerRef.current) == null ? void 0 : _a.cancel();
|
|
8598
8847
|
if (map.current) {
|
|
8599
8848
|
map.current.remove();
|
|
8600
8849
|
map.current = null;
|
|
@@ -8717,10 +8966,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8717
8966
|
updateFeatureCount();
|
|
8718
8967
|
scheduleTimelineUpdate();
|
|
8719
8968
|
}
|
|
8720
|
-
|
|
8969
|
+
scheduleSync();
|
|
8721
8970
|
return true;
|
|
8722
8971
|
},
|
|
8723
8972
|
captureScreenshot: async (options) => {
|
|
8973
|
+
var _a;
|
|
8724
8974
|
const m = map.current;
|
|
8725
8975
|
if (!m || !isMapLoadedRef.current) {
|
|
8726
8976
|
toast({
|
|
@@ -8730,6 +8980,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8730
8980
|
});
|
|
8731
8981
|
throw new Error("Map is not ready");
|
|
8732
8982
|
}
|
|
8983
|
+
(_a = syncCoalescerRef.current) == null ? void 0 : _a.flush();
|
|
8733
8984
|
const SCREENSHOT_RENDER_TIMEOUT_MS = 1e4;
|
|
8734
8985
|
try {
|
|
8735
8986
|
await new Promise((resolve, reject) => {
|
|
@@ -8872,7 +9123,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8872
9123
|
setLayers(updatedLayers);
|
|
8873
9124
|
updateFeatureCount();
|
|
8874
9125
|
scheduleTimelineUpdate();
|
|
8875
|
-
|
|
9126
|
+
scheduleSync();
|
|
8876
9127
|
if (!(options == null ? void 0 : options.skipFit) && geojson && geojson.features.length > 0 && map.current) {
|
|
8877
9128
|
try {
|
|
8878
9129
|
const bbox = turf__namespace.bbox(geojson);
|
|
@@ -8907,9 +9158,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8907
9158
|
setLayers(updatedLayers);
|
|
8908
9159
|
updateFeatureCount();
|
|
8909
9160
|
scheduleTimelineUpdate();
|
|
8910
|
-
|
|
8911
|
-
syncRef.current();
|
|
8912
|
-
});
|
|
9161
|
+
scheduleSync();
|
|
8913
9162
|
return true;
|
|
8914
9163
|
},
|
|
8915
9164
|
setLayerVisibility: (layerId, visible) => {
|
|
@@ -8923,9 +9172,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8923
9172
|
setLayers(nextLayers2);
|
|
8924
9173
|
updateFeatureCount();
|
|
8925
9174
|
scheduleTimelineUpdate();
|
|
8926
|
-
|
|
8927
|
-
syncRef.current();
|
|
8928
|
-
});
|
|
9175
|
+
scheduleSync();
|
|
8929
9176
|
return;
|
|
8930
9177
|
}
|
|
8931
9178
|
if (!draw.current) return;
|
|
@@ -8963,9 +9210,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
8963
9210
|
setLayers(nextLayers);
|
|
8964
9211
|
updateFeatureCount();
|
|
8965
9212
|
scheduleTimelineUpdate();
|
|
8966
|
-
|
|
8967
|
-
syncRef.current();
|
|
8968
|
-
});
|
|
9213
|
+
scheduleSync();
|
|
8969
9214
|
},
|
|
8970
9215
|
addFeatures: (layerId, features, options) => {
|
|
8971
9216
|
var _a;
|
|
@@ -9006,9 +9251,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9006
9251
|
if (layerHasTemporal) {
|
|
9007
9252
|
scheduleTimelineUpdate();
|
|
9008
9253
|
}
|
|
9009
|
-
|
|
9010
|
-
syncRef.current();
|
|
9011
|
-
});
|
|
9254
|
+
scheduleSync();
|
|
9012
9255
|
return addedIds2;
|
|
9013
9256
|
}
|
|
9014
9257
|
if (!draw.current) return [];
|
|
@@ -9038,7 +9281,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9038
9281
|
setLayers(updatedLayers);
|
|
9039
9282
|
updateFeatureCount();
|
|
9040
9283
|
scheduleTimelineUpdate();
|
|
9041
|
-
|
|
9284
|
+
scheduleSync();
|
|
9042
9285
|
return addedIds;
|
|
9043
9286
|
},
|
|
9044
9287
|
removeFeatures: (featureIds, options) => {
|
|
@@ -9074,7 +9317,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9074
9317
|
});
|
|
9075
9318
|
updateFeatureCount();
|
|
9076
9319
|
scheduleTimelineUpdate();
|
|
9077
|
-
|
|
9320
|
+
scheduleSync();
|
|
9078
9321
|
onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
|
|
9079
9322
|
},
|
|
9080
9323
|
selectFeatures: (featureIds) => {
|
|
@@ -9150,7 +9393,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9150
9393
|
));
|
|
9151
9394
|
updateFeatureCount();
|
|
9152
9395
|
scheduleTimelineUpdate();
|
|
9153
|
-
|
|
9396
|
+
scheduleSync();
|
|
9154
9397
|
return addedIds;
|
|
9155
9398
|
},
|
|
9156
9399
|
getActiveEditableLayerId: () => {
|
|
@@ -9264,9 +9507,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9264
9507
|
layersRef.current = updatedLayers;
|
|
9265
9508
|
setLayers(updatedLayers);
|
|
9266
9509
|
updateFeatureCount();
|
|
9267
|
-
|
|
9268
|
-
syncRef.current();
|
|
9269
|
-
});
|
|
9510
|
+
scheduleSync();
|
|
9270
9511
|
return true;
|
|
9271
9512
|
},
|
|
9272
9513
|
setLayerData: (name, geojson, options) => {
|
|
@@ -9340,9 +9581,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9340
9581
|
return result;
|
|
9341
9582
|
});
|
|
9342
9583
|
updateFeatureCount();
|
|
9343
|
-
|
|
9344
|
-
syncRef.current();
|
|
9345
|
-
});
|
|
9584
|
+
scheduleSync();
|
|
9346
9585
|
if ((options == null ? void 0 : options.fitPadding) != null && geojson.features.length > 0 && map.current) {
|
|
9347
9586
|
try {
|
|
9348
9587
|
const bbox = turf__namespace.bbox(geojson);
|
|
@@ -9396,21 +9635,18 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9396
9635
|
const features = [];
|
|
9397
9636
|
const readOnly = readOnlyFeatures.current.get(layerId);
|
|
9398
9637
|
if (readOnly) {
|
|
9399
|
-
return readOnly
|
|
9638
|
+
return cloneFeatures(readOnly);
|
|
9400
9639
|
}
|
|
9401
9640
|
if (layer.visible) {
|
|
9402
9641
|
layer.featureIds.forEach((id) => {
|
|
9403
9642
|
var _a;
|
|
9404
9643
|
const f = (_a = draw.current) == null ? void 0 : _a.get(id);
|
|
9405
|
-
if (f)
|
|
9406
|
-
features.push(JSON.parse(JSON.stringify(f)));
|
|
9407
|
-
}
|
|
9644
|
+
if (f) features.push(f);
|
|
9408
9645
|
});
|
|
9409
9646
|
} else {
|
|
9410
|
-
|
|
9411
|
-
return hidden.map((f) => JSON.parse(JSON.stringify(f)));
|
|
9647
|
+
return cloneFeatures(hiddenFeatures.current.get(layerId) || []);
|
|
9412
9648
|
}
|
|
9413
|
-
return features;
|
|
9649
|
+
return cloneFeatures(features);
|
|
9414
9650
|
},
|
|
9415
9651
|
getTimelineRange: () => {
|
|
9416
9652
|
const ts = timelineStoreApi.getState();
|
|
@@ -9449,7 +9685,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9449
9685
|
var _a;
|
|
9450
9686
|
(_a = restoreEnrichedGeoJSONRef.current) == null ? void 0 : _a.call(restoreEnrichedGeoJSONRef, enriched);
|
|
9451
9687
|
}
|
|
9452
|
-
}), [layers, isEditMode, isMapLoaded, getSelectedFeatures, updateFeatureCount, scheduleTimelineUpdate,
|
|
9688
|
+
}), [layers, isEditMode, isMapLoaded, getSelectedFeatures, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, onFeatureDelete, onTimelineChange, activeEditingLayerId, currentMapStyle, activeMode, saveStateForUndo, history]);
|
|
9453
9689
|
const handleModeChange = react.useCallback((mode) => {
|
|
9454
9690
|
if (!draw.current || !isMapLoaded) return;
|
|
9455
9691
|
if (!hasVisibleLayers && mode !== "simple_select" && mode !== "view_select") {
|
|
@@ -9526,12 +9762,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9526
9762
|
setShowProperties(false);
|
|
9527
9763
|
updateFeatureCount();
|
|
9528
9764
|
scheduleTimelineUpdate();
|
|
9529
|
-
|
|
9765
|
+
scheduleSync();
|
|
9530
9766
|
toast({
|
|
9531
9767
|
title: "Layer cleared",
|
|
9532
9768
|
description: `Removed all features from "${activeLayer.name}"`
|
|
9533
9769
|
});
|
|
9534
|
-
}, [activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
9770
|
+
}, [activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, toast]);
|
|
9535
9771
|
const handleDeleteSelected = react.useCallback(() => {
|
|
9536
9772
|
if (selectedFeatureIds.length === 0) return;
|
|
9537
9773
|
const idSet = new Set(selectedFeatureIds);
|
|
@@ -9582,8 +9818,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9582
9818
|
setShowProperties(false);
|
|
9583
9819
|
updateFeatureCount();
|
|
9584
9820
|
scheduleTimelineUpdate();
|
|
9585
|
-
|
|
9586
|
-
}, [selectedFeatureIds, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
9821
|
+
scheduleSync();
|
|
9822
|
+
}, [selectedFeatureIds, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, onFeatureDelete]);
|
|
9587
9823
|
const handleToggleEditMode = react.useCallback(() => {
|
|
9588
9824
|
setIsEditMode((prev) => {
|
|
9589
9825
|
const newMode = !prev;
|
|
@@ -9719,9 +9955,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9719
9955
|
updateFeatureCount();
|
|
9720
9956
|
scheduleTimelineUpdate();
|
|
9721
9957
|
saveStateForUndo();
|
|
9722
|
-
|
|
9958
|
+
scheduleSync();
|
|
9723
9959
|
onFeatureCreate == null ? void 0 : onFeatureCreate(feature);
|
|
9724
|
-
}, [isMapLoaded, externalPersistence, enableProperties, autoOpenProperties, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
9960
|
+
}, [isMapLoaded, externalPersistence, enableProperties, autoOpenProperties, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, onFeatureCreate]);
|
|
9725
9961
|
const handleFeatureContextMenu = react.useCallback((e) => {
|
|
9726
9962
|
var _a, _b;
|
|
9727
9963
|
contextMenuFiredRef.current = true;
|
|
@@ -9906,7 +10142,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9906
10142
|
if (properties.kind === "text" || ((_c = drawFeature.properties) == null ? void 0 : _c.kind) === "text") {
|
|
9907
10143
|
draw.current.setFeatureProperty(featureId, "text", void 0);
|
|
9908
10144
|
}
|
|
9909
|
-
|
|
10145
|
+
scheduleSync();
|
|
9910
10146
|
scheduleTimelineUpdate();
|
|
9911
10147
|
setFeatureUpdateCounter((c) => c + 1);
|
|
9912
10148
|
const updated = draw.current.get(featureId);
|
|
@@ -9941,13 +10177,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9941
10177
|
}
|
|
9942
10178
|
});
|
|
9943
10179
|
if (updatedFeature) {
|
|
9944
|
-
|
|
10180
|
+
scheduleSync();
|
|
9945
10181
|
scheduleTimelineUpdate();
|
|
9946
10182
|
setFeatureUpdateCounter((c) => c + 1);
|
|
9947
10183
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updatedFeature);
|
|
9948
10184
|
}
|
|
9949
10185
|
}
|
|
9950
|
-
}, [saveStateForUndo, scheduleTimelineUpdate, onFeatureUpdate,
|
|
10186
|
+
}, [saveStateForUndo, scheduleTimelineUpdate, onFeatureUpdate, scheduleSync]);
|
|
9951
10187
|
const handleUpdateGeometry = react.useCallback((featureId, geometry) => {
|
|
9952
10188
|
if (!draw.current || !map.current) return;
|
|
9953
10189
|
const feature = draw.current.get(featureId);
|
|
@@ -9969,13 +10205,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9969
10205
|
draw.current.setFeatureProperty(featureId, "_unsaved", true);
|
|
9970
10206
|
}
|
|
9971
10207
|
draw.current.changeMode("simple_select", { featureIds: [featureId] });
|
|
9972
|
-
|
|
10208
|
+
scheduleSync();
|
|
9973
10209
|
setFeatureUpdateCounter((c) => c + 1);
|
|
9974
10210
|
const updated = draw.current.get(featureId);
|
|
9975
10211
|
if (updated) {
|
|
9976
10212
|
onFeatureUpdate == null ? void 0 : onFeatureUpdate(updated);
|
|
9977
10213
|
}
|
|
9978
|
-
}, [saveStateForUndo, onFeatureUpdate,
|
|
10214
|
+
}, [saveStateForUndo, onFeatureUpdate, scheduleSync]);
|
|
9979
10215
|
const handleFeatureSaved = react.useCallback((oldId, newId, metadata) => {
|
|
9980
10216
|
if (!draw.current) return;
|
|
9981
10217
|
const feature = draw.current.get(oldId);
|
|
@@ -10020,7 +10256,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10020
10256
|
setSelectedFeatureIds((prev) => prev.map((fid) => fid === oldId ? featureId : fid));
|
|
10021
10257
|
draw.current.changeMode("simple_select", { featureIds: [featureId] });
|
|
10022
10258
|
}
|
|
10023
|
-
|
|
10259
|
+
scheduleSync();
|
|
10024
10260
|
updateFeatureCount();
|
|
10025
10261
|
setFeatureUpdateCounter((c) => c + 1);
|
|
10026
10262
|
const savedFeatureId = featureId;
|
|
@@ -10031,7 +10267,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10031
10267
|
}
|
|
10032
10268
|
setFeatureUpdateCounter((c) => c + 1);
|
|
10033
10269
|
});
|
|
10034
|
-
}, [
|
|
10270
|
+
}, [scheduleSync, updateFeatureCount]);
|
|
10035
10271
|
const handleAddLayer = react.useCallback((name) => {
|
|
10036
10272
|
const newLayer = {
|
|
10037
10273
|
id: `layer-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
@@ -10116,9 +10352,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10116
10352
|
updateFeatureCount();
|
|
10117
10353
|
scheduleTimelineUpdate();
|
|
10118
10354
|
if (layer.readOnly) {
|
|
10119
|
-
|
|
10120
|
-
syncRef.current();
|
|
10121
|
-
});
|
|
10355
|
+
scheduleSync();
|
|
10122
10356
|
}
|
|
10123
10357
|
}, [layers, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate]);
|
|
10124
10358
|
const handleMoveFeatureToLayer = react.useCallback((featureId, targetLayerId) => {
|
|
@@ -10176,10 +10410,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10176
10410
|
}
|
|
10177
10411
|
return remaining.length !== l.featureIds.length ? { ...l, featureIds: remaining } : l;
|
|
10178
10412
|
}));
|
|
10179
|
-
|
|
10413
|
+
scheduleSync();
|
|
10180
10414
|
updateFeatureCount();
|
|
10181
10415
|
}
|
|
10182
|
-
}, [saveStateForUndo, findFeatureById, updateFeatureCount,
|
|
10416
|
+
}, [saveStateForUndo, findFeatureById, updateFeatureCount, scheduleSync]);
|
|
10183
10417
|
const handleCopyFeaturesToLayer = react.useCallback((featureIds, targetLayerId) => {
|
|
10184
10418
|
if (!draw.current) return;
|
|
10185
10419
|
saveStateForUndo();
|
|
@@ -10236,10 +10470,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10236
10470
|
}),
|
|
10237
10471
|
{ id: newLayerId, name: layerName, visible: true, featureIds: movedIds }
|
|
10238
10472
|
]);
|
|
10239
|
-
|
|
10473
|
+
scheduleSync();
|
|
10240
10474
|
updateFeatureCount();
|
|
10241
10475
|
}
|
|
10242
|
-
}, [saveStateForUndo, findFeatureById, updateFeatureCount,
|
|
10476
|
+
}, [saveStateForUndo, findFeatureById, updateFeatureCount, scheduleSync]);
|
|
10243
10477
|
const handleCreateLayerAndCopyFeatures = react.useCallback((featureIds, layerName) => {
|
|
10244
10478
|
if (!draw.current) return;
|
|
10245
10479
|
saveStateForUndo();
|
|
@@ -10533,9 +10767,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10533
10767
|
const mapInstance = map.current;
|
|
10534
10768
|
const handleMove = () => {
|
|
10535
10769
|
if (!hasArrowFeaturesRef.current) return;
|
|
10536
|
-
|
|
10537
|
-
syncRef.current();
|
|
10538
|
-
}
|
|
10770
|
+
scheduleSync();
|
|
10539
10771
|
};
|
|
10540
10772
|
mapInstance.on("move", handleMove);
|
|
10541
10773
|
return () => {
|
|
@@ -10853,6 +11085,27 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10853
11085
|
react.useEffect(() => {
|
|
10854
11086
|
enableDrawingRef.current = enableDrawing;
|
|
10855
11087
|
}, [enableDrawing]);
|
|
11088
|
+
const trySelectionFastPath = react.useCallback(() => {
|
|
11089
|
+
var _a;
|
|
11090
|
+
const m = map.current;
|
|
11091
|
+
if (!m) return true;
|
|
11092
|
+
const source = m.getSource("custom-features");
|
|
11093
|
+
const gate = enableSelectionRef.current || enableDrawingRef.current;
|
|
11094
|
+
const next = /* @__PURE__ */ new Set();
|
|
11095
|
+
if (gate) {
|
|
11096
|
+
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
|
|
11097
|
+
selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
|
|
11098
|
+
}
|
|
11099
|
+
return applySelectionFastPath(selectionPaintCacheRef.current, next, source);
|
|
11100
|
+
}, []);
|
|
11101
|
+
trySelectionFastPathRef.current = trySelectionFastPath;
|
|
11102
|
+
const collectSelectionFeatureGroups = react.useCallback(() => {
|
|
11103
|
+
return collectVisibleFeatureGroups(
|
|
11104
|
+
draw.current ? draw.current.getAll().features : null,
|
|
11105
|
+
readOnlyFeatures.current,
|
|
11106
|
+
layersRef.current
|
|
11107
|
+
);
|
|
11108
|
+
}, []);
|
|
10856
11109
|
react.useEffect(() => {
|
|
10857
11110
|
if (!map.current || !isMapLoaded) {
|
|
10858
11111
|
return;
|
|
@@ -10943,29 +11196,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10943
11196
|
[minLng, maxLat]
|
|
10944
11197
|
// close polygon
|
|
10945
11198
|
]]);
|
|
10946
|
-
const drawFeatures = draw.current ? draw.current.getAll().features : [];
|
|
10947
|
-
const readOnlyFeaturesList = [];
|
|
10948
|
-
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
10949
|
-
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
10950
|
-
if (layer == null ? void 0 : layer.visible) pushAll(readOnlyFeaturesList, features);
|
|
10951
|
-
});
|
|
10952
|
-
const allFeatures = [...drawFeatures, ...readOnlyFeaturesList];
|
|
10953
|
-
const selectedIds = [];
|
|
10954
|
-
allFeatures.forEach((feature) => {
|
|
10955
|
-
try {
|
|
10956
|
-
const geom = feature.geometry;
|
|
10957
|
-
let isInside = false;
|
|
10958
|
-
if (geom.type === "Point") {
|
|
10959
|
-
isInside = turf__namespace.booleanPointInPolygon(geom.coordinates, selectionPolygon);
|
|
10960
|
-
} else if (geom.type === "LineString" || geom.type === "Polygon" || geom.type === "MultiPoint" || geom.type === "MultiLineString" || geom.type === "MultiPolygon") {
|
|
10961
|
-
isInside = turf__namespace.booleanIntersects(feature, selectionPolygon);
|
|
10962
|
-
}
|
|
10963
|
-
if (isInside && feature.id) {
|
|
10964
|
-
selectedIds.push(String(feature.id));
|
|
10965
|
-
}
|
|
10966
|
-
} catch (err) {
|
|
10967
|
-
}
|
|
10968
|
-
});
|
|
10969
11199
|
const isFilterAction = filterActiveRef.current && onSelectionComplete;
|
|
10970
11200
|
if (isFilterAction) {
|
|
10971
11201
|
onSelectionComplete(selectionPolygon.geometry);
|
|
@@ -10979,6 +11209,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10979
11209
|
]);
|
|
10980
11210
|
}
|
|
10981
11211
|
} else {
|
|
11212
|
+
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon, {
|
|
11213
|
+
axisAlignedRectangle: true
|
|
11214
|
+
});
|
|
10982
11215
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
10983
11216
|
applySelectionState(finalIds, { focusProperties: true });
|
|
10984
11217
|
}
|
|
@@ -10994,29 +11227,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10994
11227
|
const radiusKm = turf__namespace.distance(center, edge, { units: "kilometers" });
|
|
10995
11228
|
if (radiusKm > 0) {
|
|
10996
11229
|
const selectionPolygon = turf__namespace.circle([centerLngLat.lng, centerLngLat.lat], radiusKm, { steps: 64, units: "kilometers" });
|
|
10997
|
-
const drawFeatures = draw.current ? draw.current.getAll().features : [];
|
|
10998
|
-
const readOnlyFeaturesList = [];
|
|
10999
|
-
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
11000
|
-
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
11001
|
-
if (layer == null ? void 0 : layer.visible) pushAll(readOnlyFeaturesList, features);
|
|
11002
|
-
});
|
|
11003
|
-
const allFeatures = [...drawFeatures, ...readOnlyFeaturesList];
|
|
11004
|
-
const selectedIds = [];
|
|
11005
|
-
allFeatures.forEach((feature) => {
|
|
11006
|
-
try {
|
|
11007
|
-
const geom = feature.geometry;
|
|
11008
|
-
let isInside = false;
|
|
11009
|
-
if (geom.type === "Point") {
|
|
11010
|
-
isInside = turf__namespace.booleanPointInPolygon(geom.coordinates, selectionPolygon);
|
|
11011
|
-
} else if (geom.type === "LineString" || geom.type === "Polygon" || geom.type === "MultiPoint" || geom.type === "MultiLineString" || geom.type === "MultiPolygon") {
|
|
11012
|
-
isInside = turf__namespace.booleanIntersects(feature, selectionPolygon);
|
|
11013
|
-
}
|
|
11014
|
-
if (isInside && feature.id) {
|
|
11015
|
-
selectedIds.push(String(feature.id));
|
|
11016
|
-
}
|
|
11017
|
-
} catch (err) {
|
|
11018
|
-
}
|
|
11019
|
-
});
|
|
11020
11230
|
const isFilterAction = filterActiveRef.current && onSelectionComplete;
|
|
11021
11231
|
if (isFilterAction) {
|
|
11022
11232
|
onSelectionComplete(selectionPolygon.geometry);
|
|
@@ -11024,6 +11234,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11024
11234
|
setPersistedSelectionPolygon(selectionPolygon.geometry.coordinates[0]);
|
|
11025
11235
|
}
|
|
11026
11236
|
} else {
|
|
11237
|
+
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
11027
11238
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
11028
11239
|
applySelectionState(finalIds, { focusProperties: true });
|
|
11029
11240
|
}
|
|
@@ -11050,29 +11261,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11050
11261
|
}
|
|
11051
11262
|
const closedPoints = [...currentPoints, currentPoints[0]];
|
|
11052
11263
|
const selectionPolygon = turf__namespace.polygon([closedPoints]);
|
|
11053
|
-
const drawFeatures = draw.current ? draw.current.getAll().features : [];
|
|
11054
|
-
const readOnlyFeaturesList = [];
|
|
11055
|
-
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
11056
|
-
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
11057
|
-
if (layer == null ? void 0 : layer.visible) pushAll(readOnlyFeaturesList, features);
|
|
11058
|
-
});
|
|
11059
|
-
const allFeatures = [...drawFeatures, ...readOnlyFeaturesList];
|
|
11060
|
-
const selectedIds = [];
|
|
11061
|
-
allFeatures.forEach((feature) => {
|
|
11062
|
-
try {
|
|
11063
|
-
const geom = feature.geometry;
|
|
11064
|
-
let isInside = false;
|
|
11065
|
-
if (geom.type === "Point") {
|
|
11066
|
-
isInside = turf__namespace.booleanPointInPolygon(geom.coordinates, selectionPolygon);
|
|
11067
|
-
} else if (geom.type === "LineString" || geom.type === "Polygon" || geom.type === "MultiPoint" || geom.type === "MultiLineString" || geom.type === "MultiPolygon") {
|
|
11068
|
-
isInside = turf__namespace.booleanIntersects(feature, selectionPolygon);
|
|
11069
|
-
}
|
|
11070
|
-
if (isInside && feature.id) {
|
|
11071
|
-
selectedIds.push(String(feature.id));
|
|
11072
|
-
}
|
|
11073
|
-
} catch (err) {
|
|
11074
|
-
}
|
|
11075
|
-
});
|
|
11076
11264
|
const isFilterAction = filterActiveRef.current && onSelectionComplete;
|
|
11077
11265
|
if (isFilterAction) {
|
|
11078
11266
|
onSelectionComplete(selectionPolygon.geometry);
|
|
@@ -11080,6 +11268,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11080
11268
|
setPersistedSelectionPolygon(closedPoints);
|
|
11081
11269
|
}
|
|
11082
11270
|
} else {
|
|
11271
|
+
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
11083
11272
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
11084
11273
|
applySelectionState(finalIds, { focusProperties: true });
|
|
11085
11274
|
}
|
|
@@ -11129,7 +11318,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11129
11318
|
window.removeEventListener("keydown", handleKeyDown);
|
|
11130
11319
|
canvas.removeEventListener("contextmenu", handleContextMenu);
|
|
11131
11320
|
};
|
|
11132
|
-
}, [selectionMode, isMapLoaded, onFeatureSelect, onSelectionComplete, persistSelection, isSelectionToolActive]);
|
|
11321
|
+
}, [selectionMode, isMapLoaded, onFeatureSelect, onSelectionComplete, persistSelection, isSelectionToolActive, collectSelectionFeatureGroups]);
|
|
11133
11322
|
const shiftSelectionRef = react.useRef({ isActive: false, startPoint: null, completedAt: 0 });
|
|
11134
11323
|
react.useEffect(() => {
|
|
11135
11324
|
if (!map.current || !isMapLoaded || !draw.current) return;
|
|
@@ -11189,28 +11378,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11189
11378
|
[minLng, minLat],
|
|
11190
11379
|
[minLng, maxLat]
|
|
11191
11380
|
]]);
|
|
11192
|
-
const
|
|
11193
|
-
|
|
11194
|
-
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
11195
|
-
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
11196
|
-
if (layer == null ? void 0 : layer.visible) pushAll(readOnlyFeaturesList, features);
|
|
11197
|
-
});
|
|
11198
|
-
const allFeatures = [...drawFeatures, ...readOnlyFeaturesList];
|
|
11199
|
-
const selectedIds = [];
|
|
11200
|
-
allFeatures.forEach((feature) => {
|
|
11201
|
-
try {
|
|
11202
|
-
const geom = feature.geometry;
|
|
11203
|
-
let isInside = false;
|
|
11204
|
-
if (geom.type === "Point") {
|
|
11205
|
-
isInside = turf__namespace.booleanPointInPolygon(geom.coordinates, selectionPolygon);
|
|
11206
|
-
} else if (geom.type === "LineString" || geom.type === "Polygon" || geom.type === "MultiPoint" || geom.type === "MultiLineString" || geom.type === "MultiPolygon") {
|
|
11207
|
-
isInside = turf__namespace.booleanIntersects(feature, selectionPolygon);
|
|
11208
|
-
}
|
|
11209
|
-
if (isInside && feature.id) {
|
|
11210
|
-
selectedIds.push(String(feature.id));
|
|
11211
|
-
}
|
|
11212
|
-
} catch {
|
|
11213
|
-
}
|
|
11381
|
+
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon, {
|
|
11382
|
+
axisAlignedRectangle: true
|
|
11214
11383
|
});
|
|
11215
11384
|
const mergedIds = Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds]));
|
|
11216
11385
|
shiftSelectionRef.current = { isActive: false, startPoint: null, completedAt: Date.now() };
|
|
@@ -11230,7 +11399,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11230
11399
|
map.current.dragPan.enable();
|
|
11231
11400
|
}
|
|
11232
11401
|
};
|
|
11233
|
-
}, [isMapLoaded, isSelectionToolActive, applySelectionState]);
|
|
11402
|
+
}, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
|
|
11234
11403
|
react.useEffect(() => {
|
|
11235
11404
|
if (!map.current || !isMapLoaded) return;
|
|
11236
11405
|
const mapInstance = map.current;
|
|
@@ -11364,7 +11533,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11364
11533
|
(layer) => layer.id === targetLayer.id ? { ...layer, featureIds: [...layer.featureIds, featureId] } : layer
|
|
11365
11534
|
);
|
|
11366
11535
|
});
|
|
11367
|
-
|
|
11536
|
+
scheduleSync();
|
|
11368
11537
|
const newCount = drawInstance.getAll().features.length;
|
|
11369
11538
|
setFeatureCount(newCount);
|
|
11370
11539
|
drawInstance.changeMode("simple_select", { featureIds: [featureId] });
|
|
@@ -11486,7 +11655,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11486
11655
|
(layer) => layer.id === targetLayer.id ? { ...layer, featureIds: [...layer.featureIds, featureId] } : layer
|
|
11487
11656
|
);
|
|
11488
11657
|
});
|
|
11489
|
-
|
|
11658
|
+
scheduleSync();
|
|
11490
11659
|
const newCount = drawInstance.getAll().features.length;
|
|
11491
11660
|
setFeatureCount(newCount);
|
|
11492
11661
|
justCreatedRectangleRef.current = true;
|
|
@@ -11842,7 +12011,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11842
12011
|
}
|
|
11843
12012
|
updateFeatureCount();
|
|
11844
12013
|
scheduleTimelineUpdate();
|
|
11845
|
-
|
|
12014
|
+
scheduleSync();
|
|
11846
12015
|
}
|
|
11847
12016
|
} catch (error) {
|
|
11848
12017
|
toast({
|
|
@@ -11851,7 +12020,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11851
12020
|
variant: "destructive"
|
|
11852
12021
|
});
|
|
11853
12022
|
}
|
|
11854
|
-
}, [onSearchEngineRequest, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
12023
|
+
}, [onSearchEngineRequest, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, toast]);
|
|
11855
12024
|
const restoreEnrichedGeoJSON = react.useCallback((enriched) => {
|
|
11856
12025
|
var _a;
|
|
11857
12026
|
const mapState = enriched["octostar:map"];
|
|
@@ -11921,7 +12090,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11921
12090
|
setLayers(newLayers);
|
|
11922
12091
|
updateFeatureCount();
|
|
11923
12092
|
scheduleTimelineUpdate();
|
|
11924
|
-
|
|
12093
|
+
scheduleSync();
|
|
11925
12094
|
if (mapState.viewport && map.current) {
|
|
11926
12095
|
map.current.flyTo({
|
|
11927
12096
|
center: mapState.viewport.center,
|
|
@@ -11938,7 +12107,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11938
12107
|
title: "Map restored",
|
|
11939
12108
|
description: `Restored ${newLayers.length} layers with ${totalFeatures} features`
|
|
11940
12109
|
});
|
|
11941
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
12110
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, onMapStateLoaded, toast]);
|
|
11942
12111
|
restoreEnrichedGeoJSONRef.current = restoreEnrichedGeoJSON;
|
|
11943
12112
|
const handleWorkspaceLoad = react.useCallback(async () => {
|
|
11944
12113
|
if (!onWorkspaceLoad) return;
|
|
@@ -11976,7 +12145,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11976
12145
|
setLayers((prev) => [...prev, newLayer]);
|
|
11977
12146
|
updateFeatureCount();
|
|
11978
12147
|
scheduleTimelineUpdate();
|
|
11979
|
-
|
|
12148
|
+
scheduleSync();
|
|
11980
12149
|
toast({
|
|
11981
12150
|
title: "Features loaded",
|
|
11982
12151
|
description: `Created layer with ${featuresWithIds.length} features`
|
|
@@ -11988,7 +12157,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11988
12157
|
variant: "destructive"
|
|
11989
12158
|
});
|
|
11990
12159
|
}
|
|
11991
|
-
}, [onWorkspaceLoad, saveStateForUndo, restoreEnrichedGeoJSON, updateFeatureCount, scheduleTimelineUpdate,
|
|
12160
|
+
}, [onWorkspaceLoad, saveStateForUndo, restoreEnrichedGeoJSON, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, toast]);
|
|
11992
12161
|
const handleWorkspaceSave = react.useCallback(async () => {
|
|
11993
12162
|
if (!onWorkspaceSave) return;
|
|
11994
12163
|
const geojson = buildEnrichedGeoJSON();
|
|
@@ -12152,7 +12321,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12152
12321
|
setLayers((prev) => [...prev, newLayer]);
|
|
12153
12322
|
updateFeatureCount();
|
|
12154
12323
|
scheduleTimelineUpdate();
|
|
12155
|
-
|
|
12324
|
+
scheduleSync();
|
|
12156
12325
|
if (map.current && geojson.features.length > 0) {
|
|
12157
12326
|
try {
|
|
12158
12327
|
const bbox = turf__namespace.bbox(geojson);
|
|
@@ -12223,7 +12392,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12223
12392
|
}
|
|
12224
12393
|
updateFeatureCount();
|
|
12225
12394
|
scheduleTimelineUpdate();
|
|
12226
|
-
|
|
12395
|
+
scheduleSync();
|
|
12227
12396
|
const reprojectMsg = reprojected ? ` (reprojected from ${sourceCRS})` : "";
|
|
12228
12397
|
toast({
|
|
12229
12398
|
title: "GeoJSON loaded",
|
|
@@ -12239,7 +12408,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12239
12408
|
};
|
|
12240
12409
|
reader.readAsText(file);
|
|
12241
12410
|
e.target.value = "";
|
|
12242
|
-
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
12411
|
+
}, [layers, activeEditingLayerId, saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
12243
12412
|
const handleDropGeoJSON = react.useCallback((name, data) => {
|
|
12244
12413
|
var _a;
|
|
12245
12414
|
if (!map.current) return;
|
|
@@ -12299,7 +12468,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12299
12468
|
setLayers(nextLayers);
|
|
12300
12469
|
updateFeatureCount();
|
|
12301
12470
|
scheduleTimelineUpdate();
|
|
12302
|
-
|
|
12471
|
+
scheduleSync();
|
|
12303
12472
|
if (reprojectedData.features.length > 0) {
|
|
12304
12473
|
try {
|
|
12305
12474
|
const bbox = turf__namespace.bbox(reprojectedData);
|
|
@@ -12317,17 +12486,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12317
12486
|
title: "Layer added",
|
|
12318
12487
|
description: `Created "${newLayer.name}" with ${addedIds.length} features${reprojectMsg} (high-performance)`
|
|
12319
12488
|
});
|
|
12320
|
-
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate,
|
|
12489
|
+
}, [saveStateForUndo, updateFeatureCount, scheduleTimelineUpdate, scheduleSync, restoreEnrichedGeoJSON, toast, interceptGeoJSONFileLoad]);
|
|
12321
12490
|
const handleTimelineFilterChange = react.useCallback((visibleIds, hiddenIds, untimedIds) => {
|
|
12322
12491
|
if (!draw.current || !map.current) return;
|
|
12323
12492
|
timelineVisibleIdsRef.current = /* @__PURE__ */ new Set([...visibleIds, ...untimedIds]);
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
timelineSyncRafRef.current = null;
|
|
12327
|
-
syncFeaturesToCustomLayers();
|
|
12328
|
-
});
|
|
12329
|
-
}
|
|
12330
|
-
}, [syncFeaturesToCustomLayers]);
|
|
12493
|
+
scheduleSync();
|
|
12494
|
+
}, [scheduleSync]);
|
|
12331
12495
|
const prevTimelineEnabledRef = react.useRef(timelineStore.isEnabled);
|
|
12332
12496
|
react.useEffect(() => {
|
|
12333
12497
|
const wasEnabled = prevTimelineEnabledRef.current;
|
|
@@ -12335,11 +12499,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12335
12499
|
prevTimelineEnabledRef.current = isNowEnabled;
|
|
12336
12500
|
if (!isNowEnabled || !timelineStore.hasTemporalData) {
|
|
12337
12501
|
timelineVisibleIdsRef.current = null;
|
|
12338
|
-
|
|
12502
|
+
scheduleSync();
|
|
12339
12503
|
} else if (!wasEnabled && isNowEnabled) {
|
|
12340
12504
|
updateTimelineStore();
|
|
12341
12505
|
}
|
|
12342
|
-
}, [timelineStore.isEnabled, timelineStore.hasTemporalData,
|
|
12506
|
+
}, [timelineStore.isEnabled, timelineStore.hasTemporalData, scheduleSync, updateTimelineStore, scheduleTimelineUpdate]);
|
|
12343
12507
|
react.useEffect(() => {
|
|
12344
12508
|
if (!map.current || !draw.current || !isMapLoaded) return;
|
|
12345
12509
|
const mapInstance = map.current;
|