@octostar/map-component 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +912 -480
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +912 -480
- package/dist/index.mjs.map +1 -1
- package/dist/types/components/layers-panel.d.ts +3 -1
- package/dist/types/components/layers-panel.d.ts.map +1 -1
- package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
- package/dist/types/components/timebar.d.ts +7 -1
- package/dist/types/components/timebar.d.ts.map +1 -1
- package/dist/types/lib/custom-layer-stack.d.ts +2 -1
- package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
- package/dist/types/lib/label-pinning.d.ts +4 -1
- package/dist/types/lib/label-pinning.d.ts.map +1 -1
- package/dist/types/lib/paint-feature.d.ts +9 -27
- package/dist/types/lib/paint-feature.d.ts.map +1 -1
- package/dist/types/lib/selection-diff.d.ts +0 -51
- package/dist/types/lib/selection-diff.d.ts.map +1 -1
- package/dist/types/lib/selection-overlay.d.ts +0 -8
- package/dist/types/lib/selection-overlay.d.ts.map +1 -1
- package/dist/types/lib/selection-paint.d.ts +9 -1
- package/dist/types/lib/selection-paint.d.ts.map +1 -1
- package/dist/types/lib/selection-state.d.ts +2 -2
- package/dist/types/lib/selection-state.d.ts.map +1 -1
- package/dist/types/lib/shard-locator.d.ts +2 -0
- package/dist/types/lib/shard-locator.d.ts.map +1 -1
- package/dist/types/lib/shard-pipeline.d.ts +4 -5
- package/dist/types/lib/shard-pipeline.d.ts.map +1 -1
- package/dist/types/lib/shard-registry.d.ts +0 -28
- package/dist/types/lib/shard-registry.d.ts.map +1 -1
- package/dist/types/lib/timeline-index.d.ts +56 -0
- package/dist/types/lib/timeline-index.d.ts.map +1 -0
- package/dist/types/lib/timeline-state.d.ts +64 -0
- package/dist/types/lib/timeline-state.d.ts.map +1 -0
- package/dist/types/lib/timeline-window.d.ts +19 -0
- package/dist/types/lib/timeline-window.d.ts.map +1 -0
- package/dist/types/lib/trace-group-suggestion.d.ts +17 -0
- package/dist/types/lib/trace-group-suggestion.d.ts.map +1 -0
- package/dist/types/lib/trace-groups.d.ts +6 -5
- package/dist/types/lib/trace-groups.d.ts.map +1 -1
- package/dist/types/lib/trace-timeline.d.ts +56 -49
- package/dist/types/lib/trace-timeline.d.ts.map +1 -1
- package/dist/types/lib/visible-feature-count.d.ts +18 -4
- package/dist/types/lib/visible-feature-count.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/lib/timeline-diff.d.ts +0 -43
- package/dist/types/lib/timeline-diff.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -752,6 +752,10 @@ const SELECTED_STATE_KEY = "selected";
|
|
|
752
752
|
const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
|
|
753
753
|
const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
|
|
754
754
|
const SELECTION_COLOR = "#06b6d4";
|
|
755
|
+
const TIMELINE_HIDDEN_KEY = "timelineHidden";
|
|
756
|
+
const TIMELINE_HIDDEN = ["boolean", ["feature-state", TIMELINE_HIDDEN_KEY], false];
|
|
757
|
+
const TRACE_ENDPOINT_KEY = "traceEndpoint";
|
|
758
|
+
const TRACE_ENDPOINT = ["boolean", ["feature-state", TRACE_ENDPOINT_KEY], false];
|
|
755
759
|
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
756
760
|
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
757
761
|
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
@@ -760,8 +764,8 @@ function computeLabelNeverHide(label) {
|
|
|
760
764
|
}
|
|
761
765
|
function buildCustomLabelLayout() {
|
|
762
766
|
return {
|
|
763
|
-
// Hide labels for trace points (
|
|
764
|
-
// arrows handled by the custom-arrow-labels layer.
|
|
767
|
+
// Hide labels for trace points (a group's endpoint label is the trace
|
|
768
|
+
// source's, trace-timeline.ts), arrows handled by the custom-arrow-labels layer.Features blanked by
|
|
765
769
|
// heatmap/cluster modes stay blank in BOTH layers: "never hide"
|
|
766
770
|
// exempts labels from collision and density culling, it does not resurrect
|
|
767
771
|
// labels other mode choices explicitly blank.
|
|
@@ -773,33 +777,28 @@ function buildCustomLabelLayout() {
|
|
|
773
777
|
"",
|
|
774
778
|
["==", ["get", "kind"], "arrow"],
|
|
775
779
|
"",
|
|
776
|
-
|
|
777
|
-
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
780
|
+
["==", ["get", "isTracePoint"], true],
|
|
778
781
|
"",
|
|
779
782
|
["==", ["get", "kind"], "text"],
|
|
780
783
|
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
781
784
|
["coalesce", ["get", "name"], ""]
|
|
782
785
|
],
|
|
783
|
-
// Text features use their fontSize property;
|
|
786
|
+
// Text features use their fontSize property; others 12px
|
|
784
787
|
"text-size": [
|
|
785
788
|
"case",
|
|
786
789
|
["==", ["get", "kind"], "text"],
|
|
787
790
|
["coalesce", ["get", "fontSize"], 14],
|
|
788
|
-
["==", ["get", "isTraceLabel"], true],
|
|
789
|
-
14,
|
|
790
791
|
12
|
|
791
792
|
],
|
|
792
793
|
// Text features: center anchor; others: top anchor
|
|
793
794
|
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
794
795
|
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
795
796
|
"text-padding": 2,
|
|
796
|
-
// Bold font for text features with fontWeight=bold,
|
|
797
|
+
// Bold font for text features with fontWeight=bold, others regular
|
|
797
798
|
"text-font": [
|
|
798
799
|
"case",
|
|
799
800
|
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
800
801
|
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
801
|
-
["==", ["get", "isTraceLabel"], true],
|
|
802
|
-
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
803
802
|
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
804
803
|
]
|
|
805
804
|
};
|
|
@@ -815,16 +814,14 @@ function buildCustomLabelPaint(opts) {
|
|
|
815
814
|
"#1f2937"
|
|
816
815
|
],
|
|
817
816
|
"text-halo-color": "#ffffff",
|
|
818
|
-
// Thicker halo for
|
|
817
|
+
// Thicker halo for text features
|
|
819
818
|
"text-halo-width": [
|
|
820
819
|
"case",
|
|
821
820
|
["==", ["get", "kind"], "text"],
|
|
822
821
|
2,
|
|
823
|
-
["==", ["get", "isTraceLabel"], true],
|
|
824
|
-
2,
|
|
825
822
|
1.5
|
|
826
823
|
],
|
|
827
|
-
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
824
|
+
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", TIMELINE_HIDDEN, 0, SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
828
825
|
};
|
|
829
826
|
}
|
|
830
827
|
const CUSTOM_LAYER_ROLES = [
|
|
@@ -894,6 +891,10 @@ function shardInsertAnchor(role) {
|
|
|
894
891
|
return "custom-arrow-heads";
|
|
895
892
|
}
|
|
896
893
|
}
|
|
894
|
+
const POINT_RADIUS = ["case", TRACE_ENDPOINT, ["get", "_endpointRadius"], ["coalesce", ["get", "pointRadius"], 5]];
|
|
895
|
+
function unlessTimelineHidden(value) {
|
|
896
|
+
return ["case", TIMELINE_HIDDEN, 0, value];
|
|
897
|
+
}
|
|
897
898
|
function buildLayer(role, sourceId, opts) {
|
|
898
899
|
const id = customLayerId(role, sourceId);
|
|
899
900
|
switch (role) {
|
|
@@ -906,7 +907,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
906
907
|
filter: ["==", "$type", "Polygon"],
|
|
907
908
|
paint: {
|
|
908
909
|
"fill-color": ["get", "fill"],
|
|
909
|
-
"fill-opacity": ["get", "fill-opacity"]
|
|
910
|
+
"fill-opacity": unlessTimelineHidden(["get", "fill-opacity"])
|
|
910
911
|
}
|
|
911
912
|
};
|
|
912
913
|
case "polygon-stroke":
|
|
@@ -918,7 +919,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
918
919
|
paint: {
|
|
919
920
|
"line-color": ["get", "stroke"],
|
|
920
921
|
"line-width": ["get", "stroke-width"],
|
|
921
|
-
"line-opacity": ["get", "stroke-opacity"]
|
|
922
|
+
"line-opacity": unlessTimelineHidden(["get", "stroke-opacity"])
|
|
922
923
|
}
|
|
923
924
|
};
|
|
924
925
|
// Custom line layer - preserves original styling
|
|
@@ -931,7 +932,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
931
932
|
paint: {
|
|
932
933
|
"line-color": ["get", "stroke"],
|
|
933
934
|
"line-width": ["get", "stroke-width"],
|
|
934
|
-
"line-opacity": ["get", "stroke-opacity"]
|
|
935
|
+
"line-opacity": unlessTimelineHidden(["get", "stroke-opacity"])
|
|
935
936
|
}
|
|
936
937
|
};
|
|
937
938
|
// Shadow layer rendered beneath points for depth (hidden when emoji icon is set)
|
|
@@ -945,7 +946,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
945
946
|
"circle-color": "rgba(0, 0, 0, 0.2)",
|
|
946
947
|
"circle-radius": [
|
|
947
948
|
"case",
|
|
948
|
-
|
|
949
|
+
TIMELINE_HIDDEN,
|
|
949
950
|
0,
|
|
950
951
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
951
952
|
0,
|
|
@@ -953,7 +954,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
953
954
|
0,
|
|
954
955
|
["!=", ["get", "icon"], ""],
|
|
955
956
|
0,
|
|
956
|
-
["+",
|
|
957
|
+
["+", POINT_RADIUS, 1.5]
|
|
957
958
|
],
|
|
958
959
|
"circle-blur": 0.5,
|
|
959
960
|
"circle-opacity": [
|
|
@@ -981,7 +982,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
981
982
|
"circle-color": ["coalesce", ["get", "stroke"], "#3b82f6"],
|
|
982
983
|
"circle-radius": [
|
|
983
984
|
"case",
|
|
984
|
-
|
|
985
|
+
TIMELINE_HIDDEN,
|
|
985
986
|
0,
|
|
986
987
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
987
988
|
0,
|
|
@@ -989,7 +990,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
989
990
|
0,
|
|
990
991
|
["!=", ["get", "icon"], ""],
|
|
991
992
|
0,
|
|
992
|
-
|
|
993
|
+
POINT_RADIUS
|
|
993
994
|
],
|
|
994
995
|
"circle-opacity": [
|
|
995
996
|
"case",
|
|
@@ -1004,7 +1005,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1004
1005
|
"circle-stroke-color": ["case", SELECTED, SELECTION_COLOR, "#555555"],
|
|
1005
1006
|
"circle-stroke-width": [
|
|
1006
1007
|
"case",
|
|
1007
|
-
|
|
1008
|
+
TIMELINE_HIDDEN,
|
|
1008
1009
|
0,
|
|
1009
1010
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
1010
1011
|
0,
|
|
@@ -1044,6 +1045,8 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1044
1045
|
paint: {
|
|
1045
1046
|
"icon-opacity": [
|
|
1046
1047
|
"case",
|
|
1048
|
+
TIMELINE_HIDDEN,
|
|
1049
|
+
0,
|
|
1047
1050
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
1048
1051
|
0,
|
|
1049
1052
|
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
@@ -1053,7 +1056,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1053
1056
|
}
|
|
1054
1057
|
};
|
|
1055
1058
|
// Label layer for all features - shows 'name' property, or 'text' for text features
|
|
1056
|
-
// Trace
|
|
1059
|
+
// Trace points have no label here: a group's label is the trace source's
|
|
1057
1060
|
// Arrow labels are handled separately by the custom-arrow-labels layer.
|
|
1058
1061
|
// Shared layout/paint live in label-pinning.ts so this layer and its
|
|
1059
1062
|
// pinned twin below cannot drift.
|
|
@@ -1191,77 +1194,6 @@ function shardFingerprintsEqual(a, b) {
|
|
|
1191
1194
|
if (!a || !b) return false;
|
|
1192
1195
|
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);
|
|
1193
1196
|
}
|
|
1194
|
-
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1195
|
-
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1196
|
-
function createSelectionPaintCache() {
|
|
1197
|
-
return {
|
|
1198
|
-
presentIds: /* @__PURE__ */ new Set(),
|
|
1199
|
-
appliedHiddenIds: /* @__PURE__ */ new Set(),
|
|
1200
|
-
visibleStrokeOpacityById: /* @__PURE__ */ new Map(),
|
|
1201
|
-
visibleFillOpacityById: /* @__PURE__ */ new Map(),
|
|
1202
|
-
updatable: true
|
|
1203
|
-
};
|
|
1204
|
-
}
|
|
1205
|
-
function recordPaintedFeature(cache2, featureId, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
1206
|
-
if (cache2.presentIds.has(featureId)) {
|
|
1207
|
-
cache2.updatable = false;
|
|
1208
|
-
} else {
|
|
1209
|
-
cache2.presentIds.add(featureId);
|
|
1210
|
-
}
|
|
1211
|
-
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
1212
|
-
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
1213
|
-
}
|
|
1214
|
-
if (visibleFillOpacity !== DEFAULT_VISIBLE_FILL_OPACITY) {
|
|
1215
|
-
cache2.visibleFillOpacityById.set(featureId, visibleFillOpacity);
|
|
1216
|
-
}
|
|
1217
|
-
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
1218
|
-
}
|
|
1219
|
-
function needsDrawSelectionUpdate(input) {
|
|
1220
|
-
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
1221
|
-
}
|
|
1222
|
-
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
1223
|
-
const update = [];
|
|
1224
|
-
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
1225
|
-
cache2.presentIds.forEach((id) => {
|
|
1226
|
-
const nextHidden = nextVisibleSet !== null && !nextVisibleSet.has(id);
|
|
1227
|
-
if (nextHidden) nextHiddenIds.add(id);
|
|
1228
|
-
if (nextHidden === cache2.appliedHiddenIds.has(id)) return;
|
|
1229
|
-
if (nextHidden) {
|
|
1230
|
-
update.push({
|
|
1231
|
-
id,
|
|
1232
|
-
addOrUpdateProperties: [
|
|
1233
|
-
{ key: "stroke-opacity", value: 0 },
|
|
1234
|
-
{ key: "fill-opacity", value: 0 },
|
|
1235
|
-
{ key: "isTimelineHidden", value: 1 }
|
|
1236
|
-
]
|
|
1237
|
-
});
|
|
1238
|
-
} else {
|
|
1239
|
-
update.push({
|
|
1240
|
-
id,
|
|
1241
|
-
addOrUpdateProperties: [
|
|
1242
|
-
{ key: "stroke-opacity", value: cache2.visibleStrokeOpacityById.get(id) ?? DEFAULT_VISIBLE_STROKE_OPACITY },
|
|
1243
|
-
{ key: "fill-opacity", value: cache2.visibleFillOpacityById.get(id) ?? DEFAULT_VISIBLE_FILL_OPACITY },
|
|
1244
|
-
{ key: "isTimelineHidden", value: 0 }
|
|
1245
|
-
]
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
});
|
|
1249
|
-
return { diff: update.length > 0 ? { update } : null, nextHiddenIds };
|
|
1250
|
-
}
|
|
1251
|
-
function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
1252
|
-
var _a;
|
|
1253
|
-
if (!cache2 || !cache2.updatable || !source) return { applied: false, toggled: 0 };
|
|
1254
|
-
const { diff, nextHiddenIds } = buildTimelineVisibilityDiff(cache2, nextVisibleSet);
|
|
1255
|
-
if (diff) {
|
|
1256
|
-
try {
|
|
1257
|
-
source.updateData(diff);
|
|
1258
|
-
} catch {
|
|
1259
|
-
return { applied: false, toggled: 0 };
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
cache2.appliedHiddenIds = nextHiddenIds;
|
|
1263
|
-
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
1264
|
-
}
|
|
1265
1197
|
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
1266
1198
|
function createShardRegistry(host, hooks) {
|
|
1267
1199
|
const states = /* @__PURE__ */ new Map();
|
|
@@ -1269,7 +1201,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1269
1201
|
const ensure = (layerId) => {
|
|
1270
1202
|
let state = states.get(layerId);
|
|
1271
1203
|
if (!state) {
|
|
1272
|
-
state = { layerId, stacks: [],
|
|
1204
|
+
state = { layerId, stacks: [], fingerprint: null, inFlightFingerprint: null, generation: 0, visible: true, arrowLines: [] };
|
|
1273
1205
|
states.set(layerId, state);
|
|
1274
1206
|
}
|
|
1275
1207
|
return state;
|
|
@@ -1316,7 +1248,6 @@ function createShardRegistry(host, hooks) {
|
|
|
1316
1248
|
removeStack(state.stacks[i]);
|
|
1317
1249
|
}
|
|
1318
1250
|
state.stacks.length = Math.min(state.stacks.length, index);
|
|
1319
|
-
state.caches.length = state.stacks.length;
|
|
1320
1251
|
};
|
|
1321
1252
|
return {
|
|
1322
1253
|
registerShared(layerIds) {
|
|
@@ -1411,50 +1342,9 @@ function createShardRegistry(host, hooks) {
|
|
|
1411
1342
|
});
|
|
1412
1343
|
});
|
|
1413
1344
|
return ids;
|
|
1414
|
-
},
|
|
1415
|
-
sourceFor(layerId, index) {
|
|
1416
|
-
var _a;
|
|
1417
|
-
const stack = (_a = states.get(layerId)) == null ? void 0 : _a.stacks[index];
|
|
1418
|
-
return stack ? host.getSource(stack.sourceId) : void 0;
|
|
1419
|
-
},
|
|
1420
|
-
sourceById(sourceId) {
|
|
1421
|
-
return host.getSource(sourceId);
|
|
1422
|
-
},
|
|
1423
|
-
everyPaintedShard(visit) {
|
|
1424
|
-
let ok = true;
|
|
1425
|
-
states.forEach((state) => {
|
|
1426
|
-
if (!ok) return;
|
|
1427
|
-
state.stacks.forEach((stack, i) => {
|
|
1428
|
-
if (!ok) return;
|
|
1429
|
-
const cache2 = state.caches[i];
|
|
1430
|
-
if (!cache2) return;
|
|
1431
|
-
if (!visit(cache2, stack.sourceId)) ok = false;
|
|
1432
|
-
});
|
|
1433
|
-
});
|
|
1434
|
-
return ok;
|
|
1435
1345
|
}
|
|
1436
1346
|
};
|
|
1437
1347
|
}
|
|
1438
|
-
function reconcileShardCaches(registry, layerId, expectedShards, visibleIds) {
|
|
1439
|
-
const state = registry.state(layerId);
|
|
1440
|
-
if (!state || state.stacks.length !== expectedShards) return false;
|
|
1441
|
-
for (let i = 0; i < expectedShards; i++) {
|
|
1442
|
-
const cache2 = state.caches[i];
|
|
1443
|
-
if (!cache2) return false;
|
|
1444
|
-
const source = registry.sourceFor(layerId, i);
|
|
1445
|
-
if (!source) return false;
|
|
1446
|
-
if (!applyTimelineFastPath(cache2, visibleIds, source).applied) return false;
|
|
1447
|
-
}
|
|
1448
|
-
return true;
|
|
1449
|
-
}
|
|
1450
|
-
function forEachShardCache(registry, apply) {
|
|
1451
|
-
if (!registry) return true;
|
|
1452
|
-
return registry.everyPaintedShard((cache2, sourceId) => {
|
|
1453
|
-
const source = registry.sourceById(sourceId);
|
|
1454
|
-
if (!source) return false;
|
|
1455
|
-
return apply(cache2, source);
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
1348
|
function categoricalKey(raw) {
|
|
1459
1349
|
if (raw == null) return null;
|
|
1460
1350
|
if (typeof raw === "string") return raw === "" ? null : raw;
|
|
@@ -1573,6 +1463,158 @@ function formatGradientStop(value) {
|
|
|
1573
1463
|
}
|
|
1574
1464
|
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
1575
1465
|
}
|
|
1466
|
+
function windowFromRange(start, end) {
|
|
1467
|
+
if (!start || !end) return null;
|
|
1468
|
+
const t0 = start.getTime();
|
|
1469
|
+
const t1 = end.getTime();
|
|
1470
|
+
return Number.isFinite(t0) && Number.isFinite(t1) ? { t0, t1 } : null;
|
|
1471
|
+
}
|
|
1472
|
+
function sameWindow(a, b) {
|
|
1473
|
+
if (a === null || b === null) return a === b;
|
|
1474
|
+
return a.t0 === b.t0 && a.t1 === b.t1;
|
|
1475
|
+
}
|
|
1476
|
+
function isIntervalVisible(s, e, w) {
|
|
1477
|
+
if (w === null) return true;
|
|
1478
|
+
const noStart = Number.isNaN(s);
|
|
1479
|
+
const noEnd = Number.isNaN(e);
|
|
1480
|
+
if (noStart && noEnd) return true;
|
|
1481
|
+
return (noStart ? e : s) <= w.t1 && (noEnd ? s : e) >= w.t0;
|
|
1482
|
+
}
|
|
1483
|
+
const interval = { s: NaN, e: NaN };
|
|
1484
|
+
function readInterval(f) {
|
|
1485
|
+
interval.s = NaN;
|
|
1486
|
+
interval.e = NaN;
|
|
1487
|
+
const props = f.properties;
|
|
1488
|
+
if (!props || !hasAnyTemporalValue(props)) return;
|
|
1489
|
+
const { startDate, endDate } = normalizeTemporalProperties(props);
|
|
1490
|
+
const s = startDate ? startDate.getTime() : NaN;
|
|
1491
|
+
const e = endDate ? endDate.getTime() : NaN;
|
|
1492
|
+
interval.s = Number.isNaN(s) ? e : s;
|
|
1493
|
+
interval.e = Number.isNaN(e) ? s : e;
|
|
1494
|
+
}
|
|
1495
|
+
function featureInterval(f) {
|
|
1496
|
+
readInterval(f);
|
|
1497
|
+
return { s: interval.s, e: interval.e };
|
|
1498
|
+
}
|
|
1499
|
+
function isFeatureVisible(f, w) {
|
|
1500
|
+
if (w === null) return true;
|
|
1501
|
+
readInterval(f);
|
|
1502
|
+
return isIntervalVisible(interval.s, interval.e, w);
|
|
1503
|
+
}
|
|
1504
|
+
function collectRepeats(features) {
|
|
1505
|
+
const first = /* @__PURE__ */ new Map();
|
|
1506
|
+
const repeats = /* @__PURE__ */ new Map();
|
|
1507
|
+
for (let i = 0; i < features.length; i++) {
|
|
1508
|
+
const id = features[i].id;
|
|
1509
|
+
if (id === void 0 || id === null) continue;
|
|
1510
|
+
const key = String(id);
|
|
1511
|
+
const at = first.get(key);
|
|
1512
|
+
if (at === void 0) first.set(key, i);
|
|
1513
|
+
else {
|
|
1514
|
+
const more = repeats.get(key);
|
|
1515
|
+
if (more) more.push(i);
|
|
1516
|
+
else repeats.set(key, [at, i]);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
return repeats;
|
|
1520
|
+
}
|
|
1521
|
+
function buildIndex(features) {
|
|
1522
|
+
const size = features.length;
|
|
1523
|
+
const starts = new Float64Array(size);
|
|
1524
|
+
const ends = new Float64Array(size);
|
|
1525
|
+
let timed = 0;
|
|
1526
|
+
for (let i = 0; i < size; i++) {
|
|
1527
|
+
readInterval(features[i]);
|
|
1528
|
+
starts[i] = interval.s;
|
|
1529
|
+
ends[i] = interval.e;
|
|
1530
|
+
if (!Number.isNaN(interval.s)) timed++;
|
|
1531
|
+
}
|
|
1532
|
+
const byStart = new Uint32Array(timed);
|
|
1533
|
+
for (let i = 0, k = 0; i < size; i++) {
|
|
1534
|
+
if (!Number.isNaN(starts[i])) byStart[k++] = i;
|
|
1535
|
+
}
|
|
1536
|
+
const byEnd = byStart.slice();
|
|
1537
|
+
byStart.sort((a, b) => starts[a] - starts[b]);
|
|
1538
|
+
byEnd.sort((a, b) => ends[a] - ends[b]);
|
|
1539
|
+
return {
|
|
1540
|
+
size,
|
|
1541
|
+
starts,
|
|
1542
|
+
ends,
|
|
1543
|
+
byStart,
|
|
1544
|
+
sortedStarts: Float64Array.from(byStart, (p) => starts[p]),
|
|
1545
|
+
byEnd,
|
|
1546
|
+
sortedEnds: Float64Array.from(byEnd, (p) => ends[p]),
|
|
1547
|
+
untimedCount: size - timed,
|
|
1548
|
+
repeats: collectRepeats(features),
|
|
1549
|
+
mark: new Uint8Array(size)
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
const cache$1 = /* @__PURE__ */ new WeakMap();
|
|
1553
|
+
function getTimelineIndex(features) {
|
|
1554
|
+
let index = cache$1.get(features);
|
|
1555
|
+
if (!index) {
|
|
1556
|
+
const started = performance.now();
|
|
1557
|
+
index = buildIndex(features);
|
|
1558
|
+
cache$1.set(features, index);
|
|
1559
|
+
mapPerfLog("timeline", "index built", { n: features.length, ms: Math.round(performance.now() - started) });
|
|
1560
|
+
}
|
|
1561
|
+
return index;
|
|
1562
|
+
}
|
|
1563
|
+
function isVisibleAt(index, position, w) {
|
|
1564
|
+
return isIntervalVisible(index.starts[position], index.ends[position], w);
|
|
1565
|
+
}
|
|
1566
|
+
function upperBound(keys, x) {
|
|
1567
|
+
let lo = 0;
|
|
1568
|
+
let hi = keys.length;
|
|
1569
|
+
while (lo < hi) {
|
|
1570
|
+
const mid = lo + hi >>> 1;
|
|
1571
|
+
if (keys[mid] <= x) lo = mid + 1;
|
|
1572
|
+
else hi = mid;
|
|
1573
|
+
}
|
|
1574
|
+
return lo;
|
|
1575
|
+
}
|
|
1576
|
+
function lowerBound(keys, x) {
|
|
1577
|
+
let lo = 0;
|
|
1578
|
+
let hi = keys.length;
|
|
1579
|
+
while (lo < hi) {
|
|
1580
|
+
const mid = lo + hi >>> 1;
|
|
1581
|
+
if (keys[mid] < x) lo = mid + 1;
|
|
1582
|
+
else hi = mid;
|
|
1583
|
+
}
|
|
1584
|
+
return lo;
|
|
1585
|
+
}
|
|
1586
|
+
const ALL = { t0: -Infinity, t1: Infinity };
|
|
1587
|
+
function flippedPositions(index, from, to, out) {
|
|
1588
|
+
const a = from ?? ALL;
|
|
1589
|
+
const b = to ?? ALL;
|
|
1590
|
+
const { starts, ends, byStart, byEnd, mark } = index;
|
|
1591
|
+
const flips = (p) => isIntervalVisible(starts[p], ends[p], a) !== isIntervalVisible(starts[p], ends[p], b);
|
|
1592
|
+
const s0 = upperBound(index.sortedStarts, Math.min(a.t1, b.t1));
|
|
1593
|
+
const s1 = upperBound(index.sortedStarts, Math.max(a.t1, b.t1));
|
|
1594
|
+
const e0 = lowerBound(index.sortedEnds, Math.min(a.t0, b.t0));
|
|
1595
|
+
const e1 = lowerBound(index.sortedEnds, Math.max(a.t0, b.t0));
|
|
1596
|
+
for (let k = s0; k < s1; k++) {
|
|
1597
|
+
const p = byStart[k];
|
|
1598
|
+
mark[p] = 1;
|
|
1599
|
+
if (flips(p)) out.push(p);
|
|
1600
|
+
}
|
|
1601
|
+
for (let k = e0; k < e1; k++) {
|
|
1602
|
+
const p = byEnd[k];
|
|
1603
|
+
if (mark[p] === 0 && flips(p)) out.push(p);
|
|
1604
|
+
}
|
|
1605
|
+
for (let k = s0; k < s1; k++) mark[byStart[k]] = 0;
|
|
1606
|
+
}
|
|
1607
|
+
function countVisible(index, w) {
|
|
1608
|
+
if (w === null) return index.size;
|
|
1609
|
+
if (w.t0 > w.t1) {
|
|
1610
|
+
let timed = 0;
|
|
1611
|
+
index.byStart.forEach((p) => {
|
|
1612
|
+
if (isVisibleAt(index, p, w)) timed++;
|
|
1613
|
+
});
|
|
1614
|
+
return timed + index.untimedCount;
|
|
1615
|
+
}
|
|
1616
|
+
return upperBound(index.sortedStarts, w.t1) - lowerBound(index.sortedEnds, w.t0) + index.untimedCount;
|
|
1617
|
+
}
|
|
1576
1618
|
const TRACE_DEFAULT_COLOR = "#3b82f6";
|
|
1577
1619
|
const TRACE_UNGROUPED_KEY = "__all__";
|
|
1578
1620
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -1604,16 +1646,17 @@ function compareStaged(a, b) {
|
|
|
1604
1646
|
function buildTraceGroups(features, field) {
|
|
1605
1647
|
var _a;
|
|
1606
1648
|
const staged = /* @__PURE__ */ new Map();
|
|
1607
|
-
for (
|
|
1649
|
+
for (let position = 0; position < features.length; position++) {
|
|
1650
|
+
const feature = features[position];
|
|
1608
1651
|
if (feature.id == null || feature.geometry.type !== "Point" || !((_a = feature.properties) == null ? void 0 : _a.startDate)) continue;
|
|
1609
1652
|
const raw = field ? feature.properties[field] : void 0;
|
|
1610
|
-
const key = field && raw ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
1653
|
+
const key = field && raw != null && raw !== "" ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
1611
1654
|
let bucket = staged.get(key);
|
|
1612
1655
|
if (!bucket) {
|
|
1613
1656
|
bucket = [];
|
|
1614
1657
|
staged.set(key, bucket);
|
|
1615
1658
|
}
|
|
1616
|
-
bucket.push({ feature, time: new Date(feature.properties.startDate).getTime() });
|
|
1659
|
+
bucket.push({ feature, time: new Date(feature.properties.startDate).getTime(), position });
|
|
1617
1660
|
}
|
|
1618
1661
|
const count = staged.size;
|
|
1619
1662
|
const groups = [];
|
|
@@ -1624,6 +1667,7 @@ function buildTraceGroups(features, field) {
|
|
|
1624
1667
|
points: bucket.map((p) => p.feature),
|
|
1625
1668
|
ids: bucket.map((p) => String(p.feature.id)),
|
|
1626
1669
|
times: bucket.map((p) => p.time),
|
|
1670
|
+
positions: bucket.map((p) => p.position),
|
|
1627
1671
|
color: traceGroupColor(key, groups.length, count),
|
|
1628
1672
|
label: field && key !== TRACE_UNGROUPED_KEY ? key : null,
|
|
1629
1673
|
pairStats: /* @__PURE__ */ new Map()
|
|
@@ -1637,14 +1681,11 @@ function traceGroupColor(key, index, count) {
|
|
|
1637
1681
|
}
|
|
1638
1682
|
function visibleTraceIndices(group, isVisible) {
|
|
1639
1683
|
const indices = [];
|
|
1640
|
-
for (let i = 0; i < group.
|
|
1641
|
-
if (isVisible(group.
|
|
1684
|
+
for (let i = 0; i < group.positions.length; i++) {
|
|
1685
|
+
if (isVisible(group.positions[i])) indices.push(i);
|
|
1642
1686
|
}
|
|
1643
1687
|
return indices;
|
|
1644
1688
|
}
|
|
1645
|
-
function timelineVisibility(visibleSet) {
|
|
1646
|
-
return visibleSet === null ? () => true : (id) => visibleSet.has(id);
|
|
1647
|
-
}
|
|
1648
1689
|
function traceSegmentStats(group, fromIndex, toIndex) {
|
|
1649
1690
|
const key = `${fromIndex}:${toIndex}`;
|
|
1650
1691
|
const cached = group.pairStats.get(key);
|
|
@@ -1694,43 +1735,161 @@ function traceSegmentFeature(group, groupIndex, fromIndex, toIndex) {
|
|
|
1694
1735
|
}
|
|
1695
1736
|
};
|
|
1696
1737
|
}
|
|
1697
|
-
const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
1698
1738
|
const TRACE_POINT_RADIUS = 2;
|
|
1699
1739
|
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1740
|
+
const TRACE_SOURCE_ID = "trace-features";
|
|
1741
|
+
const TRACE_ENDPOINT_LABEL_LAYER_ID = "trace-endpoint-labels";
|
|
1742
|
+
const ENDPOINT_LABEL_KIND = "endpoint-label";
|
|
1743
|
+
const ENDPOINT_STATE = Object.freeze({ [TRACE_ENDPOINT_KEY]: true });
|
|
1744
|
+
function buildTraceEndpointLabelLayer() {
|
|
1745
|
+
return {
|
|
1746
|
+
id: TRACE_ENDPOINT_LABEL_LAYER_ID,
|
|
1747
|
+
type: "symbol",
|
|
1748
|
+
source: TRACE_SOURCE_ID,
|
|
1749
|
+
filter: ["==", ["get", "kind"], ENDPOINT_LABEL_KIND],
|
|
1750
|
+
layout: {
|
|
1751
|
+
"text-field": ["get", "name"],
|
|
1752
|
+
"text-size": 14,
|
|
1753
|
+
"text-font": ["Montserrat Medium", "Noto Sans Regular"],
|
|
1754
|
+
"text-anchor": "top",
|
|
1755
|
+
"text-offset": [0, 0.8],
|
|
1756
|
+
"text-padding": 2,
|
|
1757
|
+
"text-allow-overlap": false,
|
|
1758
|
+
"text-ignore-placement": false,
|
|
1759
|
+
"text-optional": true
|
|
1760
|
+
},
|
|
1761
|
+
paint: {
|
|
1762
|
+
"text-color": "#1f2937",
|
|
1763
|
+
"text-halo-color": "#ffffff",
|
|
1764
|
+
"text-halo-width": 2,
|
|
1765
|
+
"text-opacity": ["*", 0.9, ["coalesce", ["get", "stroke-opacity"], 1]]
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
function visibleGroupIndices(group, index, w) {
|
|
1770
|
+
return visibleTraceIndices(group, (position) => isVisibleAt(index, position, w));
|
|
1771
|
+
}
|
|
1772
|
+
const instantStarts = /* @__PURE__ */ new WeakMap();
|
|
1773
|
+
function instantsOf(group, index) {
|
|
1774
|
+
const cached = instantStarts.get(group);
|
|
1775
|
+
if (cached !== void 0) return cached;
|
|
1776
|
+
const starts = new Float64Array(group.positions.length);
|
|
1777
|
+
let instants = starts;
|
|
1778
|
+
for (let i = 0; i < starts.length; i++) {
|
|
1779
|
+
const p = group.positions[i];
|
|
1780
|
+
const s = index.starts[p];
|
|
1781
|
+
if (Number.isNaN(s) || s !== index.ends[p] || i > 0 && s < starts[i - 1]) {
|
|
1782
|
+
instants = null;
|
|
1783
|
+
break;
|
|
1784
|
+
}
|
|
1785
|
+
starts[i] = s;
|
|
1786
|
+
}
|
|
1787
|
+
instantStarts.set(group, instants);
|
|
1788
|
+
return instants;
|
|
1789
|
+
}
|
|
1790
|
+
function firstAbove(keys, x, inclusive) {
|
|
1791
|
+
let lo = 0;
|
|
1792
|
+
let hi = keys.length;
|
|
1793
|
+
while (lo < hi) {
|
|
1794
|
+
const mid = lo + hi >>> 1;
|
|
1795
|
+
if (keys[mid] < x || !inclusive && keys[mid] === x) lo = mid + 1;
|
|
1796
|
+
else hi = mid;
|
|
1797
|
+
}
|
|
1798
|
+
return lo;
|
|
1799
|
+
}
|
|
1800
|
+
function visibleRun(instants, w) {
|
|
1801
|
+
if (w === null) return { lo: 0, hi: instants.length };
|
|
1802
|
+
const lo = firstAbove(instants, w.t0, true);
|
|
1803
|
+
return { lo, hi: Math.max(lo, firstAbove(instants, w.t1, false)) };
|
|
1804
|
+
}
|
|
1805
|
+
function pairsOutside(a, b, visit) {
|
|
1806
|
+
const aEnd = a.hi - 1;
|
|
1807
|
+
const bEnd = b.hi - 1;
|
|
1808
|
+
if (bEnd <= b.lo) {
|
|
1809
|
+
for (let i = a.lo; i < aEnd; i++) visit(i);
|
|
1810
|
+
return;
|
|
1811
|
+
}
|
|
1812
|
+
for (let i = a.lo; i < Math.min(aEnd, b.lo); i++) visit(i);
|
|
1813
|
+
for (let i = Math.max(a.lo, bEnd); i < aEnd; i++) visit(i);
|
|
1814
|
+
}
|
|
1815
|
+
function traceEndpointLabelId(groupIndex) {
|
|
1816
|
+
return `label:${groupIndex}`;
|
|
1817
|
+
}
|
|
1818
|
+
function endpointLabel(group, groupIndex, pointIndex) {
|
|
1819
|
+
var _a;
|
|
1820
|
+
const point2 = group.points[pointIndex];
|
|
1821
|
+
const opacity = (_a = point2.properties) == null ? void 0 : _a["stroke-opacity"];
|
|
1822
|
+
return {
|
|
1823
|
+
type: "Feature",
|
|
1824
|
+
id: traceEndpointLabelId(groupIndex),
|
|
1825
|
+
geometry: point2.geometry,
|
|
1826
|
+
properties: {
|
|
1827
|
+
kind: ENDPOINT_LABEL_KIND,
|
|
1828
|
+
name: group.label,
|
|
1829
|
+
...typeof opacity === "number" && { "stroke-opacity": opacity }
|
|
1712
1830
|
}
|
|
1831
|
+
};
|
|
1832
|
+
}
|
|
1833
|
+
function diffGroup(diff, group, groupIndex, index, from, to) {
|
|
1834
|
+
let prevEndpoint;
|
|
1835
|
+
let nextEndpoint;
|
|
1836
|
+
const instants = instantsOf(group, index);
|
|
1837
|
+
if (instants) {
|
|
1838
|
+
const prev = visibleRun(instants, from);
|
|
1839
|
+
const next = visibleRun(instants, to);
|
|
1840
|
+
prevEndpoint = prev.hi > prev.lo ? prev.hi - 1 : -1;
|
|
1841
|
+
nextEndpoint = next.hi > next.lo ? next.hi - 1 : -1;
|
|
1842
|
+
pairsOutside(prev, next, (i) => diff.remove.push(traceSegmentId(groupIndex, i, i + 1)));
|
|
1843
|
+
pairsOutside(next, prev, (i) => diff.add.push(traceSegmentFeature(group, groupIndex, i, i + 1)));
|
|
1844
|
+
} else {
|
|
1845
|
+
const prev = visibleGroupIndices(group, index, from);
|
|
1846
|
+
const next = visibleGroupIndices(group, index, to);
|
|
1847
|
+
prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
1848
|
+
nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
1713
1849
|
diffConsecutivePairs(
|
|
1714
1850
|
prev,
|
|
1715
1851
|
next,
|
|
1716
|
-
(
|
|
1717
|
-
(
|
|
1852
|
+
(a, b) => diff.remove.push(traceSegmentId(groupIndex, a, b)),
|
|
1853
|
+
(a, b) => diff.add.push(traceSegmentFeature(group, groupIndex, a, b))
|
|
1718
1854
|
);
|
|
1855
|
+
}
|
|
1856
|
+
if (prevEndpoint === nextEndpoint) return;
|
|
1857
|
+
if (prevEndpoint >= 0) diff.endpointOff.push(group.ids[prevEndpoint]);
|
|
1858
|
+
if (nextEndpoint >= 0) diff.endpointOn.push(group.ids[nextEndpoint]);
|
|
1859
|
+
if (group.label === null) return;
|
|
1860
|
+
if (nextEndpoint >= 0) diff.add.push(endpointLabel(group, groupIndex, nextEndpoint));
|
|
1861
|
+
else diff.remove.push(traceEndpointLabelId(groupIndex));
|
|
1862
|
+
}
|
|
1863
|
+
function buildTraceTimelineDiff(trace, nextWindow) {
|
|
1864
|
+
const diff = { endpointOff: [], endpointOn: [], add: [], remove: [] };
|
|
1865
|
+
trace.groups.forEach((group, groupIndex) => {
|
|
1866
|
+
diffGroup(diff, group, groupIndex, trace.indexes[groupIndex], trace.window, nextWindow);
|
|
1719
1867
|
});
|
|
1720
1868
|
return diff;
|
|
1721
1869
|
}
|
|
1722
|
-
function
|
|
1723
|
-
const
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1870
|
+
function paintTraceAt(groups, indexes, w) {
|
|
1871
|
+
const endpoints = [];
|
|
1872
|
+
const features = [];
|
|
1873
|
+
groups.forEach((group, groupIndex) => {
|
|
1874
|
+
const visible = visibleGroupIndices(group, indexes[groupIndex], w);
|
|
1875
|
+
if (visible.length === 0) return;
|
|
1876
|
+
const endpoint = visible[visible.length - 1];
|
|
1877
|
+
endpoints.push(group.ids[endpoint]);
|
|
1878
|
+
for (let k = 1; k < visible.length; k++) {
|
|
1879
|
+
features.push(traceSegmentFeature(group, groupIndex, visible[k - 1], visible[k]));
|
|
1880
|
+
}
|
|
1881
|
+
if (group.label !== null) features.push(endpointLabel(group, groupIndex, endpoint));
|
|
1882
|
+
});
|
|
1883
|
+
return { endpoints, features };
|
|
1884
|
+
}
|
|
1885
|
+
function setTraceEndpoints(host, applied, off, on) {
|
|
1886
|
+
off.forEach((id) => {
|
|
1887
|
+
if (applied.delete(id)) host.removeFeatureState(SHARED_SOURCE_ID, id, TRACE_ENDPOINT_KEY);
|
|
1888
|
+
});
|
|
1889
|
+
on.forEach((id) => {
|
|
1890
|
+
if (applied.has(id)) return;
|
|
1891
|
+
host.setFeatureState(SHARED_SOURCE_ID, id, ENDPOINT_STATE);
|
|
1892
|
+
applied.add(id);
|
|
1734
1893
|
});
|
|
1735
1894
|
}
|
|
1736
1895
|
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
@@ -1753,19 +1912,19 @@ function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
|
1753
1912
|
}
|
|
1754
1913
|
}
|
|
1755
1914
|
}
|
|
1756
|
-
function applyTraceTimelineDiff(diff,
|
|
1915
|
+
function applyTraceTimelineDiff(diff, traceSource, host, appliedEndpoints) {
|
|
1757
1916
|
try {
|
|
1758
|
-
if (diff.
|
|
1759
|
-
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
1760
|
-
segmentSource.updateData({ add: diff.segmentAdd, remove: diff.segmentRemove });
|
|
1761
|
-
}
|
|
1917
|
+
if (diff.add.length > 0 || diff.remove.length > 0) traceSource.updateData({ add: diff.add, remove: diff.remove });
|
|
1762
1918
|
} catch (error) {
|
|
1763
1919
|
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
1764
1920
|
return false;
|
|
1765
1921
|
}
|
|
1922
|
+
setTraceEndpoints(host, appliedEndpoints, diff.endpointOff, diff.endpointOn);
|
|
1766
1923
|
return true;
|
|
1767
1924
|
}
|
|
1768
1925
|
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1926
|
+
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1927
|
+
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1769
1928
|
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
1770
1929
|
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
1771
1930
|
"kind",
|
|
@@ -1782,11 +1941,21 @@ function sanitizeValue(value) {
|
|
|
1782
1941
|
if (value instanceof Date) return value.toISOString();
|
|
1783
1942
|
return String(value);
|
|
1784
1943
|
}
|
|
1944
|
+
const heatmapHidesPoints = (layer) => {
|
|
1945
|
+
var _a;
|
|
1946
|
+
return ((_a = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _a.enabled) === true;
|
|
1947
|
+
};
|
|
1948
|
+
const clusterHidesPoints = (layer) => {
|
|
1949
|
+
var _a;
|
|
1950
|
+
return ((_a = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _a.enabled) === true && !layer.clusterConfig.showPointDots;
|
|
1951
|
+
};
|
|
1952
|
+
function layerHidesPoints(layer) {
|
|
1953
|
+
return heatmapHidesPoints(layer) || clusterHidesPoints(layer);
|
|
1954
|
+
}
|
|
1785
1955
|
function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
1786
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l
|
|
1956
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1787
1957
|
const featureId = String(f.id);
|
|
1788
1958
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
1789
|
-
const isTimelineVisible = ctx.timelineVisibleIds === null || ctx.timelineVisibleIds.has(featureId);
|
|
1790
1959
|
const baseOpacity = ((_a = f.properties) == null ? void 0 : _a["stroke-opacity"]) ?? DEFAULT_VISIBLE_STROKE_OPACITY;
|
|
1791
1960
|
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
1792
1961
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
@@ -1818,14 +1987,12 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1818
1987
|
}
|
|
1819
1988
|
}
|
|
1820
1989
|
}
|
|
1821
|
-
const
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
let traceEndpointRadius = null;
|
|
1825
|
-
if (isTracePoint && f.geometry.type === "Point") {
|
|
1990
|
+
const isTracePoint2 = ctx.tracePointIds.has(featureId);
|
|
1991
|
+
let endpointRadius = 0;
|
|
1992
|
+
if (isTracePoint2 && f.geometry.type === "Point") {
|
|
1826
1993
|
strokeColor = ctx.tracePointColors.get(featureId) || strokeColor;
|
|
1827
|
-
|
|
1828
|
-
pointRadius =
|
|
1994
|
+
endpointRadius = Math.max(pointRadius, TRACE_ENDPOINT_MIN_RADIUS);
|
|
1995
|
+
pointRadius = TRACE_POINT_RADIUS;
|
|
1829
1996
|
}
|
|
1830
1997
|
let labelText = ((_d = f.properties) == null ? void 0 : _d.name) || "";
|
|
1831
1998
|
const labelConfig = visualConfig == null ? void 0 : visualConfig.label;
|
|
@@ -1839,10 +2006,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1839
2006
|
labelText = fieldValue !== void 0 && fieldValue !== null ? String(fieldValue) : "";
|
|
1840
2007
|
}
|
|
1841
2008
|
}
|
|
1842
|
-
const nonTraceLabelText = labelText;
|
|
1843
|
-
if (traceLabel) {
|
|
1844
|
-
labelText = traceLabel;
|
|
1845
|
-
}
|
|
1846
2009
|
let featureIcon = ((_e = f.properties) == null ? void 0 : _e.pointIcon) || ((_f = f.properties) == null ? void 0 : _f.icon);
|
|
1847
2010
|
let featureIconSize = ((_g = f.properties) == null ? void 0 : _g.pointIconSize) || ((_h = f.properties) == null ? void 0 : _h.iconSize) || 24;
|
|
1848
2011
|
const iconConfig = visualConfig == null ? void 0 : visualConfig.icon;
|
|
@@ -1851,8 +2014,8 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1851
2014
|
featureIconSize = iconConfig.size ?? 24;
|
|
1852
2015
|
}
|
|
1853
2016
|
const isPoint = f.geometry.type === "Point";
|
|
1854
|
-
const hideByHeatmap = isPoint && (
|
|
1855
|
-
const hideByCluster = isPoint && (
|
|
2017
|
+
const hideByHeatmap = isPoint && heatmapHidesPoints(layer);
|
|
2018
|
+
const hideByCluster = isPoint && clusterHidesPoints(layer);
|
|
1856
2019
|
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
1857
2020
|
const hideFlatFor3DOnly = isLine && (layer == null ? void 0 : layer.hasAltitudeData) && (layer == null ? void 0 : layer.altitudeDisplayMode) === "3d";
|
|
1858
2021
|
const sanitizedProps = {};
|
|
@@ -1873,9 +2036,9 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1873
2036
|
});
|
|
1874
2037
|
}
|
|
1875
2038
|
}
|
|
1876
|
-
let
|
|
1877
|
-
if (((
|
|
1878
|
-
|
|
2039
|
+
let labelPriority = DEFAULT_LABEL_PRIORITY;
|
|
2040
|
+
if (((_i = f.properties) == null ? void 0 : _i.kind) === "text") {
|
|
2041
|
+
labelPriority = ((_j = f.properties) == null ? void 0 : _j.fontWeight) === "bold" ? 8 : 10;
|
|
1879
2042
|
} else {
|
|
1880
2043
|
const idStr = String(featureId);
|
|
1881
2044
|
let h = 0;
|
|
@@ -1883,11 +2046,10 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1883
2046
|
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
1884
2047
|
h |= 0;
|
|
1885
2048
|
}
|
|
1886
|
-
|
|
2049
|
+
labelPriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
1887
2050
|
}
|
|
1888
|
-
const labelPriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
1889
2051
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
1890
|
-
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((
|
|
2052
|
+
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_k = f.properties) == null ? void 0 : _k["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
1891
2053
|
return {
|
|
1892
2054
|
feature: {
|
|
1893
2055
|
type: "Feature",
|
|
@@ -1901,28 +2063,20 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1901
2063
|
name: labelText,
|
|
1902
2064
|
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
1903
2065
|
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
1904
|
-
isTracePoint:
|
|
1905
|
-
|
|
2066
|
+
isTracePoint: isTracePoint2 ? true : false,
|
|
2067
|
+
_endpointRadius: endpointRadius,
|
|
1906
2068
|
icon: featureIcon || "",
|
|
1907
2069
|
iconSize: featureIconSize,
|
|
1908
2070
|
stroke: strokeColor,
|
|
1909
2071
|
"stroke-width": strokeWidth,
|
|
1910
|
-
"stroke-opacity":
|
|
2072
|
+
"stroke-opacity": visibleStrokeOpacity,
|
|
1911
2073
|
fill: strokeColor,
|
|
1912
|
-
"fill-opacity":
|
|
2074
|
+
"fill-opacity": visibleFillOpacity,
|
|
1913
2075
|
pointRadius,
|
|
1914
|
-
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
1915
2076
|
_labelPriority: labelPriority,
|
|
1916
|
-
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((
|
|
2077
|
+
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_l = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _l.label)
|
|
1917
2078
|
}
|
|
1918
|
-
}
|
|
1919
|
-
paint: {
|
|
1920
|
-
featureId,
|
|
1921
|
-
visibleStrokeOpacity,
|
|
1922
|
-
visibleFillOpacity,
|
|
1923
|
-
timelineHidden: !isTimelineVisible
|
|
1924
|
-
},
|
|
1925
|
-
tracePaint: traceEndpointRadius !== null ? { name: nonTraceLabelText, endpointRadius: traceEndpointRadius, basePriority: nonTracePriority } : null
|
|
2079
|
+
}
|
|
1926
2080
|
};
|
|
1927
2081
|
}
|
|
1928
2082
|
function layerFieldRanges(visualConfig, forEachProperties) {
|
|
@@ -1959,37 +2113,32 @@ async function runShardPass(input) {
|
|
|
1959
2113
|
var _a, _b;
|
|
1960
2114
|
const { features, layer, shardSize, host } = input;
|
|
1961
2115
|
const ranges = shardRanges(features.length, shardSize);
|
|
1962
|
-
const caches = [];
|
|
1963
2116
|
const arrowLines = [];
|
|
1964
2117
|
for (let index = 0; index < ranges.length; index++) {
|
|
1965
2118
|
const { start, end } = ranges[index];
|
|
1966
2119
|
const slice = features.slice(start, end);
|
|
1967
2120
|
const roles = rolesForGeometry(geometryClassesOf(slice));
|
|
1968
2121
|
const ctx = input.contextForShard();
|
|
1969
|
-
const cache2 = createSelectionPaintCache();
|
|
1970
2122
|
const shardArrows = [];
|
|
1971
2123
|
const painted = slice.map((f) => {
|
|
1972
2124
|
var _a2;
|
|
1973
2125
|
const styled = styleFeatureForPaint(f, layer, ctx, true);
|
|
1974
|
-
const p = styled.paint;
|
|
1975
|
-
recordPaintedFeature(cache2, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
1976
2126
|
if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
|
|
1977
2127
|
shardArrows.push(styled.feature);
|
|
1978
2128
|
}
|
|
1979
2129
|
return styled.feature;
|
|
1980
2130
|
});
|
|
1981
2131
|
host.paintShard(index, roles, { type: "FeatureCollection", features: painted });
|
|
1982
|
-
caches[index] = cache2;
|
|
1983
2132
|
if (shardArrows.length > 0) pushAll$1(arrowLines, shardArrows);
|
|
1984
|
-
(_a = input.onShardPainted) == null ? void 0 : _a.call(input, index,
|
|
2133
|
+
(_a = input.onShardPainted) == null ? void 0 : _a.call(input, index, start, end);
|
|
1985
2134
|
(_b = input.onProgress) == null ? void 0 : _b.call(input, end, features.length);
|
|
1986
2135
|
await input.yieldFrame();
|
|
1987
2136
|
if (!input.isCurrent()) {
|
|
1988
|
-
return { completed: false, shardCount: index + 1,
|
|
2137
|
+
return { completed: false, shardCount: index + 1, arrowLines };
|
|
1989
2138
|
}
|
|
1990
2139
|
}
|
|
1991
2140
|
host.dropShardsFrom(ranges.length);
|
|
1992
|
-
return { completed: true, shardCount: ranges.length,
|
|
2141
|
+
return { completed: true, shardCount: ranges.length, arrowLines };
|
|
1993
2142
|
}
|
|
1994
2143
|
function pushAll$1(target, source) {
|
|
1995
2144
|
for (let i = 0; i < source.length; i++) target.push(source[i]);
|
|
@@ -4015,6 +4164,7 @@ function LayersPanel({
|
|
|
4015
4164
|
onMapStyleChange,
|
|
4016
4165
|
onUpdateTraceConfig,
|
|
4017
4166
|
getAvailableTraceFields,
|
|
4167
|
+
getSuggestedTraceField,
|
|
4018
4168
|
getLayerFields,
|
|
4019
4169
|
getFieldValueDistribution,
|
|
4020
4170
|
onUpdateHeatmapConfig,
|
|
@@ -4338,13 +4488,12 @@ function LayersPanel({
|
|
|
4338
4488
|
{
|
|
4339
4489
|
size: "small",
|
|
4340
4490
|
checked: ((_h = layer.traceConfig) == null ? void 0 : _h.enabled) ?? false,
|
|
4341
|
-
onChange: (checked) => {
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
},
|
|
4491
|
+
onChange: (checked) => onUpdateTraceConfig(layer.id, {
|
|
4492
|
+
enabled: checked,
|
|
4493
|
+
// A layer that has never had trace settings starts grouped; a
|
|
4494
|
+
// choice made before, "Connect all points" included, is kept.
|
|
4495
|
+
groupByField: layer.traceConfig ? layer.traceConfig.groupByField ?? null : checked ? (getSuggestedTraceField == null ? void 0 : getSuggestedTraceField(layer.id)) ?? null : null
|
|
4496
|
+
}),
|
|
4348
4497
|
"data-testid": `switch-trace-${layer.id}`
|
|
4349
4498
|
}
|
|
4350
4499
|
),
|
|
@@ -7233,7 +7382,7 @@ function formatDateTime(date) {
|
|
|
7233
7382
|
minute: "2-digit"
|
|
7234
7383
|
});
|
|
7235
7384
|
}
|
|
7236
|
-
function Histogram({ bins, maxCount, colorGroupedBins }) {
|
|
7385
|
+
function Histogram({ bins, maxCount, colorGroupedBins, selectedBins }) {
|
|
7237
7386
|
const [hoveredBin, setHoveredBin] = useState(null);
|
|
7238
7387
|
const containerRef = useRef(null);
|
|
7239
7388
|
if (bins.length === 0 || maxCount === 0) return null;
|
|
@@ -7292,7 +7441,8 @@ function Histogram({ bins, maxCount, colorGroupedBins }) {
|
|
|
7292
7441
|
/* @__PURE__ */ jsxs("div", { className: "text-muted-foreground", children: [
|
|
7293
7442
|
bins[hoveredBin].count,
|
|
7294
7443
|
" event",
|
|
7295
|
-
bins[hoveredBin].count !== 1 ? "s" : ""
|
|
7444
|
+
bins[hoveredBin].count !== 1 ? "s" : "",
|
|
7445
|
+
!!(selectedBins == null ? void 0 : selectedBins[hoveredBin]) && ` (${selectedBins[hoveredBin]} selected)`
|
|
7296
7446
|
] })
|
|
7297
7447
|
]
|
|
7298
7448
|
}
|
|
@@ -7363,7 +7513,9 @@ function Timebar({
|
|
|
7363
7513
|
return { ...bin, count };
|
|
7364
7514
|
});
|
|
7365
7515
|
}, [hasSelection, selectionAsLine, storeHistogramBins, selectedTemporalFeatures]);
|
|
7366
|
-
const colorGroupedBins =
|
|
7516
|
+
const colorGroupedBins = useMemo(() => {
|
|
7517
|
+
if (histogramBins.length === 0 || !hasSelection || !globalMinDate || !globalMaxDate) return [];
|
|
7518
|
+
if (!selectionAsLine && !(selectedFeatureColors && selectedFeatureColors.size > 0)) return [];
|
|
7367
7519
|
if (selectedTemporalFeatures.length === 0) return [];
|
|
7368
7520
|
const colorGroups = /* @__PURE__ */ new Map();
|
|
7369
7521
|
selectedTemporalFeatures.forEach((f) => {
|
|
@@ -7387,13 +7539,18 @@ function Timebar({
|
|
|
7387
7539
|
result.push({ color, bins });
|
|
7388
7540
|
});
|
|
7389
7541
|
return result;
|
|
7390
|
-
}
|
|
7542
|
+
}, [hasSelection, selectionAsLine, histogramBins, selectedTemporalFeatures, selectedFeatureColors, globalMinDate, globalMaxDate]);
|
|
7543
|
+
const selectedBins = useMemo(
|
|
7544
|
+
() => selectionAsLine ? histogramBins.map((_, i) => colorGroupedBins.reduce((sum, group) => sum + group.bins[i], 0)) : void 0,
|
|
7545
|
+
[selectionAsLine, histogramBins, colorGroupedBins]
|
|
7546
|
+
);
|
|
7391
7547
|
const animationFrameRef = useRef(null);
|
|
7392
7548
|
const lastFrameTimeRef = useRef(0);
|
|
7393
7549
|
const playbackDuration = 1e4;
|
|
7394
7550
|
const targetFps = 30;
|
|
7395
7551
|
const frameInterval = 1e3 / targetFps;
|
|
7396
7552
|
const applyFilter = useCallback(() => {
|
|
7553
|
+
if (!onFilterChange) return;
|
|
7397
7554
|
const visibleIds = [];
|
|
7398
7555
|
const hiddenIds = [];
|
|
7399
7556
|
temporalFeatures.forEach((feature) => {
|
|
@@ -7504,7 +7661,8 @@ function Timebar({
|
|
|
7504
7661
|
{
|
|
7505
7662
|
bins: histogramBins,
|
|
7506
7663
|
maxCount: maxBinCount,
|
|
7507
|
-
colorGroupedBins
|
|
7664
|
+
colorGroupedBins,
|
|
7665
|
+
selectedBins
|
|
7508
7666
|
}
|
|
7509
7667
|
),
|
|
7510
7668
|
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(
|
|
@@ -7815,30 +7973,138 @@ function buildReadOnlyFeatureIndex(store) {
|
|
|
7815
7973
|
});
|
|
7816
7974
|
return { sources: new Map(store), byId };
|
|
7817
7975
|
}
|
|
7818
|
-
function
|
|
7819
|
-
var _a;
|
|
7820
|
-
const { west, east, south, north } = bounds;
|
|
7821
|
-
const { threshold, visibleSet } = options;
|
|
7976
|
+
function inViewTest({ west, east, south, north }) {
|
|
7822
7977
|
const fullWidth = east - west >= 360;
|
|
7823
|
-
|
|
7978
|
+
return (lng, lat) => {
|
|
7824
7979
|
if (lat < south || lat > north) return false;
|
|
7825
7980
|
if (fullWidth) return true;
|
|
7826
7981
|
return lng >= west && lng <= east || lng + 360 >= west && lng + 360 <= east || lng - 360 >= west && lng - 360 <= east;
|
|
7827
7982
|
};
|
|
7983
|
+
}
|
|
7984
|
+
function counts(group, p, inView) {
|
|
7985
|
+
var _a;
|
|
7986
|
+
if (group.isVisible && !group.isVisible(p)) return false;
|
|
7987
|
+
const f = group.features[p];
|
|
7988
|
+
if (((_a = f.geometry) == null ? void 0 : _a.type) !== "Point") return true;
|
|
7989
|
+
const [lng, lat] = f.geometry.coordinates;
|
|
7990
|
+
return inView(lng, lat);
|
|
7991
|
+
}
|
|
7992
|
+
function countLinear(group, inView, start, threshold) {
|
|
7993
|
+
let count = start;
|
|
7994
|
+
for (let p = 0; p < group.features.length; p++) {
|
|
7995
|
+
if (!counts(group, p, inView)) continue;
|
|
7996
|
+
count += 1;
|
|
7997
|
+
if (count > threshold) return count;
|
|
7998
|
+
}
|
|
7999
|
+
return count;
|
|
8000
|
+
}
|
|
8001
|
+
function countIndexed(group, { spatial, visibleTotal }, bounds, inView, start, threshold) {
|
|
8002
|
+
const tree = spatial.tree;
|
|
8003
|
+
if (!tree) return start;
|
|
8004
|
+
const { west, east, south, north } = bounds;
|
|
8005
|
+
const fullWidth = east - west >= 360;
|
|
8006
|
+
if ((fullWidth || west <= tree.minX && east >= tree.maxX) && south <= tree.minY && north >= tree.maxY) {
|
|
8007
|
+
return Math.min(start + visibleTotal, threshold + 1);
|
|
8008
|
+
}
|
|
8009
|
+
let count = start;
|
|
8010
|
+
const visit = (item) => {
|
|
8011
|
+
if (count <= threshold && counts(group, spatial.positions[item], inView)) count += 1;
|
|
8012
|
+
return false;
|
|
8013
|
+
};
|
|
8014
|
+
if (fullWidth) {
|
|
8015
|
+
tree.search(-Infinity, south, Infinity, north, visit);
|
|
8016
|
+
return count;
|
|
8017
|
+
}
|
|
8018
|
+
tree.search(west, south, east, north, visit);
|
|
8019
|
+
if (west < -180) tree.search(west + 360, south, Math.min(east + 360, 180), north, visit);
|
|
8020
|
+
if (east > 180) tree.search(Math.max(west - 360, -180), south, east - 360, north, visit);
|
|
8021
|
+
return count;
|
|
8022
|
+
}
|
|
8023
|
+
function countFeaturesInBounds(groups, bounds, options) {
|
|
8024
|
+
const inView = inViewTest(bounds);
|
|
7828
8025
|
let count = 0;
|
|
7829
|
-
for (const
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
if (((_a = f.geometry) == null ? void 0 : _a.type) === "Point") {
|
|
7833
|
-
const [lng, lat] = f.geometry.coordinates;
|
|
7834
|
-
if (!inView(lng, lat)) continue;
|
|
7835
|
-
}
|
|
7836
|
-
count += 1;
|
|
7837
|
-
if (count > threshold) return count;
|
|
7838
|
-
}
|
|
8026
|
+
for (const group of groups) {
|
|
8027
|
+
count = group.indexed ? countIndexed(group, group.indexed, bounds, inView, count, options.threshold) : countLinear(group, inView, count, options.threshold);
|
|
8028
|
+
if (count > options.threshold) return count;
|
|
7839
8029
|
}
|
|
7840
8030
|
return count;
|
|
7841
8031
|
}
|
|
8032
|
+
function extendBounds(bounds, coords) {
|
|
8033
|
+
if (!Array.isArray(coords) || coords.length === 0) return;
|
|
8034
|
+
if (typeof coords[0] === "number") {
|
|
8035
|
+
const lng = coords[0];
|
|
8036
|
+
const lat = coords[1];
|
|
8037
|
+
if (lng < bounds.minLng) bounds.minLng = lng;
|
|
8038
|
+
if (lng > bounds.maxLng) bounds.maxLng = lng;
|
|
8039
|
+
if (lat < bounds.minLat) bounds.minLat = lat;
|
|
8040
|
+
if (lat > bounds.maxLat) bounds.maxLat = lat;
|
|
8041
|
+
return;
|
|
8042
|
+
}
|
|
8043
|
+
for (const nested of coords) extendBounds(bounds, nested);
|
|
8044
|
+
}
|
|
8045
|
+
function computeBounds(coords) {
|
|
8046
|
+
const bounds = { minLng: Infinity, minLat: Infinity, maxLng: -Infinity, maxLat: -Infinity };
|
|
8047
|
+
extendBounds(bounds, coords);
|
|
8048
|
+
return bounds;
|
|
8049
|
+
}
|
|
8050
|
+
function boundsDisjoint(a, b) {
|
|
8051
|
+
return a.maxLng < b.minLng || a.minLng > b.maxLng || a.maxLat < b.minLat || a.minLat > b.maxLat;
|
|
8052
|
+
}
|
|
8053
|
+
function pointInBounds(lng, lat, b) {
|
|
8054
|
+
return lng >= b.minLng && lng <= b.maxLng && lat >= b.minLat && lat <= b.maxLat;
|
|
8055
|
+
}
|
|
8056
|
+
function buildGroupSpatialIndex(features) {
|
|
8057
|
+
var _a;
|
|
8058
|
+
const boxes = [];
|
|
8059
|
+
const positions = [];
|
|
8060
|
+
for (let p = 0; p < features.length; p++) {
|
|
8061
|
+
const geom = (_a = features[p]) == null ? void 0 : _a.geometry;
|
|
8062
|
+
const b = computeBounds(geom == null ? void 0 : geom.coordinates);
|
|
8063
|
+
if (!isFinite(b.minLng) || !isFinite(b.minLat) || !isFinite(b.maxLng) || !isFinite(b.maxLat)) {
|
|
8064
|
+
continue;
|
|
8065
|
+
}
|
|
8066
|
+
boxes.push(b.minLng, b.minLat, b.maxLng, b.maxLat);
|
|
8067
|
+
positions.push(p);
|
|
8068
|
+
}
|
|
8069
|
+
if (positions.length === 0) {
|
|
8070
|
+
return { tree: null, positions, size: features.length };
|
|
8071
|
+
}
|
|
8072
|
+
const startedAt = performance.now();
|
|
8073
|
+
const tree = new Flatbush(positions.length);
|
|
8074
|
+
for (let i = 0; i < boxes.length; i += 4) {
|
|
8075
|
+
tree.add(boxes[i], boxes[i + 1], boxes[i + 2], boxes[i + 3]);
|
|
8076
|
+
}
|
|
8077
|
+
tree.finish();
|
|
8078
|
+
mapPerfLog("spatial-index", "built group index", {
|
|
8079
|
+
indexed: positions.length,
|
|
8080
|
+
of: features.length,
|
|
8081
|
+
ms: Math.round(performance.now() - startedAt)
|
|
8082
|
+
});
|
|
8083
|
+
return { tree, positions, size: features.length };
|
|
8084
|
+
}
|
|
8085
|
+
const indexCache = /* @__PURE__ */ new WeakMap();
|
|
8086
|
+
const failedBuilds = /* @__PURE__ */ new WeakSet();
|
|
8087
|
+
function getGroupSpatialIndex(features) {
|
|
8088
|
+
if (failedBuilds.has(features)) return void 0;
|
|
8089
|
+
let index = indexCache.get(features);
|
|
8090
|
+
if (!index) {
|
|
8091
|
+
try {
|
|
8092
|
+
index = buildGroupSpatialIndex(features);
|
|
8093
|
+
} catch {
|
|
8094
|
+
failedBuilds.add(features);
|
|
8095
|
+
return void 0;
|
|
8096
|
+
}
|
|
8097
|
+
indexCache.set(features, index);
|
|
8098
|
+
}
|
|
8099
|
+
return index;
|
|
8100
|
+
}
|
|
8101
|
+
function queryCandidatePositions(index, bounds) {
|
|
8102
|
+
if (!index.tree) return [];
|
|
8103
|
+
const items = index.tree.search(bounds.minLng, bounds.minLat, bounds.maxLng, bounds.maxLat);
|
|
8104
|
+
const positions = items.map((i) => index.positions[i]);
|
|
8105
|
+
positions.sort((a, b) => a - b);
|
|
8106
|
+
return positions;
|
|
8107
|
+
}
|
|
7842
8108
|
const rafScheduler = {
|
|
7843
8109
|
request: (cb) => requestAnimationFrame(() => cb()),
|
|
7844
8110
|
cancel: (handle) => cancelAnimationFrame(handle)
|
|
@@ -7882,13 +8148,16 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
|
7882
8148
|
}
|
|
7883
8149
|
};
|
|
7884
8150
|
}
|
|
8151
|
+
function needsDrawSelectionUpdate(input) {
|
|
8152
|
+
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
8153
|
+
}
|
|
7885
8154
|
const EMPTY = /* @__PURE__ */ new Set();
|
|
7886
8155
|
function isLive(host, entry) {
|
|
7887
8156
|
return host.source(entry.sourceId) === entry.handle;
|
|
7888
8157
|
}
|
|
7889
8158
|
function remove(host, entry, id) {
|
|
7890
8159
|
if (!isLive(host, entry)) return false;
|
|
7891
|
-
host.removeFeatureState(entry.sourceId, id);
|
|
8160
|
+
host.removeFeatureState(entry.sourceId, id, SELECTED_STATE_KEY);
|
|
7892
8161
|
return true;
|
|
7893
8162
|
}
|
|
7894
8163
|
function set(host, sourceId, id) {
|
|
@@ -7987,7 +8256,7 @@ function forEachIndex(index, id, visit) {
|
|
|
7987
8256
|
function locateFeatureHolders(id, readOnly, cache2) {
|
|
7988
8257
|
const holders = [];
|
|
7989
8258
|
readOnly.forEach((features, layerId) => {
|
|
7990
|
-
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
|
|
8259
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at], position: at }));
|
|
7991
8260
|
});
|
|
7992
8261
|
return holders;
|
|
7993
8262
|
}
|
|
@@ -8005,6 +8274,210 @@ function locateFeatureSources(id, inputs, cache2) {
|
|
|
8005
8274
|
if (sources.length === 0) add(SHARED_SOURCE_ID);
|
|
8006
8275
|
return sources;
|
|
8007
8276
|
}
|
|
8277
|
+
const HIDDEN_STATE = Object.freeze({ [TIMELINE_HIDDEN_KEY]: true });
|
|
8278
|
+
function sameSlices(a, b) {
|
|
8279
|
+
return a.length === b.length && a.every((s, i) => s.features === b[i].features && s.start === b[i].start && s.end === b[i].end);
|
|
8280
|
+
}
|
|
8281
|
+
function pushCopy(copies, id, copy, first) {
|
|
8282
|
+
const list = copies.get(id);
|
|
8283
|
+
if (list) list.push(copy);
|
|
8284
|
+
else copies.set(id, [first, copy]);
|
|
8285
|
+
}
|
|
8286
|
+
function collectCopies(slices) {
|
|
8287
|
+
const copies = /* @__PURE__ */ new Map();
|
|
8288
|
+
if (slices.length === 1) {
|
|
8289
|
+
const { features, start, end } = slices[0];
|
|
8290
|
+
const index = getTimelineIndex(features);
|
|
8291
|
+
index.repeats.forEach((positions, id) => {
|
|
8292
|
+
const inside = positions.filter((p) => p >= start && p < end);
|
|
8293
|
+
if (inside.length > 1) copies.set(id, inside.map((position) => ({ index, position })));
|
|
8294
|
+
});
|
|
8295
|
+
return copies;
|
|
8296
|
+
}
|
|
8297
|
+
const first = /* @__PURE__ */ new Map();
|
|
8298
|
+
slices.forEach(({ features, start, end }) => {
|
|
8299
|
+
const index = getTimelineIndex(features);
|
|
8300
|
+
for (let position = start; position < end; position++) {
|
|
8301
|
+
const raw = features[position].id;
|
|
8302
|
+
if (raw === void 0 || raw === null) continue;
|
|
8303
|
+
const id = String(raw);
|
|
8304
|
+
const copy = { index, position };
|
|
8305
|
+
const seen = first.get(id);
|
|
8306
|
+
if (seen) pushCopy(copies, id, copy, seen);
|
|
8307
|
+
else first.set(id, copy);
|
|
8308
|
+
}
|
|
8309
|
+
});
|
|
8310
|
+
return copies;
|
|
8311
|
+
}
|
|
8312
|
+
function copiesOf(record) {
|
|
8313
|
+
record.copies ?? (record.copies = collectCopies(record.slices));
|
|
8314
|
+
return record.copies;
|
|
8315
|
+
}
|
|
8316
|
+
function shouldHide(record, id, index, position, w) {
|
|
8317
|
+
if (isVisibleAt(index, position, w)) return false;
|
|
8318
|
+
const copies = copiesOf(record).get(id);
|
|
8319
|
+
return !copies || copies.every((c) => !isVisibleAt(c.index, c.position, w));
|
|
8320
|
+
}
|
|
8321
|
+
function setHidden(host, record, id, hide) {
|
|
8322
|
+
if (hide === record.hidden.has(id)) return false;
|
|
8323
|
+
if (hide) {
|
|
8324
|
+
host.setFeatureState(record.sourceId, id, HIDDEN_STATE);
|
|
8325
|
+
record.hidden.add(id);
|
|
8326
|
+
} else {
|
|
8327
|
+
host.removeFeatureState(record.sourceId, id, TIMELINE_HIDDEN_KEY);
|
|
8328
|
+
record.hidden.delete(id);
|
|
8329
|
+
}
|
|
8330
|
+
return true;
|
|
8331
|
+
}
|
|
8332
|
+
function idAt(features, position) {
|
|
8333
|
+
const raw = features[position].id;
|
|
8334
|
+
return raw === void 0 || raw === null ? null : String(raw);
|
|
8335
|
+
}
|
|
8336
|
+
function seedTimelineSource(host, applied, sourceId, slices, w) {
|
|
8337
|
+
const handle = host.source(sourceId);
|
|
8338
|
+
const old = applied.get(sourceId);
|
|
8339
|
+
if (!handle) {
|
|
8340
|
+
applied.delete(sourceId);
|
|
8341
|
+
return 0;
|
|
8342
|
+
}
|
|
8343
|
+
if (old && old.handle === handle && sameSlices(old.slices, slices)) return 0;
|
|
8344
|
+
const record = {
|
|
8345
|
+
sourceId,
|
|
8346
|
+
handle,
|
|
8347
|
+
slices,
|
|
8348
|
+
hidden: (old == null ? void 0 : old.handle) === handle ? old.hidden : /* @__PURE__ */ new Set(),
|
|
8349
|
+
copies: null,
|
|
8350
|
+
window: w
|
|
8351
|
+
};
|
|
8352
|
+
applied.set(sourceId, record);
|
|
8353
|
+
const hide = /* @__PURE__ */ new Set();
|
|
8354
|
+
if (w !== null) {
|
|
8355
|
+
slices.forEach(({ features, start, end }) => {
|
|
8356
|
+
const index = getTimelineIndex(features);
|
|
8357
|
+
for (let position = start; position < end; position++) {
|
|
8358
|
+
const id = idAt(features, position);
|
|
8359
|
+
if (id !== null && shouldHide(record, id, index, position, w)) hide.add(id);
|
|
8360
|
+
}
|
|
8361
|
+
});
|
|
8362
|
+
}
|
|
8363
|
+
let calls = 0;
|
|
8364
|
+
Array.from(record.hidden).forEach((id) => {
|
|
8365
|
+
if (!hide.has(id) && setHidden(host, record, id, false)) calls++;
|
|
8366
|
+
});
|
|
8367
|
+
hide.forEach((id) => {
|
|
8368
|
+
if (setHidden(host, record, id, true)) calls++;
|
|
8369
|
+
});
|
|
8370
|
+
return calls;
|
|
8371
|
+
}
|
|
8372
|
+
function isTimelineHiddenOn(applied, sourceId, id) {
|
|
8373
|
+
var _a;
|
|
8374
|
+
return ((_a = applied.get(sourceId)) == null ? void 0 : _a.hidden.has(id)) ?? false;
|
|
8375
|
+
}
|
|
8376
|
+
function ownerOf(owners, position) {
|
|
8377
|
+
let lo = 0;
|
|
8378
|
+
let hi = owners.length - 1;
|
|
8379
|
+
let found = null;
|
|
8380
|
+
while (lo <= hi) {
|
|
8381
|
+
const mid = lo + hi >>> 1;
|
|
8382
|
+
if (owners[mid].start <= position) {
|
|
8383
|
+
found = owners[mid];
|
|
8384
|
+
lo = mid + 1;
|
|
8385
|
+
} else {
|
|
8386
|
+
hi = mid - 1;
|
|
8387
|
+
}
|
|
8388
|
+
}
|
|
8389
|
+
return found && position < found.end ? found : null;
|
|
8390
|
+
}
|
|
8391
|
+
function groupBySliceArray(host, applied, next, isActive) {
|
|
8392
|
+
const groups = [];
|
|
8393
|
+
applied.forEach((record, sourceId) => {
|
|
8394
|
+
if (host.source(sourceId) !== record.handle) {
|
|
8395
|
+
applied.delete(sourceId);
|
|
8396
|
+
return;
|
|
8397
|
+
}
|
|
8398
|
+
if (!isActive(sourceId) || sameWindow(record.window, next)) return;
|
|
8399
|
+
record.slices.forEach(({ features, start, end }) => {
|
|
8400
|
+
let group = groups.find((g) => g.features === features && sameWindow(g.from, record.window));
|
|
8401
|
+
if (!group) {
|
|
8402
|
+
group = { features, from: record.window, owners: [] };
|
|
8403
|
+
groups.push(group);
|
|
8404
|
+
}
|
|
8405
|
+
group.owners.push({ record, start, end });
|
|
8406
|
+
});
|
|
8407
|
+
record.window = next;
|
|
8408
|
+
});
|
|
8409
|
+
return groups;
|
|
8410
|
+
}
|
|
8411
|
+
function applyTimelineWindow(host, applied, next, isActive = () => true) {
|
|
8412
|
+
const flipped = [];
|
|
8413
|
+
const positions = [];
|
|
8414
|
+
groupBySliceArray(host, applied, next, isActive).forEach(({ features, from, owners }) => {
|
|
8415
|
+
owners.sort((a, b) => a.start - b.start);
|
|
8416
|
+
const index = getTimelineIndex(features);
|
|
8417
|
+
positions.length = 0;
|
|
8418
|
+
flippedPositions(index, from, next, positions);
|
|
8419
|
+
positions.forEach((position) => {
|
|
8420
|
+
const owner = ownerOf(owners, position);
|
|
8421
|
+
const id = owner ? idAt(features, position) : null;
|
|
8422
|
+
if (!owner || id === null) return;
|
|
8423
|
+
if (setHidden(host, owner.record, id, shouldHide(owner.record, id, index, position, next))) flipped.push(id);
|
|
8424
|
+
});
|
|
8425
|
+
});
|
|
8426
|
+
return flipped;
|
|
8427
|
+
}
|
|
8428
|
+
const IDENTITY_PATTERNS = [
|
|
8429
|
+
/person|people|individual|subject|suspect/,
|
|
8430
|
+
/target/,
|
|
8431
|
+
/entity/,
|
|
8432
|
+
/device|imei|imsi|msisdn|phone/,
|
|
8433
|
+
/mmsi|vessel|ship/,
|
|
8434
|
+
/vehicle|plate|car_?id/,
|
|
8435
|
+
/callsign|flight|aircraft|icao/,
|
|
8436
|
+
/user|account|owner|driver/,
|
|
8437
|
+
/track|trajectory/,
|
|
8438
|
+
/(^|[^a-z])id$|_id$|^id_|uuid/
|
|
8439
|
+
];
|
|
8440
|
+
const NOT_IDENTITY = /* @__PURE__ */ new Set(["id", "name", "startdate", "enddate", "opacity", "timestamp", "time", "date"]);
|
|
8441
|
+
const CATEGORY_SUFFIX = /(type|kind|category|class|status|model|role)$/;
|
|
8442
|
+
const MIN_COVERAGE = 0.9;
|
|
8443
|
+
const MAX_GROUPS = 500;
|
|
8444
|
+
const MIN_POINTS_PER_GROUP = 2;
|
|
8445
|
+
const MAX_SAMPLES = 1e4;
|
|
8446
|
+
function isTracePoint(f) {
|
|
8447
|
+
var _a, _b;
|
|
8448
|
+
return !!f && f.id != null && ((_a = f.geometry) == null ? void 0 : _a.type) === "Point" && !!((_b = f.properties) == null ? void 0 : _b.startDate);
|
|
8449
|
+
}
|
|
8450
|
+
function identityRank(field) {
|
|
8451
|
+
const name = field.toLowerCase();
|
|
8452
|
+
if (NOT_IDENTITY.has(name) || CATEGORY_SUFFIX.test(name)) return -1;
|
|
8453
|
+
return IDENTITY_PATTERNS.findIndex((pattern) => pattern.test(name));
|
|
8454
|
+
}
|
|
8455
|
+
function suggestTraceGroupField(features, fields) {
|
|
8456
|
+
var _a;
|
|
8457
|
+
const candidates = fields.map((field) => ({ field, rank: identityRank(field) })).filter((c) => c.rank >= 0).sort((a, b) => a.rank - b.rank || a.field.localeCompare(b.field));
|
|
8458
|
+
if (candidates.length === 0) return null;
|
|
8459
|
+
const step = Math.max(1, Math.ceil(features.length / MAX_SAMPLES));
|
|
8460
|
+
const points = [];
|
|
8461
|
+
for (let i = 0; i < features.length && points.length < MAX_SAMPLES; i += step) {
|
|
8462
|
+
const f = features[i];
|
|
8463
|
+
if (isTracePoint(f)) points.push(f);
|
|
8464
|
+
}
|
|
8465
|
+
if (points.length < 2) return null;
|
|
8466
|
+
const splitsIntoTracks = (field) => {
|
|
8467
|
+
var _a2;
|
|
8468
|
+
const values = /* @__PURE__ */ new Set();
|
|
8469
|
+
let present = 0;
|
|
8470
|
+
for (const f of points) {
|
|
8471
|
+
const raw = (_a2 = f.properties) == null ? void 0 : _a2[field];
|
|
8472
|
+
if (raw === null || raw === void 0 || raw === "") continue;
|
|
8473
|
+
present++;
|
|
8474
|
+
values.add(String(raw));
|
|
8475
|
+
if (values.size > MAX_GROUPS) return false;
|
|
8476
|
+
}
|
|
8477
|
+
return present >= points.length * MIN_COVERAGE && values.size >= 2 && present >= values.size * MIN_POINTS_PER_GROUP;
|
|
8478
|
+
};
|
|
8479
|
+
return ((_a = candidates.find((c) => splitsIntoTracks(c.field))) == null ? void 0 : _a.field) ?? null;
|
|
8480
|
+
}
|
|
8008
8481
|
function deepClone(value) {
|
|
8009
8482
|
try {
|
|
8010
8483
|
return structuredClone(value);
|
|
@@ -8141,82 +8614,6 @@ function shouldDiffDrawRender({ mode, pointerDown, hasSelection }) {
|
|
|
8141
8614
|
if (mode === "simple_select" || mode === "direct_select") return pointerDown && hasSelection;
|
|
8142
8615
|
return true;
|
|
8143
8616
|
}
|
|
8144
|
-
function extendBounds(bounds, coords) {
|
|
8145
|
-
if (!Array.isArray(coords) || coords.length === 0) return;
|
|
8146
|
-
if (typeof coords[0] === "number") {
|
|
8147
|
-
const lng = coords[0];
|
|
8148
|
-
const lat = coords[1];
|
|
8149
|
-
if (lng < bounds.minLng) bounds.minLng = lng;
|
|
8150
|
-
if (lng > bounds.maxLng) bounds.maxLng = lng;
|
|
8151
|
-
if (lat < bounds.minLat) bounds.minLat = lat;
|
|
8152
|
-
if (lat > bounds.maxLat) bounds.maxLat = lat;
|
|
8153
|
-
return;
|
|
8154
|
-
}
|
|
8155
|
-
for (const nested of coords) extendBounds(bounds, nested);
|
|
8156
|
-
}
|
|
8157
|
-
function computeBounds(coords) {
|
|
8158
|
-
const bounds = { minLng: Infinity, minLat: Infinity, maxLng: -Infinity, maxLat: -Infinity };
|
|
8159
|
-
extendBounds(bounds, coords);
|
|
8160
|
-
return bounds;
|
|
8161
|
-
}
|
|
8162
|
-
function boundsDisjoint(a, b) {
|
|
8163
|
-
return a.maxLng < b.minLng || a.minLng > b.maxLng || a.maxLat < b.minLat || a.minLat > b.maxLat;
|
|
8164
|
-
}
|
|
8165
|
-
function pointInBounds(lng, lat, b) {
|
|
8166
|
-
return lng >= b.minLng && lng <= b.maxLng && lat >= b.minLat && lat <= b.maxLat;
|
|
8167
|
-
}
|
|
8168
|
-
function buildGroupSpatialIndex(features) {
|
|
8169
|
-
var _a;
|
|
8170
|
-
const boxes = [];
|
|
8171
|
-
const positions = [];
|
|
8172
|
-
for (let p = 0; p < features.length; p++) {
|
|
8173
|
-
const geom = (_a = features[p]) == null ? void 0 : _a.geometry;
|
|
8174
|
-
const b = computeBounds(geom == null ? void 0 : geom.coordinates);
|
|
8175
|
-
if (!isFinite(b.minLng) || !isFinite(b.minLat) || !isFinite(b.maxLng) || !isFinite(b.maxLat)) {
|
|
8176
|
-
continue;
|
|
8177
|
-
}
|
|
8178
|
-
boxes.push(b.minLng, b.minLat, b.maxLng, b.maxLat);
|
|
8179
|
-
positions.push(p);
|
|
8180
|
-
}
|
|
8181
|
-
if (positions.length === 0) {
|
|
8182
|
-
return { tree: null, positions, size: features.length };
|
|
8183
|
-
}
|
|
8184
|
-
const startedAt = performance.now();
|
|
8185
|
-
const tree = new Flatbush(positions.length);
|
|
8186
|
-
for (let i = 0; i < boxes.length; i += 4) {
|
|
8187
|
-
tree.add(boxes[i], boxes[i + 1], boxes[i + 2], boxes[i + 3]);
|
|
8188
|
-
}
|
|
8189
|
-
tree.finish();
|
|
8190
|
-
mapPerfLog("spatial-index", "built group index", {
|
|
8191
|
-
indexed: positions.length,
|
|
8192
|
-
of: features.length,
|
|
8193
|
-
ms: Math.round(performance.now() - startedAt)
|
|
8194
|
-
});
|
|
8195
|
-
return { tree, positions, size: features.length };
|
|
8196
|
-
}
|
|
8197
|
-
const indexCache = /* @__PURE__ */ new WeakMap();
|
|
8198
|
-
const failedBuilds = /* @__PURE__ */ new WeakSet();
|
|
8199
|
-
function getGroupSpatialIndex(features) {
|
|
8200
|
-
if (failedBuilds.has(features)) return void 0;
|
|
8201
|
-
let index = indexCache.get(features);
|
|
8202
|
-
if (!index) {
|
|
8203
|
-
try {
|
|
8204
|
-
index = buildGroupSpatialIndex(features);
|
|
8205
|
-
} catch {
|
|
8206
|
-
failedBuilds.add(features);
|
|
8207
|
-
return void 0;
|
|
8208
|
-
}
|
|
8209
|
-
indexCache.set(features, index);
|
|
8210
|
-
}
|
|
8211
|
-
return index;
|
|
8212
|
-
}
|
|
8213
|
-
function queryCandidatePositions(index, bounds) {
|
|
8214
|
-
if (!index.tree) return [];
|
|
8215
|
-
const items = index.tree.search(bounds.minLng, bounds.minLat, bounds.maxLng, bounds.maxLat);
|
|
8216
|
-
const positions = items.map((i) => index.positions[i]);
|
|
8217
|
-
positions.sort((a, b) => a - b);
|
|
8218
|
-
return positions;
|
|
8219
|
-
}
|
|
8220
8617
|
function collectVisibleFeatureGroups(drawFeatures, readOnlyByLayer, layers) {
|
|
8221
8618
|
const groups = [];
|
|
8222
8619
|
if (drawFeatures) groups.push({ features: drawFeatures });
|
|
@@ -8334,19 +8731,6 @@ function buildSelectionOverlayStack() {
|
|
|
8334
8731
|
}
|
|
8335
8732
|
];
|
|
8336
8733
|
}
|
|
8337
|
-
function overlayTimelineInputs(ids, visible) {
|
|
8338
|
-
const hidden = /* @__PURE__ */ new Set();
|
|
8339
|
-
if (visible !== null) ids.forEach((id) => {
|
|
8340
|
-
if (!visible.has(id)) hidden.add(id);
|
|
8341
|
-
});
|
|
8342
|
-
return { ids, hidden };
|
|
8343
|
-
}
|
|
8344
|
-
function sameIds(a, b) {
|
|
8345
|
-
return a.size === b.size && Array.from(a).every((id) => b.has(id));
|
|
8346
|
-
}
|
|
8347
|
-
function sameOverlayTimelineInputs(a, b) {
|
|
8348
|
-
return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
|
|
8349
|
-
}
|
|
8350
8734
|
function buildSelectionOverlayData(ids, styleFor) {
|
|
8351
8735
|
const features = [];
|
|
8352
8736
|
ids.forEach((id) => {
|
|
@@ -8733,8 +9117,8 @@ function hideTooltip() {
|
|
|
8733
9117
|
tooltipEl.style.display = "none";
|
|
8734
9118
|
}
|
|
8735
9119
|
}
|
|
8736
|
-
function fingerprintCluster(pointCount,
|
|
8737
|
-
return `${size}|${pointCount}|${badgeValue ?? ""}|${
|
|
9120
|
+
function fingerprintCluster(pointCount, counts2, size, badgeValue) {
|
|
9121
|
+
return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
|
|
8738
9122
|
}
|
|
8739
9123
|
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue) {
|
|
8740
9124
|
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
@@ -8886,6 +9270,8 @@ const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
|
8886
9270
|
const EMPTY_SOURCES = [];
|
|
8887
9271
|
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"];
|
|
8888
9272
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
9273
|
+
const TICK_COUNT_SETTLE_MS = 300;
|
|
9274
|
+
const SPATIAL_COUNT_MIN_FEATURES = 5e3;
|
|
8889
9275
|
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
8890
9276
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
8891
9277
|
const canvas = document.createElement("canvas");
|
|
@@ -9093,7 +9479,7 @@ function basemapInsertAnchor(map) {
|
|
|
9093
9479
|
function featureStateHostFor(m) {
|
|
9094
9480
|
return {
|
|
9095
9481
|
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
9096
|
-
removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
|
|
9482
|
+
removeFeatureState: (source, id, key) => m.removeFeatureState({ source, id }, key),
|
|
9097
9483
|
source: (source) => m.getSource(source)
|
|
9098
9484
|
};
|
|
9099
9485
|
}
|
|
@@ -9276,6 +9662,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9276
9662
|
const justCreatedFeatureRef = useRef(false);
|
|
9277
9663
|
const [autoLabelConfig, setAutoLabelConfig] = useState({ enabled: true, threshold: 220 });
|
|
9278
9664
|
const [visibleFeatureCount, setVisibleFeatureCount] = useState(Infinity);
|
|
9665
|
+
const visibleFeatureCountRef = useRef(visibleFeatureCount);
|
|
9666
|
+
visibleFeatureCountRef.current = visibleFeatureCount;
|
|
9667
|
+
const tickCountTimerRef = useRef(null);
|
|
9279
9668
|
const lastLabelVisibility = useRef(false);
|
|
9280
9669
|
const shardRegistryRef = useRef(null);
|
|
9281
9670
|
const applyShardedLayersRef = useRef(null);
|
|
@@ -9283,9 +9672,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9283
9672
|
const bindHoverHandlersRef = useRef(null);
|
|
9284
9673
|
const unbindHoverHandlersRef = useRef(null);
|
|
9285
9674
|
const [labelsSuppressed, setLabelsSuppressed] = useState(true);
|
|
9675
|
+
const labelsSuppressedRef = useRef(labelsSuppressed);
|
|
9676
|
+
labelsSuppressedRef.current = labelsSuppressed;
|
|
9286
9677
|
const [contextMenu, setContextMenu] = useState(null);
|
|
9287
9678
|
const [timelineStoreApi] = useState(createTimelineStore);
|
|
9288
|
-
const
|
|
9679
|
+
const timelineEnabled = useStore(timelineStoreApi, (s) => s.isEnabled);
|
|
9680
|
+
const timelineHasData = useStore(timelineStoreApi, (s) => s.hasTemporalData);
|
|
9289
9681
|
const { toast: internalToast } = useToast();
|
|
9290
9682
|
const toast = toastProvider ?? internalToast;
|
|
9291
9683
|
const featureCap = useMemo(() => resolveFeatureCap(maxFeaturesPerLayer), [maxFeaturesPerLayer]);
|
|
@@ -9546,7 +9938,13 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9546
9938
|
});
|
|
9547
9939
|
setFeatureCount(drawFeatureCount + hiddenCount + readOnlyCount);
|
|
9548
9940
|
}, []);
|
|
9549
|
-
const
|
|
9941
|
+
const timelineWindowRef = useRef(null);
|
|
9942
|
+
const appliedTimelineRef = useRef(/* @__PURE__ */ new Map());
|
|
9943
|
+
const isTimelineSourceActive = useCallback((sourceId) => {
|
|
9944
|
+
var _a;
|
|
9945
|
+
const shard = parseShardSourceId(sourceId);
|
|
9946
|
+
return !shard || ((_a = layersRef.current.find((l) => l.id === shard.layerId)) == null ? void 0 : _a.visible) === true;
|
|
9947
|
+
}, []);
|
|
9550
9948
|
const syncRef = useRef(() => {
|
|
9551
9949
|
});
|
|
9552
9950
|
const trySelectionFastPathRef = useRef(null);
|
|
@@ -9578,6 +9976,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9578
9976
|
}
|
|
9579
9977
|
(_b = syncCoalescerRef.current) == null ? void 0 : _b.schedule(reason);
|
|
9580
9978
|
}, []);
|
|
9979
|
+
useEffect(() => {
|
|
9980
|
+
const windowOf = (state) => state.isEnabled && state.hasTemporalData ? windowFromRange(state.rangeStart, state.rangeEnd) : null;
|
|
9981
|
+
const follow = (state) => {
|
|
9982
|
+
var _a;
|
|
9983
|
+
const next = windowOf(state);
|
|
9984
|
+
if (sameWindow(next, timelineWindowRef.current)) return;
|
|
9985
|
+
timelineWindowRef.current = next;
|
|
9986
|
+
scheduleSync("timeline");
|
|
9987
|
+
(_a = update3DFlightPathsRef.current) == null ? void 0 : _a.call(update3DFlightPathsRef);
|
|
9988
|
+
};
|
|
9989
|
+
follow(timelineStoreApi.getState());
|
|
9990
|
+
return timelineStoreApi.subscribe(follow);
|
|
9991
|
+
}, [timelineStoreApi, scheduleSync]);
|
|
9581
9992
|
useEffect(() => {
|
|
9582
9993
|
scheduleSync();
|
|
9583
9994
|
}, [layers, scheduleSync]);
|
|
@@ -9641,21 +10052,33 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9641
10052
|
const m = map.current;
|
|
9642
10053
|
if (!m) return 0;
|
|
9643
10054
|
const bounds = m.getBounds();
|
|
10055
|
+
const w = timelineWindowRef.current;
|
|
10056
|
+
const groupOf = (features) => {
|
|
10057
|
+
if (w === null) return { features };
|
|
10058
|
+
const index = getTimelineIndex(features);
|
|
10059
|
+
const group = { features, isVisible: (p) => isVisibleAt(index, p, w) };
|
|
10060
|
+
const spatial = features.length >= SPATIAL_COUNT_MIN_FEATURES ? getGroupSpatialIndex(features) : void 0;
|
|
10061
|
+
if (spatial) group.indexed = { spatial, visibleTotal: countVisible(index, w) };
|
|
10062
|
+
return group;
|
|
10063
|
+
};
|
|
9644
10064
|
const groups = [];
|
|
9645
|
-
if (draw.current)
|
|
10065
|
+
if (draw.current) {
|
|
10066
|
+
const features = draw.current.getAll().features;
|
|
10067
|
+
groups.push(w === null ? { features } : { features, isVisible: (p) => isFeatureVisible(features[p], w) });
|
|
10068
|
+
}
|
|
9646
10069
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9647
10070
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
9648
|
-
if (layer == null ? void 0 : layer.visible) groups.push(features);
|
|
10071
|
+
if (layer == null ? void 0 : layer.visible) groups.push(groupOf(features));
|
|
9649
10072
|
});
|
|
9650
10073
|
return countFeaturesInBounds(
|
|
9651
10074
|
groups,
|
|
9652
10075
|
{ west: bounds.getWest(), east: bounds.getEast(), south: bounds.getSouth(), north: bounds.getNorth() },
|
|
9653
|
-
{ threshold
|
|
10076
|
+
{ threshold }
|
|
9654
10077
|
);
|
|
9655
10078
|
}, []);
|
|
9656
10079
|
const isSyncingRef = useRef(false);
|
|
9657
|
-
const selectionPaintCacheRef = useRef(null);
|
|
9658
10080
|
const tracePaintCacheRef = useRef(null);
|
|
10081
|
+
const traceEndpointsRef = useRef(/* @__PURE__ */ new Set());
|
|
9659
10082
|
const paintedArrowLinesRef = useRef([]);
|
|
9660
10083
|
const renderArrowOverlays = useCallback((arrowLines) => {
|
|
9661
10084
|
const mapInstance = map.current;
|
|
@@ -9761,7 +10184,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9761
10184
|
const source = map.current.getSource("custom-features");
|
|
9762
10185
|
if (!source) return;
|
|
9763
10186
|
const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
|
|
9764
|
-
const
|
|
10187
|
+
const timelineWindow = timelineWindowRef.current;
|
|
9765
10188
|
const currentLayers = layersRef.current;
|
|
9766
10189
|
const isLayerVisible = (layer) => {
|
|
9767
10190
|
return layer.visible;
|
|
@@ -9774,11 +10197,17 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9774
10197
|
});
|
|
9775
10198
|
shardedLayerIdsRef.current = shardedLayerIds;
|
|
9776
10199
|
const allFeatures = [...drawFeatures.features];
|
|
10200
|
+
const sharedSlices = [];
|
|
10201
|
+
const addSlice = (features) => {
|
|
10202
|
+
if (features.length > 0) sharedSlices.push({ features, start: 0, end: features.length });
|
|
10203
|
+
};
|
|
10204
|
+
addSlice(drawFeatures.features);
|
|
9777
10205
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9778
10206
|
if (shardedLayerIds.has(layerId)) return;
|
|
9779
10207
|
const layer = currentLayers.find((l) => l.id === layerId);
|
|
9780
10208
|
if (layer && isLayerVisible(layer)) {
|
|
9781
10209
|
pushAll(allFeatures, features);
|
|
10210
|
+
addSlice(features);
|
|
9782
10211
|
}
|
|
9783
10212
|
});
|
|
9784
10213
|
const featureById = /* @__PURE__ */ new Map();
|
|
@@ -9826,71 +10255,69 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9826
10255
|
if (sizeField && isFinite(sMin)) sizeFieldRanges.set(layer.id, { min: sMin, max: sMax });
|
|
9827
10256
|
if (colorField && isFinite(cMin)) colorFieldRanges.set(layer.id, { min: cMin, max: cMax });
|
|
9828
10257
|
});
|
|
9829
|
-
const lastTracePointIds = /* @__PURE__ */ new Set();
|
|
9830
10258
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
9831
|
-
const lastTracePointLabels = /* @__PURE__ */ new Map();
|
|
9832
10259
|
const tracePointIds = /* @__PURE__ */ new Set();
|
|
9833
10260
|
const paintedTraceGroups = [];
|
|
9834
|
-
const
|
|
9835
|
-
const tracePointPaint = /* @__PURE__ */ new Map();
|
|
9836
|
-
const isTimelineVisibleId = timelineVisibility(visibleSet);
|
|
10261
|
+
const traceIndexes = [];
|
|
9837
10262
|
currentLayers.forEach((layer) => {
|
|
9838
10263
|
var _a2;
|
|
9839
10264
|
if (!((_a2 = layer.traceConfig) == null ? void 0 : _a2.enabled) || !layer.visible) return;
|
|
9840
|
-
const
|
|
10265
|
+
const traceFeatures = traceSourceFeatures(layer, featureById);
|
|
10266
|
+
const traceIndex = getTimelineIndex(traceFeatures);
|
|
10267
|
+
const groups = getTraceGroups(traceFeatures, layer.traceConfig.groupByField);
|
|
10268
|
+
const pointsHidden = layerHidesPoints(layer);
|
|
9841
10269
|
for (const group of groups) {
|
|
9842
|
-
|
|
10270
|
+
paintedTraceGroups.push(pointsHidden && group.label !== null ? { ...group, label: null } : group);
|
|
10271
|
+
traceIndexes.push(traceIndex);
|
|
9843
10272
|
for (const id of group.ids) {
|
|
9844
10273
|
tracePointIds.add(id);
|
|
9845
10274
|
tracePointColors.set(id, group.color);
|
|
9846
10275
|
}
|
|
9847
|
-
const visible = visibleTraceIndices(group, isTimelineVisibleId);
|
|
9848
|
-
if (visible.length === 0) continue;
|
|
9849
|
-
const endpointId = group.ids[visible[visible.length - 1]];
|
|
9850
|
-
lastTracePointIds.add(endpointId);
|
|
9851
|
-
if (group.label !== null) lastTracePointLabels.set(endpointId, group.label);
|
|
9852
|
-
for (let k = 1; k < visible.length; k++) {
|
|
9853
|
-
traceSegments.push(traceSegmentFeature(group, groupIndex, visible[k - 1], visible[k]));
|
|
9854
|
-
}
|
|
9855
10276
|
}
|
|
9856
10277
|
});
|
|
9857
|
-
const paintCache = createSelectionPaintCache();
|
|
9858
10278
|
const paintContext = {
|
|
9859
|
-
timelineVisibleIds: visibleSet,
|
|
9860
10279
|
sizeFieldRanges,
|
|
9861
10280
|
colorFieldRanges,
|
|
9862
10281
|
tracePointIds,
|
|
9863
|
-
lastTracePointIds,
|
|
9864
|
-
lastTracePointLabels,
|
|
9865
10282
|
tracePointColors
|
|
9866
10283
|
};
|
|
9867
10284
|
const drawFeatureCount = drawFeatures.features.length;
|
|
9868
10285
|
const sourceData = {
|
|
9869
10286
|
type: "FeatureCollection",
|
|
9870
10287
|
features: allFeatures.map((f, i) => {
|
|
9871
|
-
|
|
9872
|
-
const p = styled.paint;
|
|
9873
|
-
recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
9874
|
-
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
9875
|
-
return styled.feature;
|
|
10288
|
+
return styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount).feature;
|
|
9876
10289
|
})
|
|
9877
10290
|
};
|
|
9878
10291
|
source.setData(sourceData);
|
|
9879
|
-
selectionPaintCacheRef.current = paintCache;
|
|
9880
10292
|
overlayPaintContextRef.current = paintContext;
|
|
10293
|
+
const stateHost = featureStateHostFor(map.current);
|
|
10294
|
+
seedTimelineSource(stateHost, appliedTimelineRef.current, SHARED_SOURCE_ID, sharedSlices, timelineWindow);
|
|
10295
|
+
applyTimelineWindow(stateHost, appliedTimelineRef.current, timelineWindow, isTimelineSourceActive);
|
|
9881
10296
|
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
9882
|
-
const traceSource = map.current.getSource(
|
|
9883
|
-
|
|
9884
|
-
|
|
10297
|
+
const traceSource = map.current.getSource(TRACE_SOURCE_ID);
|
|
10298
|
+
const tracePaint = paintTraceAt(paintedTraceGroups, traceIndexes, timelineWindow);
|
|
10299
|
+
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: tracePaint.features });
|
|
10300
|
+
const endpoints2 = new Set(tracePaint.endpoints);
|
|
10301
|
+
setTraceEndpoints(
|
|
10302
|
+
featureStateHostFor(map.current),
|
|
10303
|
+
traceEndpointsRef.current,
|
|
10304
|
+
Array.from(traceEndpointsRef.current).filter((id) => !endpoints2.has(id)),
|
|
10305
|
+
tracePaint.endpoints
|
|
10306
|
+
);
|
|
10307
|
+
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, indexes: traceIndexes, window: timelineWindow } : null;
|
|
9885
10308
|
{
|
|
9886
10309
|
let sawArrowFeature = false;
|
|
9887
10310
|
const arrowLines = [];
|
|
9888
|
-
|
|
10311
|
+
const pushArrow = (styled, record) => {
|
|
10312
|
+
const { s, e } = record ? featureInterval(record) : { s: NaN, e: NaN };
|
|
10313
|
+
arrowLines.push(isIntervalVisible(s, e, timelineWindow) ? styled : { ...styled, properties: { ...styled.properties, "stroke-opacity": 0, "fill-opacity": 0 } });
|
|
10314
|
+
};
|
|
10315
|
+
sourceData.features.forEach((f, i) => {
|
|
9889
10316
|
var _a2;
|
|
9890
10317
|
const isArrow = ((_a2 = f.properties) == null ? void 0 : _a2.kind) === "arrow" || arrowFeatureIdsRef.current.has(String(f.id));
|
|
9891
10318
|
if (!isArrow) return;
|
|
9892
10319
|
sawArrowFeature = true;
|
|
9893
|
-
if (f.geometry.type === "LineString")
|
|
10320
|
+
if (f.geometry.type === "LineString") pushArrow(f, allFeatures[i]);
|
|
9894
10321
|
});
|
|
9895
10322
|
const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
|
|
9896
10323
|
var _a2;
|
|
@@ -9898,7 +10325,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9898
10325
|
})) ?? [];
|
|
9899
10326
|
if (shardArrows.length > 0) {
|
|
9900
10327
|
sawArrowFeature = true;
|
|
9901
|
-
|
|
10328
|
+
shardArrows.forEach((f) => pushArrow(f, getReadOnlyFeatureById(String(f.id))));
|
|
9902
10329
|
}
|
|
9903
10330
|
hasArrowFeaturesRef.current = sawArrowFeature;
|
|
9904
10331
|
paintedArrowLinesRef.current = arrowLines;
|
|
@@ -9928,7 +10355,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9928
10355
|
} finally {
|
|
9929
10356
|
isSyncingRef.current = false;
|
|
9930
10357
|
}
|
|
9931
|
-
}, [layers, hashStringToColor$1, autoLabelConfig, countVisibleFeatures, renderArrowOverlays]);
|
|
10358
|
+
}, [layers, hashStringToColor$1, autoLabelConfig, countVisibleFeatures, renderArrowOverlays, getReadOnlyFeatureById, isTimelineSourceActive]);
|
|
9932
10359
|
const update3DFlightPaths = useCallback(() => {
|
|
9933
10360
|
var _a;
|
|
9934
10361
|
if (!map.current || !is3DTerrainEnabled) {
|
|
@@ -9942,11 +10369,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9942
10369
|
return;
|
|
9943
10370
|
}
|
|
9944
10371
|
const mapInstance = map.current;
|
|
9945
|
-
const
|
|
9946
|
-
const
|
|
9947
|
-
if (
|
|
9948
|
-
const
|
|
9949
|
-
return
|
|
10372
|
+
const timelineWindow = timelineWindowRef.current;
|
|
10373
|
+
const visibleIn = (features) => {
|
|
10374
|
+
if (timelineWindow === null) return [...features];
|
|
10375
|
+
const index = getTimelineIndex(features);
|
|
10376
|
+
return features.filter((_, p) => isVisibleAt(index, p, timelineWindow));
|
|
9950
10377
|
};
|
|
9951
10378
|
const allFeatures = [];
|
|
9952
10379
|
const currentLayers = layersRef.current;
|
|
@@ -9956,9 +10383,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9956
10383
|
if (((_a = l.traceConfig) == null ? void 0 : _a.enabled) !== true) continue;
|
|
9957
10384
|
for (const featureId of l.featureIds) traceFeatureIds.add(featureId);
|
|
9958
10385
|
}
|
|
9959
|
-
const drawFeatures = draw.current.getAll().features.filter(
|
|
9960
|
-
(feature) => isFeatureVisibleInTimeline(feature) && traceFeatureIds.has(feature.id)
|
|
9961
|
-
);
|
|
10386
|
+
const drawFeatures = draw.current.getAll().features.filter((feature) => traceFeatureIds.has(feature.id) && isFeatureVisible(feature, timelineWindow));
|
|
9962
10387
|
pushAll(allFeatures, drawFeatures);
|
|
9963
10388
|
}
|
|
9964
10389
|
readOnlyFeatures.current.forEach((features, layerId2) => {
|
|
@@ -9967,8 +10392,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
9967
10392
|
const altitudeMode = (layer2 == null ? void 0 : layer2.altitudeDisplayMode) ?? "both";
|
|
9968
10393
|
const traceEnabled = ((_a2 = layer2 == null ? void 0 : layer2.traceConfig) == null ? void 0 : _a2.enabled) === true;
|
|
9969
10394
|
if ((layer2 == null ? void 0 : layer2.visible) && traceEnabled && (altitudeMode === "3d" || altitudeMode === "both")) {
|
|
9970
|
-
|
|
9971
|
-
pushAll(allFeatures, visibleFeatures);
|
|
10395
|
+
pushAll(allFeatures, visibleIn(features));
|
|
9972
10396
|
}
|
|
9973
10397
|
});
|
|
9974
10398
|
const flightPaths = extract3DFlightPaths(allFeatures);
|
|
@@ -10027,11 +10451,9 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10027
10451
|
const fingerprint = buildShardFingerprint(layer, features, shardSize2);
|
|
10028
10452
|
const expectedShards = shardRanges(features.length, shardSize2).length;
|
|
10029
10453
|
if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
return;
|
|
10034
|
-
}
|
|
10454
|
+
setLayerImporting(layer.id, false);
|
|
10455
|
+
mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
|
|
10456
|
+
return;
|
|
10035
10457
|
}
|
|
10036
10458
|
if (shardFingerprintsEqual(state.inFlightFingerprint, fingerprint)) {
|
|
10037
10459
|
setLayerImporting(layer.id, true);
|
|
@@ -10062,19 +10484,22 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10062
10484
|
isCurrent: () => map.current !== null && state.generation === generation,
|
|
10063
10485
|
contextForShard: () => {
|
|
10064
10486
|
return {
|
|
10065
|
-
timelineVisibleIds: timelineVisibleIdsRef.current,
|
|
10066
10487
|
sizeFieldRanges,
|
|
10067
10488
|
colorFieldRanges,
|
|
10068
10489
|
// Trace-enabled layers are never sharded, so these are empty by construction.
|
|
10069
10490
|
tracePointIds: EMPTY_ID_SET,
|
|
10070
|
-
lastTracePointIds: EMPTY_ID_SET,
|
|
10071
|
-
lastTracePointLabels: EMPTY_LABEL_MAP,
|
|
10072
10491
|
tracePointColors: EMPTY_LABEL_MAP
|
|
10073
10492
|
};
|
|
10074
10493
|
},
|
|
10075
|
-
onShardPainted: (index,
|
|
10494
|
+
onShardPainted: (index, start, end) => {
|
|
10076
10495
|
var _a2;
|
|
10077
|
-
|
|
10496
|
+
seedTimelineSource(
|
|
10497
|
+
featureStateHostFor(m),
|
|
10498
|
+
appliedTimelineRef.current,
|
|
10499
|
+
shardSourceId(layer.id, index),
|
|
10500
|
+
[{ features, start, end }],
|
|
10501
|
+
timelineWindowRef.current
|
|
10502
|
+
);
|
|
10078
10503
|
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10079
10504
|
overlayRestyled = true;
|
|
10080
10505
|
},
|
|
@@ -10108,7 +10533,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10108
10533
|
}, [update3DFlightPaths]);
|
|
10109
10534
|
useEffect(() => {
|
|
10110
10535
|
update3DFlightPaths();
|
|
10111
|
-
}, [update3DFlightPaths, layers, is3DTerrainEnabled
|
|
10536
|
+
}, [update3DFlightPaths, layers, is3DTerrainEnabled]);
|
|
10112
10537
|
useEffect(() => {
|
|
10113
10538
|
if (map.current && is3DTerrainEnabled) {
|
|
10114
10539
|
const timer = setTimeout(() => {
|
|
@@ -10601,7 +11026,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10601
11026
|
"text-opacity": ["coalesce", ["get", "stroke-opacity"], 1]
|
|
10602
11027
|
}
|
|
10603
11028
|
});
|
|
10604
|
-
mapInstance.addSource(
|
|
11029
|
+
mapInstance.addSource(TRACE_SOURCE_ID, {
|
|
10605
11030
|
type: "geojson",
|
|
10606
11031
|
data: { type: "FeatureCollection", features: [] },
|
|
10607
11032
|
maxzoom: 22
|
|
@@ -10609,13 +11034,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
10609
11034
|
mapInstance.addLayer({
|
|
10610
11035
|
id: "trace-lines",
|
|
10611
11036
|
type: "line",
|
|
10612
|
-
source:
|
|
11037
|
+
source: TRACE_SOURCE_ID,
|
|
11038
|
+
filter: ["==", "$type", "LineString"],
|
|
10613
11039
|
paint: {
|
|
10614
11040
|
"line-color": ["get", "color"],
|
|
10615
11041
|
"line-width": 2,
|
|
10616
11042
|
"line-opacity": 0.7
|
|
10617
11043
|
}
|
|
10618
11044
|
});
|
|
11045
|
+
mapInstance.addLayer(buildTraceEndpointLabelLayer());
|
|
10619
11046
|
mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
|
|
10620
11047
|
type: "geojson",
|
|
10621
11048
|
data: { type: "FeatureCollection", features: [] },
|
|
@@ -13273,8 +13700,10 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13273
13700
|
if (!m.getLayer(id)) return;
|
|
13274
13701
|
m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
|
|
13275
13702
|
});
|
|
13276
|
-
if (!firstVisibleBasemapSymbol
|
|
13277
|
-
|
|
13703
|
+
if (!firstVisibleBasemapSymbol) {
|
|
13704
|
+
[TRACE_ENDPOINT_LABEL_LAYER_ID, SELECTION_OVERLAY_LAYER_IDS.label].forEach((id) => {
|
|
13705
|
+
if (m.getLayer(id)) m.moveLayer(id);
|
|
13706
|
+
});
|
|
13278
13707
|
}
|
|
13279
13708
|
} catch (e) {
|
|
13280
13709
|
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
@@ -13592,7 +14021,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13592
14021
|
if (!layer) return [];
|
|
13593
14022
|
const fieldsMap = /* @__PURE__ */ new Map();
|
|
13594
14023
|
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity", ...STYLING_PROPERTY_KEYS]);
|
|
13595
|
-
const
|
|
14024
|
+
const MAX_SAMPLES2 = 1e4;
|
|
13596
14025
|
let features = [];
|
|
13597
14026
|
if (layer.readOnly) {
|
|
13598
14027
|
features = readOnlyFeatures.current.get(layerId) || [];
|
|
@@ -13601,8 +14030,8 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13601
14030
|
} else {
|
|
13602
14031
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
13603
14032
|
}
|
|
13604
|
-
const sampled = !layer.readOnly && features.length >
|
|
13605
|
-
const sampleFeatures = layer.readOnly ? features : features.slice(0,
|
|
14033
|
+
const sampled = !layer.readOnly && features.length > MAX_SAMPLES2;
|
|
14034
|
+
const sampleFeatures = layer.readOnly ? features : features.slice(0, MAX_SAMPLES2);
|
|
13606
14035
|
sampleFeatures.forEach((f) => {
|
|
13607
14036
|
if (f && f.properties) {
|
|
13608
14037
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
@@ -13650,15 +14079,15 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13650
14079
|
} else {
|
|
13651
14080
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
13652
14081
|
}
|
|
13653
|
-
const
|
|
13654
|
-
const sample = features.slice(0,
|
|
13655
|
-
const
|
|
14082
|
+
const MAX_SAMPLES2 = 1e4;
|
|
14083
|
+
const sample = features.slice(0, MAX_SAMPLES2);
|
|
14084
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
13656
14085
|
for (const f of sample) {
|
|
13657
14086
|
const key = categoricalKey((_a = f == null ? void 0 : f.properties) == null ? void 0 : _a[fieldName]);
|
|
13658
14087
|
if (key === null) continue;
|
|
13659
|
-
|
|
14088
|
+
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
13660
14089
|
}
|
|
13661
|
-
return Array.from(
|
|
14090
|
+
return Array.from(counts2.entries()).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, maxValues).map(([value, count]) => ({ value, count }));
|
|
13662
14091
|
},
|
|
13663
14092
|
[layers]
|
|
13664
14093
|
);
|
|
@@ -13724,21 +14153,19 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13724
14153
|
});
|
|
13725
14154
|
}
|
|
13726
14155
|
}, [layers]);
|
|
14156
|
+
const traceFieldSource = useCallback((layer) => {
|
|
14157
|
+
if (layer.readOnly) return readOnlyFeatures.current.get(layer.id) || [];
|
|
14158
|
+
if (layer.visible) return draw.current ? layer.featureIds.map((id) => draw.current.get(id)) : [];
|
|
14159
|
+
return hiddenFeatures.current.get(layer.id) || [];
|
|
14160
|
+
}, []);
|
|
13727
14161
|
const getAvailableTraceFields = useCallback((layerId) => {
|
|
13728
14162
|
const layer = layers.find((l) => l.id === layerId);
|
|
13729
14163
|
if (!layer) return [];
|
|
13730
14164
|
const fieldsSet = /* @__PURE__ */ new Set();
|
|
13731
14165
|
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity"]);
|
|
13732
|
-
const
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
features = readOnlyFeatures.current.get(layerId) || [];
|
|
13736
|
-
} else if (layer.visible) {
|
|
13737
|
-
features = draw.current ? layer.featureIds.map((id) => draw.current.get(id)) : [];
|
|
13738
|
-
} else {
|
|
13739
|
-
features = hiddenFeatures.current.get(layerId) || [];
|
|
13740
|
-
}
|
|
13741
|
-
const sampleFeatures = features.slice(0, MAX_SAMPLES);
|
|
14166
|
+
const MAX_SAMPLES2 = 1e4;
|
|
14167
|
+
const features = traceFieldSource(layer);
|
|
14168
|
+
const sampleFeatures = features.slice(0, MAX_SAMPLES2);
|
|
13742
14169
|
sampleFeatures.forEach((f) => {
|
|
13743
14170
|
if (f && f.properties) {
|
|
13744
14171
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
@@ -13749,7 +14176,11 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13749
14176
|
}
|
|
13750
14177
|
});
|
|
13751
14178
|
return Array.from(fieldsSet).sort();
|
|
13752
|
-
}, [layers]);
|
|
14179
|
+
}, [layers, traceFieldSource]);
|
|
14180
|
+
const getSuggestedTraceField = useCallback((layerId) => {
|
|
14181
|
+
const layer = layers.find((l) => l.id === layerId);
|
|
14182
|
+
return layer ? suggestTraceGroupField(traceFieldSource(layer), getAvailableTraceFields(layerId)) : null;
|
|
14183
|
+
}, [layers, traceFieldSource, getAvailableTraceFields]);
|
|
13753
14184
|
const handleMeasureModeChange = useCallback((mode) => {
|
|
13754
14185
|
setMeasureMode(mode);
|
|
13755
14186
|
setMeasurePoints([]);
|
|
@@ -13839,18 +14270,24 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13839
14270
|
if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
|
|
13840
14271
|
if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
|
|
13841
14272
|
});
|
|
13842
|
-
return { ...base,
|
|
14273
|
+
return { ...base, sizeFieldRanges, colorFieldRanges };
|
|
13843
14274
|
}, []);
|
|
13844
14275
|
const overlayFeatureCountRef = useRef(0);
|
|
13845
|
-
const overlayTimelineInputsRef = useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
|
|
13846
14276
|
const refreshSelectionOverlay = useCallback((m, ids) => {
|
|
13847
|
-
overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
|
|
13848
14277
|
if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
|
|
13849
14278
|
const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
|
|
13850
14279
|
if (!overlay) return;
|
|
13851
14280
|
const ctx = ids.size > 0 ? overlayPaintContext() : null;
|
|
13852
14281
|
const layers2 = layersRef.current;
|
|
13853
14282
|
const layerById = new Map(layers2.map((l) => [l.id, l]));
|
|
14283
|
+
const styled = (feature, layer, paintCtx, sourceId) => {
|
|
14284
|
+
const out = styleFeatureForPaint(feature, layer, paintCtx, true).feature;
|
|
14285
|
+
if (isTimelineHiddenOn(appliedTimelineRef.current, sourceId, String(feature.id)) && out.properties) {
|
|
14286
|
+
out.properties["stroke-opacity"] = 0;
|
|
14287
|
+
out.properties["fill-opacity"] = 0;
|
|
14288
|
+
}
|
|
14289
|
+
return out;
|
|
14290
|
+
};
|
|
13854
14291
|
const data = buildSelectionOverlayData(ids, (id) => {
|
|
13855
14292
|
if (!ctx) return [];
|
|
13856
14293
|
const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
|
|
@@ -13858,12 +14295,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13858
14295
|
return holders.filter((h) => {
|
|
13859
14296
|
var _a;
|
|
13860
14297
|
return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
|
|
13861
|
-
}).map((h) =>
|
|
14298
|
+
}).map((h) => styled(h.feature, layerById.get(h.layerId), ctx, shardedLayerIdsRef.current.has(h.layerId) ? shardSourceId(h.layerId, Math.floor(h.position / shardSizeRef.current)) : SHARED_SOURCE_ID));
|
|
13862
14299
|
}
|
|
13863
14300
|
const feature = getFeatureById(id);
|
|
13864
14301
|
if (!feature) return [];
|
|
13865
14302
|
const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
|
|
13866
|
-
return layer && !layer.visible ? [] : [
|
|
14303
|
+
return layer && !layer.visible ? [] : [styled(feature, layer, ctx, SHARED_SOURCE_ID)];
|
|
13867
14304
|
});
|
|
13868
14305
|
overlay.setData(data);
|
|
13869
14306
|
overlayFeatureCountRef.current = data.features.length;
|
|
@@ -13919,35 +14356,42 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
13919
14356
|
const m = map.current;
|
|
13920
14357
|
if (!m) return true;
|
|
13921
14358
|
if (hasArrowFeaturesRef.current) return false;
|
|
13922
|
-
const
|
|
13923
|
-
const
|
|
13924
|
-
const nextVisible = timelineVisibleIdsRef.current;
|
|
14359
|
+
const start = performance.now();
|
|
14360
|
+
const next = timelineWindowRef.current;
|
|
13925
14361
|
const trace = tracePaintCacheRef.current;
|
|
13926
|
-
|
|
13927
|
-
if (trace
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
}
|
|
14362
|
+
let endpointsMoved = 0;
|
|
14363
|
+
if (trace) {
|
|
14364
|
+
const traceSource = m.getSource(TRACE_SOURCE_ID);
|
|
14365
|
+
if (!traceSource) return false;
|
|
14366
|
+
const traceDiff = buildTraceTimelineDiff(trace, next);
|
|
14367
|
+
if (!applyTraceTimelineDiff(traceDiff, traceSource, featureStateHostFor(m), traceEndpointsRef.current)) return false;
|
|
14368
|
+
trace.window = next;
|
|
14369
|
+
endpointsMoved = traceDiff.endpointOn.length;
|
|
14370
|
+
}
|
|
14371
|
+
const flipped = applyTimelineWindow(featureStateHostFor(m), appliedTimelineRef.current, next, isTimelineSourceActive);
|
|
13935
14372
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
13936
|
-
|
|
13937
|
-
|
|
14373
|
+
const count = countVisibleFeatures(threshold);
|
|
14374
|
+
if (tickCountTimerRef.current) clearTimeout(tickCountTimerRef.current);
|
|
14375
|
+
tickCountTimerRef.current = null;
|
|
14376
|
+
if (count < threshold !== visibleFeatureCountRef.current < threshold) setVisibleFeatureCount(count);
|
|
14377
|
+
else if (count !== visibleFeatureCountRef.current) {
|
|
14378
|
+
tickCountTimerRef.current = setTimeout(() => setVisibleFeatureCount(countVisibleFeatures(threshold)), TICK_COUNT_SETTLE_MS);
|
|
14379
|
+
}
|
|
14380
|
+
if (labelsSuppressedRef.current) setLabelsSuppressed(false);
|
|
13938
14381
|
const selection = currentSelection() ?? EMPTY_ID_SET;
|
|
13939
|
-
if (
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
|
|
13944
|
-
|
|
13945
|
-
segmentsAdded: (traceDiff == null ? void 0 : traceDiff.segmentAdd.length) ?? 0,
|
|
13946
|
-
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
14382
|
+
if (selection.size > 0 && flipped.some((id) => selection.has(id))) refreshSelectionOverlay(m, selection);
|
|
14383
|
+
mapPerfLog("timeline", "applied", {
|
|
14384
|
+
flipped: flipped.length,
|
|
14385
|
+
sources: appliedTimelineRef.current.size,
|
|
14386
|
+
endpointsMoved,
|
|
14387
|
+
ms: Math.round(performance.now() - start)
|
|
13947
14388
|
});
|
|
13948
14389
|
return true;
|
|
13949
|
-
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
|
|
14390
|
+
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay, isTimelineSourceActive]);
|
|
13950
14391
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
14392
|
+
useEffect(() => () => {
|
|
14393
|
+
if (tickCountTimerRef.current) clearTimeout(tickCountTimerRef.current);
|
|
14394
|
+
}, []);
|
|
13951
14395
|
const collectSelectionFeatureGroups = useCallback(() => {
|
|
13952
14396
|
return collectVisibleFeatureGroups(
|
|
13953
14397
|
draw.current ? draw.current.getAll().features : null,
|
|
@@ -15465,25 +15909,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15465
15909
|
const handleDropGeoJSONFile = useCallback((name, file) => {
|
|
15466
15910
|
void ingestDroppedLayer(name, file);
|
|
15467
15911
|
}, [ingestDroppedLayer]);
|
|
15468
|
-
const
|
|
15469
|
-
if (!draw.current || !map.current) return;
|
|
15470
|
-
const nextVisible = new Set(visibleIds);
|
|
15471
|
-
untimedIds.forEach((id) => nextVisible.add(id));
|
|
15472
|
-
timelineVisibleIdsRef.current = nextVisible;
|
|
15473
|
-
scheduleSync("timeline");
|
|
15474
|
-
}, [scheduleSync]);
|
|
15475
|
-
const prevTimelineEnabledRef = useRef(timelineStore.isEnabled);
|
|
15912
|
+
const prevTimelineEnabledRef = useRef(timelineEnabled);
|
|
15476
15913
|
useEffect(() => {
|
|
15477
15914
|
const wasEnabled = prevTimelineEnabledRef.current;
|
|
15478
|
-
|
|
15479
|
-
|
|
15480
|
-
|
|
15481
|
-
timelineVisibleIdsRef.current = null;
|
|
15482
|
-
scheduleSync("timeline");
|
|
15483
|
-
} else if (!wasEnabled && isNowEnabled) {
|
|
15484
|
-
updateTimelineStore();
|
|
15485
|
-
}
|
|
15486
|
-
}, [timelineStore.isEnabled, timelineStore.hasTemporalData, scheduleSync, updateTimelineStore, scheduleTimelineUpdate]);
|
|
15915
|
+
prevTimelineEnabledRef.current = timelineEnabled;
|
|
15916
|
+
if (!wasEnabled && timelineEnabled && timelineHasData) updateTimelineStore();
|
|
15917
|
+
}, [timelineEnabled, timelineHasData, updateTimelineStore]);
|
|
15487
15918
|
useEffect(() => {
|
|
15488
15919
|
if (!map.current || !draw.current || !isMapLoaded) return;
|
|
15489
15920
|
const mapInstance = map.current;
|
|
@@ -15707,14 +16138,14 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
15707
16138
|
let categoryColorMap = {};
|
|
15708
16139
|
let hasOtherBucket = false;
|
|
15709
16140
|
if (groupByField) {
|
|
15710
|
-
const
|
|
16141
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
15711
16142
|
pointFeatures.forEach((f) => {
|
|
15712
16143
|
var _a2;
|
|
15713
16144
|
const key = categoricalKey((_a2 = f.properties) == null ? void 0 : _a2[groupByField]);
|
|
15714
16145
|
if (key === null) return;
|
|
15715
|
-
|
|
16146
|
+
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
15716
16147
|
});
|
|
15717
|
-
const sorted = Array.from(
|
|
16148
|
+
const sorted = Array.from(counts2.entries()).sort((a, b) => b[1] - a[1]);
|
|
15718
16149
|
const topKeys = sorted.slice(0, MAX_CATEGORIES).map(([k]) => k);
|
|
15719
16150
|
categoryValues = [...topKeys];
|
|
15720
16151
|
hasOtherBucket = true;
|
|
@@ -16235,21 +16666,21 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16235
16666
|
] })
|
|
16236
16667
|
}
|
|
16237
16668
|
),
|
|
16238
|
-
enableTimeline &&
|
|
16669
|
+
enableTimeline && timelineHasData && /* @__PURE__ */ jsx(
|
|
16239
16670
|
"div",
|
|
16240
16671
|
{
|
|
16241
16672
|
className: "absolute left-4 z-[200] transition-all",
|
|
16242
|
-
style: { bottom:
|
|
16673
|
+
style: { bottom: timelineEnabled ? TIMEBAR_HEIGHT + TIMEBAR_BOTTOM_OFFSET + 8 : 48 },
|
|
16243
16674
|
children: /* @__PURE__ */ jsx(Tooltip, { title: "Timeline", placement: "right", children: /* @__PURE__ */ jsx(
|
|
16244
16675
|
Button,
|
|
16245
16676
|
{
|
|
16246
16677
|
type: "default",
|
|
16247
16678
|
icon: /* @__PURE__ */ jsx(Clock, { className: "w-5 h-5" }),
|
|
16248
|
-
onClick: () =>
|
|
16679
|
+
onClick: () => timelineStoreApi.getState().setEnabled(!timelineEnabled),
|
|
16249
16680
|
disabled: !isMapLoaded,
|
|
16250
|
-
className: `!w-10 !h-10 !min-w-0 !p-0 bg-background shadow-lg ${
|
|
16681
|
+
className: `!w-10 !h-10 !min-w-0 !p-0 bg-background shadow-lg ${timelineEnabled ? "bg-primary/10" : ""}`,
|
|
16251
16682
|
"aria-label": "Toggle timeline",
|
|
16252
|
-
"aria-pressed":
|
|
16683
|
+
"aria-pressed": timelineEnabled,
|
|
16253
16684
|
"data-testid": "button-toggle-timeline"
|
|
16254
16685
|
}
|
|
16255
16686
|
) })
|
|
@@ -16308,6 +16739,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16308
16739
|
onMapStyleChange: handleMapStyleChange,
|
|
16309
16740
|
onUpdateTraceConfig: handleUpdateTraceConfig,
|
|
16310
16741
|
getAvailableTraceFields,
|
|
16742
|
+
getSuggestedTraceField,
|
|
16311
16743
|
getFieldValueDistribution,
|
|
16312
16744
|
onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
|
|
16313
16745
|
onUpdateClusterConfig: handleUpdateClusterConfig,
|
|
@@ -16387,12 +16819,12 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16387
16819
|
selectionMode
|
|
16388
16820
|
}
|
|
16389
16821
|
),
|
|
16390
|
-
enableTimeline &&
|
|
16822
|
+
enableTimeline && timelineEnabled && /* @__PURE__ */ jsx(
|
|
16391
16823
|
Timebar,
|
|
16392
16824
|
{
|
|
16393
|
-
onFilterChange: handleTimelineFilterChange,
|
|
16394
16825
|
selectedFeatureIds,
|
|
16395
16826
|
selectedFeatureColors,
|
|
16827
|
+
selectionDisplay: "line",
|
|
16396
16828
|
timebarExtra
|
|
16397
16829
|
}
|
|
16398
16830
|
),
|
|
@@ -16425,7 +16857,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
|
|
|
16425
16857
|
IngestProgressOverlay,
|
|
16426
16858
|
{
|
|
16427
16859
|
store: ingestProgressStore,
|
|
16428
|
-
bottomPx:
|
|
16860
|
+
bottomPx: timelineEnabled ? TIMEBAR_HEIGHT + TIMEBAR_BOTTOM_OFFSET + 8 : 32
|
|
16429
16861
|
}
|
|
16430
16862
|
),
|
|
16431
16863
|
/* @__PURE__ */ jsx(
|