@octostar/map-component 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +418 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +418 -229
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/map-editor-canvas.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/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.cjs
CHANGED
|
@@ -768,6 +768,10 @@ function createIngestProgressStore() {
|
|
|
768
768
|
}
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
|
+
const SELECTED_STATE_KEY = "selected";
|
|
772
|
+
const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
|
|
773
|
+
const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
|
|
774
|
+
const SELECTION_COLOR = "#06b6d4";
|
|
771
775
|
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
772
776
|
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
773
777
|
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
@@ -820,7 +824,8 @@ function buildCustomLabelLayout() {
|
|
|
820
824
|
]
|
|
821
825
|
};
|
|
822
826
|
}
|
|
823
|
-
function buildCustomLabelPaint() {
|
|
827
|
+
function buildCustomLabelPaint(opts) {
|
|
828
|
+
const visibleOpacity = ["*", 0.9, ["get", "stroke-opacity"]];
|
|
824
829
|
return {
|
|
825
830
|
// Text features use fontColor; others use default
|
|
826
831
|
"text-color": [
|
|
@@ -839,7 +844,7 @@ function buildCustomLabelPaint() {
|
|
|
839
844
|
2,
|
|
840
845
|
1.5
|
|
841
846
|
],
|
|
842
|
-
"text-opacity":
|
|
847
|
+
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
843
848
|
};
|
|
844
849
|
}
|
|
845
850
|
const CUSTOM_LAYER_ROLES = [
|
|
@@ -849,13 +854,13 @@ const CUSTOM_LAYER_ROLES = [
|
|
|
849
854
|
"point-shadow",
|
|
850
855
|
"point",
|
|
851
856
|
"point-icon",
|
|
852
|
-
"point-icon-selection",
|
|
853
|
-
"line-selection",
|
|
854
|
-
"polygon-selection",
|
|
855
857
|
"labels",
|
|
856
858
|
"labels-pinned"
|
|
857
859
|
];
|
|
858
860
|
const SHARED_SOURCE_ID = "custom-features";
|
|
861
|
+
function customSourceSpec() {
|
|
862
|
+
return { type: "geojson", data: { type: "FeatureCollection", features: [] }, maxzoom: 22, promoteId: "id" };
|
|
863
|
+
}
|
|
859
864
|
const EMOJI_CANVAS_SIZE = 48;
|
|
860
865
|
function customLayerId(role, sourceId) {
|
|
861
866
|
return sourceId === SHARED_SOURCE_ID ? `custom-${role}` : `custom-${role}@${sourceId}`;
|
|
@@ -878,9 +883,9 @@ function geometryClassesOf(features) {
|
|
|
878
883
|
return classes;
|
|
879
884
|
}
|
|
880
885
|
const ROLES_BY_CLASS = {
|
|
881
|
-
polygon: ["polygon-fill", "polygon-stroke"
|
|
882
|
-
line: ["line"
|
|
883
|
-
point: ["point-shadow", "point", "point-icon"
|
|
886
|
+
polygon: ["polygon-fill", "polygon-stroke"],
|
|
887
|
+
line: ["line"],
|
|
888
|
+
point: ["point-shadow", "point", "point-icon"]
|
|
884
889
|
};
|
|
885
890
|
function rolesForGeometry(classes) {
|
|
886
891
|
const needed = /* @__PURE__ */ new Set(["labels", "labels-pinned"]);
|
|
@@ -902,12 +907,6 @@ function shardInsertAnchor(role) {
|
|
|
902
907
|
case "point":
|
|
903
908
|
return "custom-point-icon";
|
|
904
909
|
case "point-icon":
|
|
905
|
-
return "custom-point-icon-selection";
|
|
906
|
-
case "point-icon-selection":
|
|
907
|
-
return "custom-line-selection";
|
|
908
|
-
case "line-selection":
|
|
909
|
-
return "custom-polygon-selection";
|
|
910
|
-
case "polygon-selection":
|
|
911
910
|
return "custom-arrow-heads";
|
|
912
911
|
case "labels":
|
|
913
912
|
return "custom-arrow-heads";
|
|
@@ -990,7 +989,8 @@ function buildLayer(role, sourceId, opts) {
|
|
|
990
989
|
"circle-translate": [1, 1]
|
|
991
990
|
}
|
|
992
991
|
};
|
|
993
|
-
// Custom point layer
|
|
992
|
+
// Custom point layer; the selection ring is paint-only and reads feature
|
|
993
|
+
// state (hidden when emoji icon is set)
|
|
994
994
|
case "point":
|
|
995
995
|
return {
|
|
996
996
|
id,
|
|
@@ -1021,7 +1021,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1021
1021
|
0,
|
|
1022
1022
|
["coalesce", ["get", "stroke-opacity"], 1]
|
|
1023
1023
|
],
|
|
1024
|
-
"circle-stroke-color": ["case",
|
|
1024
|
+
"circle-stroke-color": ["case", SELECTED, SELECTION_COLOR, "#555555"],
|
|
1025
1025
|
"circle-stroke-width": [
|
|
1026
1026
|
"case",
|
|
1027
1027
|
["==", ["get", "isTimelineHidden"], 1],
|
|
@@ -1032,7 +1032,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1032
1032
|
0,
|
|
1033
1033
|
["!=", ["get", "icon"], ""],
|
|
1034
1034
|
0,
|
|
1035
|
-
|
|
1035
|
+
SELECTED,
|
|
1036
1036
|
3,
|
|
1037
1037
|
1.5
|
|
1038
1038
|
],
|
|
@@ -1072,47 +1072,6 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1072
1072
|
]
|
|
1073
1073
|
}
|
|
1074
1074
|
};
|
|
1075
|
-
// Selection ring for icon points
|
|
1076
|
-
case "point-icon-selection":
|
|
1077
|
-
return {
|
|
1078
|
-
id,
|
|
1079
|
-
type: "circle",
|
|
1080
|
-
source: sourceId,
|
|
1081
|
-
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", "isSelected", 1], ["!=", "isHiddenByHeatmap", 1]],
|
|
1082
|
-
paint: {
|
|
1083
|
-
"circle-color": "transparent",
|
|
1084
|
-
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
1085
|
-
"circle-stroke-color": "#06b6d4",
|
|
1086
|
-
"circle-stroke-width": 3,
|
|
1087
|
-
"circle-stroke-opacity": 1
|
|
1088
|
-
}
|
|
1089
|
-
};
|
|
1090
|
-
// Selection highlight for lines - bright cyan dashed overlay
|
|
1091
|
-
case "line-selection":
|
|
1092
|
-
return {
|
|
1093
|
-
id,
|
|
1094
|
-
type: "line",
|
|
1095
|
-
source: sourceId,
|
|
1096
|
-
filter: ["all", ["==", "$type", "LineString"], ["==", "isSelected", 1]],
|
|
1097
|
-
paint: {
|
|
1098
|
-
"line-color": "#06b6d4",
|
|
1099
|
-
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
1100
|
-
"line-dasharray": [4, 2]
|
|
1101
|
-
}
|
|
1102
|
-
};
|
|
1103
|
-
// Selection highlight for polygons - bright cyan dashed outline
|
|
1104
|
-
case "polygon-selection":
|
|
1105
|
-
return {
|
|
1106
|
-
id,
|
|
1107
|
-
type: "line",
|
|
1108
|
-
source: sourceId,
|
|
1109
|
-
filter: ["all", ["==", "$type", "Polygon"], ["==", "isSelected", 1]],
|
|
1110
|
-
paint: {
|
|
1111
|
-
"line-color": "#06b6d4",
|
|
1112
|
-
"line-width": 4,
|
|
1113
|
-
"line-dasharray": [4, 2]
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1116
1075
|
// Label layer for all features - shows 'name' property, or 'text' for text features
|
|
1117
1076
|
// Trace labels are slightly bigger and bolder, hidden points have no labels
|
|
1118
1077
|
// Arrow labels are handled separately by the custom-arrow-labels layer.
|
|
@@ -1138,8 +1097,11 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1138
1097
|
//
|
|
1139
1098
|
// The fix has two parts:
|
|
1140
1099
|
// 1. (here) Re-enable collision and use `symbol-sort-key` to control
|
|
1141
|
-
// intra-layer priority.
|
|
1142
|
-
// ordinary points so they keep their labels when crowded.
|
|
1100
|
+
// intra-layer priority. Text/trace features win against
|
|
1101
|
+
// ordinary points so they keep their labels when crowded. A
|
|
1102
|
+
// selected feature's label is drawn by the selection overlay;
|
|
1103
|
+
// its copy here is hidden through `text-opacity` but still
|
|
1104
|
+
// laid out, so it claims the same collision space as before.
|
|
1143
1105
|
// 2. (see `moveLabelsBeforeBasemapSymbols` in the canvas) After each
|
|
1144
1106
|
// basemap load, move the label layers BEFORE basemap symbol layers
|
|
1145
1107
|
// in the style stack. MapLibre processes collision in painter
|
|
@@ -1157,7 +1119,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1157
1119
|
// Computed per-feature in styleFeatureForPaint.
|
|
1158
1120
|
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
1159
1121
|
},
|
|
1160
|
-
paint: buildCustomLabelPaint()
|
|
1122
|
+
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1161
1123
|
};
|
|
1162
1124
|
// Pinned twin of the labels layer for layers with visualConfig.label.neverHide.
|
|
1163
1125
|
// text-allow-overlap / text-ignore-placement are data-constant in MapLibre
|
|
@@ -1183,7 +1145,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1183
1145
|
// (low-priority-value) labels draw over their neighbours' halos.
|
|
1184
1146
|
"symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
|
|
1185
1147
|
},
|
|
1186
|
-
paint: buildCustomLabelPaint()
|
|
1148
|
+
paint: buildCustomLabelPaint({ hideSelected: true })
|
|
1187
1149
|
};
|
|
1188
1150
|
}
|
|
1189
1151
|
}
|
|
@@ -1234,7 +1196,7 @@ function resolveShardSize(value) {
|
|
|
1234
1196
|
}
|
|
1235
1197
|
return Math.floor(value);
|
|
1236
1198
|
}
|
|
1237
|
-
function buildShardFingerprint(layer, features,
|
|
1199
|
+
function buildShardFingerprint(layer, features, shardSize) {
|
|
1238
1200
|
return {
|
|
1239
1201
|
features,
|
|
1240
1202
|
visualConfig: layer.visualConfig,
|
|
@@ -1242,36 +1204,30 @@ function buildShardFingerprint(layer, features, selectionEnabled, shardSize) {
|
|
|
1242
1204
|
clusterConfig: layer.clusterConfig,
|
|
1243
1205
|
altitudeDisplayMode: layer.altitudeDisplayMode,
|
|
1244
1206
|
hasAltitudeData: layer.hasAltitudeData,
|
|
1245
|
-
selectionEnabled,
|
|
1246
1207
|
shardSize
|
|
1247
1208
|
};
|
|
1248
1209
|
}
|
|
1249
1210
|
function shardFingerprintsEqual(a, b) {
|
|
1250
1211
|
if (!a || !b) return false;
|
|
1251
|
-
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.
|
|
1212
|
+
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);
|
|
1252
1213
|
}
|
|
1253
|
-
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1254
1214
|
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1255
1215
|
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1256
1216
|
function createSelectionPaintCache() {
|
|
1257
1217
|
return {
|
|
1258
1218
|
presentIds: /* @__PURE__ */ new Set(),
|
|
1259
|
-
appliedSelectedIds: /* @__PURE__ */ new Set(),
|
|
1260
|
-
basePriorityById: /* @__PURE__ */ new Map(),
|
|
1261
1219
|
appliedHiddenIds: /* @__PURE__ */ new Set(),
|
|
1262
1220
|
visibleStrokeOpacityById: /* @__PURE__ */ new Map(),
|
|
1263
1221
|
visibleFillOpacityById: /* @__PURE__ */ new Map(),
|
|
1264
1222
|
updatable: true
|
|
1265
1223
|
};
|
|
1266
1224
|
}
|
|
1267
|
-
function recordPaintedFeature(cache2, featureId,
|
|
1225
|
+
function recordPaintedFeature(cache2, featureId, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
1268
1226
|
if (cache2.presentIds.has(featureId)) {
|
|
1269
1227
|
cache2.updatable = false;
|
|
1270
1228
|
} else {
|
|
1271
1229
|
cache2.presentIds.add(featureId);
|
|
1272
1230
|
}
|
|
1273
|
-
cache2.basePriorityById.set(featureId, basePriority);
|
|
1274
|
-
if (isSelected) cache2.appliedSelectedIds.add(featureId);
|
|
1275
1231
|
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
1276
1232
|
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
1277
1233
|
}
|
|
@@ -1280,52 +1236,9 @@ function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visib
|
|
|
1280
1236
|
}
|
|
1281
1237
|
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
1282
1238
|
}
|
|
1283
|
-
function applySelectionFastPath(cache2, nextSelectedIds, source) {
|
|
1284
|
-
if (!cache2 || !cache2.updatable || !source) return false;
|
|
1285
|
-
const diff = buildSelectionDiff(cache2, nextSelectedIds);
|
|
1286
|
-
if (diff) {
|
|
1287
|
-
try {
|
|
1288
|
-
source.updateData(diff);
|
|
1289
|
-
} catch {
|
|
1290
|
-
return false;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
const applied = /* @__PURE__ */ new Set();
|
|
1294
|
-
nextSelectedIds.forEach((id) => {
|
|
1295
|
-
if (cache2.presentIds.has(id)) applied.add(id);
|
|
1296
|
-
});
|
|
1297
|
-
cache2.appliedSelectedIds = applied;
|
|
1298
|
-
return true;
|
|
1299
|
-
}
|
|
1300
1239
|
function needsDrawSelectionUpdate(input) {
|
|
1301
1240
|
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
1302
1241
|
}
|
|
1303
|
-
function buildSelectionDiff(cache2, nextSelectedIds) {
|
|
1304
|
-
const update = [];
|
|
1305
|
-
cache2.appliedSelectedIds.forEach((id) => {
|
|
1306
|
-
if (!nextSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
1307
|
-
update.push({
|
|
1308
|
-
id,
|
|
1309
|
-
addOrUpdateProperties: [
|
|
1310
|
-
{ key: "isSelected", value: 0 },
|
|
1311
|
-
{ key: "_labelPriority", value: cache2.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
|
|
1312
|
-
]
|
|
1313
|
-
});
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1316
|
-
nextSelectedIds.forEach((id) => {
|
|
1317
|
-
if (!cache2.appliedSelectedIds.has(id) && cache2.presentIds.has(id)) {
|
|
1318
|
-
update.push({
|
|
1319
|
-
id,
|
|
1320
|
-
addOrUpdateProperties: [
|
|
1321
|
-
{ key: "isSelected", value: 1 },
|
|
1322
|
-
{ key: "_labelPriority", value: 0 }
|
|
1323
|
-
]
|
|
1324
|
-
});
|
|
1325
|
-
}
|
|
1326
|
-
});
|
|
1327
|
-
return update.length > 0 ? { update } : null;
|
|
1328
|
-
}
|
|
1329
1242
|
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
1330
1243
|
const update = [];
|
|
1331
1244
|
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
@@ -1369,7 +1282,6 @@ function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
|
1369
1282
|
cache2.appliedHiddenIds = nextHiddenIds;
|
|
1370
1283
|
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
1371
1284
|
}
|
|
1372
|
-
const EMPTY_COLLECTION = { type: "FeatureCollection", features: [] };
|
|
1373
1285
|
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
1374
1286
|
function createShardRegistry(host, hooks) {
|
|
1375
1287
|
const states = /* @__PURE__ */ new Map();
|
|
@@ -1402,7 +1314,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1402
1314
|
};
|
|
1403
1315
|
const createStack = (state, index, roles, data) => {
|
|
1404
1316
|
const sourceId = shardSourceId(state.layerId, index);
|
|
1405
|
-
host.addSource(sourceId,
|
|
1317
|
+
host.addSource(sourceId, customSourceSpec());
|
|
1406
1318
|
const specs = buildCustomLayerStack(sourceId, roles, { labelsVisible: hooks.labelsVisible() });
|
|
1407
1319
|
const ordered = CUSTOM_LAYER_ROLES.filter((role) => roles.includes(role));
|
|
1408
1320
|
const layerIds = [];
|
|
@@ -1543,7 +1455,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1543
1455
|
}
|
|
1544
1456
|
};
|
|
1545
1457
|
}
|
|
1546
|
-
function reconcileShardCaches(registry, layerId, expectedShards,
|
|
1458
|
+
function reconcileShardCaches(registry, layerId, expectedShards, visibleIds) {
|
|
1547
1459
|
const state = registry.state(layerId);
|
|
1548
1460
|
if (!state || state.stacks.length !== expectedShards) return false;
|
|
1549
1461
|
for (let i = 0; i < expectedShards; i++) {
|
|
@@ -1552,7 +1464,6 @@ function reconcileShardCaches(registry, layerId, expectedShards, selectedIds, vi
|
|
|
1552
1464
|
const source = registry.sourceFor(layerId, i);
|
|
1553
1465
|
if (!source) return false;
|
|
1554
1466
|
if (!applyTimelineFastPath(cache2, visibleIds, source).applied) return false;
|
|
1555
|
-
if (!applySelectionFastPath(cache2, selectedIds, source)) return false;
|
|
1556
1467
|
}
|
|
1557
1468
|
return true;
|
|
1558
1469
|
}
|
|
@@ -1807,7 +1718,7 @@ const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
|
1807
1718
|
const TRACE_POINT_RADIUS = 2;
|
|
1808
1719
|
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
1809
1720
|
function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
1810
|
-
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: []
|
|
1721
|
+
const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [] };
|
|
1811
1722
|
const paintedVisible = (id) => !paint.appliedHiddenIds.has(id);
|
|
1812
1723
|
const nextVisible = timelineVisibility(nextVisibleSet);
|
|
1813
1724
|
trace.groups.forEach((group, groupIndex) => {
|
|
@@ -1816,8 +1727,8 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
|
1816
1727
|
const prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
1817
1728
|
const nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
1818
1729
|
if (prevEndpoint !== nextEndpoint) {
|
|
1819
|
-
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace,
|
|
1820
|
-
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace,
|
|
1730
|
+
if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[prevEndpoint], false);
|
|
1731
|
+
if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[nextEndpoint], true);
|
|
1821
1732
|
}
|
|
1822
1733
|
diffConsecutivePairs(
|
|
1823
1734
|
prev,
|
|
@@ -1828,21 +1739,19 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
|
|
|
1828
1739
|
});
|
|
1829
1740
|
return diff;
|
|
1830
1741
|
}
|
|
1831
|
-
function pushEndpointUpdate(diff, trace,
|
|
1742
|
+
function pushEndpointUpdate(diff, trace, group, id, isEndpoint) {
|
|
1832
1743
|
const point = trace.pointPaint.get(id);
|
|
1833
1744
|
if (!point) return;
|
|
1834
1745
|
const labelled = isEndpoint && group.label !== null;
|
|
1835
|
-
const basePriority = labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point.basePriority;
|
|
1836
1746
|
diff.pointUpdates.push({
|
|
1837
1747
|
id,
|
|
1838
1748
|
addOrUpdateProperties: [
|
|
1839
1749
|
{ key: "pointRadius", value: isEndpoint ? point.endpointRadius : TRACE_POINT_RADIUS },
|
|
1840
1750
|
{ key: "name", value: labelled ? group.label : point.name },
|
|
1841
1751
|
{ key: "isTraceLabel", value: labelled },
|
|
1842
|
-
{ key: "_labelPriority", value:
|
|
1752
|
+
{ key: "_labelPriority", value: labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point.basePriority }
|
|
1843
1753
|
]
|
|
1844
1754
|
});
|
|
1845
|
-
diff.basePriorities.push([id, basePriority]);
|
|
1846
1755
|
}
|
|
1847
1756
|
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
1848
1757
|
let i = 0;
|
|
@@ -1864,7 +1773,7 @@ function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
|
1864
1773
|
}
|
|
1865
1774
|
}
|
|
1866
1775
|
}
|
|
1867
|
-
function applyTraceTimelineDiff(diff,
|
|
1776
|
+
function applyTraceTimelineDiff(diff, pointSource, segmentSource) {
|
|
1868
1777
|
try {
|
|
1869
1778
|
if (diff.pointUpdates.length > 0) pointSource.updateData({ update: diff.pointUpdates });
|
|
1870
1779
|
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
@@ -1874,9 +1783,9 @@ function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
|
|
|
1874
1783
|
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
1875
1784
|
return false;
|
|
1876
1785
|
}
|
|
1877
|
-
diff.basePriorities.forEach(([id, priority]) => paint.basePriorityById.set(id, priority));
|
|
1878
1786
|
return true;
|
|
1879
1787
|
}
|
|
1788
|
+
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1880
1789
|
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
1881
1790
|
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
1882
1791
|
"kind",
|
|
@@ -1984,7 +1893,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1984
1893
|
});
|
|
1985
1894
|
}
|
|
1986
1895
|
}
|
|
1987
|
-
const isFeatureSelected = ctx.selectionEnabled && ctx.selectedIds.has(featureId) ? 1 : 0;
|
|
1988
1896
|
let nonTracePriority = DEFAULT_LABEL_PRIORITY;
|
|
1989
1897
|
if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
|
|
1990
1898
|
nonTracePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
|
|
@@ -1997,8 +1905,7 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1997
1905
|
}
|
|
1998
1906
|
nonTracePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
1999
1907
|
}
|
|
2000
|
-
const
|
|
2001
|
-
const labelPriority = isFeatureSelected ? 0 : basePriority;
|
|
1908
|
+
const labelPriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
2002
1909
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
2003
1910
|
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
2004
1911
|
return {
|
|
@@ -2012,7 +1919,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2012
1919
|
// Override with computed visual properties
|
|
2013
1920
|
id: featureId,
|
|
2014
1921
|
name: labelText,
|
|
2015
|
-
isSelected: isFeatureSelected,
|
|
2016
1922
|
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
2017
1923
|
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
2018
1924
|
isTracePoint: isTracePoint ? true : false,
|
|
@@ -2032,8 +1938,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
2032
1938
|
},
|
|
2033
1939
|
paint: {
|
|
2034
1940
|
featureId,
|
|
2035
|
-
basePriority,
|
|
2036
|
-
selected: isFeatureSelected === 1,
|
|
2037
1941
|
visibleStrokeOpacity,
|
|
2038
1942
|
visibleFillOpacity,
|
|
2039
1943
|
timelineHidden: !isTimelineVisible
|
|
@@ -2088,15 +1992,7 @@ async function runShardPass(input) {
|
|
|
2088
1992
|
var _a2;
|
|
2089
1993
|
const styled = styleFeatureForPaint(f, layer, ctx, true);
|
|
2090
1994
|
const p = styled.paint;
|
|
2091
|
-
recordPaintedFeature(
|
|
2092
|
-
cache2,
|
|
2093
|
-
p.featureId,
|
|
2094
|
-
p.basePriority,
|
|
2095
|
-
p.selected,
|
|
2096
|
-
p.visibleStrokeOpacity,
|
|
2097
|
-
p.visibleFillOpacity,
|
|
2098
|
-
p.timelineHidden
|
|
2099
|
-
);
|
|
1995
|
+
recordPaintedFeature(cache2, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
2100
1996
|
if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
|
|
2101
1997
|
shardArrows.push(styled.feature);
|
|
2102
1998
|
}
|
|
@@ -5519,10 +5415,10 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
|
|
|
5519
5415
|
// NOTE: 'description' intentionally NOT excluded — we surface it as a regular
|
|
5520
5416
|
// property row instead of giving it its own labelled section.
|
|
5521
5417
|
]);
|
|
5522
|
-
function buildKeyExclusionPredicate(
|
|
5523
|
-
const lowered = new Set(Array.from(
|
|
5418
|
+
function buildKeyExclusionPredicate(set2) {
|
|
5419
|
+
const lowered = new Set(Array.from(set2, (k) => k.toLowerCase()));
|
|
5524
5420
|
return (key) => {
|
|
5525
|
-
if (
|
|
5421
|
+
if (set2.has(key)) return true;
|
|
5526
5422
|
const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
|
|
5527
5423
|
return lowered.has(normalized);
|
|
5528
5424
|
};
|
|
@@ -7076,7 +6972,7 @@ function computeHistogramBins(features, minDate, maxDate, binCount = 50) {
|
|
|
7076
6972
|
});
|
|
7077
6973
|
return bins;
|
|
7078
6974
|
}
|
|
7079
|
-
const timelineStoreInitializer = (
|
|
6975
|
+
const timelineStoreInitializer = (set2, get) => ({
|
|
7080
6976
|
isEnabled: false,
|
|
7081
6977
|
hasTemporalData: false,
|
|
7082
6978
|
temporalFeatures: [],
|
|
@@ -7091,13 +6987,13 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7091
6987
|
setEnabled: (enabled) => {
|
|
7092
6988
|
if (enabled) {
|
|
7093
6989
|
const state = get();
|
|
7094
|
-
|
|
6990
|
+
set2({
|
|
7095
6991
|
isEnabled: true,
|
|
7096
6992
|
rangeStart: state.globalMinDate,
|
|
7097
6993
|
rangeEnd: state.globalMaxDate
|
|
7098
6994
|
});
|
|
7099
6995
|
} else {
|
|
7100
|
-
|
|
6996
|
+
set2({ isEnabled: false, isPlaying: false });
|
|
7101
6997
|
}
|
|
7102
6998
|
},
|
|
7103
6999
|
setTemporalFeatures: (features, untimedIds) => {
|
|
@@ -7106,7 +7002,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7106
7002
|
const state = get();
|
|
7107
7003
|
if (timedFeatures.length === 0) {
|
|
7108
7004
|
if (!state.hasTemporalData && state.temporalFeatures.length === 0) return;
|
|
7109
|
-
|
|
7005
|
+
set2({
|
|
7110
7006
|
hasTemporalData: false,
|
|
7111
7007
|
temporalFeatures: [],
|
|
7112
7008
|
untimedFeatureIds: untimedIds,
|
|
@@ -7133,7 +7029,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7133
7029
|
const sameUntimed = state.untimedFeatureIds.length === untimedIds.length && untimedIds.every((id, i) => id === state.untimedFeatureIds[i]);
|
|
7134
7030
|
if (sameFeatureIds && sameDates && sameUntimed && state.hasTemporalData) return;
|
|
7135
7031
|
const histogramBins = minDate && maxDate ? computeHistogramBins(timedFeatures, minDate, maxDate) : [];
|
|
7136
|
-
|
|
7032
|
+
set2({
|
|
7137
7033
|
hasTemporalData: true,
|
|
7138
7034
|
temporalFeatures: timedFeatures,
|
|
7139
7035
|
untimedFeatureIds: untimedIds,
|
|
@@ -7144,9 +7040,9 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7144
7040
|
histogramBins
|
|
7145
7041
|
});
|
|
7146
7042
|
},
|
|
7147
|
-
setRange: (start, end) =>
|
|
7148
|
-
setPlaying: (playing) =>
|
|
7149
|
-
setPlaybackSpeed: (speed) =>
|
|
7043
|
+
setRange: (start, end) => set2({ rangeStart: start, rangeEnd: end }),
|
|
7044
|
+
setPlaying: (playing) => set2({ isPlaying: playing }),
|
|
7045
|
+
setPlaybackSpeed: (speed) => set2({ playbackSpeed: speed }),
|
|
7150
7046
|
advancePlayhead: () => {
|
|
7151
7047
|
const state = get();
|
|
7152
7048
|
if (!state.globalMinDate || !state.globalMaxDate || !state.rangeStart) {
|
|
@@ -7157,20 +7053,20 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7157
7053
|
const newStart = new Date(state.rangeStart.getTime() + stepSize);
|
|
7158
7054
|
const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepSize) : null;
|
|
7159
7055
|
if (newStart >= state.globalMaxDate) {
|
|
7160
|
-
|
|
7056
|
+
set2({
|
|
7161
7057
|
isPlaying: false,
|
|
7162
7058
|
rangeStart: state.globalMinDate,
|
|
7163
7059
|
rangeEnd: state.globalMaxDate
|
|
7164
7060
|
});
|
|
7165
7061
|
return false;
|
|
7166
7062
|
}
|
|
7167
|
-
|
|
7063
|
+
set2({
|
|
7168
7064
|
rangeStart: newStart,
|
|
7169
7065
|
rangeEnd: newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate
|
|
7170
7066
|
});
|
|
7171
7067
|
return true;
|
|
7172
7068
|
},
|
|
7173
|
-
reset: () =>
|
|
7069
|
+
reset: () => set2({
|
|
7174
7070
|
isEnabled: false,
|
|
7175
7071
|
hasTemporalData: false,
|
|
7176
7072
|
temporalFeatures: [],
|
|
@@ -7948,6 +7844,129 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
|
7948
7844
|
}
|
|
7949
7845
|
};
|
|
7950
7846
|
}
|
|
7847
|
+
const EMPTY = /* @__PURE__ */ new Set();
|
|
7848
|
+
function isLive(host, entry) {
|
|
7849
|
+
return host.source(entry.sourceId) === entry.handle;
|
|
7850
|
+
}
|
|
7851
|
+
function remove(host, entry, id) {
|
|
7852
|
+
if (!isLive(host, entry)) return false;
|
|
7853
|
+
host.removeFeatureState(entry.sourceId, id);
|
|
7854
|
+
return true;
|
|
7855
|
+
}
|
|
7856
|
+
function set(host, sourceId, id) {
|
|
7857
|
+
const handle = host.source(sourceId);
|
|
7858
|
+
if (!handle) return null;
|
|
7859
|
+
host.setFeatureState(sourceId, id, SELECTED_STATE);
|
|
7860
|
+
return { sourceId, handle };
|
|
7861
|
+
}
|
|
7862
|
+
function setAll(host, sourceIds, id) {
|
|
7863
|
+
const done = [];
|
|
7864
|
+
sourceIds.forEach((sourceId) => {
|
|
7865
|
+
const entry = set(host, sourceId, id);
|
|
7866
|
+
if (entry) done.push(entry);
|
|
7867
|
+
});
|
|
7868
|
+
return done;
|
|
7869
|
+
}
|
|
7870
|
+
function place(applied, id, sources, host) {
|
|
7871
|
+
const done = setAll(host, sources, id);
|
|
7872
|
+
if (done.length > 0) applied.set(id, done);
|
|
7873
|
+
return done.length;
|
|
7874
|
+
}
|
|
7875
|
+
function applySelectionState(applied, next, gate, locate, host) {
|
|
7876
|
+
const target = gate ? next : EMPTY;
|
|
7877
|
+
let setCount = 0;
|
|
7878
|
+
let removed = 0;
|
|
7879
|
+
const gone = [];
|
|
7880
|
+
applied.forEach((_sources, id) => {
|
|
7881
|
+
if (!target.has(id)) gone.push(id);
|
|
7882
|
+
});
|
|
7883
|
+
gone.forEach((id) => {
|
|
7884
|
+
(applied.get(id) ?? []).forEach((entry) => {
|
|
7885
|
+
if (remove(host, entry, id)) removed++;
|
|
7886
|
+
});
|
|
7887
|
+
applied.delete(id);
|
|
7888
|
+
});
|
|
7889
|
+
target.forEach((id) => {
|
|
7890
|
+
if (applied.has(id)) return;
|
|
7891
|
+
setCount += place(applied, id, locate(id), host);
|
|
7892
|
+
});
|
|
7893
|
+
return { set: setCount, removed };
|
|
7894
|
+
}
|
|
7895
|
+
function reconcileSelectionSources(applied, locate, host) {
|
|
7896
|
+
let moved = 0;
|
|
7897
|
+
let pruned = 0;
|
|
7898
|
+
const changes = [];
|
|
7899
|
+
applied.forEach((have, id) => {
|
|
7900
|
+
const want = locate(id);
|
|
7901
|
+
const live = have.filter((entry) => isLive(host, entry));
|
|
7902
|
+
const same = want.length > 0 && live.length === have.length && want.every((sourceId) => live.some((entry) => entry.sourceId === sourceId));
|
|
7903
|
+
if (!same) changes.push({ id, have, live, want });
|
|
7904
|
+
});
|
|
7905
|
+
changes.forEach(({ id, have, live, want }) => {
|
|
7906
|
+
if (want.length === 0) {
|
|
7907
|
+
have.forEach((entry) => remove(host, entry, id));
|
|
7908
|
+
applied.delete(id);
|
|
7909
|
+
pruned++;
|
|
7910
|
+
return;
|
|
7911
|
+
}
|
|
7912
|
+
const missing = want.filter((sourceId) => !live.some((entry) => entry.sourceId === sourceId));
|
|
7913
|
+
const gained = setAll(host, missing, id);
|
|
7914
|
+
const now = [...live, ...gained];
|
|
7915
|
+
if (now.length > 0) applied.set(id, now);
|
|
7916
|
+
else applied.delete(id);
|
|
7917
|
+
if (gained.length > 0) moved++;
|
|
7918
|
+
});
|
|
7919
|
+
return { moved, pruned };
|
|
7920
|
+
}
|
|
7921
|
+
function createLocatorCache() {
|
|
7922
|
+
return /* @__PURE__ */ new WeakMap();
|
|
7923
|
+
}
|
|
7924
|
+
function indexOfIds(features, cache2) {
|
|
7925
|
+
const cached = cache2.get(features);
|
|
7926
|
+
if (cached) return cached;
|
|
7927
|
+
const index = { first: /* @__PURE__ */ new Map(), repeats: /* @__PURE__ */ new Map() };
|
|
7928
|
+
for (let i = 0; i < features.length; i++) {
|
|
7929
|
+
const id = features[i].id;
|
|
7930
|
+
if (id === void 0 || id === null) continue;
|
|
7931
|
+
const key = String(id);
|
|
7932
|
+
if (!index.first.has(key)) index.first.set(key, i);
|
|
7933
|
+
else {
|
|
7934
|
+
const more = index.repeats.get(key);
|
|
7935
|
+
if (more) more.push(i);
|
|
7936
|
+
else index.repeats.set(key, [i]);
|
|
7937
|
+
}
|
|
7938
|
+
}
|
|
7939
|
+
cache2.set(features, index);
|
|
7940
|
+
return index;
|
|
7941
|
+
}
|
|
7942
|
+
function forEachIndex(index, id, visit) {
|
|
7943
|
+
var _a;
|
|
7944
|
+
const at = index.first.get(id);
|
|
7945
|
+
if (at === void 0) return;
|
|
7946
|
+
visit(at);
|
|
7947
|
+
(_a = index.repeats.get(id)) == null ? void 0 : _a.forEach(visit);
|
|
7948
|
+
}
|
|
7949
|
+
function locateFeatureHolders(id, readOnly, cache2) {
|
|
7950
|
+
const holders = [];
|
|
7951
|
+
readOnly.forEach((features, layerId) => {
|
|
7952
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
|
|
7953
|
+
});
|
|
7954
|
+
return holders;
|
|
7955
|
+
}
|
|
7956
|
+
function locateFeatureSources(id, inputs, cache2) {
|
|
7957
|
+
const sources = [];
|
|
7958
|
+
const add = (sourceId) => {
|
|
7959
|
+
if (!sources.includes(sourceId)) sources.push(sourceId);
|
|
7960
|
+
};
|
|
7961
|
+
inputs.readOnly.forEach((features, layerId) => {
|
|
7962
|
+
const sharded = inputs.shardedLayerIds.has(layerId);
|
|
7963
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => {
|
|
7964
|
+
add(sharded ? shardSourceId(layerId, Math.floor(at / inputs.shardSize)) : SHARED_SOURCE_ID);
|
|
7965
|
+
});
|
|
7966
|
+
});
|
|
7967
|
+
if (sources.length === 0) add(SHARED_SOURCE_ID);
|
|
7968
|
+
return sources;
|
|
7969
|
+
}
|
|
7951
7970
|
function deepClone(value) {
|
|
7952
7971
|
try {
|
|
7953
7972
|
return structuredClone(value);
|
|
@@ -8210,6 +8229,93 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
8210
8229
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
8211
8230
|
return selectedIds;
|
|
8212
8231
|
}
|
|
8232
|
+
const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
|
|
8233
|
+
const SELECTION_OVERLAY_LAYER_IDS = {
|
|
8234
|
+
iconRing: "selection-overlay-icon-ring",
|
|
8235
|
+
line: "selection-overlay-line",
|
|
8236
|
+
polygon: "selection-overlay-polygon",
|
|
8237
|
+
label: "selection-overlay-label"
|
|
8238
|
+
};
|
|
8239
|
+
function buildSelectionOverlayStack() {
|
|
8240
|
+
const source = SELECTION_OVERLAY_SOURCE_ID;
|
|
8241
|
+
return [
|
|
8242
|
+
{
|
|
8243
|
+
id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
|
|
8244
|
+
type: "circle",
|
|
8245
|
+
source,
|
|
8246
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
|
|
8247
|
+
paint: {
|
|
8248
|
+
"circle-color": "transparent",
|
|
8249
|
+
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
8250
|
+
"circle-stroke-color": SELECTION_COLOR,
|
|
8251
|
+
"circle-stroke-width": 3,
|
|
8252
|
+
"circle-stroke-opacity": 1
|
|
8253
|
+
}
|
|
8254
|
+
},
|
|
8255
|
+
{
|
|
8256
|
+
id: SELECTION_OVERLAY_LAYER_IDS.line,
|
|
8257
|
+
type: "line",
|
|
8258
|
+
source,
|
|
8259
|
+
filter: ["==", "$type", "LineString"],
|
|
8260
|
+
paint: {
|
|
8261
|
+
"line-color": SELECTION_COLOR,
|
|
8262
|
+
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
8263
|
+
"line-dasharray": [4, 2]
|
|
8264
|
+
}
|
|
8265
|
+
},
|
|
8266
|
+
{
|
|
8267
|
+
id: SELECTION_OVERLAY_LAYER_IDS.polygon,
|
|
8268
|
+
type: "line",
|
|
8269
|
+
source,
|
|
8270
|
+
filter: ["==", "$type", "Polygon"],
|
|
8271
|
+
paint: {
|
|
8272
|
+
"line-color": SELECTION_COLOR,
|
|
8273
|
+
"line-width": 4,
|
|
8274
|
+
"line-dasharray": [4, 2]
|
|
8275
|
+
}
|
|
8276
|
+
},
|
|
8277
|
+
{
|
|
8278
|
+
id: SELECTION_OVERLAY_LAYER_IDS.label,
|
|
8279
|
+
type: "symbol",
|
|
8280
|
+
source,
|
|
8281
|
+
layout: {
|
|
8282
|
+
...buildCustomLabelLayout(),
|
|
8283
|
+
// Never hidden by the auto-label density cap, which only flips the
|
|
8284
|
+
// unpinned base layer: with base labels off, the selected ones stay.
|
|
8285
|
+
visibility: "visible",
|
|
8286
|
+
// Full collision; topmost, so placed first (see the module comment):
|
|
8287
|
+
// selected labels thin among themselves and win against every other.
|
|
8288
|
+
"text-allow-overlap": false,
|
|
8289
|
+
"text-ignore-placement": false,
|
|
8290
|
+
"text-optional": true,
|
|
8291
|
+
// Same ranking as the base layers, so which selected label wins a
|
|
8292
|
+
// crowded spot is stable across repaints.
|
|
8293
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8294
|
+
},
|
|
8295
|
+
paint: buildCustomLabelPaint()
|
|
8296
|
+
}
|
|
8297
|
+
];
|
|
8298
|
+
}
|
|
8299
|
+
function overlayTimelineInputs(ids, visible) {
|
|
8300
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
8301
|
+
if (visible !== null) ids.forEach((id) => {
|
|
8302
|
+
if (!visible.has(id)) hidden.add(id);
|
|
8303
|
+
});
|
|
8304
|
+
return { ids, hidden };
|
|
8305
|
+
}
|
|
8306
|
+
function sameIds(a, b) {
|
|
8307
|
+
return a.size === b.size && Array.from(a).every((id) => b.has(id));
|
|
8308
|
+
}
|
|
8309
|
+
function sameOverlayTimelineInputs(a, b) {
|
|
8310
|
+
return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
|
|
8311
|
+
}
|
|
8312
|
+
function buildSelectionOverlayData(ids, styleFor) {
|
|
8313
|
+
const features = [];
|
|
8314
|
+
ids.forEach((id) => {
|
|
8315
|
+
styleFor(id).forEach((feature) => features.push(feature));
|
|
8316
|
+
});
|
|
8317
|
+
return { type: "FeatureCollection", features };
|
|
8318
|
+
}
|
|
8213
8319
|
function renderedFeatureId(f) {
|
|
8214
8320
|
var _a;
|
|
8215
8321
|
const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
|
|
@@ -8739,6 +8845,8 @@ function ClusterPieManager(props) {
|
|
|
8739
8845
|
return null;
|
|
8740
8846
|
}
|
|
8741
8847
|
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
8848
|
+
const EMPTY_SOURCES = [];
|
|
8849
|
+
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"];
|
|
8742
8850
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
8743
8851
|
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
8744
8852
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
@@ -8944,6 +9052,13 @@ function basemapInsertAnchor(map) {
|
|
|
8944
9052
|
if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
|
|
8945
9053
|
return void 0;
|
|
8946
9054
|
}
|
|
9055
|
+
function featureStateHostFor(m) {
|
|
9056
|
+
return {
|
|
9057
|
+
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
9058
|
+
removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
|
|
9059
|
+
source: (source) => m.getSource(source)
|
|
9060
|
+
};
|
|
9061
|
+
}
|
|
8947
9062
|
const BASEMAP_LAYER_PREFIXES = {
|
|
8948
9063
|
streets: "streets-",
|
|
8949
9064
|
satellite: "satellite-",
|
|
@@ -9293,6 +9408,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9293
9408
|
}
|
|
9294
9409
|
return getReadOnlyFeatureById(id);
|
|
9295
9410
|
}, [getReadOnlyFeatureById]);
|
|
9411
|
+
const appliedSelectionRef = react.useRef(/* @__PURE__ */ new Map());
|
|
9412
|
+
const locatorCacheRef = react.useRef(createLocatorCache());
|
|
9413
|
+
const shardedLayerIdsRef = react.useRef(EMPTY_ID_SET);
|
|
9414
|
+
const overlayPaintContextRef = react.useRef(null);
|
|
9415
|
+
const shardFieldRangesRef = react.useRef(/* @__PURE__ */ new Map());
|
|
9416
|
+
const locateSelectionSources = react.useCallback((id) => {
|
|
9417
|
+
if (getFeatureById(id) === null) return EMPTY_SOURCES;
|
|
9418
|
+
return locateFeatureSources(
|
|
9419
|
+
id,
|
|
9420
|
+
{ readOnly: readOnlyFeatures.current, shardedLayerIds: shardedLayerIdsRef.current, shardSize: shardSizeRef.current },
|
|
9421
|
+
locatorCacheRef.current
|
|
9422
|
+
);
|
|
9423
|
+
}, [getFeatureById]);
|
|
9296
9424
|
const canDeleteSelected = react.useMemo(() => {
|
|
9297
9425
|
if (selectedFeatureIds.length === 0) return false;
|
|
9298
9426
|
return selectedFeatureIds.some((id) => {
|
|
@@ -9314,7 +9442,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9314
9442
|
return true;
|
|
9315
9443
|
});
|
|
9316
9444
|
}, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
|
|
9317
|
-
const applySelectionState = react.useCallback((nextIds, options) => {
|
|
9445
|
+
const applySelectionState$1 = react.useCallback((nextIds, options) => {
|
|
9318
9446
|
if (!isMapLoaded || !draw.current) {
|
|
9319
9447
|
setSelectedFeatureIds(nextIds);
|
|
9320
9448
|
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
|
|
@@ -9385,6 +9513,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9385
9513
|
});
|
|
9386
9514
|
const trySelectionFastPathRef = react.useRef(null);
|
|
9387
9515
|
const tryTimelineFastPathRef = react.useRef(null);
|
|
9516
|
+
const reconcileSelectionRef = react.useRef(null);
|
|
9388
9517
|
const syncCoalescerRef = react.useRef(null);
|
|
9389
9518
|
if (syncCoalescerRef.current === null) {
|
|
9390
9519
|
syncCoalescerRef.current = createRafCoalescer((reasons) => {
|
|
@@ -9585,7 +9714,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9585
9714
|
}
|
|
9586
9715
|
}, []);
|
|
9587
9716
|
const syncFeaturesToCustomLayers = react.useCallback(() => {
|
|
9588
|
-
var _a, _b;
|
|
9717
|
+
var _a, _b, _c;
|
|
9589
9718
|
if (!map.current) return;
|
|
9590
9719
|
if (isSyncingRef.current) return;
|
|
9591
9720
|
isSyncingRef.current = true;
|
|
@@ -9594,11 +9723,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9594
9723
|
const source = map.current.getSource("custom-features");
|
|
9595
9724
|
if (!source) return;
|
|
9596
9725
|
const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
|
|
9597
|
-
const drawSelectedIds = draw.current ? draw.current.getSelectedIds() : [];
|
|
9598
|
-
const componentSelectedIds = selectedFeatureIdsRef.current;
|
|
9599
|
-
const selectedIdSet = /* @__PURE__ */ new Set();
|
|
9600
|
-
drawSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
9601
|
-
componentSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
|
|
9602
9726
|
const visibleSet = timelineVisibleIdsRef.current;
|
|
9603
9727
|
const currentLayers = layersRef.current;
|
|
9604
9728
|
const isLayerVisible = (layer) => {
|
|
@@ -9610,6 +9734,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9610
9734
|
const count = ((_a2 = readOnlyFeatures.current.get(layer.id)) == null ? void 0 : _a2.length) ?? 0;
|
|
9611
9735
|
if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
|
|
9612
9736
|
});
|
|
9737
|
+
shardedLayerIdsRef.current = shardedLayerIds;
|
|
9613
9738
|
const allFeatures = [...drawFeatures.features];
|
|
9614
9739
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9615
9740
|
if (shardedLayerIds.has(layerId)) return;
|
|
@@ -9694,8 +9819,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9694
9819
|
const paintCache = createSelectionPaintCache();
|
|
9695
9820
|
const paintContext = {
|
|
9696
9821
|
timelineVisibleIds: visibleSet,
|
|
9697
|
-
selectedIds: selectedIdSet,
|
|
9698
|
-
selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
|
|
9699
9822
|
sizeFieldRanges,
|
|
9700
9823
|
colorFieldRanges,
|
|
9701
9824
|
tracePointIds,
|
|
@@ -9709,21 +9832,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9709
9832
|
features: allFeatures.map((f, i) => {
|
|
9710
9833
|
const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
|
|
9711
9834
|
const p = styled.paint;
|
|
9712
|
-
recordPaintedFeature(
|
|
9713
|
-
paintCache,
|
|
9714
|
-
p.featureId,
|
|
9715
|
-
p.basePriority,
|
|
9716
|
-
p.selected,
|
|
9717
|
-
p.visibleStrokeOpacity,
|
|
9718
|
-
p.visibleFillOpacity,
|
|
9719
|
-
p.timelineHidden
|
|
9720
|
-
);
|
|
9835
|
+
recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
9721
9836
|
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
9722
9837
|
return styled.feature;
|
|
9723
9838
|
})
|
|
9724
9839
|
};
|
|
9725
9840
|
source.setData(sourceData);
|
|
9726
9841
|
selectionPaintCacheRef.current = paintCache;
|
|
9842
|
+
overlayPaintContextRef.current = paintContext;
|
|
9843
|
+
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
9727
9844
|
const traceSource = map.current.getSource("trace-features");
|
|
9728
9845
|
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
9729
9846
|
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
|
|
@@ -9737,7 +9854,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9737
9854
|
sawArrowFeature = true;
|
|
9738
9855
|
if (f.geometry.type === "LineString") arrowLines.push(f);
|
|
9739
9856
|
});
|
|
9740
|
-
const shardArrows = ((
|
|
9857
|
+
const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
|
|
9741
9858
|
var _a2;
|
|
9742
9859
|
return ((_a2 = currentLayers.find((l) => l.id === id)) == null ? void 0 : _a2.visible) === true;
|
|
9743
9860
|
})) ?? [];
|
|
@@ -9757,7 +9874,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9757
9874
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
9758
9875
|
setLabelsSuppressed(false);
|
|
9759
9876
|
}
|
|
9760
|
-
(
|
|
9877
|
+
(_c = applyShardedLayersRef.current) == null ? void 0 : _c.call(applyShardedLayersRef);
|
|
9761
9878
|
const requestedBy = fullSyncCallersRef.current.splice(0);
|
|
9762
9879
|
let shardedFeatures = 0;
|
|
9763
9880
|
shardedLayerIds.forEach((id) => {
|
|
@@ -9854,21 +9971,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9854
9971
|
if (!m || !registry) return;
|
|
9855
9972
|
const currentLayers = layersRef.current;
|
|
9856
9973
|
const shardSize2 = shardSizeRef.current;
|
|
9857
|
-
const selectionEnabled = enableSelectionRef.current || enableDrawingRef.current;
|
|
9858
|
-
const currentSelectedIds = () => {
|
|
9859
|
-
var _a;
|
|
9860
|
-
const ids = /* @__PURE__ */ new Set();
|
|
9861
|
-
if (selectionEnabled) {
|
|
9862
|
-
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => ids.add(String(id)));
|
|
9863
|
-
selectedFeatureIdsRef.current.forEach((id) => ids.add(String(id)));
|
|
9864
|
-
}
|
|
9865
|
-
return ids;
|
|
9866
|
-
};
|
|
9867
9974
|
currentLayers.forEach((layer) => {
|
|
9868
9975
|
var _a;
|
|
9869
9976
|
const features = readOnlyFeatures.current.get(layer.id) ?? [];
|
|
9870
9977
|
if (!isShardEligible(layer, features.length, shardSize2)) {
|
|
9871
9978
|
registry.remove(layer.id);
|
|
9979
|
+
shardFieldRangesRef.current.delete(layer.id);
|
|
9872
9980
|
setLayerImporting(layer.id, false);
|
|
9873
9981
|
return;
|
|
9874
9982
|
}
|
|
@@ -9878,10 +9986,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9878
9986
|
setLayerImporting(layer.id, false);
|
|
9879
9987
|
return;
|
|
9880
9988
|
}
|
|
9881
|
-
const fingerprint = buildShardFingerprint(layer, features,
|
|
9989
|
+
const fingerprint = buildShardFingerprint(layer, features, shardSize2);
|
|
9882
9990
|
const expectedShards = shardRanges(features.length, shardSize2).length;
|
|
9883
9991
|
if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
|
|
9884
|
-
if (reconcileShardCaches(registry, state.layerId, expectedShards,
|
|
9992
|
+
if (reconcileShardCaches(registry, state.layerId, expectedShards, timelineVisibleIdsRef.current)) {
|
|
9885
9993
|
setLayerImporting(layer.id, false);
|
|
9886
9994
|
mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
|
|
9887
9995
|
return;
|
|
@@ -9901,10 +10009,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9901
10009
|
const ranges = layerFieldRanges(layer.visualConfig, (visit) => {
|
|
9902
10010
|
for (let i = 0; i < features.length; i++) visit(features[i].properties);
|
|
9903
10011
|
});
|
|
10012
|
+
shardFieldRangesRef.current.set(layer.id, ranges);
|
|
9904
10013
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
9905
10014
|
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
9906
10015
|
if (ranges.size) sizeFieldRanges.set(layer.id, ranges.size);
|
|
9907
10016
|
if (ranges.color) colorFieldRanges.set(layer.id, ranges.color);
|
|
10017
|
+
let overlayRestyled = false;
|
|
9908
10018
|
void runShardPass({
|
|
9909
10019
|
layer,
|
|
9910
10020
|
features,
|
|
@@ -9915,8 +10025,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9915
10025
|
contextForShard: () => {
|
|
9916
10026
|
return {
|
|
9917
10027
|
timelineVisibleIds: timelineVisibleIdsRef.current,
|
|
9918
|
-
selectedIds: currentSelectedIds(),
|
|
9919
|
-
selectionEnabled,
|
|
9920
10028
|
sizeFieldRanges,
|
|
9921
10029
|
colorFieldRanges,
|
|
9922
10030
|
// Trace-enabled layers are never sharded, so these are empty by construction.
|
|
@@ -9927,7 +10035,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9927
10035
|
};
|
|
9928
10036
|
},
|
|
9929
10037
|
onShardPainted: (index, cache2) => {
|
|
10038
|
+
var _a2;
|
|
9930
10039
|
state.caches[index] = cache2;
|
|
10040
|
+
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10041
|
+
overlayRestyled = true;
|
|
9931
10042
|
},
|
|
9932
10043
|
onProgress: (painted) => progress == null ? void 0 : progress.update(painted)
|
|
9933
10044
|
}).then((result) => {
|
|
@@ -10118,7 +10229,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10118
10229
|
});
|
|
10119
10230
|
const registry = shardRegistryRef.current;
|
|
10120
10231
|
registry == null ? void 0 : registry.trackedLayerIds().forEach((layerId) => {
|
|
10121
|
-
if (!liveLayerIds.has(layerId))
|
|
10232
|
+
if (!liveLayerIds.has(layerId)) {
|
|
10233
|
+
registry.remove(layerId);
|
|
10234
|
+
shardFieldRangesRef.current.delete(layerId);
|
|
10235
|
+
}
|
|
10122
10236
|
});
|
|
10123
10237
|
Object.keys((style == null ? void 0 : style.sources) ?? {}).forEach((sid) => {
|
|
10124
10238
|
const parsed = parseShardSourceId(sid);
|
|
@@ -10241,15 +10355,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10241
10355
|
coalesceKey,
|
|
10242
10356
|
undo: () => {
|
|
10243
10357
|
applyHistoryState(featureIds, layerIds, beforeF, beforeL);
|
|
10244
|
-
applySelectionState(beforeSelectedIds, { focusProperties: false });
|
|
10358
|
+
applySelectionState$1(beforeSelectedIds, { focusProperties: false });
|
|
10245
10359
|
},
|
|
10246
10360
|
redo: () => {
|
|
10247
10361
|
applyHistoryState(featureIds, layerIds, afterF, afterL);
|
|
10248
|
-
applySelectionState(afterSelectedIds, { focusProperties: false });
|
|
10362
|
+
applySelectionState$1(afterSelectedIds, { focusProperties: false });
|
|
10249
10363
|
}
|
|
10250
10364
|
};
|
|
10251
10365
|
},
|
|
10252
|
-
[applyHistoryState, applySelectionState]
|
|
10366
|
+
[applyHistoryState, applySelectionState$1]
|
|
10253
10367
|
);
|
|
10254
10368
|
const finalizeCapture = react.useCallback(() => {
|
|
10255
10369
|
const pending = pendingCaptureRef.current;
|
|
@@ -10373,11 +10487,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10373
10487
|
var _a, _b;
|
|
10374
10488
|
map.current = mapInstance;
|
|
10375
10489
|
draw.current = drawInstance;
|
|
10376
|
-
mapInstance.addSource(
|
|
10377
|
-
type: "geojson",
|
|
10378
|
-
data: { type: "FeatureCollection", features: [] },
|
|
10379
|
-
maxzoom: 22
|
|
10380
|
-
});
|
|
10490
|
+
mapInstance.addSource(SHARED_SOURCE_ID, customSourceSpec());
|
|
10381
10491
|
const sharedStack = buildCustomLayerStack(SHARED_SOURCE_ID, CUSTOM_LAYER_ROLES, { labelsVisible: false });
|
|
10382
10492
|
sharedStack.forEach((spec) => mapInstance.addLayer(spec));
|
|
10383
10493
|
const styleHost = {
|
|
@@ -10468,6 +10578,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10468
10578
|
"line-opacity": 0.7
|
|
10469
10579
|
}
|
|
10470
10580
|
});
|
|
10581
|
+
mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
|
|
10582
|
+
type: "geojson",
|
|
10583
|
+
data: { type: "FeatureCollection", features: [] },
|
|
10584
|
+
maxzoom: 22
|
|
10585
|
+
});
|
|
10586
|
+
buildSelectionOverlayStack().forEach((spec) => mapInstance.addLayer(spec));
|
|
10471
10587
|
if (tooltipElRef.current) {
|
|
10472
10588
|
const prevCleanup = tooltipElRef.current._cleanup;
|
|
10473
10589
|
try {
|
|
@@ -10586,8 +10702,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10586
10702
|
const highlightFields = /* @__PURE__ */ new Set();
|
|
10587
10703
|
if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
|
|
10588
10704
|
if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
|
|
10589
|
-
const
|
|
10590
|
-
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);
|
|
10705
|
+
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);
|
|
10591
10706
|
const name = props.name;
|
|
10592
10707
|
let html = '<div class="text-sm space-y-0.5">';
|
|
10593
10708
|
if (name) html += `<div class="font-medium">${name}</div>`;
|
|
@@ -11263,7 +11378,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11263
11378
|
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
11264
11379
|
if (!clusterHit) {
|
|
11265
11380
|
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
11266
|
-
applySelectionState([]);
|
|
11381
|
+
applySelectionState$1([]);
|
|
11267
11382
|
}
|
|
11268
11383
|
return;
|
|
11269
11384
|
}
|
|
@@ -11285,13 +11400,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11285
11400
|
return;
|
|
11286
11401
|
}
|
|
11287
11402
|
const fid = String(featureId);
|
|
11288
|
-
const
|
|
11289
|
-
const isAlreadySelected =
|
|
11403
|
+
const currentSelection2 = selectedFeatureIdsRef.current;
|
|
11404
|
+
const isAlreadySelected = currentSelection2.includes(fid);
|
|
11290
11405
|
let nextIds;
|
|
11291
11406
|
if (isModifierKey) {
|
|
11292
|
-
nextIds = isAlreadySelected ?
|
|
11407
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [...currentSelection2, fid];
|
|
11293
11408
|
} else {
|
|
11294
|
-
nextIds = isAlreadySelected ?
|
|
11409
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [fid];
|
|
11295
11410
|
}
|
|
11296
11411
|
isSelectingReadOnlyRef.current = true;
|
|
11297
11412
|
if (drawInstance.getSelected().features.length > 0) {
|
|
@@ -11843,7 +11958,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
11843
11958
|
onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
|
|
11844
11959
|
},
|
|
11845
11960
|
selectFeatures: (featureIds) => {
|
|
11846
|
-
applySelectionState(featureIds, { focusProperties: true });
|
|
11961
|
+
applySelectionState$1(featureIds, { focusProperties: true });
|
|
11847
11962
|
},
|
|
11848
11963
|
getSelectedFeatures,
|
|
11849
11964
|
setEditMode: (enabled) => {
|
|
@@ -12132,7 +12247,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
12132
12247
|
setPersistedSelectionPolygon(null);
|
|
12133
12248
|
setSelectionPoints([]);
|
|
12134
12249
|
setSelectedFeatureIds([]);
|
|
12135
|
-
applySelectionState([], { focusProperties: true });
|
|
12250
|
+
applySelectionState$1([], { focusProperties: true });
|
|
12136
12251
|
},
|
|
12137
12252
|
// Viewport and state getters
|
|
12138
12253
|
getViewport: () => {
|
|
@@ -13120,6 +13235,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13120
13235
|
if (!m.getLayer(id)) return;
|
|
13121
13236
|
m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
|
|
13122
13237
|
});
|
|
13238
|
+
if (!firstVisibleBasemapSymbol && m.getLayer(SELECTION_OVERLAY_LAYER_IDS.label)) {
|
|
13239
|
+
m.moveLayer(SELECTION_OVERLAY_LAYER_IDS.label);
|
|
13240
|
+
}
|
|
13123
13241
|
} catch (e) {
|
|
13124
13242
|
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
13125
13243
|
}
|
|
@@ -13674,24 +13792,91 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13674
13792
|
react.useEffect(() => {
|
|
13675
13793
|
enableDrawingRef.current = enableDrawing;
|
|
13676
13794
|
}, [enableDrawing]);
|
|
13677
|
-
const
|
|
13795
|
+
const overlayPaintContext = react.useCallback(() => {
|
|
13796
|
+
const base = overlayPaintContextRef.current;
|
|
13797
|
+
if (!base) return null;
|
|
13798
|
+
const sizeFieldRanges = new Map(base.sizeFieldRanges);
|
|
13799
|
+
const colorFieldRanges = new Map(base.colorFieldRanges);
|
|
13800
|
+
shardFieldRangesRef.current.forEach((ranges, layerId) => {
|
|
13801
|
+
if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
|
|
13802
|
+
if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
|
|
13803
|
+
});
|
|
13804
|
+
return { ...base, timelineVisibleIds: timelineVisibleIdsRef.current, sizeFieldRanges, colorFieldRanges };
|
|
13805
|
+
}, []);
|
|
13806
|
+
const overlayFeatureCountRef = react.useRef(0);
|
|
13807
|
+
const overlayTimelineInputsRef = react.useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
|
|
13808
|
+
const refreshSelectionOverlay = react.useCallback((m, ids) => {
|
|
13809
|
+
overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
|
|
13810
|
+
if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
|
|
13811
|
+
const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
|
|
13812
|
+
if (!overlay) return;
|
|
13813
|
+
const ctx = ids.size > 0 ? overlayPaintContext() : null;
|
|
13814
|
+
const layers2 = layersRef.current;
|
|
13815
|
+
const layerById = new Map(layers2.map((l) => [l.id, l]));
|
|
13816
|
+
const data = buildSelectionOverlayData(ids, (id) => {
|
|
13817
|
+
if (!ctx) return [];
|
|
13818
|
+
const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
|
|
13819
|
+
if (holders.length > 0) {
|
|
13820
|
+
return holders.filter((h) => {
|
|
13821
|
+
var _a;
|
|
13822
|
+
return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
|
|
13823
|
+
}).map((h) => styleFeatureForPaint(h.feature, layerById.get(h.layerId), ctx, true).feature);
|
|
13824
|
+
}
|
|
13825
|
+
const feature = getFeatureById(id);
|
|
13826
|
+
if (!feature) return [];
|
|
13827
|
+
const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
|
|
13828
|
+
return layer && !layer.visible ? [] : [styleFeatureForPaint(feature, layer, ctx, true).feature];
|
|
13829
|
+
});
|
|
13830
|
+
overlay.setData(data);
|
|
13831
|
+
overlayFeatureCountRef.current = data.features.length;
|
|
13832
|
+
}, [getFeatureById, overlayPaintContext]);
|
|
13833
|
+
const currentSelection = react.useCallback(() => {
|
|
13678
13834
|
var _a;
|
|
13835
|
+
if (!(enableSelectionRef.current || enableDrawingRef.current)) return null;
|
|
13836
|
+
const next = /* @__PURE__ */ new Set();
|
|
13837
|
+
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
|
|
13838
|
+
selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
|
|
13839
|
+
return next;
|
|
13840
|
+
}, []);
|
|
13841
|
+
const paintSelection = react.useCallback((m, overlay = true) => {
|
|
13842
|
+
const selection = currentSelection();
|
|
13843
|
+
const { set: set2, removed } = applySelectionState(
|
|
13844
|
+
appliedSelectionRef.current,
|
|
13845
|
+
selection ?? EMPTY_ID_SET,
|
|
13846
|
+
selection !== null,
|
|
13847
|
+
locateSelectionSources,
|
|
13848
|
+
featureStateHostFor(m)
|
|
13849
|
+
);
|
|
13850
|
+
const shown = selection ?? EMPTY_ID_SET;
|
|
13851
|
+
if (overlay) refreshSelectionOverlay(m, shown);
|
|
13852
|
+
return { set: set2, removed, overlay: overlay ? shown.size : 0 };
|
|
13853
|
+
}, [currentSelection, locateSelectionSources, refreshSelectionOverlay]);
|
|
13854
|
+
const applySelectionPaint = react.useCallback(() => {
|
|
13679
13855
|
const m = map.current;
|
|
13680
13856
|
if (!m) return true;
|
|
13681
|
-
const
|
|
13682
|
-
const
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13857
|
+
const start = performance.now();
|
|
13858
|
+
const painted = paintSelection(m);
|
|
13859
|
+
mapPerfLog("selection", "feature state applied", { ...painted, ms: Math.round(performance.now() - start) });
|
|
13860
|
+
return true;
|
|
13861
|
+
}, [paintSelection]);
|
|
13862
|
+
trySelectionFastPathRef.current = applySelectionPaint;
|
|
13863
|
+
const reconcileSelectionAfterPaint = react.useCallback((options) => {
|
|
13864
|
+
const m = map.current;
|
|
13865
|
+
if (!m) return;
|
|
13866
|
+
const { moved, pruned } = reconcileSelectionSources(
|
|
13867
|
+
appliedSelectionRef.current,
|
|
13868
|
+
locateSelectionSources,
|
|
13869
|
+
featureStateHostFor(m)
|
|
13692
13870
|
);
|
|
13693
|
-
|
|
13694
|
-
|
|
13871
|
+
const applied = paintSelection(m, (options == null ? void 0 : options.overlay) ?? true);
|
|
13872
|
+
if (moved || pruned || applied.set || applied.removed) {
|
|
13873
|
+
mapPerfLog("selection", "reconciled after paint", { moved, pruned, ...applied });
|
|
13874
|
+
}
|
|
13875
|
+
}, [locateSelectionSources, paintSelection]);
|
|
13876
|
+
reconcileSelectionRef.current = reconcileSelectionAfterPaint;
|
|
13877
|
+
react.useEffect(() => {
|
|
13878
|
+
scheduleSync("selection");
|
|
13879
|
+
}, [enableSelection, enableDrawing, scheduleSync]);
|
|
13695
13880
|
const tryTimelineFastPath = react.useCallback(() => {
|
|
13696
13881
|
const m = map.current;
|
|
13697
13882
|
if (!m) return true;
|
|
@@ -13705,13 +13890,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13705
13890
|
const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
|
|
13706
13891
|
const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
|
|
13707
13892
|
if (!applied || !paintCache || !source) return false;
|
|
13708
|
-
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff,
|
|
13893
|
+
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, source, traceSource))) return false;
|
|
13709
13894
|
if (!forEachShardCache(shardRegistryRef.current, (cache2, shardSource) => applyTimelineFastPath(cache2, nextVisible, shardSource).applied)) {
|
|
13710
13895
|
return false;
|
|
13711
13896
|
}
|
|
13712
13897
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
13713
13898
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
13714
13899
|
setLabelsSuppressed(false);
|
|
13900
|
+
const selection = currentSelection() ?? EMPTY_ID_SET;
|
|
13901
|
+
if (!sameOverlayTimelineInputs(overlayTimelineInputsRef.current, overlayTimelineInputs(selection, nextVisible))) {
|
|
13902
|
+
refreshSelectionOverlay(m, selection);
|
|
13903
|
+
}
|
|
13715
13904
|
mapPerfLog("timeline", "fast path applied", {
|
|
13716
13905
|
toggled,
|
|
13717
13906
|
endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
|
|
@@ -13719,7 +13908,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13719
13908
|
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
13720
13909
|
});
|
|
13721
13910
|
return true;
|
|
13722
|
-
}, [autoLabelConfig, countVisibleFeatures]);
|
|
13911
|
+
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
|
|
13723
13912
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
13724
13913
|
const collectSelectionFeatureGroups = react.useCallback(() => {
|
|
13725
13914
|
return collectVisibleFeatureGroups(
|
|
@@ -13835,7 +14024,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13835
14024
|
axisAlignedRectangle: true
|
|
13836
14025
|
});
|
|
13837
14026
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13838
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14027
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13839
14028
|
}
|
|
13840
14029
|
setIsSelectionToolActive(false);
|
|
13841
14030
|
startPoint = null;
|
|
@@ -13858,7 +14047,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13858
14047
|
} else {
|
|
13859
14048
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13860
14049
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13861
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14050
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13862
14051
|
}
|
|
13863
14052
|
setIsSelectionToolActive(false);
|
|
13864
14053
|
}
|
|
@@ -13892,7 +14081,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13892
14081
|
} else {
|
|
13893
14082
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13894
14083
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13895
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14084
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13896
14085
|
}
|
|
13897
14086
|
setIsSelectionToolActive(false);
|
|
13898
14087
|
setSelectionPoints([]);
|
|
@@ -14008,7 +14197,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
14008
14197
|
setSelectionPoints([]);
|
|
14009
14198
|
mapInstance.dragPan.enable();
|
|
14010
14199
|
canvas.style.cursor = "";
|
|
14011
|
-
applySelectionState(mergedIds, { focusProperties: true });
|
|
14200
|
+
applySelectionState$1(mergedIds, { focusProperties: true });
|
|
14012
14201
|
};
|
|
14013
14202
|
canvas.addEventListener("mousedown", handleShiftMouseDown);
|
|
14014
14203
|
window.addEventListener("mousemove", handleShiftMouseMove);
|
|
@@ -14021,7 +14210,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
14021
14210
|
map.current.dragPan.enable();
|
|
14022
14211
|
}
|
|
14023
14212
|
};
|
|
14024
|
-
}, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
|
|
14213
|
+
}, [isMapLoaded, isSelectionToolActive, applySelectionState$1, collectSelectionFeatureGroups]);
|
|
14025
14214
|
react.useEffect(() => {
|
|
14026
14215
|
if (!map.current || !isMapLoaded) return;
|
|
14027
14216
|
const mapInstance = map.current;
|