@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.cjs
CHANGED
|
@@ -772,6 +772,10 @@ const SELECTED_STATE_KEY = "selected";
|
|
|
772
772
|
const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
|
|
773
773
|
const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
|
|
774
774
|
const SELECTION_COLOR = "#06b6d4";
|
|
775
|
+
const TIMELINE_HIDDEN_KEY = "timelineHidden";
|
|
776
|
+
const TIMELINE_HIDDEN = ["boolean", ["feature-state", TIMELINE_HIDDEN_KEY], false];
|
|
777
|
+
const TRACE_ENDPOINT_KEY = "traceEndpoint";
|
|
778
|
+
const TRACE_ENDPOINT = ["boolean", ["feature-state", TRACE_ENDPOINT_KEY], false];
|
|
775
779
|
const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
|
|
776
780
|
const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
777
781
|
const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
|
|
@@ -780,8 +784,8 @@ function computeLabelNeverHide(label) {
|
|
|
780
784
|
}
|
|
781
785
|
function buildCustomLabelLayout() {
|
|
782
786
|
return {
|
|
783
|
-
// Hide labels for trace points (
|
|
784
|
-
// arrows handled by the custom-arrow-labels layer.
|
|
787
|
+
// Hide labels for trace points (a group's endpoint label is the trace
|
|
788
|
+
// source's, trace-timeline.ts), arrows handled by the custom-arrow-labels layer.Features blanked by
|
|
785
789
|
// heatmap/cluster modes stay blank in BOTH layers: "never hide"
|
|
786
790
|
// exempts labels from collision and density culling, it does not resurrect
|
|
787
791
|
// labels other mode choices explicitly blank.
|
|
@@ -793,33 +797,28 @@ function buildCustomLabelLayout() {
|
|
|
793
797
|
"",
|
|
794
798
|
["==", ["get", "kind"], "arrow"],
|
|
795
799
|
"",
|
|
796
|
-
|
|
797
|
-
["all", ["==", ["get", "isTracePoint"], true], ["!=", ["get", "isTraceLabel"], true]],
|
|
800
|
+
["==", ["get", "isTracePoint"], true],
|
|
798
801
|
"",
|
|
799
802
|
["==", ["get", "kind"], "text"],
|
|
800
803
|
["coalesce", ["get", "label"], ["get", "text"], "New Label"],
|
|
801
804
|
["coalesce", ["get", "name"], ""]
|
|
802
805
|
],
|
|
803
|
-
// Text features use their fontSize property;
|
|
806
|
+
// Text features use their fontSize property; others 12px
|
|
804
807
|
"text-size": [
|
|
805
808
|
"case",
|
|
806
809
|
["==", ["get", "kind"], "text"],
|
|
807
810
|
["coalesce", ["get", "fontSize"], 14],
|
|
808
|
-
["==", ["get", "isTraceLabel"], true],
|
|
809
|
-
14,
|
|
810
811
|
12
|
|
811
812
|
],
|
|
812
813
|
// Text features: center anchor; others: top anchor
|
|
813
814
|
"text-anchor": ["case", ["==", ["get", "kind"], "text"], "center", "top"],
|
|
814
815
|
"text-offset": ["case", ["==", ["get", "kind"], "text"], ["literal", [0, 0]], ["literal", [0, 0.8]]],
|
|
815
816
|
"text-padding": 2,
|
|
816
|
-
// Bold font for text features with fontWeight=bold,
|
|
817
|
+
// Bold font for text features with fontWeight=bold, others regular
|
|
817
818
|
"text-font": [
|
|
818
819
|
"case",
|
|
819
820
|
["all", ["==", ["get", "kind"], "text"], ["==", ["get", "fontWeight"], "bold"]],
|
|
820
821
|
["literal", ["Montserrat SemiBold", "Noto Sans Regular"]],
|
|
821
|
-
["==", ["get", "isTraceLabel"], true],
|
|
822
|
-
["literal", ["Montserrat Medium", "Noto Sans Regular"]],
|
|
823
822
|
["literal", ["Montserrat Regular", "Noto Sans Regular"]]
|
|
824
823
|
]
|
|
825
824
|
};
|
|
@@ -835,16 +834,14 @@ function buildCustomLabelPaint(opts) {
|
|
|
835
834
|
"#1f2937"
|
|
836
835
|
],
|
|
837
836
|
"text-halo-color": "#ffffff",
|
|
838
|
-
// Thicker halo for
|
|
837
|
+
// Thicker halo for text features
|
|
839
838
|
"text-halo-width": [
|
|
840
839
|
"case",
|
|
841
840
|
["==", ["get", "kind"], "text"],
|
|
842
841
|
2,
|
|
843
|
-
["==", ["get", "isTraceLabel"], true],
|
|
844
|
-
2,
|
|
845
842
|
1.5
|
|
846
843
|
],
|
|
847
|
-
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
844
|
+
"text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", TIMELINE_HIDDEN, 0, SELECTED, 0, visibleOpacity] : visibleOpacity
|
|
848
845
|
};
|
|
849
846
|
}
|
|
850
847
|
const CUSTOM_LAYER_ROLES = [
|
|
@@ -914,6 +911,10 @@ function shardInsertAnchor(role) {
|
|
|
914
911
|
return "custom-arrow-heads";
|
|
915
912
|
}
|
|
916
913
|
}
|
|
914
|
+
const POINT_RADIUS = ["case", TRACE_ENDPOINT, ["get", "_endpointRadius"], ["coalesce", ["get", "pointRadius"], 5]];
|
|
915
|
+
function unlessTimelineHidden(value) {
|
|
916
|
+
return ["case", TIMELINE_HIDDEN, 0, value];
|
|
917
|
+
}
|
|
917
918
|
function buildLayer(role, sourceId, opts) {
|
|
918
919
|
const id = customLayerId(role, sourceId);
|
|
919
920
|
switch (role) {
|
|
@@ -926,7 +927,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
926
927
|
filter: ["==", "$type", "Polygon"],
|
|
927
928
|
paint: {
|
|
928
929
|
"fill-color": ["get", "fill"],
|
|
929
|
-
"fill-opacity": ["get", "fill-opacity"]
|
|
930
|
+
"fill-opacity": unlessTimelineHidden(["get", "fill-opacity"])
|
|
930
931
|
}
|
|
931
932
|
};
|
|
932
933
|
case "polygon-stroke":
|
|
@@ -938,7 +939,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
938
939
|
paint: {
|
|
939
940
|
"line-color": ["get", "stroke"],
|
|
940
941
|
"line-width": ["get", "stroke-width"],
|
|
941
|
-
"line-opacity": ["get", "stroke-opacity"]
|
|
942
|
+
"line-opacity": unlessTimelineHidden(["get", "stroke-opacity"])
|
|
942
943
|
}
|
|
943
944
|
};
|
|
944
945
|
// Custom line layer - preserves original styling
|
|
@@ -951,7 +952,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
951
952
|
paint: {
|
|
952
953
|
"line-color": ["get", "stroke"],
|
|
953
954
|
"line-width": ["get", "stroke-width"],
|
|
954
|
-
"line-opacity": ["get", "stroke-opacity"]
|
|
955
|
+
"line-opacity": unlessTimelineHidden(["get", "stroke-opacity"])
|
|
955
956
|
}
|
|
956
957
|
};
|
|
957
958
|
// Shadow layer rendered beneath points for depth (hidden when emoji icon is set)
|
|
@@ -965,7 +966,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
965
966
|
"circle-color": "rgba(0, 0, 0, 0.2)",
|
|
966
967
|
"circle-radius": [
|
|
967
968
|
"case",
|
|
968
|
-
|
|
969
|
+
TIMELINE_HIDDEN,
|
|
969
970
|
0,
|
|
970
971
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
971
972
|
0,
|
|
@@ -973,7 +974,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
973
974
|
0,
|
|
974
975
|
["!=", ["get", "icon"], ""],
|
|
975
976
|
0,
|
|
976
|
-
["+",
|
|
977
|
+
["+", POINT_RADIUS, 1.5]
|
|
977
978
|
],
|
|
978
979
|
"circle-blur": 0.5,
|
|
979
980
|
"circle-opacity": [
|
|
@@ -1001,7 +1002,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1001
1002
|
"circle-color": ["coalesce", ["get", "stroke"], "#3b82f6"],
|
|
1002
1003
|
"circle-radius": [
|
|
1003
1004
|
"case",
|
|
1004
|
-
|
|
1005
|
+
TIMELINE_HIDDEN,
|
|
1005
1006
|
0,
|
|
1006
1007
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
1007
1008
|
0,
|
|
@@ -1009,7 +1010,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1009
1010
|
0,
|
|
1010
1011
|
["!=", ["get", "icon"], ""],
|
|
1011
1012
|
0,
|
|
1012
|
-
|
|
1013
|
+
POINT_RADIUS
|
|
1013
1014
|
],
|
|
1014
1015
|
"circle-opacity": [
|
|
1015
1016
|
"case",
|
|
@@ -1024,7 +1025,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1024
1025
|
"circle-stroke-color": ["case", SELECTED, SELECTION_COLOR, "#555555"],
|
|
1025
1026
|
"circle-stroke-width": [
|
|
1026
1027
|
"case",
|
|
1027
|
-
|
|
1028
|
+
TIMELINE_HIDDEN,
|
|
1028
1029
|
0,
|
|
1029
1030
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
1030
1031
|
0,
|
|
@@ -1064,6 +1065,8 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1064
1065
|
paint: {
|
|
1065
1066
|
"icon-opacity": [
|
|
1066
1067
|
"case",
|
|
1068
|
+
TIMELINE_HIDDEN,
|
|
1069
|
+
0,
|
|
1067
1070
|
["==", ["get", "isHiddenByCluster"], 1],
|
|
1068
1071
|
0,
|
|
1069
1072
|
["==", ["get", "isHiddenByHeatmap"], 1],
|
|
@@ -1073,7 +1076,7 @@ function buildLayer(role, sourceId, opts) {
|
|
|
1073
1076
|
}
|
|
1074
1077
|
};
|
|
1075
1078
|
// Label layer for all features - shows 'name' property, or 'text' for text features
|
|
1076
|
-
// Trace
|
|
1079
|
+
// Trace points have no label here: a group's label is the trace source's
|
|
1077
1080
|
// Arrow labels are handled separately by the custom-arrow-labels layer.
|
|
1078
1081
|
// Shared layout/paint live in label-pinning.ts so this layer and its
|
|
1079
1082
|
// pinned twin below cannot drift.
|
|
@@ -1211,77 +1214,6 @@ function shardFingerprintsEqual(a, b) {
|
|
|
1211
1214
|
if (!a || !b) return false;
|
|
1212
1215
|
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);
|
|
1213
1216
|
}
|
|
1214
|
-
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1215
|
-
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1216
|
-
function createSelectionPaintCache() {
|
|
1217
|
-
return {
|
|
1218
|
-
presentIds: /* @__PURE__ */ new Set(),
|
|
1219
|
-
appliedHiddenIds: /* @__PURE__ */ new Set(),
|
|
1220
|
-
visibleStrokeOpacityById: /* @__PURE__ */ new Map(),
|
|
1221
|
-
visibleFillOpacityById: /* @__PURE__ */ new Map(),
|
|
1222
|
-
updatable: true
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
function recordPaintedFeature(cache2, featureId, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
|
|
1226
|
-
if (cache2.presentIds.has(featureId)) {
|
|
1227
|
-
cache2.updatable = false;
|
|
1228
|
-
} else {
|
|
1229
|
-
cache2.presentIds.add(featureId);
|
|
1230
|
-
}
|
|
1231
|
-
if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
|
|
1232
|
-
cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
|
|
1233
|
-
}
|
|
1234
|
-
if (visibleFillOpacity !== DEFAULT_VISIBLE_FILL_OPACITY) {
|
|
1235
|
-
cache2.visibleFillOpacityById.set(featureId, visibleFillOpacity);
|
|
1236
|
-
}
|
|
1237
|
-
if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
|
|
1238
|
-
}
|
|
1239
|
-
function needsDrawSelectionUpdate(input) {
|
|
1240
|
-
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
1241
|
-
}
|
|
1242
|
-
function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
|
|
1243
|
-
const update = [];
|
|
1244
|
-
const nextHiddenIds = /* @__PURE__ */ new Set();
|
|
1245
|
-
cache2.presentIds.forEach((id) => {
|
|
1246
|
-
const nextHidden = nextVisibleSet !== null && !nextVisibleSet.has(id);
|
|
1247
|
-
if (nextHidden) nextHiddenIds.add(id);
|
|
1248
|
-
if (nextHidden === cache2.appliedHiddenIds.has(id)) return;
|
|
1249
|
-
if (nextHidden) {
|
|
1250
|
-
update.push({
|
|
1251
|
-
id,
|
|
1252
|
-
addOrUpdateProperties: [
|
|
1253
|
-
{ key: "stroke-opacity", value: 0 },
|
|
1254
|
-
{ key: "fill-opacity", value: 0 },
|
|
1255
|
-
{ key: "isTimelineHidden", value: 1 }
|
|
1256
|
-
]
|
|
1257
|
-
});
|
|
1258
|
-
} else {
|
|
1259
|
-
update.push({
|
|
1260
|
-
id,
|
|
1261
|
-
addOrUpdateProperties: [
|
|
1262
|
-
{ key: "stroke-opacity", value: cache2.visibleStrokeOpacityById.get(id) ?? DEFAULT_VISIBLE_STROKE_OPACITY },
|
|
1263
|
-
{ key: "fill-opacity", value: cache2.visibleFillOpacityById.get(id) ?? DEFAULT_VISIBLE_FILL_OPACITY },
|
|
1264
|
-
{ key: "isTimelineHidden", value: 0 }
|
|
1265
|
-
]
|
|
1266
|
-
});
|
|
1267
|
-
}
|
|
1268
|
-
});
|
|
1269
|
-
return { diff: update.length > 0 ? { update } : null, nextHiddenIds };
|
|
1270
|
-
}
|
|
1271
|
-
function applyTimelineFastPath(cache2, nextVisibleSet, source) {
|
|
1272
|
-
var _a;
|
|
1273
|
-
if (!cache2 || !cache2.updatable || !source) return { applied: false, toggled: 0 };
|
|
1274
|
-
const { diff, nextHiddenIds } = buildTimelineVisibilityDiff(cache2, nextVisibleSet);
|
|
1275
|
-
if (diff) {
|
|
1276
|
-
try {
|
|
1277
|
-
source.updateData(diff);
|
|
1278
|
-
} catch {
|
|
1279
|
-
return { applied: false, toggled: 0 };
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
cache2.appliedHiddenIds = nextHiddenIds;
|
|
1283
|
-
return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
|
|
1284
|
-
}
|
|
1285
1217
|
const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
|
|
1286
1218
|
function createShardRegistry(host, hooks) {
|
|
1287
1219
|
const states = /* @__PURE__ */ new Map();
|
|
@@ -1289,7 +1221,7 @@ function createShardRegistry(host, hooks) {
|
|
|
1289
1221
|
const ensure = (layerId) => {
|
|
1290
1222
|
let state = states.get(layerId);
|
|
1291
1223
|
if (!state) {
|
|
1292
|
-
state = { layerId, stacks: [],
|
|
1224
|
+
state = { layerId, stacks: [], fingerprint: null, inFlightFingerprint: null, generation: 0, visible: true, arrowLines: [] };
|
|
1293
1225
|
states.set(layerId, state);
|
|
1294
1226
|
}
|
|
1295
1227
|
return state;
|
|
@@ -1336,7 +1268,6 @@ function createShardRegistry(host, hooks) {
|
|
|
1336
1268
|
removeStack(state.stacks[i]);
|
|
1337
1269
|
}
|
|
1338
1270
|
state.stacks.length = Math.min(state.stacks.length, index);
|
|
1339
|
-
state.caches.length = state.stacks.length;
|
|
1340
1271
|
};
|
|
1341
1272
|
return {
|
|
1342
1273
|
registerShared(layerIds) {
|
|
@@ -1431,50 +1362,9 @@ function createShardRegistry(host, hooks) {
|
|
|
1431
1362
|
});
|
|
1432
1363
|
});
|
|
1433
1364
|
return ids;
|
|
1434
|
-
},
|
|
1435
|
-
sourceFor(layerId, index) {
|
|
1436
|
-
var _a;
|
|
1437
|
-
const stack = (_a = states.get(layerId)) == null ? void 0 : _a.stacks[index];
|
|
1438
|
-
return stack ? host.getSource(stack.sourceId) : void 0;
|
|
1439
|
-
},
|
|
1440
|
-
sourceById(sourceId) {
|
|
1441
|
-
return host.getSource(sourceId);
|
|
1442
|
-
},
|
|
1443
|
-
everyPaintedShard(visit) {
|
|
1444
|
-
let ok = true;
|
|
1445
|
-
states.forEach((state) => {
|
|
1446
|
-
if (!ok) return;
|
|
1447
|
-
state.stacks.forEach((stack, i) => {
|
|
1448
|
-
if (!ok) return;
|
|
1449
|
-
const cache2 = state.caches[i];
|
|
1450
|
-
if (!cache2) return;
|
|
1451
|
-
if (!visit(cache2, stack.sourceId)) ok = false;
|
|
1452
|
-
});
|
|
1453
|
-
});
|
|
1454
|
-
return ok;
|
|
1455
1365
|
}
|
|
1456
1366
|
};
|
|
1457
1367
|
}
|
|
1458
|
-
function reconcileShardCaches(registry, layerId, expectedShards, visibleIds) {
|
|
1459
|
-
const state = registry.state(layerId);
|
|
1460
|
-
if (!state || state.stacks.length !== expectedShards) return false;
|
|
1461
|
-
for (let i = 0; i < expectedShards; i++) {
|
|
1462
|
-
const cache2 = state.caches[i];
|
|
1463
|
-
if (!cache2) return false;
|
|
1464
|
-
const source = registry.sourceFor(layerId, i);
|
|
1465
|
-
if (!source) return false;
|
|
1466
|
-
if (!applyTimelineFastPath(cache2, visibleIds, source).applied) return false;
|
|
1467
|
-
}
|
|
1468
|
-
return true;
|
|
1469
|
-
}
|
|
1470
|
-
function forEachShardCache(registry, apply) {
|
|
1471
|
-
if (!registry) return true;
|
|
1472
|
-
return registry.everyPaintedShard((cache2, sourceId) => {
|
|
1473
|
-
const source = registry.sourceById(sourceId);
|
|
1474
|
-
if (!source) return false;
|
|
1475
|
-
return apply(cache2, source);
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
1368
|
function categoricalKey(raw) {
|
|
1479
1369
|
if (raw == null) return null;
|
|
1480
1370
|
if (typeof raw === "string") return raw === "" ? null : raw;
|
|
@@ -1593,6 +1483,158 @@ function formatGradientStop(value) {
|
|
|
1593
1483
|
}
|
|
1594
1484
|
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);
|
|
1595
1485
|
}
|
|
1486
|
+
function windowFromRange(start, end) {
|
|
1487
|
+
if (!start || !end) return null;
|
|
1488
|
+
const t0 = start.getTime();
|
|
1489
|
+
const t1 = end.getTime();
|
|
1490
|
+
return Number.isFinite(t0) && Number.isFinite(t1) ? { t0, t1 } : null;
|
|
1491
|
+
}
|
|
1492
|
+
function sameWindow(a, b) {
|
|
1493
|
+
if (a === null || b === null) return a === b;
|
|
1494
|
+
return a.t0 === b.t0 && a.t1 === b.t1;
|
|
1495
|
+
}
|
|
1496
|
+
function isIntervalVisible(s, e, w) {
|
|
1497
|
+
if (w === null) return true;
|
|
1498
|
+
const noStart = Number.isNaN(s);
|
|
1499
|
+
const noEnd = Number.isNaN(e);
|
|
1500
|
+
if (noStart && noEnd) return true;
|
|
1501
|
+
return (noStart ? e : s) <= w.t1 && (noEnd ? s : e) >= w.t0;
|
|
1502
|
+
}
|
|
1503
|
+
const interval = { s: NaN, e: NaN };
|
|
1504
|
+
function readInterval(f) {
|
|
1505
|
+
interval.s = NaN;
|
|
1506
|
+
interval.e = NaN;
|
|
1507
|
+
const props = f.properties;
|
|
1508
|
+
if (!props || !hasAnyTemporalValue(props)) return;
|
|
1509
|
+
const { startDate, endDate } = normalizeTemporalProperties(props);
|
|
1510
|
+
const s = startDate ? startDate.getTime() : NaN;
|
|
1511
|
+
const e = endDate ? endDate.getTime() : NaN;
|
|
1512
|
+
interval.s = Number.isNaN(s) ? e : s;
|
|
1513
|
+
interval.e = Number.isNaN(e) ? s : e;
|
|
1514
|
+
}
|
|
1515
|
+
function featureInterval(f) {
|
|
1516
|
+
readInterval(f);
|
|
1517
|
+
return { s: interval.s, e: interval.e };
|
|
1518
|
+
}
|
|
1519
|
+
function isFeatureVisible(f, w) {
|
|
1520
|
+
if (w === null) return true;
|
|
1521
|
+
readInterval(f);
|
|
1522
|
+
return isIntervalVisible(interval.s, interval.e, w);
|
|
1523
|
+
}
|
|
1524
|
+
function collectRepeats(features) {
|
|
1525
|
+
const first = /* @__PURE__ */ new Map();
|
|
1526
|
+
const repeats = /* @__PURE__ */ new Map();
|
|
1527
|
+
for (let i = 0; i < features.length; i++) {
|
|
1528
|
+
const id = features[i].id;
|
|
1529
|
+
if (id === void 0 || id === null) continue;
|
|
1530
|
+
const key = String(id);
|
|
1531
|
+
const at = first.get(key);
|
|
1532
|
+
if (at === void 0) first.set(key, i);
|
|
1533
|
+
else {
|
|
1534
|
+
const more = repeats.get(key);
|
|
1535
|
+
if (more) more.push(i);
|
|
1536
|
+
else repeats.set(key, [at, i]);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
return repeats;
|
|
1540
|
+
}
|
|
1541
|
+
function buildIndex(features) {
|
|
1542
|
+
const size = features.length;
|
|
1543
|
+
const starts = new Float64Array(size);
|
|
1544
|
+
const ends = new Float64Array(size);
|
|
1545
|
+
let timed = 0;
|
|
1546
|
+
for (let i = 0; i < size; i++) {
|
|
1547
|
+
readInterval(features[i]);
|
|
1548
|
+
starts[i] = interval.s;
|
|
1549
|
+
ends[i] = interval.e;
|
|
1550
|
+
if (!Number.isNaN(interval.s)) timed++;
|
|
1551
|
+
}
|
|
1552
|
+
const byStart = new Uint32Array(timed);
|
|
1553
|
+
for (let i = 0, k = 0; i < size; i++) {
|
|
1554
|
+
if (!Number.isNaN(starts[i])) byStart[k++] = i;
|
|
1555
|
+
}
|
|
1556
|
+
const byEnd = byStart.slice();
|
|
1557
|
+
byStart.sort((a, b) => starts[a] - starts[b]);
|
|
1558
|
+
byEnd.sort((a, b) => ends[a] - ends[b]);
|
|
1559
|
+
return {
|
|
1560
|
+
size,
|
|
1561
|
+
starts,
|
|
1562
|
+
ends,
|
|
1563
|
+
byStart,
|
|
1564
|
+
sortedStarts: Float64Array.from(byStart, (p) => starts[p]),
|
|
1565
|
+
byEnd,
|
|
1566
|
+
sortedEnds: Float64Array.from(byEnd, (p) => ends[p]),
|
|
1567
|
+
untimedCount: size - timed,
|
|
1568
|
+
repeats: collectRepeats(features),
|
|
1569
|
+
mark: new Uint8Array(size)
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
const cache$1 = /* @__PURE__ */ new WeakMap();
|
|
1573
|
+
function getTimelineIndex(features) {
|
|
1574
|
+
let index = cache$1.get(features);
|
|
1575
|
+
if (!index) {
|
|
1576
|
+
const started = performance.now();
|
|
1577
|
+
index = buildIndex(features);
|
|
1578
|
+
cache$1.set(features, index);
|
|
1579
|
+
mapPerfLog("timeline", "index built", { n: features.length, ms: Math.round(performance.now() - started) });
|
|
1580
|
+
}
|
|
1581
|
+
return index;
|
|
1582
|
+
}
|
|
1583
|
+
function isVisibleAt(index, position, w) {
|
|
1584
|
+
return isIntervalVisible(index.starts[position], index.ends[position], w);
|
|
1585
|
+
}
|
|
1586
|
+
function upperBound(keys, x) {
|
|
1587
|
+
let lo = 0;
|
|
1588
|
+
let hi = keys.length;
|
|
1589
|
+
while (lo < hi) {
|
|
1590
|
+
const mid = lo + hi >>> 1;
|
|
1591
|
+
if (keys[mid] <= x) lo = mid + 1;
|
|
1592
|
+
else hi = mid;
|
|
1593
|
+
}
|
|
1594
|
+
return lo;
|
|
1595
|
+
}
|
|
1596
|
+
function lowerBound(keys, x) {
|
|
1597
|
+
let lo = 0;
|
|
1598
|
+
let hi = keys.length;
|
|
1599
|
+
while (lo < hi) {
|
|
1600
|
+
const mid = lo + hi >>> 1;
|
|
1601
|
+
if (keys[mid] < x) lo = mid + 1;
|
|
1602
|
+
else hi = mid;
|
|
1603
|
+
}
|
|
1604
|
+
return lo;
|
|
1605
|
+
}
|
|
1606
|
+
const ALL = { t0: -Infinity, t1: Infinity };
|
|
1607
|
+
function flippedPositions(index, from, to, out) {
|
|
1608
|
+
const a = from ?? ALL;
|
|
1609
|
+
const b = to ?? ALL;
|
|
1610
|
+
const { starts, ends, byStart, byEnd, mark } = index;
|
|
1611
|
+
const flips = (p) => isIntervalVisible(starts[p], ends[p], a) !== isIntervalVisible(starts[p], ends[p], b);
|
|
1612
|
+
const s0 = upperBound(index.sortedStarts, Math.min(a.t1, b.t1));
|
|
1613
|
+
const s1 = upperBound(index.sortedStarts, Math.max(a.t1, b.t1));
|
|
1614
|
+
const e0 = lowerBound(index.sortedEnds, Math.min(a.t0, b.t0));
|
|
1615
|
+
const e1 = lowerBound(index.sortedEnds, Math.max(a.t0, b.t0));
|
|
1616
|
+
for (let k = s0; k < s1; k++) {
|
|
1617
|
+
const p = byStart[k];
|
|
1618
|
+
mark[p] = 1;
|
|
1619
|
+
if (flips(p)) out.push(p);
|
|
1620
|
+
}
|
|
1621
|
+
for (let k = e0; k < e1; k++) {
|
|
1622
|
+
const p = byEnd[k];
|
|
1623
|
+
if (mark[p] === 0 && flips(p)) out.push(p);
|
|
1624
|
+
}
|
|
1625
|
+
for (let k = s0; k < s1; k++) mark[byStart[k]] = 0;
|
|
1626
|
+
}
|
|
1627
|
+
function countVisible(index, w) {
|
|
1628
|
+
if (w === null) return index.size;
|
|
1629
|
+
if (w.t0 > w.t1) {
|
|
1630
|
+
let timed = 0;
|
|
1631
|
+
index.byStart.forEach((p) => {
|
|
1632
|
+
if (isVisibleAt(index, p, w)) timed++;
|
|
1633
|
+
});
|
|
1634
|
+
return timed + index.untimedCount;
|
|
1635
|
+
}
|
|
1636
|
+
return upperBound(index.sortedStarts, w.t1) - lowerBound(index.sortedEnds, w.t0) + index.untimedCount;
|
|
1637
|
+
}
|
|
1596
1638
|
const TRACE_DEFAULT_COLOR = "#3b82f6";
|
|
1597
1639
|
const TRACE_UNGROUPED_KEY = "__all__";
|
|
1598
1640
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -1624,16 +1666,17 @@ function compareStaged(a, b) {
|
|
|
1624
1666
|
function buildTraceGroups(features, field) {
|
|
1625
1667
|
var _a;
|
|
1626
1668
|
const staged = /* @__PURE__ */ new Map();
|
|
1627
|
-
for (
|
|
1669
|
+
for (let position = 0; position < features.length; position++) {
|
|
1670
|
+
const feature = features[position];
|
|
1628
1671
|
if (feature.id == null || feature.geometry.type !== "Point" || !((_a = feature.properties) == null ? void 0 : _a.startDate)) continue;
|
|
1629
1672
|
const raw = field ? feature.properties[field] : void 0;
|
|
1630
|
-
const key = field && raw ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
1673
|
+
const key = field && raw != null && raw !== "" ? String(raw) : TRACE_UNGROUPED_KEY;
|
|
1631
1674
|
let bucket = staged.get(key);
|
|
1632
1675
|
if (!bucket) {
|
|
1633
1676
|
bucket = [];
|
|
1634
1677
|
staged.set(key, bucket);
|
|
1635
1678
|
}
|
|
1636
|
-
bucket.push({ feature, time: new Date(feature.properties.startDate).getTime() });
|
|
1679
|
+
bucket.push({ feature, time: new Date(feature.properties.startDate).getTime(), position });
|
|
1637
1680
|
}
|
|
1638
1681
|
const count = staged.size;
|
|
1639
1682
|
const groups = [];
|
|
@@ -1644,6 +1687,7 @@ function buildTraceGroups(features, field) {
|
|
|
1644
1687
|
points: bucket.map((p) => p.feature),
|
|
1645
1688
|
ids: bucket.map((p) => String(p.feature.id)),
|
|
1646
1689
|
times: bucket.map((p) => p.time),
|
|
1690
|
+
positions: bucket.map((p) => p.position),
|
|
1647
1691
|
color: traceGroupColor(key, groups.length, count),
|
|
1648
1692
|
label: field && key !== TRACE_UNGROUPED_KEY ? key : null,
|
|
1649
1693
|
pairStats: /* @__PURE__ */ new Map()
|
|
@@ -1657,14 +1701,11 @@ function traceGroupColor(key, index, count) {
|
|
|
1657
1701
|
}
|
|
1658
1702
|
function visibleTraceIndices(group, isVisible) {
|
|
1659
1703
|
const indices = [];
|
|
1660
|
-
for (let i = 0; i < group.
|
|
1661
|
-
if (isVisible(group.
|
|
1704
|
+
for (let i = 0; i < group.positions.length; i++) {
|
|
1705
|
+
if (isVisible(group.positions[i])) indices.push(i);
|
|
1662
1706
|
}
|
|
1663
1707
|
return indices;
|
|
1664
1708
|
}
|
|
1665
|
-
function timelineVisibility(visibleSet) {
|
|
1666
|
-
return visibleSet === null ? () => true : (id) => visibleSet.has(id);
|
|
1667
|
-
}
|
|
1668
1709
|
function traceSegmentStats(group, fromIndex, toIndex) {
|
|
1669
1710
|
const key = `${fromIndex}:${toIndex}`;
|
|
1670
1711
|
const cached = group.pairStats.get(key);
|
|
@@ -1714,43 +1755,161 @@ function traceSegmentFeature(group, groupIndex, fromIndex, toIndex) {
|
|
|
1714
1755
|
}
|
|
1715
1756
|
};
|
|
1716
1757
|
}
|
|
1717
|
-
const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
|
|
1718
1758
|
const TRACE_POINT_RADIUS = 2;
|
|
1719
1759
|
const TRACE_ENDPOINT_MIN_RADIUS = 8;
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1760
|
+
const TRACE_SOURCE_ID = "trace-features";
|
|
1761
|
+
const TRACE_ENDPOINT_LABEL_LAYER_ID = "trace-endpoint-labels";
|
|
1762
|
+
const ENDPOINT_LABEL_KIND = "endpoint-label";
|
|
1763
|
+
const ENDPOINT_STATE = Object.freeze({ [TRACE_ENDPOINT_KEY]: true });
|
|
1764
|
+
function buildTraceEndpointLabelLayer() {
|
|
1765
|
+
return {
|
|
1766
|
+
id: TRACE_ENDPOINT_LABEL_LAYER_ID,
|
|
1767
|
+
type: "symbol",
|
|
1768
|
+
source: TRACE_SOURCE_ID,
|
|
1769
|
+
filter: ["==", ["get", "kind"], ENDPOINT_LABEL_KIND],
|
|
1770
|
+
layout: {
|
|
1771
|
+
"text-field": ["get", "name"],
|
|
1772
|
+
"text-size": 14,
|
|
1773
|
+
"text-font": ["Montserrat Medium", "Noto Sans Regular"],
|
|
1774
|
+
"text-anchor": "top",
|
|
1775
|
+
"text-offset": [0, 0.8],
|
|
1776
|
+
"text-padding": 2,
|
|
1777
|
+
"text-allow-overlap": false,
|
|
1778
|
+
"text-ignore-placement": false,
|
|
1779
|
+
"text-optional": true
|
|
1780
|
+
},
|
|
1781
|
+
paint: {
|
|
1782
|
+
"text-color": "#1f2937",
|
|
1783
|
+
"text-halo-color": "#ffffff",
|
|
1784
|
+
"text-halo-width": 2,
|
|
1785
|
+
"text-opacity": ["*", 0.9, ["coalesce", ["get", "stroke-opacity"], 1]]
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
function visibleGroupIndices(group, index, w) {
|
|
1790
|
+
return visibleTraceIndices(group, (position) => isVisibleAt(index, position, w));
|
|
1791
|
+
}
|
|
1792
|
+
const instantStarts = /* @__PURE__ */ new WeakMap();
|
|
1793
|
+
function instantsOf(group, index) {
|
|
1794
|
+
const cached = instantStarts.get(group);
|
|
1795
|
+
if (cached !== void 0) return cached;
|
|
1796
|
+
const starts = new Float64Array(group.positions.length);
|
|
1797
|
+
let instants = starts;
|
|
1798
|
+
for (let i = 0; i < starts.length; i++) {
|
|
1799
|
+
const p = group.positions[i];
|
|
1800
|
+
const s = index.starts[p];
|
|
1801
|
+
if (Number.isNaN(s) || s !== index.ends[p] || i > 0 && s < starts[i - 1]) {
|
|
1802
|
+
instants = null;
|
|
1803
|
+
break;
|
|
1804
|
+
}
|
|
1805
|
+
starts[i] = s;
|
|
1806
|
+
}
|
|
1807
|
+
instantStarts.set(group, instants);
|
|
1808
|
+
return instants;
|
|
1809
|
+
}
|
|
1810
|
+
function firstAbove(keys, x, inclusive) {
|
|
1811
|
+
let lo = 0;
|
|
1812
|
+
let hi = keys.length;
|
|
1813
|
+
while (lo < hi) {
|
|
1814
|
+
const mid = lo + hi >>> 1;
|
|
1815
|
+
if (keys[mid] < x || !inclusive && keys[mid] === x) lo = mid + 1;
|
|
1816
|
+
else hi = mid;
|
|
1817
|
+
}
|
|
1818
|
+
return lo;
|
|
1819
|
+
}
|
|
1820
|
+
function visibleRun(instants, w) {
|
|
1821
|
+
if (w === null) return { lo: 0, hi: instants.length };
|
|
1822
|
+
const lo = firstAbove(instants, w.t0, true);
|
|
1823
|
+
return { lo, hi: Math.max(lo, firstAbove(instants, w.t1, false)) };
|
|
1824
|
+
}
|
|
1825
|
+
function pairsOutside(a, b, visit) {
|
|
1826
|
+
const aEnd = a.hi - 1;
|
|
1827
|
+
const bEnd = b.hi - 1;
|
|
1828
|
+
if (bEnd <= b.lo) {
|
|
1829
|
+
for (let i = a.lo; i < aEnd; i++) visit(i);
|
|
1830
|
+
return;
|
|
1831
|
+
}
|
|
1832
|
+
for (let i = a.lo; i < Math.min(aEnd, b.lo); i++) visit(i);
|
|
1833
|
+
for (let i = Math.max(a.lo, bEnd); i < aEnd; i++) visit(i);
|
|
1834
|
+
}
|
|
1835
|
+
function traceEndpointLabelId(groupIndex) {
|
|
1836
|
+
return `label:${groupIndex}`;
|
|
1837
|
+
}
|
|
1838
|
+
function endpointLabel(group, groupIndex, pointIndex) {
|
|
1839
|
+
var _a;
|
|
1840
|
+
const point = group.points[pointIndex];
|
|
1841
|
+
const opacity = (_a = point.properties) == null ? void 0 : _a["stroke-opacity"];
|
|
1842
|
+
return {
|
|
1843
|
+
type: "Feature",
|
|
1844
|
+
id: traceEndpointLabelId(groupIndex),
|
|
1845
|
+
geometry: point.geometry,
|
|
1846
|
+
properties: {
|
|
1847
|
+
kind: ENDPOINT_LABEL_KIND,
|
|
1848
|
+
name: group.label,
|
|
1849
|
+
...typeof opacity === "number" && { "stroke-opacity": opacity }
|
|
1732
1850
|
}
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
function diffGroup(diff, group, groupIndex, index, from, to) {
|
|
1854
|
+
let prevEndpoint;
|
|
1855
|
+
let nextEndpoint;
|
|
1856
|
+
const instants = instantsOf(group, index);
|
|
1857
|
+
if (instants) {
|
|
1858
|
+
const prev = visibleRun(instants, from);
|
|
1859
|
+
const next = visibleRun(instants, to);
|
|
1860
|
+
prevEndpoint = prev.hi > prev.lo ? prev.hi - 1 : -1;
|
|
1861
|
+
nextEndpoint = next.hi > next.lo ? next.hi - 1 : -1;
|
|
1862
|
+
pairsOutside(prev, next, (i) => diff.remove.push(traceSegmentId(groupIndex, i, i + 1)));
|
|
1863
|
+
pairsOutside(next, prev, (i) => diff.add.push(traceSegmentFeature(group, groupIndex, i, i + 1)));
|
|
1864
|
+
} else {
|
|
1865
|
+
const prev = visibleGroupIndices(group, index, from);
|
|
1866
|
+
const next = visibleGroupIndices(group, index, to);
|
|
1867
|
+
prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
|
|
1868
|
+
nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
|
|
1733
1869
|
diffConsecutivePairs(
|
|
1734
1870
|
prev,
|
|
1735
1871
|
next,
|
|
1736
|
-
(
|
|
1737
|
-
(
|
|
1872
|
+
(a, b) => diff.remove.push(traceSegmentId(groupIndex, a, b)),
|
|
1873
|
+
(a, b) => diff.add.push(traceSegmentFeature(group, groupIndex, a, b))
|
|
1738
1874
|
);
|
|
1875
|
+
}
|
|
1876
|
+
if (prevEndpoint === nextEndpoint) return;
|
|
1877
|
+
if (prevEndpoint >= 0) diff.endpointOff.push(group.ids[prevEndpoint]);
|
|
1878
|
+
if (nextEndpoint >= 0) diff.endpointOn.push(group.ids[nextEndpoint]);
|
|
1879
|
+
if (group.label === null) return;
|
|
1880
|
+
if (nextEndpoint >= 0) diff.add.push(endpointLabel(group, groupIndex, nextEndpoint));
|
|
1881
|
+
else diff.remove.push(traceEndpointLabelId(groupIndex));
|
|
1882
|
+
}
|
|
1883
|
+
function buildTraceTimelineDiff(trace, nextWindow) {
|
|
1884
|
+
const diff = { endpointOff: [], endpointOn: [], add: [], remove: [] };
|
|
1885
|
+
trace.groups.forEach((group, groupIndex) => {
|
|
1886
|
+
diffGroup(diff, group, groupIndex, trace.indexes[groupIndex], trace.window, nextWindow);
|
|
1739
1887
|
});
|
|
1740
1888
|
return diff;
|
|
1741
1889
|
}
|
|
1742
|
-
function
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1890
|
+
function paintTraceAt(groups, indexes, w) {
|
|
1891
|
+
const endpoints = [];
|
|
1892
|
+
const features = [];
|
|
1893
|
+
groups.forEach((group, groupIndex) => {
|
|
1894
|
+
const visible = visibleGroupIndices(group, indexes[groupIndex], w);
|
|
1895
|
+
if (visible.length === 0) return;
|
|
1896
|
+
const endpoint = visible[visible.length - 1];
|
|
1897
|
+
endpoints.push(group.ids[endpoint]);
|
|
1898
|
+
for (let k = 1; k < visible.length; k++) {
|
|
1899
|
+
features.push(traceSegmentFeature(group, groupIndex, visible[k - 1], visible[k]));
|
|
1900
|
+
}
|
|
1901
|
+
if (group.label !== null) features.push(endpointLabel(group, groupIndex, endpoint));
|
|
1902
|
+
});
|
|
1903
|
+
return { endpoints, features };
|
|
1904
|
+
}
|
|
1905
|
+
function setTraceEndpoints(host, applied, off, on) {
|
|
1906
|
+
off.forEach((id) => {
|
|
1907
|
+
if (applied.delete(id)) host.removeFeatureState(SHARED_SOURCE_ID, id, TRACE_ENDPOINT_KEY);
|
|
1908
|
+
});
|
|
1909
|
+
on.forEach((id) => {
|
|
1910
|
+
if (applied.has(id)) return;
|
|
1911
|
+
host.setFeatureState(SHARED_SOURCE_ID, id, ENDPOINT_STATE);
|
|
1912
|
+
applied.add(id);
|
|
1754
1913
|
});
|
|
1755
1914
|
}
|
|
1756
1915
|
function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
@@ -1773,19 +1932,19 @@ function diffConsecutivePairs(prev, next, onRemove, onAdd) {
|
|
|
1773
1932
|
}
|
|
1774
1933
|
}
|
|
1775
1934
|
}
|
|
1776
|
-
function applyTraceTimelineDiff(diff,
|
|
1935
|
+
function applyTraceTimelineDiff(diff, traceSource, host, appliedEndpoints) {
|
|
1777
1936
|
try {
|
|
1778
|
-
if (diff.
|
|
1779
|
-
if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
|
|
1780
|
-
segmentSource.updateData({ add: diff.segmentAdd, remove: diff.segmentRemove });
|
|
1781
|
-
}
|
|
1937
|
+
if (diff.add.length > 0 || diff.remove.length > 0) traceSource.updateData({ add: diff.add, remove: diff.remove });
|
|
1782
1938
|
} catch (error) {
|
|
1783
1939
|
console.error("Trace timeline fast path failed; falling back to the full sync:", error);
|
|
1784
1940
|
return false;
|
|
1785
1941
|
}
|
|
1942
|
+
setTraceEndpoints(host, appliedEndpoints, diff.endpointOff, diff.endpointOn);
|
|
1786
1943
|
return true;
|
|
1787
1944
|
}
|
|
1788
1945
|
const DEFAULT_LABEL_PRIORITY = 100;
|
|
1946
|
+
const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
|
|
1947
|
+
const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
|
|
1789
1948
|
const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
|
|
1790
1949
|
const ANNOTATION_PASSTHROUGH_KEYS = [
|
|
1791
1950
|
"kind",
|
|
@@ -1802,11 +1961,21 @@ function sanitizeValue(value) {
|
|
|
1802
1961
|
if (value instanceof Date) return value.toISOString();
|
|
1803
1962
|
return String(value);
|
|
1804
1963
|
}
|
|
1964
|
+
const heatmapHidesPoints = (layer) => {
|
|
1965
|
+
var _a;
|
|
1966
|
+
return ((_a = layer == null ? void 0 : layer.heatmapConfig) == null ? void 0 : _a.enabled) === true;
|
|
1967
|
+
};
|
|
1968
|
+
const clusterHidesPoints = (layer) => {
|
|
1969
|
+
var _a;
|
|
1970
|
+
return ((_a = layer == null ? void 0 : layer.clusterConfig) == null ? void 0 : _a.enabled) === true && !layer.clusterConfig.showPointDots;
|
|
1971
|
+
};
|
|
1972
|
+
function layerHidesPoints(layer) {
|
|
1973
|
+
return heatmapHidesPoints(layer) || clusterHidesPoints(layer);
|
|
1974
|
+
}
|
|
1805
1975
|
function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
1806
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l
|
|
1976
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1807
1977
|
const featureId = String(f.id);
|
|
1808
1978
|
const visualConfig = layer == null ? void 0 : layer.visualConfig;
|
|
1809
|
-
const isTimelineVisible = ctx.timelineVisibleIds === null || ctx.timelineVisibleIds.has(featureId);
|
|
1810
1979
|
const baseOpacity = ((_a = f.properties) == null ? void 0 : _a["stroke-opacity"]) ?? DEFAULT_VISIBLE_STROKE_OPACITY;
|
|
1811
1980
|
let strokeColor = ((_b = f.properties) == null ? void 0 : _b.stroke) || "#3b82f6";
|
|
1812
1981
|
const colorConfig = visualConfig == null ? void 0 : visualConfig.color;
|
|
@@ -1838,14 +2007,12 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1838
2007
|
}
|
|
1839
2008
|
}
|
|
1840
2009
|
}
|
|
1841
|
-
const
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
let traceEndpointRadius = null;
|
|
1845
|
-
if (isTracePoint && f.geometry.type === "Point") {
|
|
2010
|
+
const isTracePoint2 = ctx.tracePointIds.has(featureId);
|
|
2011
|
+
let endpointRadius = 0;
|
|
2012
|
+
if (isTracePoint2 && f.geometry.type === "Point") {
|
|
1846
2013
|
strokeColor = ctx.tracePointColors.get(featureId) || strokeColor;
|
|
1847
|
-
|
|
1848
|
-
pointRadius =
|
|
2014
|
+
endpointRadius = Math.max(pointRadius, TRACE_ENDPOINT_MIN_RADIUS);
|
|
2015
|
+
pointRadius = TRACE_POINT_RADIUS;
|
|
1849
2016
|
}
|
|
1850
2017
|
let labelText = ((_d = f.properties) == null ? void 0 : _d.name) || "";
|
|
1851
2018
|
const labelConfig = visualConfig == null ? void 0 : visualConfig.label;
|
|
@@ -1859,10 +2026,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1859
2026
|
labelText = fieldValue !== void 0 && fieldValue !== null ? String(fieldValue) : "";
|
|
1860
2027
|
}
|
|
1861
2028
|
}
|
|
1862
|
-
const nonTraceLabelText = labelText;
|
|
1863
|
-
if (traceLabel) {
|
|
1864
|
-
labelText = traceLabel;
|
|
1865
|
-
}
|
|
1866
2029
|
let featureIcon = ((_e = f.properties) == null ? void 0 : _e.pointIcon) || ((_f = f.properties) == null ? void 0 : _f.icon);
|
|
1867
2030
|
let featureIconSize = ((_g = f.properties) == null ? void 0 : _g.pointIconSize) || ((_h = f.properties) == null ? void 0 : _h.iconSize) || 24;
|
|
1868
2031
|
const iconConfig = visualConfig == null ? void 0 : visualConfig.icon;
|
|
@@ -1871,8 +2034,8 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1871
2034
|
featureIconSize = iconConfig.size ?? 24;
|
|
1872
2035
|
}
|
|
1873
2036
|
const isPoint = f.geometry.type === "Point";
|
|
1874
|
-
const hideByHeatmap = isPoint && (
|
|
1875
|
-
const hideByCluster = isPoint && (
|
|
2037
|
+
const hideByHeatmap = isPoint && heatmapHidesPoints(layer);
|
|
2038
|
+
const hideByCluster = isPoint && clusterHidesPoints(layer);
|
|
1876
2039
|
const isLine = f.geometry.type === "LineString" || f.geometry.type === "MultiLineString";
|
|
1877
2040
|
const hideFlatFor3DOnly = isLine && (layer == null ? void 0 : layer.hasAltitudeData) && (layer == null ? void 0 : layer.altitudeDisplayMode) === "3d";
|
|
1878
2041
|
const sanitizedProps = {};
|
|
@@ -1893,9 +2056,9 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1893
2056
|
});
|
|
1894
2057
|
}
|
|
1895
2058
|
}
|
|
1896
|
-
let
|
|
1897
|
-
if (((
|
|
1898
|
-
|
|
2059
|
+
let labelPriority = DEFAULT_LABEL_PRIORITY;
|
|
2060
|
+
if (((_i = f.properties) == null ? void 0 : _i.kind) === "text") {
|
|
2061
|
+
labelPriority = ((_j = f.properties) == null ? void 0 : _j.fontWeight) === "bold" ? 8 : 10;
|
|
1899
2062
|
} else {
|
|
1900
2063
|
const idStr = String(featureId);
|
|
1901
2064
|
let h = 0;
|
|
@@ -1903,11 +2066,10 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1903
2066
|
h = (h << 5) - h + idStr.charCodeAt(i);
|
|
1904
2067
|
h |= 0;
|
|
1905
2068
|
}
|
|
1906
|
-
|
|
2069
|
+
labelPriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
|
|
1907
2070
|
}
|
|
1908
|
-
const labelPriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
|
|
1909
2071
|
const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
|
|
1910
|
-
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((
|
|
2072
|
+
const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_k = f.properties) == null ? void 0 : _k["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
|
|
1911
2073
|
return {
|
|
1912
2074
|
feature: {
|
|
1913
2075
|
type: "Feature",
|
|
@@ -1921,28 +2083,20 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
|
|
|
1921
2083
|
name: labelText,
|
|
1922
2084
|
isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
|
|
1923
2085
|
isHiddenByCluster: hideByCluster ? 1 : 0,
|
|
1924
|
-
isTracePoint:
|
|
1925
|
-
|
|
2086
|
+
isTracePoint: isTracePoint2 ? true : false,
|
|
2087
|
+
_endpointRadius: endpointRadius,
|
|
1926
2088
|
icon: featureIcon || "",
|
|
1927
2089
|
iconSize: featureIconSize,
|
|
1928
2090
|
stroke: strokeColor,
|
|
1929
2091
|
"stroke-width": strokeWidth,
|
|
1930
|
-
"stroke-opacity":
|
|
2092
|
+
"stroke-opacity": visibleStrokeOpacity,
|
|
1931
2093
|
fill: strokeColor,
|
|
1932
|
-
"fill-opacity":
|
|
2094
|
+
"fill-opacity": visibleFillOpacity,
|
|
1933
2095
|
pointRadius,
|
|
1934
|
-
isTimelineHidden: isTimelineVisible ? 0 : 1,
|
|
1935
2096
|
_labelPriority: labelPriority,
|
|
1936
|
-
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((
|
|
2097
|
+
[LABEL_NEVER_HIDE_PROP]: computeLabelNeverHide((_l = layer == null ? void 0 : layer.visualConfig) == null ? void 0 : _l.label)
|
|
1937
2098
|
}
|
|
1938
|
-
}
|
|
1939
|
-
paint: {
|
|
1940
|
-
featureId,
|
|
1941
|
-
visibleStrokeOpacity,
|
|
1942
|
-
visibleFillOpacity,
|
|
1943
|
-
timelineHidden: !isTimelineVisible
|
|
1944
|
-
},
|
|
1945
|
-
tracePaint: traceEndpointRadius !== null ? { name: nonTraceLabelText, endpointRadius: traceEndpointRadius, basePriority: nonTracePriority } : null
|
|
2099
|
+
}
|
|
1946
2100
|
};
|
|
1947
2101
|
}
|
|
1948
2102
|
function layerFieldRanges(visualConfig, forEachProperties) {
|
|
@@ -1979,37 +2133,32 @@ async function runShardPass(input) {
|
|
|
1979
2133
|
var _a, _b;
|
|
1980
2134
|
const { features, layer, shardSize, host } = input;
|
|
1981
2135
|
const ranges = shardRanges(features.length, shardSize);
|
|
1982
|
-
const caches = [];
|
|
1983
2136
|
const arrowLines = [];
|
|
1984
2137
|
for (let index = 0; index < ranges.length; index++) {
|
|
1985
2138
|
const { start, end } = ranges[index];
|
|
1986
2139
|
const slice = features.slice(start, end);
|
|
1987
2140
|
const roles = rolesForGeometry(geometryClassesOf(slice));
|
|
1988
2141
|
const ctx = input.contextForShard();
|
|
1989
|
-
const cache2 = createSelectionPaintCache();
|
|
1990
2142
|
const shardArrows = [];
|
|
1991
2143
|
const painted = slice.map((f) => {
|
|
1992
2144
|
var _a2;
|
|
1993
2145
|
const styled = styleFeatureForPaint(f, layer, ctx, true);
|
|
1994
|
-
const p = styled.paint;
|
|
1995
|
-
recordPaintedFeature(cache2, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
1996
2146
|
if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
|
|
1997
2147
|
shardArrows.push(styled.feature);
|
|
1998
2148
|
}
|
|
1999
2149
|
return styled.feature;
|
|
2000
2150
|
});
|
|
2001
2151
|
host.paintShard(index, roles, { type: "FeatureCollection", features: painted });
|
|
2002
|
-
caches[index] = cache2;
|
|
2003
2152
|
if (shardArrows.length > 0) pushAll$1(arrowLines, shardArrows);
|
|
2004
|
-
(_a = input.onShardPainted) == null ? void 0 : _a.call(input, index,
|
|
2153
|
+
(_a = input.onShardPainted) == null ? void 0 : _a.call(input, index, start, end);
|
|
2005
2154
|
(_b = input.onProgress) == null ? void 0 : _b.call(input, end, features.length);
|
|
2006
2155
|
await input.yieldFrame();
|
|
2007
2156
|
if (!input.isCurrent()) {
|
|
2008
|
-
return { completed: false, shardCount: index + 1,
|
|
2157
|
+
return { completed: false, shardCount: index + 1, arrowLines };
|
|
2009
2158
|
}
|
|
2010
2159
|
}
|
|
2011
2160
|
host.dropShardsFrom(ranges.length);
|
|
2012
|
-
return { completed: true, shardCount: ranges.length,
|
|
2161
|
+
return { completed: true, shardCount: ranges.length, arrowLines };
|
|
2013
2162
|
}
|
|
2014
2163
|
function pushAll$1(target, source) {
|
|
2015
2164
|
for (let i = 0; i < source.length; i++) target.push(source[i]);
|
|
@@ -4035,6 +4184,7 @@ function LayersPanel({
|
|
|
4035
4184
|
onMapStyleChange,
|
|
4036
4185
|
onUpdateTraceConfig,
|
|
4037
4186
|
getAvailableTraceFields,
|
|
4187
|
+
getSuggestedTraceField,
|
|
4038
4188
|
getLayerFields,
|
|
4039
4189
|
getFieldValueDistribution,
|
|
4040
4190
|
onUpdateHeatmapConfig,
|
|
@@ -4358,13 +4508,12 @@ function LayersPanel({
|
|
|
4358
4508
|
{
|
|
4359
4509
|
size: "small",
|
|
4360
4510
|
checked: ((_h = layer.traceConfig) == null ? void 0 : _h.enabled) ?? false,
|
|
4361
|
-
onChange: (checked) => {
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
},
|
|
4511
|
+
onChange: (checked) => onUpdateTraceConfig(layer.id, {
|
|
4512
|
+
enabled: checked,
|
|
4513
|
+
// A layer that has never had trace settings starts grouped; a
|
|
4514
|
+
// choice made before, "Connect all points" included, is kept.
|
|
4515
|
+
groupByField: layer.traceConfig ? layer.traceConfig.groupByField ?? null : checked ? (getSuggestedTraceField == null ? void 0 : getSuggestedTraceField(layer.id)) ?? null : null
|
|
4516
|
+
}),
|
|
4368
4517
|
"data-testid": `switch-trace-${layer.id}`
|
|
4369
4518
|
}
|
|
4370
4519
|
),
|
|
@@ -7253,7 +7402,7 @@ function formatDateTime(date) {
|
|
|
7253
7402
|
minute: "2-digit"
|
|
7254
7403
|
});
|
|
7255
7404
|
}
|
|
7256
|
-
function Histogram({ bins, maxCount, colorGroupedBins }) {
|
|
7405
|
+
function Histogram({ bins, maxCount, colorGroupedBins, selectedBins }) {
|
|
7257
7406
|
const [hoveredBin, setHoveredBin] = react.useState(null);
|
|
7258
7407
|
const containerRef = react.useRef(null);
|
|
7259
7408
|
if (bins.length === 0 || maxCount === 0) return null;
|
|
@@ -7312,7 +7461,8 @@ function Histogram({ bins, maxCount, colorGroupedBins }) {
|
|
|
7312
7461
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-muted-foreground", children: [
|
|
7313
7462
|
bins[hoveredBin].count,
|
|
7314
7463
|
" event",
|
|
7315
|
-
bins[hoveredBin].count !== 1 ? "s" : ""
|
|
7464
|
+
bins[hoveredBin].count !== 1 ? "s" : "",
|
|
7465
|
+
!!(selectedBins == null ? void 0 : selectedBins[hoveredBin]) && ` (${selectedBins[hoveredBin]} selected)`
|
|
7316
7466
|
] })
|
|
7317
7467
|
]
|
|
7318
7468
|
}
|
|
@@ -7383,7 +7533,9 @@ function Timebar({
|
|
|
7383
7533
|
return { ...bin, count };
|
|
7384
7534
|
});
|
|
7385
7535
|
}, [hasSelection, selectionAsLine, storeHistogramBins, selectedTemporalFeatures]);
|
|
7386
|
-
const colorGroupedBins =
|
|
7536
|
+
const colorGroupedBins = react.useMemo(() => {
|
|
7537
|
+
if (histogramBins.length === 0 || !hasSelection || !globalMinDate || !globalMaxDate) return [];
|
|
7538
|
+
if (!selectionAsLine && !(selectedFeatureColors && selectedFeatureColors.size > 0)) return [];
|
|
7387
7539
|
if (selectedTemporalFeatures.length === 0) return [];
|
|
7388
7540
|
const colorGroups = /* @__PURE__ */ new Map();
|
|
7389
7541
|
selectedTemporalFeatures.forEach((f) => {
|
|
@@ -7407,13 +7559,18 @@ function Timebar({
|
|
|
7407
7559
|
result.push({ color, bins });
|
|
7408
7560
|
});
|
|
7409
7561
|
return result;
|
|
7410
|
-
}
|
|
7562
|
+
}, [hasSelection, selectionAsLine, histogramBins, selectedTemporalFeatures, selectedFeatureColors, globalMinDate, globalMaxDate]);
|
|
7563
|
+
const selectedBins = react.useMemo(
|
|
7564
|
+
() => selectionAsLine ? histogramBins.map((_, i) => colorGroupedBins.reduce((sum, group) => sum + group.bins[i], 0)) : void 0,
|
|
7565
|
+
[selectionAsLine, histogramBins, colorGroupedBins]
|
|
7566
|
+
);
|
|
7411
7567
|
const animationFrameRef = react.useRef(null);
|
|
7412
7568
|
const lastFrameTimeRef = react.useRef(0);
|
|
7413
7569
|
const playbackDuration = 1e4;
|
|
7414
7570
|
const targetFps = 30;
|
|
7415
7571
|
const frameInterval = 1e3 / targetFps;
|
|
7416
7572
|
const applyFilter = react.useCallback(() => {
|
|
7573
|
+
if (!onFilterChange) return;
|
|
7417
7574
|
const visibleIds = [];
|
|
7418
7575
|
const hiddenIds = [];
|
|
7419
7576
|
temporalFeatures.forEach((feature) => {
|
|
@@ -7524,7 +7681,8 @@ function Timebar({
|
|
|
7524
7681
|
{
|
|
7525
7682
|
bins: histogramBins,
|
|
7526
7683
|
maxCount: maxBinCount,
|
|
7527
|
-
colorGroupedBins
|
|
7684
|
+
colorGroupedBins,
|
|
7685
|
+
selectedBins
|
|
7528
7686
|
}
|
|
7529
7687
|
),
|
|
7530
7688
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -7835,30 +7993,138 @@ function buildReadOnlyFeatureIndex(store) {
|
|
|
7835
7993
|
});
|
|
7836
7994
|
return { sources: new Map(store), byId };
|
|
7837
7995
|
}
|
|
7838
|
-
function
|
|
7839
|
-
var _a;
|
|
7840
|
-
const { west, east, south, north } = bounds;
|
|
7841
|
-
const { threshold, visibleSet } = options;
|
|
7996
|
+
function inViewTest({ west, east, south, north }) {
|
|
7842
7997
|
const fullWidth = east - west >= 360;
|
|
7843
|
-
|
|
7998
|
+
return (lng, lat) => {
|
|
7844
7999
|
if (lat < south || lat > north) return false;
|
|
7845
8000
|
if (fullWidth) return true;
|
|
7846
8001
|
return lng >= west && lng <= east || lng + 360 >= west && lng + 360 <= east || lng - 360 >= west && lng - 360 <= east;
|
|
7847
8002
|
};
|
|
8003
|
+
}
|
|
8004
|
+
function counts(group, p, inView) {
|
|
8005
|
+
var _a;
|
|
8006
|
+
if (group.isVisible && !group.isVisible(p)) return false;
|
|
8007
|
+
const f = group.features[p];
|
|
8008
|
+
if (((_a = f.geometry) == null ? void 0 : _a.type) !== "Point") return true;
|
|
8009
|
+
const [lng, lat] = f.geometry.coordinates;
|
|
8010
|
+
return inView(lng, lat);
|
|
8011
|
+
}
|
|
8012
|
+
function countLinear(group, inView, start, threshold) {
|
|
8013
|
+
let count = start;
|
|
8014
|
+
for (let p = 0; p < group.features.length; p++) {
|
|
8015
|
+
if (!counts(group, p, inView)) continue;
|
|
8016
|
+
count += 1;
|
|
8017
|
+
if (count > threshold) return count;
|
|
8018
|
+
}
|
|
8019
|
+
return count;
|
|
8020
|
+
}
|
|
8021
|
+
function countIndexed(group, { spatial, visibleTotal }, bounds, inView, start, threshold) {
|
|
8022
|
+
const tree = spatial.tree;
|
|
8023
|
+
if (!tree) return start;
|
|
8024
|
+
const { west, east, south, north } = bounds;
|
|
8025
|
+
const fullWidth = east - west >= 360;
|
|
8026
|
+
if ((fullWidth || west <= tree.minX && east >= tree.maxX) && south <= tree.minY && north >= tree.maxY) {
|
|
8027
|
+
return Math.min(start + visibleTotal, threshold + 1);
|
|
8028
|
+
}
|
|
8029
|
+
let count = start;
|
|
8030
|
+
const visit = (item) => {
|
|
8031
|
+
if (count <= threshold && counts(group, spatial.positions[item], inView)) count += 1;
|
|
8032
|
+
return false;
|
|
8033
|
+
};
|
|
8034
|
+
if (fullWidth) {
|
|
8035
|
+
tree.search(-Infinity, south, Infinity, north, visit);
|
|
8036
|
+
return count;
|
|
8037
|
+
}
|
|
8038
|
+
tree.search(west, south, east, north, visit);
|
|
8039
|
+
if (west < -180) tree.search(west + 360, south, Math.min(east + 360, 180), north, visit);
|
|
8040
|
+
if (east > 180) tree.search(Math.max(west - 360, -180), south, east - 360, north, visit);
|
|
8041
|
+
return count;
|
|
8042
|
+
}
|
|
8043
|
+
function countFeaturesInBounds(groups, bounds, options) {
|
|
8044
|
+
const inView = inViewTest(bounds);
|
|
7848
8045
|
let count = 0;
|
|
7849
|
-
for (const
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
if (((_a = f.geometry) == null ? void 0 : _a.type) === "Point") {
|
|
7853
|
-
const [lng, lat] = f.geometry.coordinates;
|
|
7854
|
-
if (!inView(lng, lat)) continue;
|
|
7855
|
-
}
|
|
7856
|
-
count += 1;
|
|
7857
|
-
if (count > threshold) return count;
|
|
7858
|
-
}
|
|
8046
|
+
for (const group of groups) {
|
|
8047
|
+
count = group.indexed ? countIndexed(group, group.indexed, bounds, inView, count, options.threshold) : countLinear(group, inView, count, options.threshold);
|
|
8048
|
+
if (count > options.threshold) return count;
|
|
7859
8049
|
}
|
|
7860
8050
|
return count;
|
|
7861
8051
|
}
|
|
8052
|
+
function extendBounds(bounds, coords) {
|
|
8053
|
+
if (!Array.isArray(coords) || coords.length === 0) return;
|
|
8054
|
+
if (typeof coords[0] === "number") {
|
|
8055
|
+
const lng = coords[0];
|
|
8056
|
+
const lat = coords[1];
|
|
8057
|
+
if (lng < bounds.minLng) bounds.minLng = lng;
|
|
8058
|
+
if (lng > bounds.maxLng) bounds.maxLng = lng;
|
|
8059
|
+
if (lat < bounds.minLat) bounds.minLat = lat;
|
|
8060
|
+
if (lat > bounds.maxLat) bounds.maxLat = lat;
|
|
8061
|
+
return;
|
|
8062
|
+
}
|
|
8063
|
+
for (const nested of coords) extendBounds(bounds, nested);
|
|
8064
|
+
}
|
|
8065
|
+
function computeBounds(coords) {
|
|
8066
|
+
const bounds = { minLng: Infinity, minLat: Infinity, maxLng: -Infinity, maxLat: -Infinity };
|
|
8067
|
+
extendBounds(bounds, coords);
|
|
8068
|
+
return bounds;
|
|
8069
|
+
}
|
|
8070
|
+
function boundsDisjoint(a, b) {
|
|
8071
|
+
return a.maxLng < b.minLng || a.minLng > b.maxLng || a.maxLat < b.minLat || a.minLat > b.maxLat;
|
|
8072
|
+
}
|
|
8073
|
+
function pointInBounds(lng, lat, b) {
|
|
8074
|
+
return lng >= b.minLng && lng <= b.maxLng && lat >= b.minLat && lat <= b.maxLat;
|
|
8075
|
+
}
|
|
8076
|
+
function buildGroupSpatialIndex(features) {
|
|
8077
|
+
var _a;
|
|
8078
|
+
const boxes = [];
|
|
8079
|
+
const positions = [];
|
|
8080
|
+
for (let p = 0; p < features.length; p++) {
|
|
8081
|
+
const geom = (_a = features[p]) == null ? void 0 : _a.geometry;
|
|
8082
|
+
const b = computeBounds(geom == null ? void 0 : geom.coordinates);
|
|
8083
|
+
if (!isFinite(b.minLng) || !isFinite(b.minLat) || !isFinite(b.maxLng) || !isFinite(b.maxLat)) {
|
|
8084
|
+
continue;
|
|
8085
|
+
}
|
|
8086
|
+
boxes.push(b.minLng, b.minLat, b.maxLng, b.maxLat);
|
|
8087
|
+
positions.push(p);
|
|
8088
|
+
}
|
|
8089
|
+
if (positions.length === 0) {
|
|
8090
|
+
return { tree: null, positions, size: features.length };
|
|
8091
|
+
}
|
|
8092
|
+
const startedAt = performance.now();
|
|
8093
|
+
const tree = new Flatbush(positions.length);
|
|
8094
|
+
for (let i = 0; i < boxes.length; i += 4) {
|
|
8095
|
+
tree.add(boxes[i], boxes[i + 1], boxes[i + 2], boxes[i + 3]);
|
|
8096
|
+
}
|
|
8097
|
+
tree.finish();
|
|
8098
|
+
mapPerfLog("spatial-index", "built group index", {
|
|
8099
|
+
indexed: positions.length,
|
|
8100
|
+
of: features.length,
|
|
8101
|
+
ms: Math.round(performance.now() - startedAt)
|
|
8102
|
+
});
|
|
8103
|
+
return { tree, positions, size: features.length };
|
|
8104
|
+
}
|
|
8105
|
+
const indexCache = /* @__PURE__ */ new WeakMap();
|
|
8106
|
+
const failedBuilds = /* @__PURE__ */ new WeakSet();
|
|
8107
|
+
function getGroupSpatialIndex(features) {
|
|
8108
|
+
if (failedBuilds.has(features)) return void 0;
|
|
8109
|
+
let index = indexCache.get(features);
|
|
8110
|
+
if (!index) {
|
|
8111
|
+
try {
|
|
8112
|
+
index = buildGroupSpatialIndex(features);
|
|
8113
|
+
} catch {
|
|
8114
|
+
failedBuilds.add(features);
|
|
8115
|
+
return void 0;
|
|
8116
|
+
}
|
|
8117
|
+
indexCache.set(features, index);
|
|
8118
|
+
}
|
|
8119
|
+
return index;
|
|
8120
|
+
}
|
|
8121
|
+
function queryCandidatePositions(index, bounds) {
|
|
8122
|
+
if (!index.tree) return [];
|
|
8123
|
+
const items = index.tree.search(bounds.minLng, bounds.minLat, bounds.maxLng, bounds.maxLat);
|
|
8124
|
+
const positions = items.map((i) => index.positions[i]);
|
|
8125
|
+
positions.sort((a, b) => a - b);
|
|
8126
|
+
return positions;
|
|
8127
|
+
}
|
|
7862
8128
|
const rafScheduler = {
|
|
7863
8129
|
request: (cb) => requestAnimationFrame(() => cb()),
|
|
7864
8130
|
cancel: (handle) => cancelAnimationFrame(handle)
|
|
@@ -7902,13 +8168,16 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
|
|
|
7902
8168
|
}
|
|
7903
8169
|
};
|
|
7904
8170
|
}
|
|
8171
|
+
function needsDrawSelectionUpdate(input) {
|
|
8172
|
+
return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
|
|
8173
|
+
}
|
|
7905
8174
|
const EMPTY = /* @__PURE__ */ new Set();
|
|
7906
8175
|
function isLive(host, entry) {
|
|
7907
8176
|
return host.source(entry.sourceId) === entry.handle;
|
|
7908
8177
|
}
|
|
7909
8178
|
function remove(host, entry, id) {
|
|
7910
8179
|
if (!isLive(host, entry)) return false;
|
|
7911
|
-
host.removeFeatureState(entry.sourceId, id);
|
|
8180
|
+
host.removeFeatureState(entry.sourceId, id, SELECTED_STATE_KEY);
|
|
7912
8181
|
return true;
|
|
7913
8182
|
}
|
|
7914
8183
|
function set(host, sourceId, id) {
|
|
@@ -8007,7 +8276,7 @@ function forEachIndex(index, id, visit) {
|
|
|
8007
8276
|
function locateFeatureHolders(id, readOnly, cache2) {
|
|
8008
8277
|
const holders = [];
|
|
8009
8278
|
readOnly.forEach((features, layerId) => {
|
|
8010
|
-
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
|
|
8279
|
+
forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at], position: at }));
|
|
8011
8280
|
});
|
|
8012
8281
|
return holders;
|
|
8013
8282
|
}
|
|
@@ -8025,6 +8294,210 @@ function locateFeatureSources(id, inputs, cache2) {
|
|
|
8025
8294
|
if (sources.length === 0) add(SHARED_SOURCE_ID);
|
|
8026
8295
|
return sources;
|
|
8027
8296
|
}
|
|
8297
|
+
const HIDDEN_STATE = Object.freeze({ [TIMELINE_HIDDEN_KEY]: true });
|
|
8298
|
+
function sameSlices(a, b) {
|
|
8299
|
+
return a.length === b.length && a.every((s, i) => s.features === b[i].features && s.start === b[i].start && s.end === b[i].end);
|
|
8300
|
+
}
|
|
8301
|
+
function pushCopy(copies, id, copy, first) {
|
|
8302
|
+
const list = copies.get(id);
|
|
8303
|
+
if (list) list.push(copy);
|
|
8304
|
+
else copies.set(id, [first, copy]);
|
|
8305
|
+
}
|
|
8306
|
+
function collectCopies(slices) {
|
|
8307
|
+
const copies = /* @__PURE__ */ new Map();
|
|
8308
|
+
if (slices.length === 1) {
|
|
8309
|
+
const { features, start, end } = slices[0];
|
|
8310
|
+
const index = getTimelineIndex(features);
|
|
8311
|
+
index.repeats.forEach((positions, id) => {
|
|
8312
|
+
const inside = positions.filter((p) => p >= start && p < end);
|
|
8313
|
+
if (inside.length > 1) copies.set(id, inside.map((position) => ({ index, position })));
|
|
8314
|
+
});
|
|
8315
|
+
return copies;
|
|
8316
|
+
}
|
|
8317
|
+
const first = /* @__PURE__ */ new Map();
|
|
8318
|
+
slices.forEach(({ features, start, end }) => {
|
|
8319
|
+
const index = getTimelineIndex(features);
|
|
8320
|
+
for (let position = start; position < end; position++) {
|
|
8321
|
+
const raw = features[position].id;
|
|
8322
|
+
if (raw === void 0 || raw === null) continue;
|
|
8323
|
+
const id = String(raw);
|
|
8324
|
+
const copy = { index, position };
|
|
8325
|
+
const seen = first.get(id);
|
|
8326
|
+
if (seen) pushCopy(copies, id, copy, seen);
|
|
8327
|
+
else first.set(id, copy);
|
|
8328
|
+
}
|
|
8329
|
+
});
|
|
8330
|
+
return copies;
|
|
8331
|
+
}
|
|
8332
|
+
function copiesOf(record) {
|
|
8333
|
+
record.copies ?? (record.copies = collectCopies(record.slices));
|
|
8334
|
+
return record.copies;
|
|
8335
|
+
}
|
|
8336
|
+
function shouldHide(record, id, index, position, w) {
|
|
8337
|
+
if (isVisibleAt(index, position, w)) return false;
|
|
8338
|
+
const copies = copiesOf(record).get(id);
|
|
8339
|
+
return !copies || copies.every((c) => !isVisibleAt(c.index, c.position, w));
|
|
8340
|
+
}
|
|
8341
|
+
function setHidden(host, record, id, hide) {
|
|
8342
|
+
if (hide === record.hidden.has(id)) return false;
|
|
8343
|
+
if (hide) {
|
|
8344
|
+
host.setFeatureState(record.sourceId, id, HIDDEN_STATE);
|
|
8345
|
+
record.hidden.add(id);
|
|
8346
|
+
} else {
|
|
8347
|
+
host.removeFeatureState(record.sourceId, id, TIMELINE_HIDDEN_KEY);
|
|
8348
|
+
record.hidden.delete(id);
|
|
8349
|
+
}
|
|
8350
|
+
return true;
|
|
8351
|
+
}
|
|
8352
|
+
function idAt(features, position) {
|
|
8353
|
+
const raw = features[position].id;
|
|
8354
|
+
return raw === void 0 || raw === null ? null : String(raw);
|
|
8355
|
+
}
|
|
8356
|
+
function seedTimelineSource(host, applied, sourceId, slices, w) {
|
|
8357
|
+
const handle = host.source(sourceId);
|
|
8358
|
+
const old = applied.get(sourceId);
|
|
8359
|
+
if (!handle) {
|
|
8360
|
+
applied.delete(sourceId);
|
|
8361
|
+
return 0;
|
|
8362
|
+
}
|
|
8363
|
+
if (old && old.handle === handle && sameSlices(old.slices, slices)) return 0;
|
|
8364
|
+
const record = {
|
|
8365
|
+
sourceId,
|
|
8366
|
+
handle,
|
|
8367
|
+
slices,
|
|
8368
|
+
hidden: (old == null ? void 0 : old.handle) === handle ? old.hidden : /* @__PURE__ */ new Set(),
|
|
8369
|
+
copies: null,
|
|
8370
|
+
window: w
|
|
8371
|
+
};
|
|
8372
|
+
applied.set(sourceId, record);
|
|
8373
|
+
const hide = /* @__PURE__ */ new Set();
|
|
8374
|
+
if (w !== null) {
|
|
8375
|
+
slices.forEach(({ features, start, end }) => {
|
|
8376
|
+
const index = getTimelineIndex(features);
|
|
8377
|
+
for (let position = start; position < end; position++) {
|
|
8378
|
+
const id = idAt(features, position);
|
|
8379
|
+
if (id !== null && shouldHide(record, id, index, position, w)) hide.add(id);
|
|
8380
|
+
}
|
|
8381
|
+
});
|
|
8382
|
+
}
|
|
8383
|
+
let calls = 0;
|
|
8384
|
+
Array.from(record.hidden).forEach((id) => {
|
|
8385
|
+
if (!hide.has(id) && setHidden(host, record, id, false)) calls++;
|
|
8386
|
+
});
|
|
8387
|
+
hide.forEach((id) => {
|
|
8388
|
+
if (setHidden(host, record, id, true)) calls++;
|
|
8389
|
+
});
|
|
8390
|
+
return calls;
|
|
8391
|
+
}
|
|
8392
|
+
function isTimelineHiddenOn(applied, sourceId, id) {
|
|
8393
|
+
var _a;
|
|
8394
|
+
return ((_a = applied.get(sourceId)) == null ? void 0 : _a.hidden.has(id)) ?? false;
|
|
8395
|
+
}
|
|
8396
|
+
function ownerOf(owners, position) {
|
|
8397
|
+
let lo = 0;
|
|
8398
|
+
let hi = owners.length - 1;
|
|
8399
|
+
let found = null;
|
|
8400
|
+
while (lo <= hi) {
|
|
8401
|
+
const mid = lo + hi >>> 1;
|
|
8402
|
+
if (owners[mid].start <= position) {
|
|
8403
|
+
found = owners[mid];
|
|
8404
|
+
lo = mid + 1;
|
|
8405
|
+
} else {
|
|
8406
|
+
hi = mid - 1;
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8409
|
+
return found && position < found.end ? found : null;
|
|
8410
|
+
}
|
|
8411
|
+
function groupBySliceArray(host, applied, next, isActive) {
|
|
8412
|
+
const groups = [];
|
|
8413
|
+
applied.forEach((record, sourceId) => {
|
|
8414
|
+
if (host.source(sourceId) !== record.handle) {
|
|
8415
|
+
applied.delete(sourceId);
|
|
8416
|
+
return;
|
|
8417
|
+
}
|
|
8418
|
+
if (!isActive(sourceId) || sameWindow(record.window, next)) return;
|
|
8419
|
+
record.slices.forEach(({ features, start, end }) => {
|
|
8420
|
+
let group = groups.find((g) => g.features === features && sameWindow(g.from, record.window));
|
|
8421
|
+
if (!group) {
|
|
8422
|
+
group = { features, from: record.window, owners: [] };
|
|
8423
|
+
groups.push(group);
|
|
8424
|
+
}
|
|
8425
|
+
group.owners.push({ record, start, end });
|
|
8426
|
+
});
|
|
8427
|
+
record.window = next;
|
|
8428
|
+
});
|
|
8429
|
+
return groups;
|
|
8430
|
+
}
|
|
8431
|
+
function applyTimelineWindow(host, applied, next, isActive = () => true) {
|
|
8432
|
+
const flipped = [];
|
|
8433
|
+
const positions = [];
|
|
8434
|
+
groupBySliceArray(host, applied, next, isActive).forEach(({ features, from, owners }) => {
|
|
8435
|
+
owners.sort((a, b) => a.start - b.start);
|
|
8436
|
+
const index = getTimelineIndex(features);
|
|
8437
|
+
positions.length = 0;
|
|
8438
|
+
flippedPositions(index, from, next, positions);
|
|
8439
|
+
positions.forEach((position) => {
|
|
8440
|
+
const owner = ownerOf(owners, position);
|
|
8441
|
+
const id = owner ? idAt(features, position) : null;
|
|
8442
|
+
if (!owner || id === null) return;
|
|
8443
|
+
if (setHidden(host, owner.record, id, shouldHide(owner.record, id, index, position, next))) flipped.push(id);
|
|
8444
|
+
});
|
|
8445
|
+
});
|
|
8446
|
+
return flipped;
|
|
8447
|
+
}
|
|
8448
|
+
const IDENTITY_PATTERNS = [
|
|
8449
|
+
/person|people|individual|subject|suspect/,
|
|
8450
|
+
/target/,
|
|
8451
|
+
/entity/,
|
|
8452
|
+
/device|imei|imsi|msisdn|phone/,
|
|
8453
|
+
/mmsi|vessel|ship/,
|
|
8454
|
+
/vehicle|plate|car_?id/,
|
|
8455
|
+
/callsign|flight|aircraft|icao/,
|
|
8456
|
+
/user|account|owner|driver/,
|
|
8457
|
+
/track|trajectory/,
|
|
8458
|
+
/(^|[^a-z])id$|_id$|^id_|uuid/
|
|
8459
|
+
];
|
|
8460
|
+
const NOT_IDENTITY = /* @__PURE__ */ new Set(["id", "name", "startdate", "enddate", "opacity", "timestamp", "time", "date"]);
|
|
8461
|
+
const CATEGORY_SUFFIX = /(type|kind|category|class|status|model|role)$/;
|
|
8462
|
+
const MIN_COVERAGE = 0.9;
|
|
8463
|
+
const MAX_GROUPS = 500;
|
|
8464
|
+
const MIN_POINTS_PER_GROUP = 2;
|
|
8465
|
+
const MAX_SAMPLES = 1e4;
|
|
8466
|
+
function isTracePoint(f) {
|
|
8467
|
+
var _a, _b;
|
|
8468
|
+
return !!f && f.id != null && ((_a = f.geometry) == null ? void 0 : _a.type) === "Point" && !!((_b = f.properties) == null ? void 0 : _b.startDate);
|
|
8469
|
+
}
|
|
8470
|
+
function identityRank(field) {
|
|
8471
|
+
const name = field.toLowerCase();
|
|
8472
|
+
if (NOT_IDENTITY.has(name) || CATEGORY_SUFFIX.test(name)) return -1;
|
|
8473
|
+
return IDENTITY_PATTERNS.findIndex((pattern) => pattern.test(name));
|
|
8474
|
+
}
|
|
8475
|
+
function suggestTraceGroupField(features, fields) {
|
|
8476
|
+
var _a;
|
|
8477
|
+
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));
|
|
8478
|
+
if (candidates.length === 0) return null;
|
|
8479
|
+
const step = Math.max(1, Math.ceil(features.length / MAX_SAMPLES));
|
|
8480
|
+
const points = [];
|
|
8481
|
+
for (let i = 0; i < features.length && points.length < MAX_SAMPLES; i += step) {
|
|
8482
|
+
const f = features[i];
|
|
8483
|
+
if (isTracePoint(f)) points.push(f);
|
|
8484
|
+
}
|
|
8485
|
+
if (points.length < 2) return null;
|
|
8486
|
+
const splitsIntoTracks = (field) => {
|
|
8487
|
+
var _a2;
|
|
8488
|
+
const values = /* @__PURE__ */ new Set();
|
|
8489
|
+
let present = 0;
|
|
8490
|
+
for (const f of points) {
|
|
8491
|
+
const raw = (_a2 = f.properties) == null ? void 0 : _a2[field];
|
|
8492
|
+
if (raw === null || raw === void 0 || raw === "") continue;
|
|
8493
|
+
present++;
|
|
8494
|
+
values.add(String(raw));
|
|
8495
|
+
if (values.size > MAX_GROUPS) return false;
|
|
8496
|
+
}
|
|
8497
|
+
return present >= points.length * MIN_COVERAGE && values.size >= 2 && present >= values.size * MIN_POINTS_PER_GROUP;
|
|
8498
|
+
};
|
|
8499
|
+
return ((_a = candidates.find((c) => splitsIntoTracks(c.field))) == null ? void 0 : _a.field) ?? null;
|
|
8500
|
+
}
|
|
8028
8501
|
function deepClone(value) {
|
|
8029
8502
|
try {
|
|
8030
8503
|
return structuredClone(value);
|
|
@@ -8161,82 +8634,6 @@ function shouldDiffDrawRender({ mode, pointerDown, hasSelection }) {
|
|
|
8161
8634
|
if (mode === "simple_select" || mode === "direct_select") return pointerDown && hasSelection;
|
|
8162
8635
|
return true;
|
|
8163
8636
|
}
|
|
8164
|
-
function extendBounds(bounds, coords) {
|
|
8165
|
-
if (!Array.isArray(coords) || coords.length === 0) return;
|
|
8166
|
-
if (typeof coords[0] === "number") {
|
|
8167
|
-
const lng = coords[0];
|
|
8168
|
-
const lat = coords[1];
|
|
8169
|
-
if (lng < bounds.minLng) bounds.minLng = lng;
|
|
8170
|
-
if (lng > bounds.maxLng) bounds.maxLng = lng;
|
|
8171
|
-
if (lat < bounds.minLat) bounds.minLat = lat;
|
|
8172
|
-
if (lat > bounds.maxLat) bounds.maxLat = lat;
|
|
8173
|
-
return;
|
|
8174
|
-
}
|
|
8175
|
-
for (const nested of coords) extendBounds(bounds, nested);
|
|
8176
|
-
}
|
|
8177
|
-
function computeBounds(coords) {
|
|
8178
|
-
const bounds = { minLng: Infinity, minLat: Infinity, maxLng: -Infinity, maxLat: -Infinity };
|
|
8179
|
-
extendBounds(bounds, coords);
|
|
8180
|
-
return bounds;
|
|
8181
|
-
}
|
|
8182
|
-
function boundsDisjoint(a, b) {
|
|
8183
|
-
return a.maxLng < b.minLng || a.minLng > b.maxLng || a.maxLat < b.minLat || a.minLat > b.maxLat;
|
|
8184
|
-
}
|
|
8185
|
-
function pointInBounds(lng, lat, b) {
|
|
8186
|
-
return lng >= b.minLng && lng <= b.maxLng && lat >= b.minLat && lat <= b.maxLat;
|
|
8187
|
-
}
|
|
8188
|
-
function buildGroupSpatialIndex(features) {
|
|
8189
|
-
var _a;
|
|
8190
|
-
const boxes = [];
|
|
8191
|
-
const positions = [];
|
|
8192
|
-
for (let p = 0; p < features.length; p++) {
|
|
8193
|
-
const geom = (_a = features[p]) == null ? void 0 : _a.geometry;
|
|
8194
|
-
const b = computeBounds(geom == null ? void 0 : geom.coordinates);
|
|
8195
|
-
if (!isFinite(b.minLng) || !isFinite(b.minLat) || !isFinite(b.maxLng) || !isFinite(b.maxLat)) {
|
|
8196
|
-
continue;
|
|
8197
|
-
}
|
|
8198
|
-
boxes.push(b.minLng, b.minLat, b.maxLng, b.maxLat);
|
|
8199
|
-
positions.push(p);
|
|
8200
|
-
}
|
|
8201
|
-
if (positions.length === 0) {
|
|
8202
|
-
return { tree: null, positions, size: features.length };
|
|
8203
|
-
}
|
|
8204
|
-
const startedAt = performance.now();
|
|
8205
|
-
const tree = new Flatbush(positions.length);
|
|
8206
|
-
for (let i = 0; i < boxes.length; i += 4) {
|
|
8207
|
-
tree.add(boxes[i], boxes[i + 1], boxes[i + 2], boxes[i + 3]);
|
|
8208
|
-
}
|
|
8209
|
-
tree.finish();
|
|
8210
|
-
mapPerfLog("spatial-index", "built group index", {
|
|
8211
|
-
indexed: positions.length,
|
|
8212
|
-
of: features.length,
|
|
8213
|
-
ms: Math.round(performance.now() - startedAt)
|
|
8214
|
-
});
|
|
8215
|
-
return { tree, positions, size: features.length };
|
|
8216
|
-
}
|
|
8217
|
-
const indexCache = /* @__PURE__ */ new WeakMap();
|
|
8218
|
-
const failedBuilds = /* @__PURE__ */ new WeakSet();
|
|
8219
|
-
function getGroupSpatialIndex(features) {
|
|
8220
|
-
if (failedBuilds.has(features)) return void 0;
|
|
8221
|
-
let index = indexCache.get(features);
|
|
8222
|
-
if (!index) {
|
|
8223
|
-
try {
|
|
8224
|
-
index = buildGroupSpatialIndex(features);
|
|
8225
|
-
} catch {
|
|
8226
|
-
failedBuilds.add(features);
|
|
8227
|
-
return void 0;
|
|
8228
|
-
}
|
|
8229
|
-
indexCache.set(features, index);
|
|
8230
|
-
}
|
|
8231
|
-
return index;
|
|
8232
|
-
}
|
|
8233
|
-
function queryCandidatePositions(index, bounds) {
|
|
8234
|
-
if (!index.tree) return [];
|
|
8235
|
-
const items = index.tree.search(bounds.minLng, bounds.minLat, bounds.maxLng, bounds.maxLat);
|
|
8236
|
-
const positions = items.map((i) => index.positions[i]);
|
|
8237
|
-
positions.sort((a, b) => a - b);
|
|
8238
|
-
return positions;
|
|
8239
|
-
}
|
|
8240
8637
|
function collectVisibleFeatureGroups(drawFeatures, readOnlyByLayer, layers) {
|
|
8241
8638
|
const groups = [];
|
|
8242
8639
|
if (drawFeatures) groups.push({ features: drawFeatures });
|
|
@@ -8354,19 +8751,6 @@ function buildSelectionOverlayStack() {
|
|
|
8354
8751
|
}
|
|
8355
8752
|
];
|
|
8356
8753
|
}
|
|
8357
|
-
function overlayTimelineInputs(ids, visible) {
|
|
8358
|
-
const hidden = /* @__PURE__ */ new Set();
|
|
8359
|
-
if (visible !== null) ids.forEach((id) => {
|
|
8360
|
-
if (!visible.has(id)) hidden.add(id);
|
|
8361
|
-
});
|
|
8362
|
-
return { ids, hidden };
|
|
8363
|
-
}
|
|
8364
|
-
function sameIds(a, b) {
|
|
8365
|
-
return a.size === b.size && Array.from(a).every((id) => b.has(id));
|
|
8366
|
-
}
|
|
8367
|
-
function sameOverlayTimelineInputs(a, b) {
|
|
8368
|
-
return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
|
|
8369
|
-
}
|
|
8370
8754
|
function buildSelectionOverlayData(ids, styleFor) {
|
|
8371
8755
|
const features = [];
|
|
8372
8756
|
ids.forEach((id) => {
|
|
@@ -8753,8 +9137,8 @@ function hideTooltip() {
|
|
|
8753
9137
|
tooltipEl.style.display = "none";
|
|
8754
9138
|
}
|
|
8755
9139
|
}
|
|
8756
|
-
function fingerprintCluster(pointCount,
|
|
8757
|
-
return `${size}|${pointCount}|${badgeValue ?? ""}|${
|
|
9140
|
+
function fingerprintCluster(pointCount, counts2, size, badgeValue) {
|
|
9141
|
+
return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
|
|
8758
9142
|
}
|
|
8759
9143
|
function buildPieElement(categories, pointCount, size, source, clusterId, map, coords, badgeValue) {
|
|
8760
9144
|
const el = createPieSVG(categories, pointCount, size, (cat, event) => {
|
|
@@ -8906,6 +9290,8 @@ const EMPTY_ID_SET = /* @__PURE__ */ new Set();
|
|
|
8906
9290
|
const EMPTY_SOURCES = [];
|
|
8907
9291
|
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"];
|
|
8908
9292
|
const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
|
|
9293
|
+
const TICK_COUNT_SETTLE_MS = 300;
|
|
9294
|
+
const SPATIAL_COUNT_MIN_FEATURES = 5e3;
|
|
8909
9295
|
function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
|
|
8910
9296
|
const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
8911
9297
|
const canvas = document.createElement("canvas");
|
|
@@ -9113,7 +9499,7 @@ function basemapInsertAnchor(map) {
|
|
|
9113
9499
|
function featureStateHostFor(m) {
|
|
9114
9500
|
return {
|
|
9115
9501
|
setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
|
|
9116
|
-
removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
|
|
9502
|
+
removeFeatureState: (source, id, key) => m.removeFeatureState({ source, id }, key),
|
|
9117
9503
|
source: (source) => m.getSource(source)
|
|
9118
9504
|
};
|
|
9119
9505
|
}
|
|
@@ -9296,6 +9682,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9296
9682
|
const justCreatedFeatureRef = react.useRef(false);
|
|
9297
9683
|
const [autoLabelConfig, setAutoLabelConfig] = react.useState({ enabled: true, threshold: 220 });
|
|
9298
9684
|
const [visibleFeatureCount, setVisibleFeatureCount] = react.useState(Infinity);
|
|
9685
|
+
const visibleFeatureCountRef = react.useRef(visibleFeatureCount);
|
|
9686
|
+
visibleFeatureCountRef.current = visibleFeatureCount;
|
|
9687
|
+
const tickCountTimerRef = react.useRef(null);
|
|
9299
9688
|
const lastLabelVisibility = react.useRef(false);
|
|
9300
9689
|
const shardRegistryRef = react.useRef(null);
|
|
9301
9690
|
const applyShardedLayersRef = react.useRef(null);
|
|
@@ -9303,9 +9692,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9303
9692
|
const bindHoverHandlersRef = react.useRef(null);
|
|
9304
9693
|
const unbindHoverHandlersRef = react.useRef(null);
|
|
9305
9694
|
const [labelsSuppressed, setLabelsSuppressed] = react.useState(true);
|
|
9695
|
+
const labelsSuppressedRef = react.useRef(labelsSuppressed);
|
|
9696
|
+
labelsSuppressedRef.current = labelsSuppressed;
|
|
9306
9697
|
const [contextMenu, setContextMenu] = react.useState(null);
|
|
9307
9698
|
const [timelineStoreApi] = react.useState(createTimelineStore);
|
|
9308
|
-
const
|
|
9699
|
+
const timelineEnabled = zustand.useStore(timelineStoreApi, (s) => s.isEnabled);
|
|
9700
|
+
const timelineHasData = zustand.useStore(timelineStoreApi, (s) => s.hasTemporalData);
|
|
9309
9701
|
const { toast: internalToast } = useToast();
|
|
9310
9702
|
const toast = toastProvider ?? internalToast;
|
|
9311
9703
|
const featureCap = react.useMemo(() => resolveFeatureCap(maxFeaturesPerLayer), [maxFeaturesPerLayer]);
|
|
@@ -9566,7 +9958,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9566
9958
|
});
|
|
9567
9959
|
setFeatureCount(drawFeatureCount + hiddenCount + readOnlyCount);
|
|
9568
9960
|
}, []);
|
|
9569
|
-
const
|
|
9961
|
+
const timelineWindowRef = react.useRef(null);
|
|
9962
|
+
const appliedTimelineRef = react.useRef(/* @__PURE__ */ new Map());
|
|
9963
|
+
const isTimelineSourceActive = react.useCallback((sourceId) => {
|
|
9964
|
+
var _a;
|
|
9965
|
+
const shard = parseShardSourceId(sourceId);
|
|
9966
|
+
return !shard || ((_a = layersRef.current.find((l) => l.id === shard.layerId)) == null ? void 0 : _a.visible) === true;
|
|
9967
|
+
}, []);
|
|
9570
9968
|
const syncRef = react.useRef(() => {
|
|
9571
9969
|
});
|
|
9572
9970
|
const trySelectionFastPathRef = react.useRef(null);
|
|
@@ -9598,6 +9996,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9598
9996
|
}
|
|
9599
9997
|
(_b = syncCoalescerRef.current) == null ? void 0 : _b.schedule(reason);
|
|
9600
9998
|
}, []);
|
|
9999
|
+
react.useEffect(() => {
|
|
10000
|
+
const windowOf = (state) => state.isEnabled && state.hasTemporalData ? windowFromRange(state.rangeStart, state.rangeEnd) : null;
|
|
10001
|
+
const follow = (state) => {
|
|
10002
|
+
var _a;
|
|
10003
|
+
const next = windowOf(state);
|
|
10004
|
+
if (sameWindow(next, timelineWindowRef.current)) return;
|
|
10005
|
+
timelineWindowRef.current = next;
|
|
10006
|
+
scheduleSync("timeline");
|
|
10007
|
+
(_a = update3DFlightPathsRef.current) == null ? void 0 : _a.call(update3DFlightPathsRef);
|
|
10008
|
+
};
|
|
10009
|
+
follow(timelineStoreApi.getState());
|
|
10010
|
+
return timelineStoreApi.subscribe(follow);
|
|
10011
|
+
}, [timelineStoreApi, scheduleSync]);
|
|
9601
10012
|
react.useEffect(() => {
|
|
9602
10013
|
scheduleSync();
|
|
9603
10014
|
}, [layers, scheduleSync]);
|
|
@@ -9661,21 +10072,33 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9661
10072
|
const m = map.current;
|
|
9662
10073
|
if (!m) return 0;
|
|
9663
10074
|
const bounds = m.getBounds();
|
|
10075
|
+
const w = timelineWindowRef.current;
|
|
10076
|
+
const groupOf = (features) => {
|
|
10077
|
+
if (w === null) return { features };
|
|
10078
|
+
const index = getTimelineIndex(features);
|
|
10079
|
+
const group = { features, isVisible: (p) => isVisibleAt(index, p, w) };
|
|
10080
|
+
const spatial = features.length >= SPATIAL_COUNT_MIN_FEATURES ? getGroupSpatialIndex(features) : void 0;
|
|
10081
|
+
if (spatial) group.indexed = { spatial, visibleTotal: countVisible(index, w) };
|
|
10082
|
+
return group;
|
|
10083
|
+
};
|
|
9664
10084
|
const groups = [];
|
|
9665
|
-
if (draw.current)
|
|
10085
|
+
if (draw.current) {
|
|
10086
|
+
const features = draw.current.getAll().features;
|
|
10087
|
+
groups.push(w === null ? { features } : { features, isVisible: (p) => isFeatureVisible(features[p], w) });
|
|
10088
|
+
}
|
|
9666
10089
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9667
10090
|
const layer = layersRef.current.find((l) => l.id === layerId);
|
|
9668
|
-
if (layer == null ? void 0 : layer.visible) groups.push(features);
|
|
10091
|
+
if (layer == null ? void 0 : layer.visible) groups.push(groupOf(features));
|
|
9669
10092
|
});
|
|
9670
10093
|
return countFeaturesInBounds(
|
|
9671
10094
|
groups,
|
|
9672
10095
|
{ west: bounds.getWest(), east: bounds.getEast(), south: bounds.getSouth(), north: bounds.getNorth() },
|
|
9673
|
-
{ threshold
|
|
10096
|
+
{ threshold }
|
|
9674
10097
|
);
|
|
9675
10098
|
}, []);
|
|
9676
10099
|
const isSyncingRef = react.useRef(false);
|
|
9677
|
-
const selectionPaintCacheRef = react.useRef(null);
|
|
9678
10100
|
const tracePaintCacheRef = react.useRef(null);
|
|
10101
|
+
const traceEndpointsRef = react.useRef(/* @__PURE__ */ new Set());
|
|
9679
10102
|
const paintedArrowLinesRef = react.useRef([]);
|
|
9680
10103
|
const renderArrowOverlays = react.useCallback((arrowLines) => {
|
|
9681
10104
|
const mapInstance = map.current;
|
|
@@ -9781,7 +10204,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9781
10204
|
const source = map.current.getSource("custom-features");
|
|
9782
10205
|
if (!source) return;
|
|
9783
10206
|
const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
|
|
9784
|
-
const
|
|
10207
|
+
const timelineWindow = timelineWindowRef.current;
|
|
9785
10208
|
const currentLayers = layersRef.current;
|
|
9786
10209
|
const isLayerVisible = (layer) => {
|
|
9787
10210
|
return layer.visible;
|
|
@@ -9794,11 +10217,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9794
10217
|
});
|
|
9795
10218
|
shardedLayerIdsRef.current = shardedLayerIds;
|
|
9796
10219
|
const allFeatures = [...drawFeatures.features];
|
|
10220
|
+
const sharedSlices = [];
|
|
10221
|
+
const addSlice = (features) => {
|
|
10222
|
+
if (features.length > 0) sharedSlices.push({ features, start: 0, end: features.length });
|
|
10223
|
+
};
|
|
10224
|
+
addSlice(drawFeatures.features);
|
|
9797
10225
|
readOnlyFeatures.current.forEach((features, layerId) => {
|
|
9798
10226
|
if (shardedLayerIds.has(layerId)) return;
|
|
9799
10227
|
const layer = currentLayers.find((l) => l.id === layerId);
|
|
9800
10228
|
if (layer && isLayerVisible(layer)) {
|
|
9801
10229
|
pushAll(allFeatures, features);
|
|
10230
|
+
addSlice(features);
|
|
9802
10231
|
}
|
|
9803
10232
|
});
|
|
9804
10233
|
const featureById = /* @__PURE__ */ new Map();
|
|
@@ -9846,71 +10275,69 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9846
10275
|
if (sizeField && isFinite(sMin)) sizeFieldRanges.set(layer.id, { min: sMin, max: sMax });
|
|
9847
10276
|
if (colorField && isFinite(cMin)) colorFieldRanges.set(layer.id, { min: cMin, max: cMax });
|
|
9848
10277
|
});
|
|
9849
|
-
const lastTracePointIds = /* @__PURE__ */ new Set();
|
|
9850
10278
|
const tracePointColors = /* @__PURE__ */ new Map();
|
|
9851
|
-
const lastTracePointLabels = /* @__PURE__ */ new Map();
|
|
9852
10279
|
const tracePointIds = /* @__PURE__ */ new Set();
|
|
9853
10280
|
const paintedTraceGroups = [];
|
|
9854
|
-
const
|
|
9855
|
-
const tracePointPaint = /* @__PURE__ */ new Map();
|
|
9856
|
-
const isTimelineVisibleId = timelineVisibility(visibleSet);
|
|
10281
|
+
const traceIndexes = [];
|
|
9857
10282
|
currentLayers.forEach((layer) => {
|
|
9858
10283
|
var _a2;
|
|
9859
10284
|
if (!((_a2 = layer.traceConfig) == null ? void 0 : _a2.enabled) || !layer.visible) return;
|
|
9860
|
-
const
|
|
10285
|
+
const traceFeatures = traceSourceFeatures(layer, featureById);
|
|
10286
|
+
const traceIndex = getTimelineIndex(traceFeatures);
|
|
10287
|
+
const groups = getTraceGroups(traceFeatures, layer.traceConfig.groupByField);
|
|
10288
|
+
const pointsHidden = layerHidesPoints(layer);
|
|
9861
10289
|
for (const group of groups) {
|
|
9862
|
-
|
|
10290
|
+
paintedTraceGroups.push(pointsHidden && group.label !== null ? { ...group, label: null } : group);
|
|
10291
|
+
traceIndexes.push(traceIndex);
|
|
9863
10292
|
for (const id of group.ids) {
|
|
9864
10293
|
tracePointIds.add(id);
|
|
9865
10294
|
tracePointColors.set(id, group.color);
|
|
9866
10295
|
}
|
|
9867
|
-
const visible = visibleTraceIndices(group, isTimelineVisibleId);
|
|
9868
|
-
if (visible.length === 0) continue;
|
|
9869
|
-
const endpointId = group.ids[visible[visible.length - 1]];
|
|
9870
|
-
lastTracePointIds.add(endpointId);
|
|
9871
|
-
if (group.label !== null) lastTracePointLabels.set(endpointId, group.label);
|
|
9872
|
-
for (let k = 1; k < visible.length; k++) {
|
|
9873
|
-
traceSegments.push(traceSegmentFeature(group, groupIndex, visible[k - 1], visible[k]));
|
|
9874
|
-
}
|
|
9875
10296
|
}
|
|
9876
10297
|
});
|
|
9877
|
-
const paintCache = createSelectionPaintCache();
|
|
9878
10298
|
const paintContext = {
|
|
9879
|
-
timelineVisibleIds: visibleSet,
|
|
9880
10299
|
sizeFieldRanges,
|
|
9881
10300
|
colorFieldRanges,
|
|
9882
10301
|
tracePointIds,
|
|
9883
|
-
lastTracePointIds,
|
|
9884
|
-
lastTracePointLabels,
|
|
9885
10302
|
tracePointColors
|
|
9886
10303
|
};
|
|
9887
10304
|
const drawFeatureCount = drawFeatures.features.length;
|
|
9888
10305
|
const sourceData = {
|
|
9889
10306
|
type: "FeatureCollection",
|
|
9890
10307
|
features: allFeatures.map((f, i) => {
|
|
9891
|
-
|
|
9892
|
-
const p = styled.paint;
|
|
9893
|
-
recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
|
|
9894
|
-
if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
|
|
9895
|
-
return styled.feature;
|
|
10308
|
+
return styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount).feature;
|
|
9896
10309
|
})
|
|
9897
10310
|
};
|
|
9898
10311
|
source.setData(sourceData);
|
|
9899
|
-
selectionPaintCacheRef.current = paintCache;
|
|
9900
10312
|
overlayPaintContextRef.current = paintContext;
|
|
10313
|
+
const stateHost = featureStateHostFor(map.current);
|
|
10314
|
+
seedTimelineSource(stateHost, appliedTimelineRef.current, SHARED_SOURCE_ID, sharedSlices, timelineWindow);
|
|
10315
|
+
applyTimelineWindow(stateHost, appliedTimelineRef.current, timelineWindow, isTimelineSourceActive);
|
|
9901
10316
|
(_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
|
|
9902
|
-
const traceSource = map.current.getSource(
|
|
9903
|
-
|
|
9904
|
-
|
|
10317
|
+
const traceSource = map.current.getSource(TRACE_SOURCE_ID);
|
|
10318
|
+
const tracePaint = paintTraceAt(paintedTraceGroups, traceIndexes, timelineWindow);
|
|
10319
|
+
if (traceSource) traceSource.setData({ type: "FeatureCollection", features: tracePaint.features });
|
|
10320
|
+
const endpoints2 = new Set(tracePaint.endpoints);
|
|
10321
|
+
setTraceEndpoints(
|
|
10322
|
+
featureStateHostFor(map.current),
|
|
10323
|
+
traceEndpointsRef.current,
|
|
10324
|
+
Array.from(traceEndpointsRef.current).filter((id) => !endpoints2.has(id)),
|
|
10325
|
+
tracePaint.endpoints
|
|
10326
|
+
);
|
|
10327
|
+
tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, indexes: traceIndexes, window: timelineWindow } : null;
|
|
9905
10328
|
{
|
|
9906
10329
|
let sawArrowFeature = false;
|
|
9907
10330
|
const arrowLines = [];
|
|
9908
|
-
|
|
10331
|
+
const pushArrow = (styled, record) => {
|
|
10332
|
+
const { s, e } = record ? featureInterval(record) : { s: NaN, e: NaN };
|
|
10333
|
+
arrowLines.push(isIntervalVisible(s, e, timelineWindow) ? styled : { ...styled, properties: { ...styled.properties, "stroke-opacity": 0, "fill-opacity": 0 } });
|
|
10334
|
+
};
|
|
10335
|
+
sourceData.features.forEach((f, i) => {
|
|
9909
10336
|
var _a2;
|
|
9910
10337
|
const isArrow = ((_a2 = f.properties) == null ? void 0 : _a2.kind) === "arrow" || arrowFeatureIdsRef.current.has(String(f.id));
|
|
9911
10338
|
if (!isArrow) return;
|
|
9912
10339
|
sawArrowFeature = true;
|
|
9913
|
-
if (f.geometry.type === "LineString")
|
|
10340
|
+
if (f.geometry.type === "LineString") pushArrow(f, allFeatures[i]);
|
|
9914
10341
|
});
|
|
9915
10342
|
const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
|
|
9916
10343
|
var _a2;
|
|
@@ -9918,7 +10345,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9918
10345
|
})) ?? [];
|
|
9919
10346
|
if (shardArrows.length > 0) {
|
|
9920
10347
|
sawArrowFeature = true;
|
|
9921
|
-
|
|
10348
|
+
shardArrows.forEach((f) => pushArrow(f, getReadOnlyFeatureById(String(f.id))));
|
|
9922
10349
|
}
|
|
9923
10350
|
hasArrowFeaturesRef.current = sawArrowFeature;
|
|
9924
10351
|
paintedArrowLinesRef.current = arrowLines;
|
|
@@ -9948,7 +10375,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9948
10375
|
} finally {
|
|
9949
10376
|
isSyncingRef.current = false;
|
|
9950
10377
|
}
|
|
9951
|
-
}, [layers, hashStringToColor$1, autoLabelConfig, countVisibleFeatures, renderArrowOverlays]);
|
|
10378
|
+
}, [layers, hashStringToColor$1, autoLabelConfig, countVisibleFeatures, renderArrowOverlays, getReadOnlyFeatureById, isTimelineSourceActive]);
|
|
9952
10379
|
const update3DFlightPaths = react.useCallback(() => {
|
|
9953
10380
|
var _a;
|
|
9954
10381
|
if (!map.current || !is3DTerrainEnabled) {
|
|
@@ -9962,11 +10389,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9962
10389
|
return;
|
|
9963
10390
|
}
|
|
9964
10391
|
const mapInstance = map.current;
|
|
9965
|
-
const
|
|
9966
|
-
const
|
|
9967
|
-
if (
|
|
9968
|
-
const
|
|
9969
|
-
return
|
|
10392
|
+
const timelineWindow = timelineWindowRef.current;
|
|
10393
|
+
const visibleIn = (features) => {
|
|
10394
|
+
if (timelineWindow === null) return [...features];
|
|
10395
|
+
const index = getTimelineIndex(features);
|
|
10396
|
+
return features.filter((_, p) => isVisibleAt(index, p, timelineWindow));
|
|
9970
10397
|
};
|
|
9971
10398
|
const allFeatures = [];
|
|
9972
10399
|
const currentLayers = layersRef.current;
|
|
@@ -9976,9 +10403,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9976
10403
|
if (((_a = l.traceConfig) == null ? void 0 : _a.enabled) !== true) continue;
|
|
9977
10404
|
for (const featureId of l.featureIds) traceFeatureIds.add(featureId);
|
|
9978
10405
|
}
|
|
9979
|
-
const drawFeatures = draw.current.getAll().features.filter(
|
|
9980
|
-
(feature) => isFeatureVisibleInTimeline(feature) && traceFeatureIds.has(feature.id)
|
|
9981
|
-
);
|
|
10406
|
+
const drawFeatures = draw.current.getAll().features.filter((feature) => traceFeatureIds.has(feature.id) && isFeatureVisible(feature, timelineWindow));
|
|
9982
10407
|
pushAll(allFeatures, drawFeatures);
|
|
9983
10408
|
}
|
|
9984
10409
|
readOnlyFeatures.current.forEach((features, layerId2) => {
|
|
@@ -9987,8 +10412,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
9987
10412
|
const altitudeMode = (layer2 == null ? void 0 : layer2.altitudeDisplayMode) ?? "both";
|
|
9988
10413
|
const traceEnabled = ((_a2 = layer2 == null ? void 0 : layer2.traceConfig) == null ? void 0 : _a2.enabled) === true;
|
|
9989
10414
|
if ((layer2 == null ? void 0 : layer2.visible) && traceEnabled && (altitudeMode === "3d" || altitudeMode === "both")) {
|
|
9990
|
-
|
|
9991
|
-
pushAll(allFeatures, visibleFeatures);
|
|
10415
|
+
pushAll(allFeatures, visibleIn(features));
|
|
9992
10416
|
}
|
|
9993
10417
|
});
|
|
9994
10418
|
const flightPaths = extract3DFlightPaths(allFeatures);
|
|
@@ -10047,11 +10471,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10047
10471
|
const fingerprint = buildShardFingerprint(layer, features, shardSize2);
|
|
10048
10472
|
const expectedShards = shardRanges(features.length, shardSize2).length;
|
|
10049
10473
|
if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
return;
|
|
10054
|
-
}
|
|
10474
|
+
setLayerImporting(layer.id, false);
|
|
10475
|
+
mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
|
|
10476
|
+
return;
|
|
10055
10477
|
}
|
|
10056
10478
|
if (shardFingerprintsEqual(state.inFlightFingerprint, fingerprint)) {
|
|
10057
10479
|
setLayerImporting(layer.id, true);
|
|
@@ -10082,19 +10504,22 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10082
10504
|
isCurrent: () => map.current !== null && state.generation === generation,
|
|
10083
10505
|
contextForShard: () => {
|
|
10084
10506
|
return {
|
|
10085
|
-
timelineVisibleIds: timelineVisibleIdsRef.current,
|
|
10086
10507
|
sizeFieldRanges,
|
|
10087
10508
|
colorFieldRanges,
|
|
10088
10509
|
// Trace-enabled layers are never sharded, so these are empty by construction.
|
|
10089
10510
|
tracePointIds: EMPTY_ID_SET,
|
|
10090
|
-
lastTracePointIds: EMPTY_ID_SET,
|
|
10091
|
-
lastTracePointLabels: EMPTY_LABEL_MAP,
|
|
10092
10511
|
tracePointColors: EMPTY_LABEL_MAP
|
|
10093
10512
|
};
|
|
10094
10513
|
},
|
|
10095
|
-
onShardPainted: (index,
|
|
10514
|
+
onShardPainted: (index, start, end) => {
|
|
10096
10515
|
var _a2;
|
|
10097
|
-
|
|
10516
|
+
seedTimelineSource(
|
|
10517
|
+
featureStateHostFor(m),
|
|
10518
|
+
appliedTimelineRef.current,
|
|
10519
|
+
shardSourceId(layer.id, index),
|
|
10520
|
+
[{ features, start, end }],
|
|
10521
|
+
timelineWindowRef.current
|
|
10522
|
+
);
|
|
10098
10523
|
(_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
|
|
10099
10524
|
overlayRestyled = true;
|
|
10100
10525
|
},
|
|
@@ -10128,7 +10553,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10128
10553
|
}, [update3DFlightPaths]);
|
|
10129
10554
|
react.useEffect(() => {
|
|
10130
10555
|
update3DFlightPaths();
|
|
10131
|
-
}, [update3DFlightPaths, layers, is3DTerrainEnabled
|
|
10556
|
+
}, [update3DFlightPaths, layers, is3DTerrainEnabled]);
|
|
10132
10557
|
react.useEffect(() => {
|
|
10133
10558
|
if (map.current && is3DTerrainEnabled) {
|
|
10134
10559
|
const timer = setTimeout(() => {
|
|
@@ -10621,7 +11046,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10621
11046
|
"text-opacity": ["coalesce", ["get", "stroke-opacity"], 1]
|
|
10622
11047
|
}
|
|
10623
11048
|
});
|
|
10624
|
-
mapInstance.addSource(
|
|
11049
|
+
mapInstance.addSource(TRACE_SOURCE_ID, {
|
|
10625
11050
|
type: "geojson",
|
|
10626
11051
|
data: { type: "FeatureCollection", features: [] },
|
|
10627
11052
|
maxzoom: 22
|
|
@@ -10629,13 +11054,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
10629
11054
|
mapInstance.addLayer({
|
|
10630
11055
|
id: "trace-lines",
|
|
10631
11056
|
type: "line",
|
|
10632
|
-
source:
|
|
11057
|
+
source: TRACE_SOURCE_ID,
|
|
11058
|
+
filter: ["==", "$type", "LineString"],
|
|
10633
11059
|
paint: {
|
|
10634
11060
|
"line-color": ["get", "color"],
|
|
10635
11061
|
"line-width": 2,
|
|
10636
11062
|
"line-opacity": 0.7
|
|
10637
11063
|
}
|
|
10638
11064
|
});
|
|
11065
|
+
mapInstance.addLayer(buildTraceEndpointLabelLayer());
|
|
10639
11066
|
mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
|
|
10640
11067
|
type: "geojson",
|
|
10641
11068
|
data: { type: "FeatureCollection", features: [] },
|
|
@@ -13293,8 +13720,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13293
13720
|
if (!m.getLayer(id)) return;
|
|
13294
13721
|
m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
|
|
13295
13722
|
});
|
|
13296
|
-
if (!firstVisibleBasemapSymbol
|
|
13297
|
-
|
|
13723
|
+
if (!firstVisibleBasemapSymbol) {
|
|
13724
|
+
[TRACE_ENDPOINT_LABEL_LAYER_ID, SELECTION_OVERLAY_LAYER_IDS.label].forEach((id) => {
|
|
13725
|
+
if (m.getLayer(id)) m.moveLayer(id);
|
|
13726
|
+
});
|
|
13298
13727
|
}
|
|
13299
13728
|
} catch (e) {
|
|
13300
13729
|
console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
|
|
@@ -13612,7 +14041,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13612
14041
|
if (!layer) return [];
|
|
13613
14042
|
const fieldsMap = /* @__PURE__ */ new Map();
|
|
13614
14043
|
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity", ...STYLING_PROPERTY_KEYS]);
|
|
13615
|
-
const
|
|
14044
|
+
const MAX_SAMPLES2 = 1e4;
|
|
13616
14045
|
let features = [];
|
|
13617
14046
|
if (layer.readOnly) {
|
|
13618
14047
|
features = readOnlyFeatures.current.get(layerId) || [];
|
|
@@ -13621,8 +14050,8 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13621
14050
|
} else {
|
|
13622
14051
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
13623
14052
|
}
|
|
13624
|
-
const sampled = !layer.readOnly && features.length >
|
|
13625
|
-
const sampleFeatures = layer.readOnly ? features : features.slice(0,
|
|
14053
|
+
const sampled = !layer.readOnly && features.length > MAX_SAMPLES2;
|
|
14054
|
+
const sampleFeatures = layer.readOnly ? features : features.slice(0, MAX_SAMPLES2);
|
|
13626
14055
|
sampleFeatures.forEach((f) => {
|
|
13627
14056
|
if (f && f.properties) {
|
|
13628
14057
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
@@ -13670,15 +14099,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13670
14099
|
} else {
|
|
13671
14100
|
features = hiddenFeatures.current.get(layerId) || [];
|
|
13672
14101
|
}
|
|
13673
|
-
const
|
|
13674
|
-
const sample = features.slice(0,
|
|
13675
|
-
const
|
|
14102
|
+
const MAX_SAMPLES2 = 1e4;
|
|
14103
|
+
const sample = features.slice(0, MAX_SAMPLES2);
|
|
14104
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
13676
14105
|
for (const f of sample) {
|
|
13677
14106
|
const key = categoricalKey((_a = f == null ? void 0 : f.properties) == null ? void 0 : _a[fieldName]);
|
|
13678
14107
|
if (key === null) continue;
|
|
13679
|
-
|
|
14108
|
+
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
13680
14109
|
}
|
|
13681
|
-
return Array.from(
|
|
14110
|
+
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 }));
|
|
13682
14111
|
},
|
|
13683
14112
|
[layers]
|
|
13684
14113
|
);
|
|
@@ -13744,21 +14173,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13744
14173
|
});
|
|
13745
14174
|
}
|
|
13746
14175
|
}, [layers]);
|
|
14176
|
+
const traceFieldSource = react.useCallback((layer) => {
|
|
14177
|
+
if (layer.readOnly) return readOnlyFeatures.current.get(layer.id) || [];
|
|
14178
|
+
if (layer.visible) return draw.current ? layer.featureIds.map((id) => draw.current.get(id)) : [];
|
|
14179
|
+
return hiddenFeatures.current.get(layer.id) || [];
|
|
14180
|
+
}, []);
|
|
13747
14181
|
const getAvailableTraceFields = react.useCallback((layerId) => {
|
|
13748
14182
|
const layer = layers.find((l) => l.id === layerId);
|
|
13749
14183
|
if (!layer) return [];
|
|
13750
14184
|
const fieldsSet = /* @__PURE__ */ new Set();
|
|
13751
14185
|
const excludedFields = /* @__PURE__ */ new Set(["name", "startDate", "endDate", "opacity"]);
|
|
13752
|
-
const
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
features = readOnlyFeatures.current.get(layerId) || [];
|
|
13756
|
-
} else if (layer.visible) {
|
|
13757
|
-
features = draw.current ? layer.featureIds.map((id) => draw.current.get(id)) : [];
|
|
13758
|
-
} else {
|
|
13759
|
-
features = hiddenFeatures.current.get(layerId) || [];
|
|
13760
|
-
}
|
|
13761
|
-
const sampleFeatures = features.slice(0, MAX_SAMPLES);
|
|
14186
|
+
const MAX_SAMPLES2 = 1e4;
|
|
14187
|
+
const features = traceFieldSource(layer);
|
|
14188
|
+
const sampleFeatures = features.slice(0, MAX_SAMPLES2);
|
|
13762
14189
|
sampleFeatures.forEach((f) => {
|
|
13763
14190
|
if (f && f.properties) {
|
|
13764
14191
|
Object.entries(f.properties).forEach(([key, value]) => {
|
|
@@ -13769,7 +14196,11 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13769
14196
|
}
|
|
13770
14197
|
});
|
|
13771
14198
|
return Array.from(fieldsSet).sort();
|
|
13772
|
-
}, [layers]);
|
|
14199
|
+
}, [layers, traceFieldSource]);
|
|
14200
|
+
const getSuggestedTraceField = react.useCallback((layerId) => {
|
|
14201
|
+
const layer = layers.find((l) => l.id === layerId);
|
|
14202
|
+
return layer ? suggestTraceGroupField(traceFieldSource(layer), getAvailableTraceFields(layerId)) : null;
|
|
14203
|
+
}, [layers, traceFieldSource, getAvailableTraceFields]);
|
|
13773
14204
|
const handleMeasureModeChange = react.useCallback((mode) => {
|
|
13774
14205
|
setMeasureMode(mode);
|
|
13775
14206
|
setMeasurePoints([]);
|
|
@@ -13859,18 +14290,24 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13859
14290
|
if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
|
|
13860
14291
|
if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
|
|
13861
14292
|
});
|
|
13862
|
-
return { ...base,
|
|
14293
|
+
return { ...base, sizeFieldRanges, colorFieldRanges };
|
|
13863
14294
|
}, []);
|
|
13864
14295
|
const overlayFeatureCountRef = react.useRef(0);
|
|
13865
|
-
const overlayTimelineInputsRef = react.useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
|
|
13866
14296
|
const refreshSelectionOverlay = react.useCallback((m, ids) => {
|
|
13867
|
-
overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
|
|
13868
14297
|
if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
|
|
13869
14298
|
const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
|
|
13870
14299
|
if (!overlay) return;
|
|
13871
14300
|
const ctx = ids.size > 0 ? overlayPaintContext() : null;
|
|
13872
14301
|
const layers2 = layersRef.current;
|
|
13873
14302
|
const layerById = new Map(layers2.map((l) => [l.id, l]));
|
|
14303
|
+
const styled = (feature, layer, paintCtx, sourceId) => {
|
|
14304
|
+
const out = styleFeatureForPaint(feature, layer, paintCtx, true).feature;
|
|
14305
|
+
if (isTimelineHiddenOn(appliedTimelineRef.current, sourceId, String(feature.id)) && out.properties) {
|
|
14306
|
+
out.properties["stroke-opacity"] = 0;
|
|
14307
|
+
out.properties["fill-opacity"] = 0;
|
|
14308
|
+
}
|
|
14309
|
+
return out;
|
|
14310
|
+
};
|
|
13874
14311
|
const data = buildSelectionOverlayData(ids, (id) => {
|
|
13875
14312
|
if (!ctx) return [];
|
|
13876
14313
|
const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
|
|
@@ -13878,12 +14315,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13878
14315
|
return holders.filter((h) => {
|
|
13879
14316
|
var _a;
|
|
13880
14317
|
return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
|
|
13881
|
-
}).map((h) =>
|
|
14318
|
+
}).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));
|
|
13882
14319
|
}
|
|
13883
14320
|
const feature = getFeatureById(id);
|
|
13884
14321
|
if (!feature) return [];
|
|
13885
14322
|
const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
|
|
13886
|
-
return layer && !layer.visible ? [] : [
|
|
14323
|
+
return layer && !layer.visible ? [] : [styled(feature, layer, ctx, SHARED_SOURCE_ID)];
|
|
13887
14324
|
});
|
|
13888
14325
|
overlay.setData(data);
|
|
13889
14326
|
overlayFeatureCountRef.current = data.features.length;
|
|
@@ -13939,35 +14376,42 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
13939
14376
|
const m = map.current;
|
|
13940
14377
|
if (!m) return true;
|
|
13941
14378
|
if (hasArrowFeaturesRef.current) return false;
|
|
13942
|
-
const
|
|
13943
|
-
const
|
|
13944
|
-
const nextVisible = timelineVisibleIdsRef.current;
|
|
14379
|
+
const start = performance.now();
|
|
14380
|
+
const next = timelineWindowRef.current;
|
|
13945
14381
|
const trace = tracePaintCacheRef.current;
|
|
13946
|
-
|
|
13947
|
-
if (trace
|
|
13948
|
-
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
}
|
|
14382
|
+
let endpointsMoved = 0;
|
|
14383
|
+
if (trace) {
|
|
14384
|
+
const traceSource = m.getSource(TRACE_SOURCE_ID);
|
|
14385
|
+
if (!traceSource) return false;
|
|
14386
|
+
const traceDiff = buildTraceTimelineDiff(trace, next);
|
|
14387
|
+
if (!applyTraceTimelineDiff(traceDiff, traceSource, featureStateHostFor(m), traceEndpointsRef.current)) return false;
|
|
14388
|
+
trace.window = next;
|
|
14389
|
+
endpointsMoved = traceDiff.endpointOn.length;
|
|
14390
|
+
}
|
|
14391
|
+
const flipped = applyTimelineWindow(featureStateHostFor(m), appliedTimelineRef.current, next, isTimelineSourceActive);
|
|
13955
14392
|
const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
|
|
13956
|
-
|
|
13957
|
-
|
|
14393
|
+
const count = countVisibleFeatures(threshold);
|
|
14394
|
+
if (tickCountTimerRef.current) clearTimeout(tickCountTimerRef.current);
|
|
14395
|
+
tickCountTimerRef.current = null;
|
|
14396
|
+
if (count < threshold !== visibleFeatureCountRef.current < threshold) setVisibleFeatureCount(count);
|
|
14397
|
+
else if (count !== visibleFeatureCountRef.current) {
|
|
14398
|
+
tickCountTimerRef.current = setTimeout(() => setVisibleFeatureCount(countVisibleFeatures(threshold)), TICK_COUNT_SETTLE_MS);
|
|
14399
|
+
}
|
|
14400
|
+
if (labelsSuppressedRef.current) setLabelsSuppressed(false);
|
|
13958
14401
|
const selection = currentSelection() ?? EMPTY_ID_SET;
|
|
13959
|
-
if (
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
segmentsAdded: (traceDiff == null ? void 0 : traceDiff.segmentAdd.length) ?? 0,
|
|
13966
|
-
segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
|
|
14402
|
+
if (selection.size > 0 && flipped.some((id) => selection.has(id))) refreshSelectionOverlay(m, selection);
|
|
14403
|
+
mapPerfLog("timeline", "applied", {
|
|
14404
|
+
flipped: flipped.length,
|
|
14405
|
+
sources: appliedTimelineRef.current.size,
|
|
14406
|
+
endpointsMoved,
|
|
14407
|
+
ms: Math.round(performance.now() - start)
|
|
13967
14408
|
});
|
|
13968
14409
|
return true;
|
|
13969
|
-
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
|
|
14410
|
+
}, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay, isTimelineSourceActive]);
|
|
13970
14411
|
tryTimelineFastPathRef.current = tryTimelineFastPath;
|
|
14412
|
+
react.useEffect(() => () => {
|
|
14413
|
+
if (tickCountTimerRef.current) clearTimeout(tickCountTimerRef.current);
|
|
14414
|
+
}, []);
|
|
13971
14415
|
const collectSelectionFeatureGroups = react.useCallback(() => {
|
|
13972
14416
|
return collectVisibleFeatureGroups(
|
|
13973
14417
|
draw.current ? draw.current.getAll().features : null,
|
|
@@ -15485,25 +15929,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
15485
15929
|
const handleDropGeoJSONFile = react.useCallback((name, file) => {
|
|
15486
15930
|
void ingestDroppedLayer(name, file);
|
|
15487
15931
|
}, [ingestDroppedLayer]);
|
|
15488
|
-
const
|
|
15489
|
-
if (!draw.current || !map.current) return;
|
|
15490
|
-
const nextVisible = new Set(visibleIds);
|
|
15491
|
-
untimedIds.forEach((id) => nextVisible.add(id));
|
|
15492
|
-
timelineVisibleIdsRef.current = nextVisible;
|
|
15493
|
-
scheduleSync("timeline");
|
|
15494
|
-
}, [scheduleSync]);
|
|
15495
|
-
const prevTimelineEnabledRef = react.useRef(timelineStore.isEnabled);
|
|
15932
|
+
const prevTimelineEnabledRef = react.useRef(timelineEnabled);
|
|
15496
15933
|
react.useEffect(() => {
|
|
15497
15934
|
const wasEnabled = prevTimelineEnabledRef.current;
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
timelineVisibleIdsRef.current = null;
|
|
15502
|
-
scheduleSync("timeline");
|
|
15503
|
-
} else if (!wasEnabled && isNowEnabled) {
|
|
15504
|
-
updateTimelineStore();
|
|
15505
|
-
}
|
|
15506
|
-
}, [timelineStore.isEnabled, timelineStore.hasTemporalData, scheduleSync, updateTimelineStore, scheduleTimelineUpdate]);
|
|
15935
|
+
prevTimelineEnabledRef.current = timelineEnabled;
|
|
15936
|
+
if (!wasEnabled && timelineEnabled && timelineHasData) updateTimelineStore();
|
|
15937
|
+
}, [timelineEnabled, timelineHasData, updateTimelineStore]);
|
|
15507
15938
|
react.useEffect(() => {
|
|
15508
15939
|
if (!map.current || !draw.current || !isMapLoaded) return;
|
|
15509
15940
|
const mapInstance = map.current;
|
|
@@ -15727,14 +16158,14 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
15727
16158
|
let categoryColorMap = {};
|
|
15728
16159
|
let hasOtherBucket = false;
|
|
15729
16160
|
if (groupByField) {
|
|
15730
|
-
const
|
|
16161
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
15731
16162
|
pointFeatures.forEach((f) => {
|
|
15732
16163
|
var _a2;
|
|
15733
16164
|
const key = categoricalKey((_a2 = f.properties) == null ? void 0 : _a2[groupByField]);
|
|
15734
16165
|
if (key === null) return;
|
|
15735
|
-
|
|
16166
|
+
counts2.set(key, (counts2.get(key) ?? 0) + 1);
|
|
15736
16167
|
});
|
|
15737
|
-
const sorted = Array.from(
|
|
16168
|
+
const sorted = Array.from(counts2.entries()).sort((a, b) => b[1] - a[1]);
|
|
15738
16169
|
const topKeys = sorted.slice(0, MAX_CATEGORIES).map(([k]) => k);
|
|
15739
16170
|
categoryValues = [...topKeys];
|
|
15740
16171
|
hasOtherBucket = true;
|
|
@@ -16255,21 +16686,21 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
16255
16686
|
] })
|
|
16256
16687
|
}
|
|
16257
16688
|
),
|
|
16258
|
-
enableTimeline &&
|
|
16689
|
+
enableTimeline && timelineHasData && /* @__PURE__ */ jsxRuntime.jsx(
|
|
16259
16690
|
"div",
|
|
16260
16691
|
{
|
|
16261
16692
|
className: "absolute left-4 z-[200] transition-all",
|
|
16262
|
-
style: { bottom:
|
|
16693
|
+
style: { bottom: timelineEnabled ? TIMEBAR_HEIGHT + TIMEBAR_BOTTOM_OFFSET + 8 : 48 },
|
|
16263
16694
|
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: "Timeline", placement: "right", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16264
16695
|
antd.Button,
|
|
16265
16696
|
{
|
|
16266
16697
|
type: "default",
|
|
16267
16698
|
icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "w-5 h-5" }),
|
|
16268
|
-
onClick: () =>
|
|
16699
|
+
onClick: () => timelineStoreApi.getState().setEnabled(!timelineEnabled),
|
|
16269
16700
|
disabled: !isMapLoaded,
|
|
16270
|
-
className: `!w-10 !h-10 !min-w-0 !p-0 bg-background shadow-lg ${
|
|
16701
|
+
className: `!w-10 !h-10 !min-w-0 !p-0 bg-background shadow-lg ${timelineEnabled ? "bg-primary/10" : ""}`,
|
|
16271
16702
|
"aria-label": "Toggle timeline",
|
|
16272
|
-
"aria-pressed":
|
|
16703
|
+
"aria-pressed": timelineEnabled,
|
|
16273
16704
|
"data-testid": "button-toggle-timeline"
|
|
16274
16705
|
}
|
|
16275
16706
|
) })
|
|
@@ -16328,6 +16759,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
16328
16759
|
onMapStyleChange: handleMapStyleChange,
|
|
16329
16760
|
onUpdateTraceConfig: handleUpdateTraceConfig,
|
|
16330
16761
|
getAvailableTraceFields,
|
|
16762
|
+
getSuggestedTraceField,
|
|
16331
16763
|
getFieldValueDistribution,
|
|
16332
16764
|
onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
|
|
16333
16765
|
onUpdateClusterConfig: handleUpdateClusterConfig,
|
|
@@ -16407,12 +16839,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
16407
16839
|
selectionMode
|
|
16408
16840
|
}
|
|
16409
16841
|
),
|
|
16410
|
-
enableTimeline &&
|
|
16842
|
+
enableTimeline && timelineEnabled && /* @__PURE__ */ jsxRuntime.jsx(
|
|
16411
16843
|
Timebar,
|
|
16412
16844
|
{
|
|
16413
|
-
onFilterChange: handleTimelineFilterChange,
|
|
16414
16845
|
selectedFeatureIds,
|
|
16415
16846
|
selectedFeatureColors,
|
|
16847
|
+
selectionDisplay: "line",
|
|
16416
16848
|
timebarExtra
|
|
16417
16849
|
}
|
|
16418
16850
|
),
|
|
@@ -16445,7 +16877,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
|
|
|
16445
16877
|
IngestProgressOverlay,
|
|
16446
16878
|
{
|
|
16447
16879
|
store: ingestProgressStore,
|
|
16448
|
-
bottomPx:
|
|
16880
|
+
bottomPx: timelineEnabled ? TIMEBAR_HEIGHT + TIMEBAR_BOTTOM_OFFSET + 8 : 32
|
|
16449
16881
|
}
|
|
16450
16882
|
),
|
|
16451
16883
|
/* @__PURE__ */ jsxRuntime.jsx(
|