@octostar/map-component 0.3.0 → 0.3.2
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 +501 -251
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +502 -252
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/timebar.d.ts +23 -3
- package/dist/types/components/timebar.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/custom-layer-stack.d.ts +20 -7
- package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
- package/dist/types/lib/label-pinning.d.ts +10 -2
- package/dist/types/lib/label-pinning.d.ts.map +1 -1
- package/dist/types/lib/paint-feature.d.ts +11 -11
- package/dist/types/lib/paint-feature.d.ts.map +1 -1
- package/dist/types/lib/selection-diff.d.ts +9 -34
- package/dist/types/lib/selection-diff.d.ts.map +1 -1
- package/dist/types/lib/selection-overlay.d.ts +53 -0
- package/dist/types/lib/selection-overlay.d.ts.map +1 -0
- package/dist/types/lib/selection-paint.d.ts +23 -0
- package/dist/types/lib/selection-paint.d.ts.map +1 -0
- package/dist/types/lib/selection-state.d.ts +60 -0
- package/dist/types/lib/selection-state.d.ts.map +1 -0
- package/dist/types/lib/shard-fingerprint.d.ts +6 -7
- package/dist/types/lib/shard-fingerprint.d.ts.map +1 -1
- package/dist/types/lib/shard-locator.d.ts +53 -0
- package/dist/types/lib/shard-locator.d.ts.map +1 -0
- package/dist/types/lib/shard-pipeline.d.ts.map +1 -1
- package/dist/types/lib/shard-registry.d.ts +5 -4
- package/dist/types/lib/shard-registry.d.ts.map +1 -1
- package/dist/types/lib/timeline-store.d.ts +12 -2
- package/dist/types/lib/timeline-store.d.ts.map +1 -1
- package/dist/types/lib/trace-timeline.d.ts +3 -6
- package/dist/types/lib/trace-timeline.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { twMerge } from "tailwind-merge";
|
|
|
12
12
|
import { MousePointer2, Square, Hexagon, Circle, MoreVertical, ChevronDown, Filter, X, Move, Ruler, Search, Scan, Pencil, Database, MapPin, Minus, Pentagon, Type, MoveRight, Undo2, Redo2, Trash2, Navigation, Loader2, Map as Map$1, Satellite, FolderOpen, Upload, Download, MoreHorizontal, Focus, Box, Layers, Plus, ChevronRight, Eye, EyeOff, Lock, Smile, Package, Copy, FolderInput, Save, Calendar, Palette, Blend, RefreshCw, ExternalLink, Info, SkipBack, Pause, Play, Clock, AlertTriangle, TestTube, Users, GripVertical, Plane, FileJson, Check, Phone, Car, AlertCircle } from "lucide-react";
|
|
13
13
|
import { createPortal } from "react-dom";
|
|
14
14
|
import { format } from "date-fns";
|
|
15
|
-
import {
|
|
15
|
+
import { createStore, useStore } from "zustand";
|
|
16
16
|
import Flatbush from "flatbush";
|
|
17
17
|
import dayjs from "dayjs";
|
|
18
18
|
import * as toGeoJSON from "@mapbox/togeojson";
|
|
@@ -748,6 +748,10 @@ function createIngestProgressStore() {
|
|
|
748
748
|
}
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
|
+
const SELECTED_STATE_KEY = "selected";
|
|
752
|
+
const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
|
|
753
|
+
const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
|
|
754
|
+
const SELECTION_COLOR = "#06b6d4";
|
|
751
755
|
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
752
756
|
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
753
757
|
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
@@ -800,7 +804,8 @@ function buildCustomLabelLayout() {
|
|
|
800
804
|
]
|
|
801
805
|
};
|
|
802
806
|
}
|
|
803
|
-
function buildCustomLabelPaint() {
|
|
807
|
+
function buildCustomLabelPaint(opts) {
|
|
808
|
+
const visibleOpacity = ["*", 0.9, ["get", "stroke-opacity"]];
|
|
804
809
|
return {
|
|
805
810
|
// Text features use fontColor; others use default
|
|
806
811
|
"text-color": [
|
|
@@ -819,7 +824,7 @@ function buildCustomLabelPaint() {
|
|
|
819
824
|
2,
|
|
820
825
|
1.5
|
|
821
826
|
],
|
|
822
|
-
"text-opacity":
|
|
827
|
+
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
823
828
|
};
|
|
824
829
|
}
|
|
825
830
|
const CUSTOM_LAYER_ROLES = [
|
|
@@ -829,13 +834,13 @@ const CUSTOM_LAYER_ROLES = [
|
|
|
829
834
|
"point-shadow",
|
|
830
835
|
"point",
|
|
831
836
|
"point-icon",
|
|
832
|
-
"point-icon-selection",
|
|
833
|
-
"line-selection",
|
|
834
|
-
"polygon-selection",
|
|
835
837
|
"labels",
|
|
836
838
|
"labels-pinned"
|
|
837
839
|
];
|
|
838
840
|
const SHARED_SOURCE_ID = "custom-features";
|
|
841
|
+
function customSourceSpec() {
|
|
842
|
+
return { type: "geojson", data: { type: "FeatureCollection", features: [] }, maxzoom: 22, promoteId: "id" };
|
|
843
|
+
}
|
|
839
844
|
const EMOJI_CANVAS_SIZE = 48;
|
|
840
845
|
function customLayerId(role, sourceId) {
|
|
841
846
|
return sourceId === SHARED_SOURCE_ID ? `custom-${role}` : `custom-${role}@${sourceId}`;
|
|
@@ -858,9 +863,9 @@ function geometryClassesOf(features) {
|
|
|
858
863
|
return classes;
|
|
859
864
|
}
|
|
860
865
|
const ROLES_BY_CLASS = {
|
|
861
|
-
polygon: ["polygon-fill", "polygon-stroke"
|
|
862
|
-
line: ["line"
|
|
863
|
-
point: ["point-shadow", "point", "point-icon"
|
|
866
|
+
polygon: ["polygon-fill", "polygon-stroke"],
|
|
867
|
+
line: ["line"],
|
|
868
|
+
point: ["point-shadow", "point", "point-icon"]
|
|
864
869
|
};
|
|
865
870
|
function rolesForGeometry(classes) {
|
|
866
871
|
const needed = /* @__PURE__ */ new Set(["labels", "labels-pinned"]);
|
|
@@ -882,12 +887,6 @@ function shardInsertAnchor(role) {
|
|
|
882
887
|
case "point":
|
|
883
888
|
return "custom-point-icon";
|
|
884
889
|
case "point-icon":
|
|
885
|
-
return "custom-point-icon-selection";
|
|
886
|
-
case "point-icon-selection":
|
|
887
|
-
return "custom-line-selection";
|
|
888
|
-
case "line-selection":
|
|
889
|
-
return "custom-polygon-selection";
|
|
890
|
-
case "polygon-selection":
|
|
891
890
|
return "custom-arrow-heads";
|
|
892
891
|
case "labels":
|
|
893
892
|
return "custom-arrow-heads";
|
|
@@ -970,7 +969,8 @@ function buildLayer(role, sourceId, opts) {
|
|
|
970
969
|
"circle-translate": [1, 1]
|
|
971
970
|
}
|
|
972
971
|
};
|
|
973
|
-
// Custom point layer
|
|
972
|
+
// Custom point layer; the selection ring is paint-only and reads feature
|
|
973
|
+
// state (hidden when emoji icon is set)
|
|
974
974
|
case "point":
|
|
975
975
|
return {
|
|
976
976
|
id,
|
|
@@ -1001,7 +1001,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1001
1001
|
0,
|
|
1002
1002
|
["coalesce", ["get", "stroke-opacity"], 1]
|
|
1003
1003
|
],
|
|
1004
|
-
"circle-stroke-color": ["case",
|
|
1004
|
+
"circle-stroke-color": ["case", SELECTED, SELECTION_COLOR, "#555555"],
|
|
1005
1005
|
"circle-stroke-width": [
|
|
1006
1006
|
"case",
|
|
1007
1007
|
["==", ["get", "isTimelineHidden"], 1],
|
|
@@ -1012,7 +1012,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1012
1012
|
0,
|
|
1013
1013
|
["!=", ["get", "icon"], ""],
|
|
1014
1014
|
0,
|
|
1015
|
-
|
|
1015
|
+
SELECTED,
|
|
1016
1016
|
3,
|
|
1017
1017
|
1.5
|
|
1018
1018
|
],
|
|
@@ -1052,47 +1052,6 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1052
1052
|
]
|
|
1053
1053
|
}
|
|
1054
1054
|
};
|
|
1055
|
-
// Selection ring for icon points
|
|
1056
|
-
case "point-icon-selection":
|
|
1057
|
-
return {
|
|
1058
|
-
id,
|
|
1059
|
-
type: "circle",
|
|
1060
|
-
source: sourceId,
|
|
1061
|
-
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", "isSelected", 1], ["!=", "isHiddenByHeatmap", 1]],
|
|
1062
|
-
paint: {
|
|
1063
|
-
"circle-color": "transparent",
|
|
1064
|
-
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
1065
|
-
"circle-stroke-color": "#06b6d4",
|
|
1066
|
-
"circle-stroke-width": 3,
|
|
1067
|
-
"circle-stroke-opacity": 1
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
// Selection highlight for lines - bright cyan dashed overlay
|
|
1071
|
-
case "line-selection":
|
|
1072
|
-
return {
|
|
1073
|
-
id,
|
|
1074
|
-
type: "line",
|
|
1075
|
-
source: sourceId,
|
|
1076
|
-
filter: ["all", ["==", "$type", "LineString"], ["==", "isSelected", 1]],
|
|
1077
|
-
paint: {
|
|
1078
|
-
"line-color": "#06b6d4",
|
|
1079
|
-
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
1080
|
-
"line-dasharray": [4, 2]
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
// Selection highlight for polygons - bright cyan dashed outline
|
|
1084
|
-
case "polygon-selection":
|
|
1085
|
-
return {
|
|
1086
|
-
id,
|
|
1087
|
-
type: "line",
|
|
1088
|
-
source: sourceId,
|
|
1089
|
-
filter: ["all", ["==", "$type", "Polygon"], ["==", "isSelected", 1]],
|
|
1090
|
-
paint: {
|
|
1091
|
-
"line-color": "#06b6d4",
|
|
1092
|
-
"line-width": 4,
|
|
1093
|
-
"line-dasharray": [4, 2]
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
1055
|
// Label layer for all features - shows 'name' property, or 'text' for text features
|
|
1097
1056
|
// Trace labels are slightly bigger and bolder, hidden points have no labels
|
|
1098
1057
|
// Arrow labels are handled separately by the custom-arrow-labels layer.
|
|
@@ -1118,8 +1077,11 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1118
1077
|
//
|
|
1119
1078
|
// The fix has two parts:
|
|
1120
1079
|
// 1. (here) Re-enable collision and use `symbol-sort-key` to control
|
|
1121
|
-
// intra-layer priority.
|
|
1122
|
-
// ordinary points so they keep their labels when crowded.
|
|
1080
|
+
// intra-layer priority. Text/trace features win against
|
|
1081
|
+
// ordinary points so they keep their labels when crowded. A
|
|
1082
|
+
// selected feature's label is drawn by the selection overlay;
|
|
1083
|
+
// its copy here is hidden through `text-opacity` but still
|
|
1084
|
+
// laid out, so it claims the same collision space as before.
|
|
1123
1085
|
// 2. (see `moveLabelsBeforeBasemapSymbols` in the canvas) After each
|
|
1124
1086
|
// basemap load, move the label layers BEFORE basemap symbol layers
|
|
1125
1087
|
// in the style stack. MapLibre processes collision in painter
|
|
@@ -1137,7 +1099,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1137
1099
|
// Computed per-feature in styleFeatureForPaint.
|
|
1138
1100
|
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
1139
1101
|
},
|
|
1140
|
-
paint: buildCustomLabelPaint()
|
|
1102
|
+
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1141
1103
|
};
|
|
1142
1104
|
// Pinned twin of the labels layer for layers with visualConfig.label.neverHide.
|
|
1143
1105
|
// text-allow-overlap / text-ignore-placement are data-constant in MapLibre
|
|
@@ -1163,7 +1125,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1163
1125
|
// (low-priority-value) labels draw over their neighbours' halos.
|
|
1164
1126
|
"symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
|
|
1165
1127
|
},
|
|
1166
|
-
paint: buildCustomLabelPaint()
|
|
1128
|
+
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1167
1129
|
};
|
|
1168
1130
|
}
|
|
1169
1131
|
}
|
|
@@ -1214,7 +1176,7 @@ function resolveShardSize(value) {
|
|
|
1214
1176
|
}
|
|
1215
1177
|
return Math.floor(value);
|
|
1216
1178
|
}
|
|
1217
|
-
function buildShardFingerprint(layer, features,
|
|
1179
|
+
function buildShardFingerprint(layer, features, shardSize) {
|
|
1218
1180
|
return {
|
|
1219
1181
|
features,
|
|
1220
1182
|
visualConfig: layer.visualConfig,
|
|
@@ -1222,36 +1184,30 @@ function buildShardFingerprint(layer, features, selectionEnabled, shardSize) {
|
|
|
1222
1184
|
clusterConfig: layer.clusterConfig,
|
|
1223
1185
|
altitudeDisplayMode: layer.altitudeDisplayMode,
|
|
1224
1186
|
hasAltitudeData: layer.hasAltitudeData,
|
|
1225
|
-
selectionEnabled,
|
|
1226
1187
|
shardSize
|
|
1227
1188
|
};
|
|
1228
1189
|
}
|
|
1229
1190
|
function shardFingerprintsEqual(a, b) {
|
|
1230
1191
|
if (!a || !b) return false;
|
|
1231
|
-
return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.
|
|
1192
|
+
return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.shardSize, b.shardSize);
|
|
1232
1193
|
}
|
|
1233
|
-
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1234
1194
|
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1235
1195
|
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1236
1196
|
function createSelectionPaintCache() {
|
|
1237
1197
|
return {
|
|
1238
1198
|
presentIds: /* @__PURE__ */ new Set(),
|
|
1239
|
-
appliedSelectedIds: /* @__PURE__ */ new Set(),
|
|
1240
|
-
basePriorityById: /* @__PURE__ */ new Map(),
|
|
1241
1199
|
appliedHiddenIds: /* @__PURE__ */ new Set(),
|
|
1242
1200
|
visibleStrokeOpacityById: /* @__PURE__ */ new Map(),
|
|
1243
1201
|
visibleFillOpacityById: /* @__PURE__ */ new Map(),
|
|
1244
1202
|
updatable: true
|
|
1245
1203
|
};
|
|
1246
1204
|
}
|
|
1247
|
-
function recordPaintedFeature(cache2, featureId,
|
|
1205
|
+
function recordPaintedFeature(cache2, featureId, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
1248
1206
|
if (cache2.presentIds.has(featureId)) {
|
|
1249
1207
|
cache2.updatable = false;
|
|
1250
1208
|
} else {
|
|
1251
1209
|
cache2.presentIds.add(featureId);
|
|
1252
1210
|
}
|
|
1253
|
-
cache2.basePriorityById.set(featureId, basePriority);
|
|
1254
|
-
if (isSelected) cache2.appliedSelectedIds.add(featureId);
|
|
1255
1211
|
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
1256
1212
|
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
1257
1213
|
}
|
|
@@ -1260,52 +1216,9 @@ function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visib
|
|
|
1260
1216
|
}
|
|
1261
1217
|
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
1262
1218
|
}
|
|
1263
|
-
function applySelectionFastPath(cache2, nextSelectedIds, source) {
|
|
1264
|
-
if (!cache2 || !cache2.updatable || !source) return false;
|
|
1265
|
-
const diff = buildSelectionDiff(cache2, nextSelectedIds);
|
|
1266
|
-
if (diff) {
|
|
1267
|
-
try {
|
|
1268
|
-
source.updateData(diff);
|
|
1269
|
-
} catch {
|
|
1270
|
-
return false;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
const applied = /* @__PURE__ */ new Set();
|
|
1274
|
-
nextSelectedIds.forEach((id) => {
|
|
1275
|
-
if (cache2.presentIds.has(id)) applied.add(id);
|
|
1276
|
-
});
|
|
1277
|
-
cache2.appliedSelectedIds = applied;
|
|
1278
|
-
return true;
|
|
1279
|
-
}
|
|
1280
1219
|
function needsDrawSelectionUpdate(input) {
|
|
1281
1220
|
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
1282
1221
|
}
|
|
1283
|
-
function buildSelectionDiff(cache2, nextSelectedIds) {
|
|
1284
|
-
const update = [];
|
|
1285
|
-
cache2.appliedSelectedIds.forEach((id) => {
|
|
1286
|
-
if (!nextSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
1287
|
-
update.push({
|
|
1288
|
-
id,
|
|
1289
|
-
addOrUpdateProperties: [
|
|
1290
|
-
{ key: "isSelected", value: 0 },
|
|
1291
|
-
{ key: "_labelPriority", value: cache2.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
|
|
1292
|
-
]
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
nextSelectedIds.forEach((id) => {
|
|
1297
|
-
if (!cache2.appliedSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
1298
|
-
update.push({
|
|
1299
|
-
id,
|
|
1300
|
-
addOrUpdateProperties: [
|
|
1301
|
-
{ key: "isSelected", value: 1 },
|
|
1302
|
-
{ key: "_labelPriority", value: 0 }
|
|
1303
|
-
]
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
});
|
|
1307
|
-
return update.length > 0 ? { update } : null;
|
|
1308
|
-
}
|
|
1309
1222
|
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
1310
1223
|
const update = [];
|
|
1311
1224
|
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
@@ -1349,7 +1262,6 @@ function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
|
1349
1262
|
cache2.appliedHiddenIds = nextHiddenIds;
|
|
1350
1263
|
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
1351
1264
|
}
|
|
1352
|
-
const EMPTY_COLLECTION = { type: "FeatureCollection", features: [] };
|
|
1353
1265
|
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
1354
1266
|
function createShardRegistry(host, hooks) {
|
|
1355
1267
|
const states = /* @__PURE__ */ new Map();
|
|
@@ -1382,7 +1294,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1382
1294
|
};
|
|
1383
1295
|
const createStack = (state, index, roles, data) => {
|
|
1384
1296
|
const sourceId = shardSourceId(state.layerId, index);
|
|
1385
|
-
host.addSource(sourceId,
|
|
1297
|
+
host.addSource(sourceId, customSourceSpec());
|
|
1386
1298
|
const specs = buildCustomLayerStack(sourceId, roles, { labelsVisible: hooks.labelsVisible() });
|
|
1387
1299
|
const ordered = CUSTOM_LAYER_ROLES.filter((role) => roles.includes(role));
|
|
1388
1300
|
const layerIds = [];
|
|
@@ -1523,7 +1435,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1523
1435
|
}
|
|
1524
1436
|
};
|
|
1525
1437
|
}
|
|
1526
|
-
function reconcileShardCaches(registry, layerId, expectedShards,
|
|
1438
|
+
function reconcileShardCaches(registry, layerId, expectedShards, visibleIds) {
|
|
1527
1439
|
const state = registry.state(layerId);
|
|
1528
1440
|
if (!state || state.stacks.length !== expectedShards) return false;
|
|
1529
1441
|
for (let i = 0; i < expectedShards; i++) {
|
|
@@ -1532,7 +1444,6 @@ function reconcileShardCaches(registry, layerId, expectedShards, selectedIds, vi
|
|
|
1532
1444
|
const source = registry.sourceFor(layerId, i);
|
|
1533
1445
|
if (!source) return false;
|
|
1534
1446
|
if (!applyTimelineFastPath(cache2, visibleIds, source).applied) return false;
|
|
1535
|
-
if (!applySelectionFastPath(cache2, selectedIds, source)) return false;
|
|
1536
1447
|
}
|
|
1537
1448
|
return true;
|
|
1538
1449
|
}
|
|
@@ -1787,7 +1698,7 @@ const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
|
1787
1698
|
const TRACE_POINT_RADIUS = 2;
|
|
1788
1699
|
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
1789
1700
|
function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
1790
|
-
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: []
|
|
1701
|
+
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [] };
|
|
1791
1702
|
const paintedVisible = (id) => !paint.appliedHiddenIds.has(id);
|
|
1792
1703
|
const nextVisible = timelineVisibility(nextVisibleSet);
|
|
1793
1704
|
trace.groups.forEach((group, groupIndex) => {
|
|
@@ -1796,8 +1707,8 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
|
1796
1707
|
const prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
1797
1708
|
const nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
1798
1709
|
if (prevEndpoint !== nextEndpoint) {
|
|
1799
|
-
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace,
|
|
1800
|
-
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace,
|
|
1710
|
+
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[prevEndpoint], false);
|
|
1711
|
+
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[nextEndpoint], true);
|
|
1801
1712
|
}
|
|
1802
1713
|
diffConsecutivePairs(
|
|
1803
1714
|
prev,
|
|
@@ -1808,21 +1719,19 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
|
1808
1719
|
});
|
|
1809
1720
|
return diff;
|
|
1810
1721
|
}
|
|
1811
|
-
function pushEndpointUpdate(diff, trace,
|
|
1722
|
+
function pushEndpointUpdate(diff, trace, group, id, isEndpoint) {
|
|
1812
1723
|
const point2 = trace.pointPaint.get(id);
|
|
1813
1724
|
if (!point2) return;
|
|
1814
1725
|
const labelled = isEndpoint && group.label !== null;
|
|
1815
|
-
const basePriority = labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point2.basePriority;
|
|
1816
1726
|
diff.pointUpdates.push({
|
|
1817
1727
|
id,
|
|
1818
1728
|
addOrUpdateProperties: [
|
|
1819
1729
|
{ key: "pointRadius", value: isEndpoint ? point2.endpointRadius : TRACE_POINT_RADIUS },
|
|
1820
1730
|
{ key: "name", value: labelled ? group.label : point2.name },
|
|
1821
1731
|
{ key: "isTraceLabel", value: labelled },
|
|
1822
|
-
{ key: "_labelPriority", value:
|
|
1732
|
+
{ key: "_labelPriority", value: labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point2.basePriority }
|
|
1823
1733
|
]
|
|
1824
1734
|
});
|
|
1825
|
-
diff.basePriorities.push([id, basePriority]);
|
|
1826
1735
|
}
|
|
1827
1736
|
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
1828
1737
|
let i = 0;
|
|
@@ -1844,7 +1753,7 @@ function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
|
1844
1753
|
}
|
|
1845
1754
|
}
|
|
1846
1755
|
}
|
|
1847
|
-
function applyTraceTimelineDiff(diff,
|
|
1756
|
+
function applyTraceTimelineDiff(diff, pointSource, segmentSource) {
|
|
1848
1757
|
try {
|
|
1849
1758
|
if (diff.pointUpdates.length > 0) pointSource.updateData({ update: diff.pointUpdates });
|
|
1850
1759
|
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
@@ -1854,9 +1763,9 @@ function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
|
|
|
1854
1763
|
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
1855
1764
|
return false;
|
|
1856
1765
|
}
|
|
1857
|
-
diff.basePriorities.forEach(([id, priority]) => paint.basePriorityById.set(id, priority));
|
|
1858
1766
|
return true;
|
|
1859
1767
|
}
|
|
1768
|
+
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1860
1769
|
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
1861
1770
|
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
1862
1771
|
"kind",
|
|
@@ -1964,7 +1873,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1964
1873
|
});
|
|
1965
1874
|
}
|
|
1966
1875
|
}
|
|
1967
|
-
const isFeatureSelected = ctx.selectionEnabled && ctx.selectedIds.has(featureId) ? 1 : 0;
|
|
1968
1876
|
let nonTracePriority = DEFAULT_LABEL_PRIORITY;
|
|
1969
1877
|
if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
1970
1878
|
nonTracePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
@@ -1977,8 +1885,7 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1977
1885
|
}
|
|
1978
1886
|
nonTracePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
1979
1887
|
}
|
|
1980
|
-
const
|
|
1981
|
-
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
1888
|
+
const labelPriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
1982
1889
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
1983
1890
|
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
1984
1891
|
return {
|
|
@@ -1992,7 +1899,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1992
1899
|
// Override with computed visual properties
|
|
1993
1900
|
id: featureId,
|
|
1994
1901
|
name: labelText,
|
|
1995
|
-
isSelected: isFeatureSelected,
|
|
1996
1902
|
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
1997
1903
|
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
1998
1904
|
isTracePoint: isTracePoint ? true : false,
|
|
@@ -2012,8 +1918,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2012
1918
|
},
|
|
2013
1919
|
paint: {
|
|
2014
1920
|
featureId,
|
|
2015
|
-
basePriority,
|
|
2016
|
-
selected: isFeatureSelected === 1,
|
|
2017
1921
|
visibleStrokeOpacity,
|
|
2018
1922
|
visibleFillOpacity,
|
|
2019
1923
|
timelineHidden: !isTimelineVisible
|
|
@@ -2068,15 +1972,7 @@ async function runShardPass(input) {
|
|
|
2068
1972
|
var _a2;
|
|
2069
1973
|
const styled = styleFeatureForPaint(f, layer, ctx, true);
|
|
2070
1974
|
const p = styled.paint;
|
|
2071
|
-
recordPaintedFeature(
|
|
2072
|
-
cache2,
|
|
2073
|
-
p.featureId,
|
|
2074
|
-
p.basePriority,
|
|
2075
|
-
p.selected,
|
|
2076
|
-
p.visibleStrokeOpacity,
|
|
2077
|
-
p.visibleFillOpacity,
|
|
2078
|
-
p.timelineHidden
|
|
2079
|
-
);
|
|
1975
|
+
recordPaintedFeature(cache2, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
2080
1976
|
if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
|
|
2081
1977
|
shardArrows.push(styled.feature);
|
|
2082
1978
|
}
|
|
@@ -5499,10 +5395,10 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
5499
5395
|
// NOTE: 'description' intentionally NOT excluded — we surface it as a regular
|
|
5500
5396
|
// property row instead of giving it its own labelled section.
|
|
5501
5397
|
]);
|
|
5502
|
-
function buildKeyExclusionPredicate(
|
|
5503
|
-
const lowered = new Set(Array.from(
|
|
5398
|
+
function buildKeyExclusionPredicate(set2) {
|
|
5399
|
+
const lowered = new Set(Array.from(set2, (k) => k.toLowerCase()));
|
|
5504
5400
|
return (key) => {
|
|
5505
|
-
if (
|
|
5401
|
+
if (set2.has(key)) return true;
|
|
5506
5402
|
const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
|
|
5507
5403
|
return lowered.has(normalized);
|
|
5508
5404
|
};
|
|
@@ -7056,7 +6952,7 @@ function computeHistogramBins(features, minDate, maxDate, binCount = 50) {
|
|
|
7056
6952
|
});
|
|
7057
6953
|
return bins;
|
|
7058
6954
|
}
|
|
7059
|
-
const timelineStoreInitializer = (
|
|
6955
|
+
const timelineStoreInitializer = (set2, get) => ({
|
|
7060
6956
|
isEnabled: false,
|
|
7061
6957
|
hasTemporalData: false,
|
|
7062
6958
|
temporalFeatures: [],
|
|
@@ -7067,17 +6963,18 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7067
6963
|
rangeEnd: null,
|
|
7068
6964
|
isPlaying: false,
|
|
7069
6965
|
playbackSpeed: 1,
|
|
6966
|
+
playMode: "sliding",
|
|
7070
6967
|
histogramBins: [],
|
|
7071
6968
|
setEnabled: (enabled) => {
|
|
7072
6969
|
if (enabled) {
|
|
7073
6970
|
const state = get();
|
|
7074
|
-
|
|
6971
|
+
set2({
|
|
7075
6972
|
isEnabled: true,
|
|
7076
6973
|
rangeStart: state.globalMinDate,
|
|
7077
6974
|
rangeEnd: state.globalMaxDate
|
|
7078
6975
|
});
|
|
7079
6976
|
} else {
|
|
7080
|
-
|
|
6977
|
+
set2({ isEnabled: false, isPlaying: false });
|
|
7081
6978
|
}
|
|
7082
6979
|
},
|
|
7083
6980
|
setTemporalFeatures: (features, untimedIds) => {
|
|
@@ -7086,7 +6983,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7086
6983
|
const state = get();
|
|
7087
6984
|
if (timedFeatures.length === 0) {
|
|
7088
6985
|
if (!state.hasTemporalData && state.temporalFeatures.length === 0) return;
|
|
7089
|
-
|
|
6986
|
+
set2({
|
|
7090
6987
|
hasTemporalData: false,
|
|
7091
6988
|
temporalFeatures: [],
|
|
7092
6989
|
untimedFeatureIds: untimedIds,
|
|
@@ -7108,12 +7005,16 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7108
7005
|
});
|
|
7109
7006
|
const computedMin = minDate;
|
|
7110
7007
|
const computedMax = maxDate;
|
|
7111
|
-
const
|
|
7008
|
+
const sameFeatures = state.temporalFeatures.length === timedFeatures.length && timedFeatures.every((f, i) => {
|
|
7009
|
+
var _a2, _b2, _c, _d;
|
|
7010
|
+
const prev = state.temporalFeatures[i];
|
|
7011
|
+
return f.id === prev.id && ((_a2 = f.startDate) == null ? void 0 : _a2.getTime()) === ((_b2 = prev.startDate) == null ? void 0 : _b2.getTime()) && ((_c = f.endDate) == null ? void 0 : _c.getTime()) === ((_d = prev.endDate) == null ? void 0 : _d.getTime());
|
|
7012
|
+
});
|
|
7112
7013
|
const sameDates = ((_a = state.globalMinDate) == null ? void 0 : _a.getTime()) === (computedMin == null ? void 0 : computedMin.getTime()) && ((_b = state.globalMaxDate) == null ? void 0 : _b.getTime()) === (computedMax == null ? void 0 : computedMax.getTime());
|
|
7113
7014
|
const sameUntimed = state.untimedFeatureIds.length === untimedIds.length && untimedIds.every((id, i) => id === state.untimedFeatureIds[i]);
|
|
7114
|
-
if (
|
|
7015
|
+
if (sameFeatures && sameDates && sameUntimed && state.hasTemporalData) return;
|
|
7115
7016
|
const histogramBins = minDate && maxDate ? computeHistogramBins(timedFeatures, minDate, maxDate) : [];
|
|
7116
|
-
|
|
7017
|
+
set2({
|
|
7117
7018
|
hasTemporalData: true,
|
|
7118
7019
|
temporalFeatures: timedFeatures,
|
|
7119
7020
|
untimedFeatureIds: untimedIds,
|
|
@@ -7124,9 +7025,10 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7124
7025
|
histogramBins
|
|
7125
7026
|
});
|
|
7126
7027
|
},
|
|
7127
|
-
setRange: (start, end) =>
|
|
7128
|
-
setPlaying: (playing) =>
|
|
7129
|
-
setPlaybackSpeed: (speed) =>
|
|
7028
|
+
setRange: (start, end) => set2({ rangeStart: start, rangeEnd: end }),
|
|
7029
|
+
setPlaying: (playing) => set2({ isPlaying: playing }),
|
|
7030
|
+
setPlaybackSpeed: (speed) => set2({ playbackSpeed: speed }),
|
|
7031
|
+
setPlayMode: (mode) => set2({ playMode: mode }),
|
|
7130
7032
|
advancePlayhead: () => {
|
|
7131
7033
|
const state = get();
|
|
7132
7034
|
if (!state.globalMinDate || !state.globalMaxDate || !state.rangeStart) {
|
|
@@ -7137,20 +7039,20 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7137
7039
|
const newStart = new Date(state.rangeStart.getTime() + stepSize);
|
|
7138
7040
|
const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepSize) : null;
|
|
7139
7041
|
if (newStart >= state.globalMaxDate) {
|
|
7140
|
-
|
|
7042
|
+
set2({
|
|
7141
7043
|
isPlaying: false,
|
|
7142
7044
|
rangeStart: state.globalMinDate,
|
|
7143
7045
|
rangeEnd: state.globalMaxDate
|
|
7144
7046
|
});
|
|
7145
7047
|
return false;
|
|
7146
7048
|
}
|
|
7147
|
-
|
|
7049
|
+
set2({
|
|
7148
7050
|
rangeStart: newStart,
|
|
7149
7051
|
rangeEnd: newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate
|
|
7150
7052
|
});
|
|
7151
7053
|
return true;
|
|
7152
7054
|
},
|
|
7153
|
-
reset: () =>
|
|
7055
|
+
reset: () => set2({
|
|
7154
7056
|
isEnabled: false,
|
|
7155
7057
|
hasTemporalData: false,
|
|
7156
7058
|
temporalFeatures: [],
|
|
@@ -7170,7 +7072,7 @@ const TimelineStoreContext = createContext(null);
|
|
|
7170
7072
|
function useTimelineStoreApi() {
|
|
7171
7073
|
const store = useContext(TimelineStoreContext);
|
|
7172
7074
|
if (!store) {
|
|
7173
|
-
throw new Error("useTimelineStoreApi must be used within a MapEditorCanvas
|
|
7075
|
+
throw new Error("useTimelineStoreApi must be used within a MapEditorCanvas or a TimelineStoreContext.Provider");
|
|
7174
7076
|
}
|
|
7175
7077
|
return store;
|
|
7176
7078
|
}
|
|
@@ -7182,6 +7084,12 @@ function useTimelineStore(selector) {
|
|
|
7182
7084
|
}
|
|
7183
7085
|
const TIMEBAR_HEIGHT = 158;
|
|
7184
7086
|
const TIMEBAR_BOTTOM_OFFSET = 12;
|
|
7087
|
+
const DEFAULT_LABELS = {
|
|
7088
|
+
play: "Play",
|
|
7089
|
+
pause: "Pause",
|
|
7090
|
+
reset: "Reset timeline",
|
|
7091
|
+
cumulative: "Cumulative: keep what has appeared"
|
|
7092
|
+
};
|
|
7185
7093
|
const MINUTE_MS = 6e4;
|
|
7186
7094
|
const HOUR_MS = 36e5;
|
|
7187
7095
|
const DAY_MS = 864e5;
|
|
@@ -7330,7 +7238,7 @@ function Histogram({ bins, maxCount, colorGroupedBins }) {
|
|
|
7330
7238
|
const containerRef = useRef(null);
|
|
7331
7239
|
if (bins.length === 0 || maxCount === 0) return null;
|
|
7332
7240
|
const hasColorGroups = colorGroupedBins && colorGroupedBins.length > 0 && colorGroupedBins.some((group) => group.bins.some((count) => count > 0));
|
|
7333
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative h-16", ref: containerRef, children: [
|
|
7241
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative h-16", ref: containerRef, "data-testid": "timebar-histogram", children: [
|
|
7334
7242
|
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-end gap-px", children: bins.map((bin, i) => {
|
|
7335
7243
|
const height = bin.count / maxCount * 100;
|
|
7336
7244
|
const isHovered = hoveredBin === i;
|
|
@@ -7405,7 +7313,17 @@ function TimebarToggle({ onClick, hasData }) {
|
|
|
7405
7313
|
}
|
|
7406
7314
|
);
|
|
7407
7315
|
}
|
|
7408
|
-
function Timebar({
|
|
7316
|
+
function Timebar({
|
|
7317
|
+
onFilterChange,
|
|
7318
|
+
selectedFeatureIds = [],
|
|
7319
|
+
selectedFeatureColors,
|
|
7320
|
+
selectionDisplay = "bars",
|
|
7321
|
+
className,
|
|
7322
|
+
timebarExtra,
|
|
7323
|
+
formatCount: formatCount2,
|
|
7324
|
+
labels: labelOverrides
|
|
7325
|
+
}) {
|
|
7326
|
+
const labels = { ...DEFAULT_LABELS, ...labelOverrides };
|
|
7409
7327
|
const {
|
|
7410
7328
|
isEnabled,
|
|
7411
7329
|
hasTemporalData,
|
|
@@ -7416,19 +7334,22 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
7416
7334
|
rangeStart,
|
|
7417
7335
|
rangeEnd,
|
|
7418
7336
|
isPlaying,
|
|
7337
|
+
playMode,
|
|
7419
7338
|
histogramBins: storeHistogramBins,
|
|
7420
7339
|
setRange,
|
|
7421
|
-
setPlaying
|
|
7340
|
+
setPlaying,
|
|
7341
|
+
setPlayMode
|
|
7422
7342
|
} = useTimelineStore();
|
|
7423
7343
|
const timelineStoreApi = useTimelineStoreApi();
|
|
7424
7344
|
const hasSelection = selectedFeatureIds.length > 0;
|
|
7345
|
+
const selectionAsLine = hasSelection && selectionDisplay === "line";
|
|
7425
7346
|
const selectedTemporalFeatures = useMemo(() => {
|
|
7426
7347
|
if (!hasSelection) return temporalFeatures;
|
|
7427
7348
|
const selectedSet = new Set(selectedFeatureIds);
|
|
7428
7349
|
return temporalFeatures.filter((f) => selectedSet.has(f.id));
|
|
7429
7350
|
}, [hasSelection, selectedFeatureIds, temporalFeatures]);
|
|
7430
7351
|
const histogramBins = useMemo(() => {
|
|
7431
|
-
if (!hasSelection || storeHistogramBins.length === 0) return storeHistogramBins;
|
|
7352
|
+
if (!hasSelection || selectionAsLine || storeHistogramBins.length === 0) return storeHistogramBins;
|
|
7432
7353
|
return storeHistogramBins.map((bin, binIndex) => {
|
|
7433
7354
|
const isLastBin = binIndex === storeHistogramBins.length - 1;
|
|
7434
7355
|
let count = 0;
|
|
@@ -7441,16 +7362,16 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
7441
7362
|
}
|
|
7442
7363
|
return { ...bin, count };
|
|
7443
7364
|
});
|
|
7444
|
-
}, [hasSelection, storeHistogramBins, selectedTemporalFeatures]);
|
|
7445
|
-
const colorGroupedBins = histogramBins.length > 0 && hasSelection && selectedFeatureColors && selectedFeatureColors.size > 0 && globalMinDate && globalMaxDate ? (() => {
|
|
7365
|
+
}, [hasSelection, selectionAsLine, storeHistogramBins, selectedTemporalFeatures]);
|
|
7366
|
+
const colorGroupedBins = histogramBins.length > 0 && hasSelection && (selectionAsLine || selectedFeatureColors && selectedFeatureColors.size > 0) && globalMinDate && globalMaxDate ? (() => {
|
|
7446
7367
|
if (selectedTemporalFeatures.length === 0) return [];
|
|
7447
7368
|
const colorGroups = /* @__PURE__ */ new Map();
|
|
7448
7369
|
selectedTemporalFeatures.forEach((f) => {
|
|
7449
|
-
const color = selectedFeatureColors.get(f.id) || "#3b82f6";
|
|
7370
|
+
const color = (selectedFeatureColors == null ? void 0 : selectedFeatureColors.get(f.id)) || "#3b82f6";
|
|
7450
7371
|
if (!colorGroups.has(color)) colorGroups.set(color, []);
|
|
7451
7372
|
colorGroups.get(color).push(f);
|
|
7452
7373
|
});
|
|
7453
|
-
if (colorGroups.size <= 1) return [];
|
|
7374
|
+
if (!selectionAsLine && colorGroups.size <= 1) return [];
|
|
7454
7375
|
const result = [];
|
|
7455
7376
|
colorGroups.forEach((features, color) => {
|
|
7456
7377
|
const bins = histogramBins.map((bin, binIndex) => {
|
|
@@ -7509,14 +7430,24 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
7509
7430
|
setPlaying(false);
|
|
7510
7431
|
return;
|
|
7511
7432
|
}
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7433
|
+
if (state.playMode === "cumulative") {
|
|
7434
|
+
const grown = new Date((state.rangeEnd ?? state.rangeStart).getTime() + stepPerFrame);
|
|
7435
|
+
if (grown >= state.globalMaxDate) {
|
|
7436
|
+
setRange(state.rangeStart, state.globalMaxDate);
|
|
7437
|
+
setPlaying(false);
|
|
7438
|
+
return;
|
|
7439
|
+
}
|
|
7440
|
+
setRange(state.rangeStart, grown);
|
|
7441
|
+
} else {
|
|
7442
|
+
const newStart = new Date(state.rangeStart.getTime() + stepPerFrame);
|
|
7443
|
+
const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepPerFrame) : null;
|
|
7444
|
+
if (newStart >= state.globalMaxDate) {
|
|
7445
|
+
setRange(state.globalMinDate, state.globalMaxDate);
|
|
7446
|
+
setPlaying(false);
|
|
7447
|
+
return;
|
|
7448
|
+
}
|
|
7449
|
+
setRange(newStart, newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate);
|
|
7518
7450
|
}
|
|
7519
|
-
setRange(newStart, newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate);
|
|
7520
7451
|
}
|
|
7521
7452
|
animationFrameRef.current = requestAnimationFrame(animate);
|
|
7522
7453
|
};
|
|
@@ -7547,11 +7478,17 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
7547
7478
|
setPlaying(false);
|
|
7548
7479
|
};
|
|
7549
7480
|
const handlePlayPause = () => {
|
|
7550
|
-
if (!isPlaying &&
|
|
7481
|
+
if (!isPlaying && playMode === "cumulative") {
|
|
7482
|
+
if (!rangeEnd || rangeEnd >= globalMaxDate) {
|
|
7483
|
+
const from = rangeStart && rangeStart < globalMaxDate ? rangeStart : globalMinDate;
|
|
7484
|
+
setRange(from, from);
|
|
7485
|
+
}
|
|
7486
|
+
} else if (!isPlaying && rangeStart && rangeStart >= globalMaxDate) {
|
|
7551
7487
|
setRange(globalMinDate, globalMaxDate);
|
|
7552
7488
|
}
|
|
7553
7489
|
setPlaying(!isPlaying);
|
|
7554
7490
|
};
|
|
7491
|
+
const cumulative = playMode === "cumulative";
|
|
7555
7492
|
return /* @__PURE__ */ jsxs(
|
|
7556
7493
|
"div",
|
|
7557
7494
|
{
|
|
@@ -7599,7 +7536,7 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
7599
7536
|
size: "small",
|
|
7600
7537
|
icon: /* @__PURE__ */ jsx(SkipBack, { className: "w-3.5 h-3.5" }),
|
|
7601
7538
|
onClick: handleReset,
|
|
7602
|
-
"aria-label":
|
|
7539
|
+
"aria-label": labels.reset,
|
|
7603
7540
|
"data-testid": "button-timeline-reset",
|
|
7604
7541
|
className: "!h-7 !w-7 !p-0 !min-w-0"
|
|
7605
7542
|
}
|
|
@@ -7611,17 +7548,34 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
|
|
|
7611
7548
|
size: "small",
|
|
7612
7549
|
icon: isPlaying ? /* @__PURE__ */ jsx(Pause, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsx(Play, { className: "w-3.5 h-3.5" }),
|
|
7613
7550
|
onClick: handlePlayPause,
|
|
7614
|
-
"aria-label": isPlaying ?
|
|
7551
|
+
"aria-label": isPlaying ? labels.pause : labels.play,
|
|
7615
7552
|
"data-testid": "button-timeline-play",
|
|
7616
7553
|
className: "!h-7 !w-7 !p-0 !min-w-0"
|
|
7617
7554
|
}
|
|
7618
7555
|
),
|
|
7556
|
+
/* @__PURE__ */ jsx(Tooltip, { title: labels.cumulative, children: /* @__PURE__ */ jsx(
|
|
7557
|
+
Button,
|
|
7558
|
+
{
|
|
7559
|
+
size: "small",
|
|
7560
|
+
color: cumulative ? "primary" : "default",
|
|
7561
|
+
variant: cumulative ? "filled" : "text",
|
|
7562
|
+
icon: /* @__PURE__ */ jsx(Layers, { className: "w-3.5 h-3.5" }),
|
|
7563
|
+
onClick: () => setPlayMode(cumulative ? "sliding" : "cumulative"),
|
|
7564
|
+
"aria-label": labels.cumulative,
|
|
7565
|
+
"aria-pressed": cumulative,
|
|
7566
|
+
"data-testid": "button-timeline-cumulative",
|
|
7567
|
+
className: "!h-7 !w-7 !p-0 !min-w-0"
|
|
7568
|
+
}
|
|
7569
|
+
) }),
|
|
7619
7570
|
/* @__PURE__ */ jsx(
|
|
7620
7571
|
"span",
|
|
7621
7572
|
{
|
|
7622
7573
|
className: "text-xs text-muted-foreground ml-1",
|
|
7623
7574
|
"data-testid": "text-timeline-feature-count",
|
|
7624
|
-
children:
|
|
7575
|
+
children: formatCount2 ? formatCount2({
|
|
7576
|
+
total: temporalFeatures.length,
|
|
7577
|
+
selected: hasSelection ? selectedTemporalFeatures.length : null
|
|
7578
|
+
}) : hasSelection ? `${selectedTemporalFeatures.length} of ${temporalFeatures.length} selected` : `${temporalFeatures.length} feature${temporalFeatures.length !== 1 ? "s" : ""}`
|
|
7625
7579
|
}
|
|
7626
7580
|
)
|
|
7627
7581
|
] }),
|
|
@@ -7928,6 +7882,129 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
|
7928
7882
|
}
|
|
7929
7883
|
};
|
|
7930
7884
|
}
|
|
7885
|
+
const EMPTY = /* @__PURE__ */ new Set();
|
|
7886
|
+
function isLive(host, entry) {
|
|
7887
|
+
return host.source(entry.sourceId) === entry.handle;
|
|
7888
|
+
}
|
|
7889
|
+
function remove(host, entry, id) {
|
|
7890
|
+
if (!isLive(host, entry)) return false;
|
|
7891
|
+
host.removeFeatureState(entry.sourceId, id);
|
|
7892
|
+
return true;
|
|
7893
|
+
}
|
|
7894
|
+
function set(host, sourceId, id) {
|
|
7895
|
+
const handle = host.source(sourceId);
|
|
7896
|
+
if (!handle) return null;
|
|
7897
|
+
host.setFeatureState(sourceId, id, SELECTED_STATE);
|
|
7898
|
+
return { sourceId, handle };
|
|
7899
|
+
}
|
|
7900
|
+
function setAll(host, sourceIds, id) {
|
|
7901
|
+
const done = [];
|
|
7902
|
+
sourceIds.forEach((sourceId) => {
|
|
7903
|
+
const entry = set(host, sourceId, id);
|
|
7904
|
+
if (entry) done.push(entry);
|
|
7905
|
+
});
|
|
7906
|
+
return done;
|
|
7907
|
+
}
|
|
7908
|
+
function place(applied, id, sources, host) {
|
|
7909
|
+
const done = setAll(host, sources, id);
|
|
7910
|
+
if (done.length > 0) applied.set(id, done);
|
|
7911
|
+
return done.length;
|
|
7912
|
+
}
|
|
7913
|
+
function applySelectionState(applied, next, gate, locate, host) {
|
|
7914
|
+
const target = gate ? next : EMPTY;
|
|
7915
|
+
let setCount = 0;
|
|
7916
|
+
let removed = 0;
|
|
7917
|
+
const gone = [];
|
|
7918
|
+
applied.forEach((_sources, id) => {
|
|
7919
|
+
if (!target.has(id)) gone.push(id);
|
|
7920
|
+
});
|
|
7921
|
+
gone.forEach((id) => {
|
|
7922
|
+
(applied.get(id) ?? []).forEach((entry) => {
|
|
7923
|
+
if (remove(host, entry, id)) removed++;
|
|
7924
|
+
});
|
|
7925
|
+
applied.delete(id);
|
|
7926
|
+
});
|
|
7927
|
+
target.forEach((id) => {
|
|
7928
|
+
if (applied.has(id)) return;
|
|
7929
|
+
setCount += place(applied, id, locate(id), host);
|
|
7930
|
+
});
|
|
7931
|
+
return { set: setCount, removed };
|
|
7932
|
+
}
|
|
7933
|
+
function reconcileSelectionSources(applied, locate, host) {
|
|
7934
|
+
let moved = 0;
|
|
7935
|
+
let pruned = 0;
|
|
7936
|
+
const changes = [];
|
|
7937
|
+
applied.forEach((have, id) => {
|
|
7938
|
+
const want = locate(id);
|
|
7939
|
+
const live = have.filter((entry) => isLive(host, entry));
|
|
7940
|
+
const same = want.length > 0 && live.length === have.length && want.every((sourceId) => live.some((entry) => entry.sourceId === sourceId));
|
|
7941
|
+
if (!same) changes.push({ id, have, live, want });
|
|
7942
|
+
});
|
|
7943
|
+
changes.forEach(({ id, have, live, want }) => {
|
|
7944
|
+
if (want.length === 0) {
|
|
7945
|
+
have.forEach((entry) => remove(host, entry, id));
|
|
7946
|
+
applied.delete(id);
|
|
7947
|
+
pruned++;
|
|
7948
|
+
return;
|
|
7949
|
+
}
|
|
7950
|
+
const missing = want.filter((sourceId) => !live.some((entry) => entry.sourceId === sourceId));
|
|
7951
|
+
const gained = setAll(host, missing, id);
|
|
7952
|
+
const now = [...live, ...gained];
|
|
7953
|
+
if (now.length > 0) applied.set(id, now);
|
|
7954
|
+
else applied.delete(id);
|
|
7955
|
+
if (gained.length > 0) moved++;
|
|
7956
|
+
});
|
|
7957
|
+
return { moved, pruned };
|
|
7958
|
+
}
|
|
7959
|
+
function createLocatorCache() {
|
|
7960
|
+
return /* @__PURE__ */ new WeakMap();
|
|
7961
|
+
}
|
|
7962
|
+
function indexOfIds(features, cache2) {
|
|
7963
|
+
const cached = cache2.get(features);
|
|
7964
|
+
if (cached) return cached;
|
|
7965
|
+
const index = { first: /* @__PURE__ */ new Map(), repeats: /* @__PURE__ */ new Map() };
|
|
7966
|
+
for (let i = 0; i < features.length; i++) {
|
|
7967
|
+
const id = features[i].id;
|
|
7968
|
+
if (id === void 0 || id === null) continue;
|
|
7969
|
+
const key = String(id);
|
|
7970
|
+
if (!index.first.has(key)) index.first.set(key, i);
|
|
7971
|
+
else {
|
|
7972
|
+
const more = index.repeats.get(key);
|
|
7973
|
+
if (more) more.push(i);
|
|
7974
|
+
else index.repeats.set(key, [i]);
|
|
7975
|
+
}
|
|
7976
|
+
}
|
|
7977
|
+
cache2.set(features, index);
|
|
7978
|
+
return index;
|
|
7979
|
+
}
|
|
7980
|
+
function forEachIndex(index, id, visit) {
|
|
7981
|
+
var _a;
|
|
7982
|
+
const at = index.first.get(id);
|
|
7983
|
+
if (at === void 0) return;
|
|
7984
|
+
visit(at);
|
|
7985
|
+
(_a = index.repeats.get(id)) == null ? void 0 : _a.forEach(visit);
|
|
7986
|
+
}
|
|
7987
|
+
function locateFeatureHolders(id, readOnly, cache2) {
|
|
7988
|
+
const holders = [];
|
|
7989
|
+
readOnly.forEach((features, layerId) => {
|
|
7990
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
|
|
7991
|
+
});
|
|
7992
|
+
return holders;
|
|
7993
|
+
}
|
|
7994
|
+
function locateFeatureSources(id, inputs, cache2) {
|
|
7995
|
+
const sources = [];
|
|
7996
|
+
const add = (sourceId) => {
|
|
7997
|
+
if (!sources.includes(sourceId)) sources.push(sourceId);
|
|
7998
|
+
};
|
|
7999
|
+
inputs.readOnly.forEach((features, layerId) => {
|
|
8000
|
+
const sharded = inputs.shardedLayerIds.has(layerId);
|
|
8001
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => {
|
|
8002
|
+
add(sharded ? shardSourceId(layerId, Math.floor(at / inputs.shardSize)) : SHARED_SOURCE_ID);
|
|
8003
|
+
});
|
|
8004
|
+
});
|
|
8005
|
+
if (sources.length === 0) add(SHARED_SOURCE_ID);
|
|
8006
|
+
return sources;
|
|
8007
|
+
}
|
|
7931
8008
|
function deepClone(value) {
|
|
7932
8009
|
try {
|
|
7933
8010
|
return structuredClone(value);
|
|
@@ -8190,6 +8267,93 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
8190
8267
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
8191
8268
|
return selectedIds;
|
|
8192
8269
|
}
|
|
8270
|
+
const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
|
|
8271
|
+
const SELECTION_OVERLAY_LAYER_IDS = {
|
|
8272
|
+
iconRing: "selection-overlay-icon-ring",
|
|
8273
|
+
line: "selection-overlay-line",
|
|
8274
|
+
polygon: "selection-overlay-polygon",
|
|
8275
|
+
label: "selection-overlay-label"
|
|
8276
|
+
};
|
|
8277
|
+
function buildSelectionOverlayStack() {
|
|
8278
|
+
const source = SELECTION_OVERLAY_SOURCE_ID;
|
|
8279
|
+
return [
|
|
8280
|
+
{
|
|
8281
|
+
id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
|
|
8282
|
+
type: "circle",
|
|
8283
|
+
source,
|
|
8284
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
|
|
8285
|
+
paint: {
|
|
8286
|
+
"circle-color": "transparent",
|
|
8287
|
+
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
8288
|
+
"circle-stroke-color": SELECTION_COLOR,
|
|
8289
|
+
"circle-stroke-width": 3,
|
|
8290
|
+
"circle-stroke-opacity": 1
|
|
8291
|
+
}
|
|
8292
|
+
},
|
|
8293
|
+
{
|
|
8294
|
+
id: SELECTION_OVERLAY_LAYER_IDS.line,
|
|
8295
|
+
type: "line",
|
|
8296
|
+
source,
|
|
8297
|
+
filter: ["==", "$type", "LineString"],
|
|
8298
|
+
paint: {
|
|
8299
|
+
"line-color": SELECTION_COLOR,
|
|
8300
|
+
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
8301
|
+
"line-dasharray": [4, 2]
|
|
8302
|
+
}
|
|
8303
|
+
},
|
|
8304
|
+
{
|
|
8305
|
+
id: SELECTION_OVERLAY_LAYER_IDS.polygon,
|
|
8306
|
+
type: "line",
|
|
8307
|
+
source,
|
|
8308
|
+
filter: ["==", "$type", "Polygon"],
|
|
8309
|
+
paint: {
|
|
8310
|
+
"line-color": SELECTION_COLOR,
|
|
8311
|
+
"line-width": 4,
|
|
8312
|
+
"line-dasharray": [4, 2]
|
|
8313
|
+
}
|
|
8314
|
+
},
|
|
8315
|
+
{
|
|
8316
|
+
id: SELECTION_OVERLAY_LAYER_IDS.label,
|
|
8317
|
+
type: "symbol",
|
|
8318
|
+
source,
|
|
8319
|
+
layout: {
|
|
8320
|
+
...buildCustomLabelLayout(),
|
|
8321
|
+
// Never hidden by the auto-label density cap, which only flips the
|
|
8322
|
+
// unpinned base layer: with base labels off, the selected ones stay.
|
|
8323
|
+
visibility: "visible",
|
|
8324
|
+
// Full collision; topmost, so placed first (see the module comment):
|
|
8325
|
+
// selected labels thin among themselves and win against every other.
|
|
8326
|
+
"text-allow-overlap": false,
|
|
8327
|
+
"text-ignore-placement": false,
|
|
8328
|
+
"text-optional": true,
|
|
8329
|
+
// Same ranking as the base layers, so which selected label wins a
|
|
8330
|
+
// crowded spot is stable across repaints.
|
|
8331
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8332
|
+
},
|
|
8333
|
+
paint: buildCustomLabelPaint()
|
|
8334
|
+
}
|
|
8335
|
+
];
|
|
8336
|
+
}
|
|
8337
|
+
function overlayTimelineInputs(ids, visible) {
|
|
8338
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
8339
|
+
if (visible !== null) ids.forEach((id) => {
|
|
8340
|
+
if (!visible.has(id)) hidden.add(id);
|
|
8341
|
+
});
|
|
8342
|
+
return { ids, hidden };
|
|
8343
|
+
}
|
|
8344
|
+
function sameIds(a, b) {
|
|
8345
|
+
return a.size === b.size && Array.from(a).every((id) => b.has(id));
|
|
8346
|
+
}
|
|
8347
|
+
function sameOverlayTimelineInputs(a, b) {
|
|
8348
|
+
return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
|
|
8349
|
+
}
|
|
8350
|
+
function buildSelectionOverlayData(ids, styleFor) {
|
|
8351
|
+
const features = [];
|
|
8352
|
+
ids.forEach((id) => {
|
|
8353
|
+
styleFor(id).forEach((feature) => features.push(feature));
|
|
8354
|
+
});
|
|
8355
|
+
return { type: "FeatureCollection", features };
|
|
8356
|
+
}
|
|
8193
8357
|
function renderedFeatureId(f) {
|
|
8194
8358
|
var _a;
|
|
8195
8359
|
const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
|
|
@@ -8719,6 +8883,8 @@ function ClusterPieManager(props) {
|
|
|
8719
8883
|
return null;
|
|
8720
8884
|
}
|
|
8721
8885
|
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
8886
|
+
const EMPTY_SOURCES = [];
|
|
8887
|
+
const TOOLTIP_EXCLUDED_KEYS = ["stroke", "stroke-width", "stroke-opacity", "fill", "fill-opacity", "pointRadius", "kind", "meta:type", "circleCenter", "circleRadius", "icon", "iconSize", "pointIcon", "pointIconSize", "fontSize", "fontColor", "fontWeight", "arrowSize", "label", "entityType"];
|
|
8722
8888
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
8723
8889
|
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
8724
8890
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
@@ -8924,6 +9090,13 @@ function basemapInsertAnchor(map) {
|
|
|
8924
9090
|
if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
|
|
8925
9091
|
return void 0;
|
|
8926
9092
|
}
|
|
9093
|
+
function featureStateHostFor(m) {
|
|
9094
|
+
return {
|
|
9095
|
+
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
9096
|
+
removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
|
|
9097
|
+
source: (source) => m.getSource(source)
|
|
9098
|
+
};
|
|
9099
|
+
}
|
|
8927
9100
|
const BASEMAP_LAYER_PREFIXES = {
|
|
8928
9101
|
streets: "streets-",
|
|
8929
9102
|
satellite: "satellite-",
|
|
@@ -9273,6 +9446,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9273
9446
|
}
|
|
9274
9447
|
return getReadOnlyFeatureById(id);
|
|
9275
9448
|
}, [getReadOnlyFeatureById]);
|
|
9449
|
+
const appliedSelectionRef = useRef(/* @__PURE__ */ new Map());
|
|
9450
|
+
const locatorCacheRef = useRef(createLocatorCache());
|
|
9451
|
+
const shardedLayerIdsRef = useRef(EMPTY_ID_SET);
|
|
9452
|
+
const overlayPaintContextRef = useRef(null);
|
|
9453
|
+
const shardFieldRangesRef = useRef(/* @__PURE__ */ new Map());
|
|
9454
|
+
const locateSelectionSources = useCallback((id) => {
|
|
9455
|
+
if (getFeatureById(id) === null) return EMPTY_SOURCES;
|
|
9456
|
+
return locateFeatureSources(
|
|
9457
|
+
id,
|
|
9458
|
+
{ readOnly: readOnlyFeatures.current, shardedLayerIds: shardedLayerIdsRef.current, shardSize: shardSizeRef.current },
|
|
9459
|
+
locatorCacheRef.current
|
|
9460
|
+
);
|
|
9461
|
+
}, [getFeatureById]);
|
|
9276
9462
|
const canDeleteSelected = useMemo(() => {
|
|
9277
9463
|
if (selectedFeatureIds.length === 0) return false;
|
|
9278
9464
|
return selectedFeatureIds.some((id) => {
|
|
@@ -9294,7 +9480,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9294
9480
|
return true;
|
|
9295
9481
|
});
|
|
9296
9482
|
}, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
|
|
9297
|
-
const applySelectionState = useCallback((nextIds, options) => {
|
|
9483
|
+
const applySelectionState$1 = useCallback((nextIds, options) => {
|
|
9298
9484
|
if (!isMapLoaded || !draw.current) {
|
|
9299
9485
|
setSelectedFeatureIds(nextIds);
|
|
9300
9486
|
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
|
|
@@ -9365,6 +9551,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9365
9551
|
});
|
|
9366
9552
|
const trySelectionFastPathRef = useRef(null);
|
|
9367
9553
|
const tryTimelineFastPathRef = useRef(null);
|
|
9554
|
+
const reconcileSelectionRef = useRef(null);
|
|
9368
9555
|
const syncCoalescerRef = useRef(null);
|
|
9369
9556
|
if (syncCoalescerRef.current === null) {
|
|
9370
9557
|
syncCoalescerRef.current = createRafCoalescer((reasons) => {
|
|
@@ -9565,7 +9752,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9565
9752
|
}
|
|
9566
9753
|
}, []);
|
|
9567
9754
|
const syncFeaturesToCustomLayers = useCallback(() => {
|
|
9568
|
-
var _a, _b;
|
|
9755
|
+
var _a, _b, _c;
|
|
9569
9756
|
if (!map.current) return;
|
|
9570
9757
|
if (isSyncingRef.current) return;
|
|
9571
9758
|
isSyncingRef.current = true;
|
|
@@ -9574,11 +9761,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9574
9761
|
const source = map.current.getSource("custom-features");
|
|
9575
9762
|
if (!source) return;
|
|
9576
9763
|
const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
|
|
9577
|
-
const drawSelectedIds = draw.current ? draw.current.getSelectedIds() : [];
|
|
9578
|
-
const componentSelectedIds = selectedFeatureIdsRef.current;
|
|
9579
|
-
const selectedIdSet = /* @__PURE__ */ new Set();
|
|
9580
|
-
drawSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
9581
|
-
componentSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
9582
9764
|
const visibleSet = timelineVisibleIdsRef.current;
|
|
9583
9765
|
const currentLayers = layersRef.current;
|
|
9584
9766
|
const isLayerVisible = (layer) => {
|
|
@@ -9590,6 +9772,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9590
9772
|
const count = ((_a2 = readOnlyFeatures.current.get(layer.id)) == null ? void 0 : _a2.length) ?? 0;
|
|
9591
9773
|
if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
|
|
9592
9774
|
});
|
|
9775
|
+
shardedLayerIdsRef.current = shardedLayerIds;
|
|
9593
9776
|
const allFeatures = [...drawFeatures.features];
|
|
9594
9777
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9595
9778
|
if (shardedLayerIds.has(layerId)) return;
|
|
@@ -9674,8 +9857,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9674
9857
|
const paintCache = createSelectionPaintCache();
|
|
9675
9858
|
const paintContext = {
|
|
9676
9859
|
timelineVisibleIds: visibleSet,
|
|
9677
|
-
selectedIds: selectedIdSet,
|
|
9678
|
-
selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
|
|
9679
9860
|
sizeFieldRanges,
|
|
9680
9861
|
colorFieldRanges,
|
|
9681
9862
|
tracePointIds,
|
|
@@ -9689,21 +9870,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9689
9870
|
features: allFeatures.map((f, i) => {
|
|
9690
9871
|
const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
|
|
9691
9872
|
const p = styled.paint;
|
|
9692
|
-
recordPaintedFeature(
|
|
9693
|
-
paintCache,
|
|
9694
|
-
p.featureId,
|
|
9695
|
-
p.basePriority,
|
|
9696
|
-
p.selected,
|
|
9697
|
-
p.visibleStrokeOpacity,
|
|
9698
|
-
p.visibleFillOpacity,
|
|
9699
|
-
p.timelineHidden
|
|
9700
|
-
);
|
|
9873
|
+
recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
9701
9874
|
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
9702
9875
|
return styled.feature;
|
|
9703
9876
|
})
|
|
9704
9877
|
};
|
|
9705
9878
|
source.setData(sourceData);
|
|
9706
9879
|
selectionPaintCacheRef.current = paintCache;
|
|
9880
|
+
overlayPaintContextRef.current = paintContext;
|
|
9881
|
+
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
9707
9882
|
const traceSource = map.current.getSource("trace-features");
|
|
9708
9883
|
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
9709
9884
|
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
|
|
@@ -9717,7 +9892,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9717
9892
|
sawArrowFeature = true;
|
|
9718
9893
|
if (f.geometry.type === "LineString") arrowLines.push(f);
|
|
9719
9894
|
});
|
|
9720
|
-
const shardArrows = ((
|
|
9895
|
+
const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
|
|
9721
9896
|
var _a2;
|
|
9722
9897
|
return ((_a2 = currentLayers.find((l) => l.id === id)) == null ? void 0 : _a2.visible) === true;
|
|
9723
9898
|
})) ?? [];
|
|
@@ -9737,7 +9912,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9737
9912
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
9738
9913
|
setLabelsSuppressed(false);
|
|
9739
9914
|
}
|
|
9740
|
-
(
|
|
9915
|
+
(_c = applyShardedLayersRef.current) == null ? void 0 : _c.call(applyShardedLayersRef);
|
|
9741
9916
|
const requestedBy = fullSyncCallersRef.current.splice(0);
|
|
9742
9917
|
let shardedFeatures = 0;
|
|
9743
9918
|
shardedLayerIds.forEach((id) => {
|
|
@@ -9834,21 +10009,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9834
10009
|
if (!m || !registry) return;
|
|
9835
10010
|
const currentLayers = layersRef.current;
|
|
9836
10011
|
const shardSize2 = shardSizeRef.current;
|
|
9837
|
-
const selectionEnabled = enableSelectionRef.current || enableDrawingRef.current;
|
|
9838
|
-
const currentSelectedIds = () => {
|
|
9839
|
-
var _a;
|
|
9840
|
-
const ids = /* @__PURE__ */ new Set();
|
|
9841
|
-
if (selectionEnabled) {
|
|
9842
|
-
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => ids.add(String(id)));
|
|
9843
|
-
selectedFeatureIdsRef.current.forEach((id) => ids.add(String(id)));
|
|
9844
|
-
}
|
|
9845
|
-
return ids;
|
|
9846
|
-
};
|
|
9847
10012
|
currentLayers.forEach((layer) => {
|
|
9848
10013
|
var _a;
|
|
9849
10014
|
const features = readOnlyFeatures.current.get(layer.id) ?? [];
|
|
9850
10015
|
if (!isShardEligible(layer, features.length, shardSize2)) {
|
|
9851
10016
|
registry.remove(layer.id);
|
|
10017
|
+
shardFieldRangesRef.current.delete(layer.id);
|
|
9852
10018
|
setLayerImporting(layer.id, false);
|
|
9853
10019
|
return;
|
|
9854
10020
|
}
|
|
@@ -9858,10 +10024,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9858
10024
|
setLayerImporting(layer.id, false);
|
|
9859
10025
|
return;
|
|
9860
10026
|
}
|
|
9861
|
-
const fingerprint = buildShardFingerprint(layer, features,
|
|
10027
|
+
const fingerprint = buildShardFingerprint(layer, features, shardSize2);
|
|
9862
10028
|
const expectedShards = shardRanges(features.length, shardSize2).length;
|
|
9863
10029
|
if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
|
|
9864
|
-
if (reconcileShardCaches(registry, state.layerId, expectedShards,
|
|
10030
|
+
if (reconcileShardCaches(registry, state.layerId, expectedShards, timelineVisibleIdsRef.current)) {
|
|
9865
10031
|
setLayerImporting(layer.id, false);
|
|
9866
10032
|
mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
|
|
9867
10033
|
return;
|
|
@@ -9881,10 +10047,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9881
10047
|
const ranges = layerFieldRanges(layer.visualConfig, (visit) => {
|
|
9882
10048
|
for (let i = 0; i < features.length; i++) visit(features[i].properties);
|
|
9883
10049
|
});
|
|
10050
|
+
shardFieldRangesRef.current.set(layer.id, ranges);
|
|
9884
10051
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
9885
10052
|
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
9886
10053
|
if (ranges.size) sizeFieldRanges.set(layer.id, ranges.size);
|
|
9887
10054
|
if (ranges.color) colorFieldRanges.set(layer.id, ranges.color);
|
|
10055
|
+
let overlayRestyled = false;
|
|
9888
10056
|
void runShardPass({
|
|
9889
10057
|
layer,
|
|
9890
10058
|
features,
|
|
@@ -9895,8 +10063,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9895
10063
|
contextForShard: () => {
|
|
9896
10064
|
return {
|
|
9897
10065
|
timelineVisibleIds: timelineVisibleIdsRef.current,
|
|
9898
|
-
selectedIds: currentSelectedIds(),
|
|
9899
|
-
selectionEnabled,
|
|
9900
10066
|
sizeFieldRanges,
|
|
9901
10067
|
colorFieldRanges,
|
|
9902
10068
|
// Trace-enabled layers are never sharded, so these are empty by construction.
|
|
@@ -9907,7 +10073,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9907
10073
|
};
|
|
9908
10074
|
},
|
|
9909
10075
|
onShardPainted: (index, cache2) => {
|
|
10076
|
+
var _a2;
|
|
9910
10077
|
state.caches[index] = cache2;
|
|
10078
|
+
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10079
|
+
overlayRestyled = true;
|
|
9911
10080
|
},
|
|
9912
10081
|
onProgress: (painted) => progress == null ? void 0 : progress.update(painted)
|
|
9913
10082
|
}).then((result) => {
|
|
@@ -10098,7 +10267,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10098
10267
|
});
|
|
10099
10268
|
const registry = shardRegistryRef.current;
|
|
10100
10269
|
registry == null ? void 0 : registry.trackedLayerIds().forEach((layerId) => {
|
|
10101
|
-
if (!liveLayerIds.has(layerId))
|
|
10270
|
+
if (!liveLayerIds.has(layerId)) {
|
|
10271
|
+
registry.remove(layerId);
|
|
10272
|
+
shardFieldRangesRef.current.delete(layerId);
|
|
10273
|
+
}
|
|
10102
10274
|
});
|
|
10103
10275
|
Object.keys((style == null ? void 0 : style.sources) ?? {}).forEach((sid) => {
|
|
10104
10276
|
const parsed = parseShardSourceId(sid);
|
|
@@ -10221,15 +10393,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10221
10393
|
coalesceKey,
|
|
10222
10394
|
undo: () => {
|
|
10223
10395
|
applyHistoryState(featureIds, layerIds, beforeF, beforeL);
|
|
10224
|
-
applySelectionState(beforeSelectedIds, { focusProperties: false });
|
|
10396
|
+
applySelectionState$1(beforeSelectedIds, { focusProperties: false });
|
|
10225
10397
|
},
|
|
10226
10398
|
redo: () => {
|
|
10227
10399
|
applyHistoryState(featureIds, layerIds, afterF, afterL);
|
|
10228
|
-
applySelectionState(afterSelectedIds, { focusProperties: false });
|
|
10400
|
+
applySelectionState$1(afterSelectedIds, { focusProperties: false });
|
|
10229
10401
|
}
|
|
10230
10402
|
};
|
|
10231
10403
|
},
|
|
10232
|
-
[applyHistoryState, applySelectionState]
|
|
10404
|
+
[applyHistoryState, applySelectionState$1]
|
|
10233
10405
|
);
|
|
10234
10406
|
const finalizeCapture = useCallback(() => {
|
|
10235
10407
|
const pending = pendingCaptureRef.current;
|
|
@@ -10353,11 +10525,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10353
10525
|
var _a, _b;
|
|
10354
10526
|
map.current = mapInstance;
|
|
10355
10527
|
draw.current = drawInstance;
|
|
10356
|
-
mapInstance.addSource(
|
|
10357
|
-
type: "geojson",
|
|
10358
|
-
data: { type: "FeatureCollection", features: [] },
|
|
10359
|
-
maxzoom: 22
|
|
10360
|
-
});
|
|
10528
|
+
mapInstance.addSource(SHARED_SOURCE_ID, customSourceSpec());
|
|
10361
10529
|
const sharedStack = buildCustomLayerStack(SHARED_SOURCE_ID, CUSTOM_LAYER_ROLES, { labelsVisible: false });
|
|
10362
10530
|
sharedStack.forEach((spec) => mapInstance.addLayer(spec));
|
|
10363
10531
|
const styleHost = {
|
|
@@ -10448,6 +10616,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10448
10616
|
"line-opacity": 0.7
|
|
10449
10617
|
}
|
|
10450
10618
|
});
|
|
10619
|
+
mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
|
|
10620
|
+
type: "geojson",
|
|
10621
|
+
data: { type: "FeatureCollection", features: [] },
|
|
10622
|
+
maxzoom: 22
|
|
10623
|
+
});
|
|
10624
|
+
buildSelectionOverlayStack().forEach((spec) => mapInstance.addLayer(spec));
|
|
10451
10625
|
if (tooltipElRef.current) {
|
|
10452
10626
|
const prevCleanup = tooltipElRef.current._cleanup;
|
|
10453
10627
|
try {
|
|
@@ -10566,8 +10740,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10566
10740
|
const highlightFields = /* @__PURE__ */ new Set();
|
|
10567
10741
|
if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
|
|
10568
10742
|
if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
|
|
10569
|
-
const
|
|
10570
|
-
const displayProps = Object.entries(props).filter(([key, value]) => !excludeKeys.includes(key) && !key.startsWith("_") && !key.startsWith("isHidden") && !key.startsWith("isTrace") && !key.startsWith("isTimeline") && !key.startsWith("trace") && value != null && value !== "").slice(0, 5);
|
|
10743
|
+
const displayProps = Object.entries(props).filter(([key, value]) => !TOOLTIP_EXCLUDED_KEYS.includes(key) && !key.startsWith("_") && !key.startsWith("isHidden") && !key.startsWith("isTrace") && !key.startsWith("isTimeline") && !key.startsWith("trace") && value != null && value !== "").slice(0, 5);
|
|
10571
10744
|
const name = props.name;
|
|
10572
10745
|
let html = '<div class="text-sm space-y-0.5">';
|
|
10573
10746
|
if (name) html += `<div class="font-medium">${name}</div>`;
|
|
@@ -11243,7 +11416,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11243
11416
|
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
11244
11417
|
if (!clusterHit) {
|
|
11245
11418
|
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
11246
|
-
applySelectionState([]);
|
|
11419
|
+
applySelectionState$1([]);
|
|
11247
11420
|
}
|
|
11248
11421
|
return;
|
|
11249
11422
|
}
|
|
@@ -11265,13 +11438,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11265
11438
|
return;
|
|
11266
11439
|
}
|
|
11267
11440
|
const fid = String(featureId);
|
|
11268
|
-
const
|
|
11269
|
-
const isAlreadySelected =
|
|
11441
|
+
const currentSelection2 = selectedFeatureIdsRef.current;
|
|
11442
|
+
const isAlreadySelected = currentSelection2.includes(fid);
|
|
11270
11443
|
let nextIds;
|
|
11271
11444
|
if (isModifierKey) {
|
|
11272
|
-
nextIds = isAlreadySelected ?
|
|
11445
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [...currentSelection2, fid];
|
|
11273
11446
|
} else {
|
|
11274
|
-
nextIds = isAlreadySelected ?
|
|
11447
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [fid];
|
|
11275
11448
|
}
|
|
11276
11449
|
isSelectingReadOnlyRef.current = true;
|
|
11277
11450
|
if (drawInstance.getSelected().features.length > 0) {
|
|
@@ -11823,7 +11996,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11823
11996
|
onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
|
|
11824
11997
|
},
|
|
11825
11998
|
selectFeatures: (featureIds) => {
|
|
11826
|
-
applySelectionState(featureIds, { focusProperties: true });
|
|
11999
|
+
applySelectionState$1(featureIds, { focusProperties: true });
|
|
11827
12000
|
},
|
|
11828
12001
|
getSelectedFeatures,
|
|
11829
12002
|
setEditMode: (enabled) => {
|
|
@@ -12112,7 +12285,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12112
12285
|
setPersistedSelectionPolygon(null);
|
|
12113
12286
|
setSelectionPoints([]);
|
|
12114
12287
|
setSelectedFeatureIds([]);
|
|
12115
|
-
applySelectionState([], { focusProperties: true });
|
|
12288
|
+
applySelectionState$1([], { focusProperties: true });
|
|
12116
12289
|
},
|
|
12117
12290
|
// Viewport and state getters
|
|
12118
12291
|
getViewport: () => {
|
|
@@ -13100,6 +13273,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13100
13273
|
if (!m.getLayer(id)) return;
|
|
13101
13274
|
m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
|
|
13102
13275
|
});
|
|
13276
|
+
if (!firstVisibleBasemapSymbol && m.getLayer(SELECTION_OVERLAY_LAYER_IDS.label)) {
|
|
13277
|
+
m.moveLayer(SELECTION_OVERLAY_LAYER_IDS.label);
|
|
13278
|
+
}
|
|
13103
13279
|
} catch (e) {
|
|
13104
13280
|
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
13105
13281
|
}
|
|
@@ -13654,24 +13830,91 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13654
13830
|
useEffect(() => {
|
|
13655
13831
|
enableDrawingRef.current = enableDrawing;
|
|
13656
13832
|
}, [enableDrawing]);
|
|
13657
|
-
const
|
|
13833
|
+
const overlayPaintContext = useCallback(() => {
|
|
13834
|
+
const base = overlayPaintContextRef.current;
|
|
13835
|
+
if (!base) return null;
|
|
13836
|
+
const sizeFieldRanges = new Map(base.sizeFieldRanges);
|
|
13837
|
+
const colorFieldRanges = new Map(base.colorFieldRanges);
|
|
13838
|
+
shardFieldRangesRef.current.forEach((ranges, layerId) => {
|
|
13839
|
+
if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
|
|
13840
|
+
if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
|
|
13841
|
+
});
|
|
13842
|
+
return { ...base, timelineVisibleIds: timelineVisibleIdsRef.current, sizeFieldRanges, colorFieldRanges };
|
|
13843
|
+
}, []);
|
|
13844
|
+
const overlayFeatureCountRef = useRef(0);
|
|
13845
|
+
const overlayTimelineInputsRef = useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
|
|
13846
|
+
const refreshSelectionOverlay = useCallback((m, ids) => {
|
|
13847
|
+
overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
|
|
13848
|
+
if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
|
|
13849
|
+
const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
|
|
13850
|
+
if (!overlay) return;
|
|
13851
|
+
const ctx = ids.size > 0 ? overlayPaintContext() : null;
|
|
13852
|
+
const layers2 = layersRef.current;
|
|
13853
|
+
const layerById = new Map(layers2.map((l) => [l.id, l]));
|
|
13854
|
+
const data = buildSelectionOverlayData(ids, (id) => {
|
|
13855
|
+
if (!ctx) return [];
|
|
13856
|
+
const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
|
|
13857
|
+
if (holders.length > 0) {
|
|
13858
|
+
return holders.filter((h) => {
|
|
13859
|
+
var _a;
|
|
13860
|
+
return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
|
|
13861
|
+
}).map((h) => styleFeatureForPaint(h.feature, layerById.get(h.layerId), ctx, true).feature);
|
|
13862
|
+
}
|
|
13863
|
+
const feature = getFeatureById(id);
|
|
13864
|
+
if (!feature) return [];
|
|
13865
|
+
const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
|
|
13866
|
+
return layer && !layer.visible ? [] : [styleFeatureForPaint(feature, layer, ctx, true).feature];
|
|
13867
|
+
});
|
|
13868
|
+
overlay.setData(data);
|
|
13869
|
+
overlayFeatureCountRef.current = data.features.length;
|
|
13870
|
+
}, [getFeatureById, overlayPaintContext]);
|
|
13871
|
+
const currentSelection = useCallback(() => {
|
|
13658
13872
|
var _a;
|
|
13873
|
+
if (!(enableSelectionRef.current || enableDrawingRef.current)) return null;
|
|
13874
|
+
const next = /* @__PURE__ */ new Set();
|
|
13875
|
+
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
|
|
13876
|
+
selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
|
|
13877
|
+
return next;
|
|
13878
|
+
}, []);
|
|
13879
|
+
const paintSelection = useCallback((m, overlay = true) => {
|
|
13880
|
+
const selection = currentSelection();
|
|
13881
|
+
const { set: set2, removed } = applySelectionState(
|
|
13882
|
+
appliedSelectionRef.current,
|
|
13883
|
+
selection ?? EMPTY_ID_SET,
|
|
13884
|
+
selection !== null,
|
|
13885
|
+
locateSelectionSources,
|
|
13886
|
+
featureStateHostFor(m)
|
|
13887
|
+
);
|
|
13888
|
+
const shown = selection ?? EMPTY_ID_SET;
|
|
13889
|
+
if (overlay) refreshSelectionOverlay(m, shown);
|
|
13890
|
+
return { set: set2, removed, overlay: overlay ? shown.size : 0 };
|
|
13891
|
+
}, [currentSelection, locateSelectionSources, refreshSelectionOverlay]);
|
|
13892
|
+
const applySelectionPaint = useCallback(() => {
|
|
13659
13893
|
const m = map.current;
|
|
13660
13894
|
if (!m) return true;
|
|
13661
|
-
const
|
|
13662
|
-
const
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13895
|
+
const start = performance.now();
|
|
13896
|
+
const painted = paintSelection(m);
|
|
13897
|
+
mapPerfLog("selection", "feature state applied", { ...painted, ms: Math.round(performance.now() - start) });
|
|
13898
|
+
return true;
|
|
13899
|
+
}, [paintSelection]);
|
|
13900
|
+
trySelectionFastPathRef.current = applySelectionPaint;
|
|
13901
|
+
const reconcileSelectionAfterPaint = useCallback((options) => {
|
|
13902
|
+
const m = map.current;
|
|
13903
|
+
if (!m) return;
|
|
13904
|
+
const { moved, pruned } = reconcileSelectionSources(
|
|
13905
|
+
appliedSelectionRef.current,
|
|
13906
|
+
locateSelectionSources,
|
|
13907
|
+
featureStateHostFor(m)
|
|
13672
13908
|
);
|
|
13673
|
-
|
|
13674
|
-
|
|
13909
|
+
const applied = paintSelection(m, (options == null ? void 0 : options.overlay) ?? true);
|
|
13910
|
+
if (moved || pruned || applied.set || applied.removed) {
|
|
13911
|
+
mapPerfLog("selection", "reconciled after paint", { moved, pruned, ...applied });
|
|
13912
|
+
}
|
|
13913
|
+
}, [locateSelectionSources, paintSelection]);
|
|
13914
|
+
reconcileSelectionRef.current = reconcileSelectionAfterPaint;
|
|
13915
|
+
useEffect(() => {
|
|
13916
|
+
scheduleSync("selection");
|
|
13917
|
+
}, [enableSelection, enableDrawing, scheduleSync]);
|
|
13675
13918
|
const tryTimelineFastPath = useCallback(() => {
|
|
13676
13919
|
const m = map.current;
|
|
13677
13920
|
if (!m) return true;
|
|
@@ -13685,13 +13928,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13685
13928
|
const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
|
|
13686
13929
|
const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
|
|
13687
13930
|
if (!applied || !paintCache || !source) return false;
|
|
13688
|
-
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff,
|
|
13931
|
+
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, source, traceSource))) return false;
|
|
13689
13932
|
if (!forEachShardCache(shardRegistryRef.current, (cache2, shardSource) => applyTimelineFastPath(cache2, nextVisible, shardSource).applied)) {
|
|
13690
13933
|
return false;
|
|
13691
13934
|
}
|
|
13692
13935
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
13693
13936
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
13694
13937
|
setLabelsSuppressed(false);
|
|
13938
|
+
const selection = currentSelection() ?? EMPTY_ID_SET;
|
|
13939
|
+
if (!sameOverlayTimelineInputs(overlayTimelineInputsRef.current, overlayTimelineInputs(selection, nextVisible))) {
|
|
13940
|
+
refreshSelectionOverlay(m, selection);
|
|
13941
|
+
}
|
|
13695
13942
|
mapPerfLog("timeline", "fast path applied", {
|
|
13696
13943
|
toggled,
|
|
13697
13944
|
endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
|
|
@@ -13699,7 +13946,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13699
13946
|
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
13700
13947
|
});
|
|
13701
13948
|
return true;
|
|
13702
|
-
}, [autoLabelConfig, countVisibleFeatures]);
|
|
13949
|
+
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
|
|
13703
13950
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
13704
13951
|
const collectSelectionFeatureGroups = useCallback(() => {
|
|
13705
13952
|
return collectVisibleFeatureGroups(
|
|
@@ -13815,7 +14062,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13815
14062
|
axisAlignedRectangle: true
|
|
13816
14063
|
});
|
|
13817
14064
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13818
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14065
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13819
14066
|
}
|
|
13820
14067
|
setIsSelectionToolActive(false);
|
|
13821
14068
|
startPoint = null;
|
|
@@ -13838,7 +14085,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13838
14085
|
} else {
|
|
13839
14086
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13840
14087
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13841
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14088
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13842
14089
|
}
|
|
13843
14090
|
setIsSelectionToolActive(false);
|
|
13844
14091
|
}
|
|
@@ -13872,7 +14119,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13872
14119
|
} else {
|
|
13873
14120
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13874
14121
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13875
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14122
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13876
14123
|
}
|
|
13877
14124
|
setIsSelectionToolActive(false);
|
|
13878
14125
|
setSelectionPoints([]);
|
|
@@ -13988,7 +14235,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13988
14235
|
setSelectionPoints([]);
|
|
13989
14236
|
mapInstance.dragPan.enable();
|
|
13990
14237
|
canvas.style.cursor = "";
|
|
13991
|
-
applySelectionState(mergedIds, { focusProperties: true });
|
|
14238
|
+
applySelectionState$1(mergedIds, { focusProperties: true });
|
|
13992
14239
|
};
|
|
13993
14240
|
canvas.addEventListener("mousedown", handleShiftMouseDown);
|
|
13994
14241
|
window.addEventListener("mousemove", handleShiftMouseMove);
|
|
@@ -14001,7 +14248,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14001
14248
|
map.current.dragPan.enable();
|
|
14002
14249
|
}
|
|
14003
14250
|
};
|
|
14004
|
-
}, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
|
|
14251
|
+
}, [isMapLoaded, isSelectionToolActive, applySelectionState$1, collectSelectionFeatureGroups]);
|
|
14005
14252
|
useEffect(() => {
|
|
14006
14253
|
if (!map.current || !isMapLoaded) return;
|
|
14007
14254
|
const mapInstance = map.current;
|
|
@@ -17218,8 +17465,10 @@ export {
|
|
|
17218
17465
|
TIMEBAR_HEIGHT,
|
|
17219
17466
|
Timebar,
|
|
17220
17467
|
TimebarToggle,
|
|
17468
|
+
TimelineStoreContext,
|
|
17221
17469
|
cn,
|
|
17222
17470
|
createClusterPieManager,
|
|
17471
|
+
createTimelineStore,
|
|
17223
17472
|
featureCollectionBlobPartsAsync,
|
|
17224
17473
|
getIconEmoji,
|
|
17225
17474
|
isFeatureInRange,
|
|
@@ -17229,6 +17478,7 @@ export {
|
|
|
17229
17478
|
parseKMLToGeoJSON,
|
|
17230
17479
|
useToast as toast,
|
|
17231
17480
|
useTimelineStore,
|
|
17481
|
+
useTimelineStoreApi,
|
|
17232
17482
|
useToast
|
|
17233
17483
|
};
|
|
17234
17484
|
//# sourceMappingURL=index.mjs.map
|