@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.mjs
CHANGED
|
@@ -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: [],
|
|
@@ -7071,13 +6967,13 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7071
6967
|
setEnabled: (enabled) => {
|
|
7072
6968
|
if (enabled) {
|
|
7073
6969
|
const state = get();
|
|
7074
|
-
|
|
6970
|
+
set2({
|
|
7075
6971
|
isEnabled: true,
|
|
7076
6972
|
rangeStart: state.globalMinDate,
|
|
7077
6973
|
rangeEnd: state.globalMaxDate
|
|
7078
6974
|
});
|
|
7079
6975
|
} else {
|
|
7080
|
-
|
|
6976
|
+
set2({ isEnabled: false, isPlaying: false });
|
|
7081
6977
|
}
|
|
7082
6978
|
},
|
|
7083
6979
|
setTemporalFeatures: (features, untimedIds) => {
|
|
@@ -7086,7 +6982,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7086
6982
|
const state = get();
|
|
7087
6983
|
if (timedFeatures.length === 0) {
|
|
7088
6984
|
if (!state.hasTemporalData && state.temporalFeatures.length === 0) return;
|
|
7089
|
-
|
|
6985
|
+
set2({
|
|
7090
6986
|
hasTemporalData: false,
|
|
7091
6987
|
temporalFeatures: [],
|
|
7092
6988
|
untimedFeatureIds: untimedIds,
|
|
@@ -7113,7 +7009,7 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7113
7009
|
const sameUntimed = state.untimedFeatureIds.length === untimedIds.length && untimedIds.every((id, i) => id === state.untimedFeatureIds[i]);
|
|
7114
7010
|
if (sameFeatureIds && sameDates && sameUntimed && state.hasTemporalData) return;
|
|
7115
7011
|
const histogramBins = minDate && maxDate ? computeHistogramBins(timedFeatures, minDate, maxDate) : [];
|
|
7116
|
-
|
|
7012
|
+
set2({
|
|
7117
7013
|
hasTemporalData: true,
|
|
7118
7014
|
temporalFeatures: timedFeatures,
|
|
7119
7015
|
untimedFeatureIds: untimedIds,
|
|
@@ -7124,9 +7020,9 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7124
7020
|
histogramBins
|
|
7125
7021
|
});
|
|
7126
7022
|
},
|
|
7127
|
-
setRange: (start, end) =>
|
|
7128
|
-
setPlaying: (playing) =>
|
|
7129
|
-
setPlaybackSpeed: (speed) =>
|
|
7023
|
+
setRange: (start, end) => set2({ rangeStart: start, rangeEnd: end }),
|
|
7024
|
+
setPlaying: (playing) => set2({ isPlaying: playing }),
|
|
7025
|
+
setPlaybackSpeed: (speed) => set2({ playbackSpeed: speed }),
|
|
7130
7026
|
advancePlayhead: () => {
|
|
7131
7027
|
const state = get();
|
|
7132
7028
|
if (!state.globalMinDate || !state.globalMaxDate || !state.rangeStart) {
|
|
@@ -7137,20 +7033,20 @@ const timelineStoreInitializer = (set, get) => ({
|
|
|
7137
7033
|
const newStart = new Date(state.rangeStart.getTime() + stepSize);
|
|
7138
7034
|
const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepSize) : null;
|
|
7139
7035
|
if (newStart >= state.globalMaxDate) {
|
|
7140
|
-
|
|
7036
|
+
set2({
|
|
7141
7037
|
isPlaying: false,
|
|
7142
7038
|
rangeStart: state.globalMinDate,
|
|
7143
7039
|
rangeEnd: state.globalMaxDate
|
|
7144
7040
|
});
|
|
7145
7041
|
return false;
|
|
7146
7042
|
}
|
|
7147
|
-
|
|
7043
|
+
set2({
|
|
7148
7044
|
rangeStart: newStart,
|
|
7149
7045
|
rangeEnd: newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate
|
|
7150
7046
|
});
|
|
7151
7047
|
return true;
|
|
7152
7048
|
},
|
|
7153
|
-
reset: () =>
|
|
7049
|
+
reset: () => set2({
|
|
7154
7050
|
isEnabled: false,
|
|
7155
7051
|
hasTemporalData: false,
|
|
7156
7052
|
temporalFeatures: [],
|
|
@@ -7928,6 +7824,129 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
|
7928
7824
|
}
|
|
7929
7825
|
};
|
|
7930
7826
|
}
|
|
7827
|
+
const EMPTY = /* @__PURE__ */ new Set();
|
|
7828
|
+
function isLive(host, entry) {
|
|
7829
|
+
return host.source(entry.sourceId) === entry.handle;
|
|
7830
|
+
}
|
|
7831
|
+
function remove(host, entry, id) {
|
|
7832
|
+
if (!isLive(host, entry)) return false;
|
|
7833
|
+
host.removeFeatureState(entry.sourceId, id);
|
|
7834
|
+
return true;
|
|
7835
|
+
}
|
|
7836
|
+
function set(host, sourceId, id) {
|
|
7837
|
+
const handle = host.source(sourceId);
|
|
7838
|
+
if (!handle) return null;
|
|
7839
|
+
host.setFeatureState(sourceId, id, SELECTED_STATE);
|
|
7840
|
+
return { sourceId, handle };
|
|
7841
|
+
}
|
|
7842
|
+
function setAll(host, sourceIds, id) {
|
|
7843
|
+
const done = [];
|
|
7844
|
+
sourceIds.forEach((sourceId) => {
|
|
7845
|
+
const entry = set(host, sourceId, id);
|
|
7846
|
+
if (entry) done.push(entry);
|
|
7847
|
+
});
|
|
7848
|
+
return done;
|
|
7849
|
+
}
|
|
7850
|
+
function place(applied, id, sources, host) {
|
|
7851
|
+
const done = setAll(host, sources, id);
|
|
7852
|
+
if (done.length > 0) applied.set(id, done);
|
|
7853
|
+
return done.length;
|
|
7854
|
+
}
|
|
7855
|
+
function applySelectionState(applied, next, gate, locate, host) {
|
|
7856
|
+
const target = gate ? next : EMPTY;
|
|
7857
|
+
let setCount = 0;
|
|
7858
|
+
let removed = 0;
|
|
7859
|
+
const gone = [];
|
|
7860
|
+
applied.forEach((_sources, id) => {
|
|
7861
|
+
if (!target.has(id)) gone.push(id);
|
|
7862
|
+
});
|
|
7863
|
+
gone.forEach((id) => {
|
|
7864
|
+
(applied.get(id) ?? []).forEach((entry) => {
|
|
7865
|
+
if (remove(host, entry, id)) removed++;
|
|
7866
|
+
});
|
|
7867
|
+
applied.delete(id);
|
|
7868
|
+
});
|
|
7869
|
+
target.forEach((id) => {
|
|
7870
|
+
if (applied.has(id)) return;
|
|
7871
|
+
setCount += place(applied, id, locate(id), host);
|
|
7872
|
+
});
|
|
7873
|
+
return { set: setCount, removed };
|
|
7874
|
+
}
|
|
7875
|
+
function reconcileSelectionSources(applied, locate, host) {
|
|
7876
|
+
let moved = 0;
|
|
7877
|
+
let pruned = 0;
|
|
7878
|
+
const changes = [];
|
|
7879
|
+
applied.forEach((have, id) => {
|
|
7880
|
+
const want = locate(id);
|
|
7881
|
+
const live = have.filter((entry) => isLive(host, entry));
|
|
7882
|
+
const same = want.length > 0 && live.length === have.length && want.every((sourceId) => live.some((entry) => entry.sourceId === sourceId));
|
|
7883
|
+
if (!same) changes.push({ id, have, live, want });
|
|
7884
|
+
});
|
|
7885
|
+
changes.forEach(({ id, have, live, want }) => {
|
|
7886
|
+
if (want.length === 0) {
|
|
7887
|
+
have.forEach((entry) => remove(host, entry, id));
|
|
7888
|
+
applied.delete(id);
|
|
7889
|
+
pruned++;
|
|
7890
|
+
return;
|
|
7891
|
+
}
|
|
7892
|
+
const missing = want.filter((sourceId) => !live.some((entry) => entry.sourceId === sourceId));
|
|
7893
|
+
const gained = setAll(host, missing, id);
|
|
7894
|
+
const now = [...live, ...gained];
|
|
7895
|
+
if (now.length > 0) applied.set(id, now);
|
|
7896
|
+
else applied.delete(id);
|
|
7897
|
+
if (gained.length > 0) moved++;
|
|
7898
|
+
});
|
|
7899
|
+
return { moved, pruned };
|
|
7900
|
+
}
|
|
7901
|
+
function createLocatorCache() {
|
|
7902
|
+
return /* @__PURE__ */ new WeakMap();
|
|
7903
|
+
}
|
|
7904
|
+
function indexOfIds(features, cache2) {
|
|
7905
|
+
const cached = cache2.get(features);
|
|
7906
|
+
if (cached) return cached;
|
|
7907
|
+
const index = { first: /* @__PURE__ */ new Map(), repeats: /* @__PURE__ */ new Map() };
|
|
7908
|
+
for (let i = 0; i < features.length; i++) {
|
|
7909
|
+
const id = features[i].id;
|
|
7910
|
+
if (id === void 0 || id === null) continue;
|
|
7911
|
+
const key = String(id);
|
|
7912
|
+
if (!index.first.has(key)) index.first.set(key, i);
|
|
7913
|
+
else {
|
|
7914
|
+
const more = index.repeats.get(key);
|
|
7915
|
+
if (more) more.push(i);
|
|
7916
|
+
else index.repeats.set(key, [i]);
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
cache2.set(features, index);
|
|
7920
|
+
return index;
|
|
7921
|
+
}
|
|
7922
|
+
function forEachIndex(index, id, visit) {
|
|
7923
|
+
var _a;
|
|
7924
|
+
const at = index.first.get(id);
|
|
7925
|
+
if (at === void 0) return;
|
|
7926
|
+
visit(at);
|
|
7927
|
+
(_a = index.repeats.get(id)) == null ? void 0 : _a.forEach(visit);
|
|
7928
|
+
}
|
|
7929
|
+
function locateFeatureHolders(id, readOnly, cache2) {
|
|
7930
|
+
const holders = [];
|
|
7931
|
+
readOnly.forEach((features, layerId) => {
|
|
7932
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
|
|
7933
|
+
});
|
|
7934
|
+
return holders;
|
|
7935
|
+
}
|
|
7936
|
+
function locateFeatureSources(id, inputs, cache2) {
|
|
7937
|
+
const sources = [];
|
|
7938
|
+
const add = (sourceId) => {
|
|
7939
|
+
if (!sources.includes(sourceId)) sources.push(sourceId);
|
|
7940
|
+
};
|
|
7941
|
+
inputs.readOnly.forEach((features, layerId) => {
|
|
7942
|
+
const sharded = inputs.shardedLayerIds.has(layerId);
|
|
7943
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => {
|
|
7944
|
+
add(sharded ? shardSourceId(layerId, Math.floor(at / inputs.shardSize)) : SHARED_SOURCE_ID);
|
|
7945
|
+
});
|
|
7946
|
+
});
|
|
7947
|
+
if (sources.length === 0) add(SHARED_SOURCE_ID);
|
|
7948
|
+
return sources;
|
|
7949
|
+
}
|
|
7931
7950
|
function deepClone(value) {
|
|
7932
7951
|
try {
|
|
7933
7952
|
return structuredClone(value);
|
|
@@ -8190,6 +8209,93 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
|
|
|
8190
8209
|
mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
|
|
8191
8210
|
return selectedIds;
|
|
8192
8211
|
}
|
|
8212
|
+
const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
|
|
8213
|
+
const SELECTION_OVERLAY_LAYER_IDS = {
|
|
8214
|
+
iconRing: "selection-overlay-icon-ring",
|
|
8215
|
+
line: "selection-overlay-line",
|
|
8216
|
+
polygon: "selection-overlay-polygon",
|
|
8217
|
+
label: "selection-overlay-label"
|
|
8218
|
+
};
|
|
8219
|
+
function buildSelectionOverlayStack() {
|
|
8220
|
+
const source = SELECTION_OVERLAY_SOURCE_ID;
|
|
8221
|
+
return [
|
|
8222
|
+
{
|
|
8223
|
+
id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
|
|
8224
|
+
type: "circle",
|
|
8225
|
+
source,
|
|
8226
|
+
filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
|
|
8227
|
+
paint: {
|
|
8228
|
+
"circle-color": "transparent",
|
|
8229
|
+
"circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
|
|
8230
|
+
"circle-stroke-color": SELECTION_COLOR,
|
|
8231
|
+
"circle-stroke-width": 3,
|
|
8232
|
+
"circle-stroke-opacity": 1
|
|
8233
|
+
}
|
|
8234
|
+
},
|
|
8235
|
+
{
|
|
8236
|
+
id: SELECTION_OVERLAY_LAYER_IDS.line,
|
|
8237
|
+
type: "line",
|
|
8238
|
+
source,
|
|
8239
|
+
filter: ["==", "$type", "LineString"],
|
|
8240
|
+
paint: {
|
|
8241
|
+
"line-color": SELECTION_COLOR,
|
|
8242
|
+
"line-width": ["+", ["get", "stroke-width"], 4],
|
|
8243
|
+
"line-dasharray": [4, 2]
|
|
8244
|
+
}
|
|
8245
|
+
},
|
|
8246
|
+
{
|
|
8247
|
+
id: SELECTION_OVERLAY_LAYER_IDS.polygon,
|
|
8248
|
+
type: "line",
|
|
8249
|
+
source,
|
|
8250
|
+
filter: ["==", "$type", "Polygon"],
|
|
8251
|
+
paint: {
|
|
8252
|
+
"line-color": SELECTION_COLOR,
|
|
8253
|
+
"line-width": 4,
|
|
8254
|
+
"line-dasharray": [4, 2]
|
|
8255
|
+
}
|
|
8256
|
+
},
|
|
8257
|
+
{
|
|
8258
|
+
id: SELECTION_OVERLAY_LAYER_IDS.label,
|
|
8259
|
+
type: "symbol",
|
|
8260
|
+
source,
|
|
8261
|
+
layout: {
|
|
8262
|
+
...buildCustomLabelLayout(),
|
|
8263
|
+
// Never hidden by the auto-label density cap, which only flips the
|
|
8264
|
+
// unpinned base layer: with base labels off, the selected ones stay.
|
|
8265
|
+
visibility: "visible",
|
|
8266
|
+
// Full collision; topmost, so placed first (see the module comment):
|
|
8267
|
+
// selected labels thin among themselves and win against every other.
|
|
8268
|
+
"text-allow-overlap": false,
|
|
8269
|
+
"text-ignore-placement": false,
|
|
8270
|
+
"text-optional": true,
|
|
8271
|
+
// Same ranking as the base layers, so which selected label wins a
|
|
8272
|
+
// crowded spot is stable across repaints.
|
|
8273
|
+
"symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
|
|
8274
|
+
},
|
|
8275
|
+
paint: buildCustomLabelPaint()
|
|
8276
|
+
}
|
|
8277
|
+
];
|
|
8278
|
+
}
|
|
8279
|
+
function overlayTimelineInputs(ids, visible) {
|
|
8280
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
8281
|
+
if (visible !== null) ids.forEach((id) => {
|
|
8282
|
+
if (!visible.has(id)) hidden.add(id);
|
|
8283
|
+
});
|
|
8284
|
+
return { ids, hidden };
|
|
8285
|
+
}
|
|
8286
|
+
function sameIds(a, b) {
|
|
8287
|
+
return a.size === b.size && Array.from(a).every((id) => b.has(id));
|
|
8288
|
+
}
|
|
8289
|
+
function sameOverlayTimelineInputs(a, b) {
|
|
8290
|
+
return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
|
|
8291
|
+
}
|
|
8292
|
+
function buildSelectionOverlayData(ids, styleFor) {
|
|
8293
|
+
const features = [];
|
|
8294
|
+
ids.forEach((id) => {
|
|
8295
|
+
styleFor(id).forEach((feature) => features.push(feature));
|
|
8296
|
+
});
|
|
8297
|
+
return { type: "FeatureCollection", features };
|
|
8298
|
+
}
|
|
8193
8299
|
function renderedFeatureId(f) {
|
|
8194
8300
|
var _a;
|
|
8195
8301
|
const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
|
|
@@ -8719,6 +8825,8 @@ function ClusterPieManager(props) {
|
|
|
8719
8825
|
return null;
|
|
8720
8826
|
}
|
|
8721
8827
|
const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
8828
|
+
const EMPTY_SOURCES = [];
|
|
8829
|
+
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
8830
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
8723
8831
|
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
8724
8832
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
@@ -8924,6 +9032,13 @@ function basemapInsertAnchor(map) {
|
|
|
8924
9032
|
if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
|
|
8925
9033
|
return void 0;
|
|
8926
9034
|
}
|
|
9035
|
+
function featureStateHostFor(m) {
|
|
9036
|
+
return {
|
|
9037
|
+
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
9038
|
+
removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
|
|
9039
|
+
source: (source) => m.getSource(source)
|
|
9040
|
+
};
|
|
9041
|
+
}
|
|
8927
9042
|
const BASEMAP_LAYER_PREFIXES = {
|
|
8928
9043
|
streets: "streets-",
|
|
8929
9044
|
satellite: "satellite-",
|
|
@@ -9273,6 +9388,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9273
9388
|
}
|
|
9274
9389
|
return getReadOnlyFeatureById(id);
|
|
9275
9390
|
}, [getReadOnlyFeatureById]);
|
|
9391
|
+
const appliedSelectionRef = useRef(/* @__PURE__ */ new Map());
|
|
9392
|
+
const locatorCacheRef = useRef(createLocatorCache());
|
|
9393
|
+
const shardedLayerIdsRef = useRef(EMPTY_ID_SET);
|
|
9394
|
+
const overlayPaintContextRef = useRef(null);
|
|
9395
|
+
const shardFieldRangesRef = useRef(/* @__PURE__ */ new Map());
|
|
9396
|
+
const locateSelectionSources = useCallback((id) => {
|
|
9397
|
+
if (getFeatureById(id) === null) return EMPTY_SOURCES;
|
|
9398
|
+
return locateFeatureSources(
|
|
9399
|
+
id,
|
|
9400
|
+
{ readOnly: readOnlyFeatures.current, shardedLayerIds: shardedLayerIdsRef.current, shardSize: shardSizeRef.current },
|
|
9401
|
+
locatorCacheRef.current
|
|
9402
|
+
);
|
|
9403
|
+
}, [getFeatureById]);
|
|
9276
9404
|
const canDeleteSelected = useMemo(() => {
|
|
9277
9405
|
if (selectedFeatureIds.length === 0) return false;
|
|
9278
9406
|
return selectedFeatureIds.some((id) => {
|
|
@@ -9294,7 +9422,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9294
9422
|
return true;
|
|
9295
9423
|
});
|
|
9296
9424
|
}, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
|
|
9297
|
-
const applySelectionState = useCallback((nextIds, options) => {
|
|
9425
|
+
const applySelectionState$1 = useCallback((nextIds, options) => {
|
|
9298
9426
|
if (!isMapLoaded || !draw.current) {
|
|
9299
9427
|
setSelectedFeatureIds(nextIds);
|
|
9300
9428
|
if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
|
|
@@ -9365,6 +9493,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9365
9493
|
});
|
|
9366
9494
|
const trySelectionFastPathRef = useRef(null);
|
|
9367
9495
|
const tryTimelineFastPathRef = useRef(null);
|
|
9496
|
+
const reconcileSelectionRef = useRef(null);
|
|
9368
9497
|
const syncCoalescerRef = useRef(null);
|
|
9369
9498
|
if (syncCoalescerRef.current === null) {
|
|
9370
9499
|
syncCoalescerRef.current = createRafCoalescer((reasons) => {
|
|
@@ -9565,7 +9694,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9565
9694
|
}
|
|
9566
9695
|
}, []);
|
|
9567
9696
|
const syncFeaturesToCustomLayers = useCallback(() => {
|
|
9568
|
-
var _a, _b;
|
|
9697
|
+
var _a, _b, _c;
|
|
9569
9698
|
if (!map.current) return;
|
|
9570
9699
|
if (isSyncingRef.current) return;
|
|
9571
9700
|
isSyncingRef.current = true;
|
|
@@ -9574,11 +9703,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9574
9703
|
const source = map.current.getSource("custom-features");
|
|
9575
9704
|
if (!source) return;
|
|
9576
9705
|
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
9706
|
const visibleSet = timelineVisibleIdsRef.current;
|
|
9583
9707
|
const currentLayers = layersRef.current;
|
|
9584
9708
|
const isLayerVisible = (layer) => {
|
|
@@ -9590,6 +9714,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9590
9714
|
const count = ((_a2 = readOnlyFeatures.current.get(layer.id)) == null ? void 0 : _a2.length) ?? 0;
|
|
9591
9715
|
if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
|
|
9592
9716
|
});
|
|
9717
|
+
shardedLayerIdsRef.current = shardedLayerIds;
|
|
9593
9718
|
const allFeatures = [...drawFeatures.features];
|
|
9594
9719
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9595
9720
|
if (shardedLayerIds.has(layerId)) return;
|
|
@@ -9674,8 +9799,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9674
9799
|
const paintCache = createSelectionPaintCache();
|
|
9675
9800
|
const paintContext = {
|
|
9676
9801
|
timelineVisibleIds: visibleSet,
|
|
9677
|
-
selectedIds: selectedIdSet,
|
|
9678
|
-
selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
|
|
9679
9802
|
sizeFieldRanges,
|
|
9680
9803
|
colorFieldRanges,
|
|
9681
9804
|
tracePointIds,
|
|
@@ -9689,21 +9812,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9689
9812
|
features: allFeatures.map((f, i) => {
|
|
9690
9813
|
const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
|
|
9691
9814
|
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
|
-
);
|
|
9815
|
+
recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
9701
9816
|
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
9702
9817
|
return styled.feature;
|
|
9703
9818
|
})
|
|
9704
9819
|
};
|
|
9705
9820
|
source.setData(sourceData);
|
|
9706
9821
|
selectionPaintCacheRef.current = paintCache;
|
|
9822
|
+
overlayPaintContextRef.current = paintContext;
|
|
9823
|
+
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
9707
9824
|
const traceSource = map.current.getSource("trace-features");
|
|
9708
9825
|
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
|
|
9709
9826
|
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
|
|
@@ -9717,7 +9834,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9717
9834
|
sawArrowFeature = true;
|
|
9718
9835
|
if (f.geometry.type === "LineString") arrowLines.push(f);
|
|
9719
9836
|
});
|
|
9720
|
-
const shardArrows = ((
|
|
9837
|
+
const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
|
|
9721
9838
|
var _a2;
|
|
9722
9839
|
return ((_a2 = currentLayers.find((l) => l.id === id)) == null ? void 0 : _a2.visible) === true;
|
|
9723
9840
|
})) ?? [];
|
|
@@ -9737,7 +9854,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9737
9854
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
9738
9855
|
setLabelsSuppressed(false);
|
|
9739
9856
|
}
|
|
9740
|
-
(
|
|
9857
|
+
(_c = applyShardedLayersRef.current) == null ? void 0 : _c.call(applyShardedLayersRef);
|
|
9741
9858
|
const requestedBy = fullSyncCallersRef.current.splice(0);
|
|
9742
9859
|
let shardedFeatures = 0;
|
|
9743
9860
|
shardedLayerIds.forEach((id) => {
|
|
@@ -9834,21 +9951,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9834
9951
|
if (!m || !registry) return;
|
|
9835
9952
|
const currentLayers = layersRef.current;
|
|
9836
9953
|
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
9954
|
currentLayers.forEach((layer) => {
|
|
9848
9955
|
var _a;
|
|
9849
9956
|
const features = readOnlyFeatures.current.get(layer.id) ?? [];
|
|
9850
9957
|
if (!isShardEligible(layer, features.length, shardSize2)) {
|
|
9851
9958
|
registry.remove(layer.id);
|
|
9959
|
+
shardFieldRangesRef.current.delete(layer.id);
|
|
9852
9960
|
setLayerImporting(layer.id, false);
|
|
9853
9961
|
return;
|
|
9854
9962
|
}
|
|
@@ -9858,10 +9966,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9858
9966
|
setLayerImporting(layer.id, false);
|
|
9859
9967
|
return;
|
|
9860
9968
|
}
|
|
9861
|
-
const fingerprint = buildShardFingerprint(layer, features,
|
|
9969
|
+
const fingerprint = buildShardFingerprint(layer, features, shardSize2);
|
|
9862
9970
|
const expectedShards = shardRanges(features.length, shardSize2).length;
|
|
9863
9971
|
if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
|
|
9864
|
-
if (reconcileShardCaches(registry, state.layerId, expectedShards,
|
|
9972
|
+
if (reconcileShardCaches(registry, state.layerId, expectedShards, timelineVisibleIdsRef.current)) {
|
|
9865
9973
|
setLayerImporting(layer.id, false);
|
|
9866
9974
|
mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
|
|
9867
9975
|
return;
|
|
@@ -9881,10 +9989,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9881
9989
|
const ranges = layerFieldRanges(layer.visualConfig, (visit) => {
|
|
9882
9990
|
for (let i = 0; i < features.length; i++) visit(features[i].properties);
|
|
9883
9991
|
});
|
|
9992
|
+
shardFieldRangesRef.current.set(layer.id, ranges);
|
|
9884
9993
|
const sizeFieldRanges = /* @__PURE__ */ new Map();
|
|
9885
9994
|
const colorFieldRanges = /* @__PURE__ */ new Map();
|
|
9886
9995
|
if (ranges.size) sizeFieldRanges.set(layer.id, ranges.size);
|
|
9887
9996
|
if (ranges.color) colorFieldRanges.set(layer.id, ranges.color);
|
|
9997
|
+
let overlayRestyled = false;
|
|
9888
9998
|
void runShardPass({
|
|
9889
9999
|
layer,
|
|
9890
10000
|
features,
|
|
@@ -9895,8 +10005,6 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9895
10005
|
contextForShard: () => {
|
|
9896
10006
|
return {
|
|
9897
10007
|
timelineVisibleIds: timelineVisibleIdsRef.current,
|
|
9898
|
-
selectedIds: currentSelectedIds(),
|
|
9899
|
-
selectionEnabled,
|
|
9900
10008
|
sizeFieldRanges,
|
|
9901
10009
|
colorFieldRanges,
|
|
9902
10010
|
// Trace-enabled layers are never sharded, so these are empty by construction.
|
|
@@ -9907,7 +10015,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9907
10015
|
};
|
|
9908
10016
|
},
|
|
9909
10017
|
onShardPainted: (index, cache2) => {
|
|
10018
|
+
var _a2;
|
|
9910
10019
|
state.caches[index] = cache2;
|
|
10020
|
+
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10021
|
+
overlayRestyled = true;
|
|
9911
10022
|
},
|
|
9912
10023
|
onProgress: (painted) => progress == null ? void 0 : progress.update(painted)
|
|
9913
10024
|
}).then((result) => {
|
|
@@ -10098,7 +10209,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10098
10209
|
});
|
|
10099
10210
|
const registry = shardRegistryRef.current;
|
|
10100
10211
|
registry == null ? void 0 : registry.trackedLayerIds().forEach((layerId) => {
|
|
10101
|
-
if (!liveLayerIds.has(layerId))
|
|
10212
|
+
if (!liveLayerIds.has(layerId)) {
|
|
10213
|
+
registry.remove(layerId);
|
|
10214
|
+
shardFieldRangesRef.current.delete(layerId);
|
|
10215
|
+
}
|
|
10102
10216
|
});
|
|
10103
10217
|
Object.keys((style == null ? void 0 : style.sources) ?? {}).forEach((sid) => {
|
|
10104
10218
|
const parsed = parseShardSourceId(sid);
|
|
@@ -10221,15 +10335,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10221
10335
|
coalesceKey,
|
|
10222
10336
|
undo: () => {
|
|
10223
10337
|
applyHistoryState(featureIds, layerIds, beforeF, beforeL);
|
|
10224
|
-
applySelectionState(beforeSelectedIds, { focusProperties: false });
|
|
10338
|
+
applySelectionState$1(beforeSelectedIds, { focusProperties: false });
|
|
10225
10339
|
},
|
|
10226
10340
|
redo: () => {
|
|
10227
10341
|
applyHistoryState(featureIds, layerIds, afterF, afterL);
|
|
10228
|
-
applySelectionState(afterSelectedIds, { focusProperties: false });
|
|
10342
|
+
applySelectionState$1(afterSelectedIds, { focusProperties: false });
|
|
10229
10343
|
}
|
|
10230
10344
|
};
|
|
10231
10345
|
},
|
|
10232
|
-
[applyHistoryState, applySelectionState]
|
|
10346
|
+
[applyHistoryState, applySelectionState$1]
|
|
10233
10347
|
);
|
|
10234
10348
|
const finalizeCapture = useCallback(() => {
|
|
10235
10349
|
const pending = pendingCaptureRef.current;
|
|
@@ -10353,11 +10467,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10353
10467
|
var _a, _b;
|
|
10354
10468
|
map.current = mapInstance;
|
|
10355
10469
|
draw.current = drawInstance;
|
|
10356
|
-
mapInstance.addSource(
|
|
10357
|
-
type: "geojson",
|
|
10358
|
-
data: { type: "FeatureCollection", features: [] },
|
|
10359
|
-
maxzoom: 22
|
|
10360
|
-
});
|
|
10470
|
+
mapInstance.addSource(SHARED_SOURCE_ID, customSourceSpec());
|
|
10361
10471
|
const sharedStack = buildCustomLayerStack(SHARED_SOURCE_ID, CUSTOM_LAYER_ROLES, { labelsVisible: false });
|
|
10362
10472
|
sharedStack.forEach((spec) => mapInstance.addLayer(spec));
|
|
10363
10473
|
const styleHost = {
|
|
@@ -10448,6 +10558,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10448
10558
|
"line-opacity": 0.7
|
|
10449
10559
|
}
|
|
10450
10560
|
});
|
|
10561
|
+
mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
|
|
10562
|
+
type: "geojson",
|
|
10563
|
+
data: { type: "FeatureCollection", features: [] },
|
|
10564
|
+
maxzoom: 22
|
|
10565
|
+
});
|
|
10566
|
+
buildSelectionOverlayStack().forEach((spec) => mapInstance.addLayer(spec));
|
|
10451
10567
|
if (tooltipElRef.current) {
|
|
10452
10568
|
const prevCleanup = tooltipElRef.current._cleanup;
|
|
10453
10569
|
try {
|
|
@@ -10566,8 +10682,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10566
10682
|
const highlightFields = /* @__PURE__ */ new Set();
|
|
10567
10683
|
if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
|
|
10568
10684
|
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);
|
|
10685
|
+
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
10686
|
const name = props.name;
|
|
10572
10687
|
let html = '<div class="text-sm space-y-0.5">';
|
|
10573
10688
|
if (name) html += `<div class="font-medium">${name}</div>`;
|
|
@@ -11243,7 +11358,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11243
11358
|
const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
|
|
11244
11359
|
if (!clusterHit) {
|
|
11245
11360
|
if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
|
|
11246
|
-
applySelectionState([]);
|
|
11361
|
+
applySelectionState$1([]);
|
|
11247
11362
|
}
|
|
11248
11363
|
return;
|
|
11249
11364
|
}
|
|
@@ -11265,13 +11380,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11265
11380
|
return;
|
|
11266
11381
|
}
|
|
11267
11382
|
const fid = String(featureId);
|
|
11268
|
-
const
|
|
11269
|
-
const isAlreadySelected =
|
|
11383
|
+
const currentSelection2 = selectedFeatureIdsRef.current;
|
|
11384
|
+
const isAlreadySelected = currentSelection2.includes(fid);
|
|
11270
11385
|
let nextIds;
|
|
11271
11386
|
if (isModifierKey) {
|
|
11272
|
-
nextIds = isAlreadySelected ?
|
|
11387
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [...currentSelection2, fid];
|
|
11273
11388
|
} else {
|
|
11274
|
-
nextIds = isAlreadySelected ?
|
|
11389
|
+
nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [fid];
|
|
11275
11390
|
}
|
|
11276
11391
|
isSelectingReadOnlyRef.current = true;
|
|
11277
11392
|
if (drawInstance.getSelected().features.length > 0) {
|
|
@@ -11823,7 +11938,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
11823
11938
|
onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
|
|
11824
11939
|
},
|
|
11825
11940
|
selectFeatures: (featureIds) => {
|
|
11826
|
-
applySelectionState(featureIds, { focusProperties: true });
|
|
11941
|
+
applySelectionState$1(featureIds, { focusProperties: true });
|
|
11827
11942
|
},
|
|
11828
11943
|
getSelectedFeatures,
|
|
11829
11944
|
setEditMode: (enabled) => {
|
|
@@ -12112,7 +12227,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
12112
12227
|
setPersistedSelectionPolygon(null);
|
|
12113
12228
|
setSelectionPoints([]);
|
|
12114
12229
|
setSelectedFeatureIds([]);
|
|
12115
|
-
applySelectionState([], { focusProperties: true });
|
|
12230
|
+
applySelectionState$1([], { focusProperties: true });
|
|
12116
12231
|
},
|
|
12117
12232
|
// Viewport and state getters
|
|
12118
12233
|
getViewport: () => {
|
|
@@ -13100,6 +13215,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13100
13215
|
if (!m.getLayer(id)) return;
|
|
13101
13216
|
m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
|
|
13102
13217
|
});
|
|
13218
|
+
if (!firstVisibleBasemapSymbol && m.getLayer(SELECTION_OVERLAY_LAYER_IDS.label)) {
|
|
13219
|
+
m.moveLayer(SELECTION_OVERLAY_LAYER_IDS.label);
|
|
13220
|
+
}
|
|
13103
13221
|
} catch (e) {
|
|
13104
13222
|
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
13105
13223
|
}
|
|
@@ -13654,24 +13772,91 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13654
13772
|
useEffect(() => {
|
|
13655
13773
|
enableDrawingRef.current = enableDrawing;
|
|
13656
13774
|
}, [enableDrawing]);
|
|
13657
|
-
const
|
|
13775
|
+
const overlayPaintContext = useCallback(() => {
|
|
13776
|
+
const base = overlayPaintContextRef.current;
|
|
13777
|
+
if (!base) return null;
|
|
13778
|
+
const sizeFieldRanges = new Map(base.sizeFieldRanges);
|
|
13779
|
+
const colorFieldRanges = new Map(base.colorFieldRanges);
|
|
13780
|
+
shardFieldRangesRef.current.forEach((ranges, layerId) => {
|
|
13781
|
+
if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
|
|
13782
|
+
if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
|
|
13783
|
+
});
|
|
13784
|
+
return { ...base, timelineVisibleIds: timelineVisibleIdsRef.current, sizeFieldRanges, colorFieldRanges };
|
|
13785
|
+
}, []);
|
|
13786
|
+
const overlayFeatureCountRef = useRef(0);
|
|
13787
|
+
const overlayTimelineInputsRef = useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
|
|
13788
|
+
const refreshSelectionOverlay = useCallback((m, ids) => {
|
|
13789
|
+
overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
|
|
13790
|
+
if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
|
|
13791
|
+
const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
|
|
13792
|
+
if (!overlay) return;
|
|
13793
|
+
const ctx = ids.size > 0 ? overlayPaintContext() : null;
|
|
13794
|
+
const layers2 = layersRef.current;
|
|
13795
|
+
const layerById = new Map(layers2.map((l) => [l.id, l]));
|
|
13796
|
+
const data = buildSelectionOverlayData(ids, (id) => {
|
|
13797
|
+
if (!ctx) return [];
|
|
13798
|
+
const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
|
|
13799
|
+
if (holders.length > 0) {
|
|
13800
|
+
return holders.filter((h) => {
|
|
13801
|
+
var _a;
|
|
13802
|
+
return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
|
|
13803
|
+
}).map((h) => styleFeatureForPaint(h.feature, layerById.get(h.layerId), ctx, true).feature);
|
|
13804
|
+
}
|
|
13805
|
+
const feature = getFeatureById(id);
|
|
13806
|
+
if (!feature) return [];
|
|
13807
|
+
const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
|
|
13808
|
+
return layer && !layer.visible ? [] : [styleFeatureForPaint(feature, layer, ctx, true).feature];
|
|
13809
|
+
});
|
|
13810
|
+
overlay.setData(data);
|
|
13811
|
+
overlayFeatureCountRef.current = data.features.length;
|
|
13812
|
+
}, [getFeatureById, overlayPaintContext]);
|
|
13813
|
+
const currentSelection = useCallback(() => {
|
|
13658
13814
|
var _a;
|
|
13815
|
+
if (!(enableSelectionRef.current || enableDrawingRef.current)) return null;
|
|
13816
|
+
const next = /* @__PURE__ */ new Set();
|
|
13817
|
+
(((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
|
|
13818
|
+
selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
|
|
13819
|
+
return next;
|
|
13820
|
+
}, []);
|
|
13821
|
+
const paintSelection = useCallback((m, overlay = true) => {
|
|
13822
|
+
const selection = currentSelection();
|
|
13823
|
+
const { set: set2, removed } = applySelectionState(
|
|
13824
|
+
appliedSelectionRef.current,
|
|
13825
|
+
selection ?? EMPTY_ID_SET,
|
|
13826
|
+
selection !== null,
|
|
13827
|
+
locateSelectionSources,
|
|
13828
|
+
featureStateHostFor(m)
|
|
13829
|
+
);
|
|
13830
|
+
const shown = selection ?? EMPTY_ID_SET;
|
|
13831
|
+
if (overlay) refreshSelectionOverlay(m, shown);
|
|
13832
|
+
return { set: set2, removed, overlay: overlay ? shown.size : 0 };
|
|
13833
|
+
}, [currentSelection, locateSelectionSources, refreshSelectionOverlay]);
|
|
13834
|
+
const applySelectionPaint = useCallback(() => {
|
|
13659
13835
|
const m = map.current;
|
|
13660
13836
|
if (!m) return true;
|
|
13661
|
-
const
|
|
13662
|
-
const
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13837
|
+
const start = performance.now();
|
|
13838
|
+
const painted = paintSelection(m);
|
|
13839
|
+
mapPerfLog("selection", "feature state applied", { ...painted, ms: Math.round(performance.now() - start) });
|
|
13840
|
+
return true;
|
|
13841
|
+
}, [paintSelection]);
|
|
13842
|
+
trySelectionFastPathRef.current = applySelectionPaint;
|
|
13843
|
+
const reconcileSelectionAfterPaint = useCallback((options) => {
|
|
13844
|
+
const m = map.current;
|
|
13845
|
+
if (!m) return;
|
|
13846
|
+
const { moved, pruned } = reconcileSelectionSources(
|
|
13847
|
+
appliedSelectionRef.current,
|
|
13848
|
+
locateSelectionSources,
|
|
13849
|
+
featureStateHostFor(m)
|
|
13672
13850
|
);
|
|
13673
|
-
|
|
13674
|
-
|
|
13851
|
+
const applied = paintSelection(m, (options == null ? void 0 : options.overlay) ?? true);
|
|
13852
|
+
if (moved || pruned || applied.set || applied.removed) {
|
|
13853
|
+
mapPerfLog("selection", "reconciled after paint", { moved, pruned, ...applied });
|
|
13854
|
+
}
|
|
13855
|
+
}, [locateSelectionSources, paintSelection]);
|
|
13856
|
+
reconcileSelectionRef.current = reconcileSelectionAfterPaint;
|
|
13857
|
+
useEffect(() => {
|
|
13858
|
+
scheduleSync("selection");
|
|
13859
|
+
}, [enableSelection, enableDrawing, scheduleSync]);
|
|
13675
13860
|
const tryTimelineFastPath = useCallback(() => {
|
|
13676
13861
|
const m = map.current;
|
|
13677
13862
|
if (!m) return true;
|
|
@@ -13685,13 +13870,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13685
13870
|
const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
|
|
13686
13871
|
const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
|
|
13687
13872
|
if (!applied || !paintCache || !source) return false;
|
|
13688
|
-
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff,
|
|
13873
|
+
if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, source, traceSource))) return false;
|
|
13689
13874
|
if (!forEachShardCache(shardRegistryRef.current, (cache2, shardSource) => applyTimelineFastPath(cache2, nextVisible, shardSource).applied)) {
|
|
13690
13875
|
return false;
|
|
13691
13876
|
}
|
|
13692
13877
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
13693
13878
|
setVisibleFeatureCount(countVisibleFeatures(threshold));
|
|
13694
13879
|
setLabelsSuppressed(false);
|
|
13880
|
+
const selection = currentSelection() ?? EMPTY_ID_SET;
|
|
13881
|
+
if (!sameOverlayTimelineInputs(overlayTimelineInputsRef.current, overlayTimelineInputs(selection, nextVisible))) {
|
|
13882
|
+
refreshSelectionOverlay(m, selection);
|
|
13883
|
+
}
|
|
13695
13884
|
mapPerfLog("timeline", "fast path applied", {
|
|
13696
13885
|
toggled,
|
|
13697
13886
|
endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
|
|
@@ -13699,7 +13888,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13699
13888
|
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
13700
13889
|
});
|
|
13701
13890
|
return true;
|
|
13702
|
-
}, [autoLabelConfig, countVisibleFeatures]);
|
|
13891
|
+
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
|
|
13703
13892
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
13704
13893
|
const collectSelectionFeatureGroups = useCallback(() => {
|
|
13705
13894
|
return collectVisibleFeatureGroups(
|
|
@@ -13815,7 +14004,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13815
14004
|
axisAlignedRectangle: true
|
|
13816
14005
|
});
|
|
13817
14006
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13818
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14007
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13819
14008
|
}
|
|
13820
14009
|
setIsSelectionToolActive(false);
|
|
13821
14010
|
startPoint = null;
|
|
@@ -13838,7 +14027,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13838
14027
|
} else {
|
|
13839
14028
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13840
14029
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13841
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14030
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13842
14031
|
}
|
|
13843
14032
|
setIsSelectionToolActive(false);
|
|
13844
14033
|
}
|
|
@@ -13872,7 +14061,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13872
14061
|
} else {
|
|
13873
14062
|
const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
|
|
13874
14063
|
const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
|
|
13875
|
-
applySelectionState(finalIds, { focusProperties: true });
|
|
14064
|
+
applySelectionState$1(finalIds, { focusProperties: true });
|
|
13876
14065
|
}
|
|
13877
14066
|
setIsSelectionToolActive(false);
|
|
13878
14067
|
setSelectionPoints([]);
|
|
@@ -13988,7 +14177,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13988
14177
|
setSelectionPoints([]);
|
|
13989
14178
|
mapInstance.dragPan.enable();
|
|
13990
14179
|
canvas.style.cursor = "";
|
|
13991
|
-
applySelectionState(mergedIds, { focusProperties: true });
|
|
14180
|
+
applySelectionState$1(mergedIds, { focusProperties: true });
|
|
13992
14181
|
};
|
|
13993
14182
|
canvas.addEventListener("mousedown", handleShiftMouseDown);
|
|
13994
14183
|
window.addEventListener("mousemove", handleShiftMouseMove);
|
|
@@ -14001,7 +14190,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
14001
14190
|
map.current.dragPan.enable();
|
|
14002
14191
|
}
|
|
14003
14192
|
};
|
|
14004
|
-
}, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
|
|
14193
|
+
}, [isMapLoaded, isSelectionToolActive, applySelectionState$1, collectSelectionFeatureGroups]);
|
|
14005
14194
|
useEffect(() => {
|
|
14006
14195
|
if (!map.current || !isMapLoaded) return;
|
|
14007
14196
|
const mapInstance = map.current;
|