feat(workbench): summarize junction facilities and diagnostics
This commit is contained in:
1 parent
1bd1fd712f
commit
ecfa391eea
2 files changed
+46
No files matched your search
@@ -207,6 +207,29 @@ function App() {
|
||||
nodeIds.has(String(handle.anchor.nodeId)),
|
||||
);
|
||||
}, [editMode, junctionDescriptor, manifest]);
|
||||
const junctionFacilitySummary = useMemo(() => {
|
||||
if (!junctionDescriptor || !state) return { crosswalks: 0, stopLines: 0, signals: 0 };
|
||||
const nodeIds = new Set(junctionDescriptor.nodeIds.map(String));
|
||||
const crossingIds = new Set(
|
||||
(state.layers.crosswalks?.features ?? [])
|
||||
.filter((feature) => nodeIds.has(String(feature.properties?.crossing_node_id)))
|
||||
.map((feature) => String(feature.properties?.crossing_node_id)),
|
||||
);
|
||||
const stopLines = (state.layers.vehicleStopLines?.features ?? []).filter((feature) =>
|
||||
nodeIds.has(String(feature.properties?.crossing_node_id)),
|
||||
).length;
|
||||
const signals = state.trafficSignals.assemblies.features.filter((feature) =>
|
||||
nodeIds.has(String(feature.properties?.node_id)),
|
||||
).length;
|
||||
return { crosswalks: crossingIds.size, stopLines, signals };
|
||||
}, [junctionDescriptor, state]);
|
||||
const junctionDiagnostics = useMemo(() => {
|
||||
if (!junctionDescriptor || !state) return [];
|
||||
const ids = new Set(junctionDescriptor.diagnosticIds);
|
||||
return state.compiled.diagnostics.filter(
|
||||
(item) => ids.has(item.id) || item.subjectId === junctionDescriptor.ref.id,
|
||||
);
|
||||
}, [junctionDescriptor, state]);
|
||||
// A greyed handle without a reason reads as a bug rather than an ownership
|
||||
// boundary, so the first blocked handle explains itself in the header.
|
||||
const blockedHandle = editHandles.find((handle) => !handle.editable);
|
||||
@@ -999,6 +1022,8 @@ function App() {
|
||||
<JunctionWorkspace
|
||||
descriptor={junctionDescriptor}
|
||||
session={junctionSession}
|
||||
diagnostics={junctionDiagnostics}
|
||||
facilitySummary={junctionFacilitySummary}
|
||||
onClose={closeJunction}
|
||||
onApply={() => setJunctionSession((current) => (current ? applyJunctionDraft(current) : current))}
|
||||
onDiscard={() => setJunctionSession((current) => (current ? cancelJunctionSession(current) : current))}
|
||||
|
||||
Reference in new issue
Block a user