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)),
|
nodeIds.has(String(handle.anchor.nodeId)),
|
||||||
);
|
);
|
||||||
}, [editMode, junctionDescriptor, manifest]);
|
}, [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
|
// 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.
|
// boundary, so the first blocked handle explains itself in the header.
|
||||||
const blockedHandle = editHandles.find((handle) => !handle.editable);
|
const blockedHandle = editHandles.find((handle) => !handle.editable);
|
||||||
@@ -999,6 +1022,8 @@ function App() {
|
|||||||
<JunctionWorkspace
|
<JunctionWorkspace
|
||||||
descriptor={junctionDescriptor}
|
descriptor={junctionDescriptor}
|
||||||
session={junctionSession}
|
session={junctionSession}
|
||||||
|
diagnostics={junctionDiagnostics}
|
||||||
|
facilitySummary={junctionFacilitySummary}
|
||||||
onClose={closeJunction}
|
onClose={closeJunction}
|
||||||
onApply={() => setJunctionSession((current) => (current ? applyJunctionDraft(current) : current))}
|
onApply={() => setJunctionSession((current) => (current ? applyJunctionDraft(current) : current))}
|
||||||
onDiscard={() => setJunctionSession((current) => (current ? cancelJunctionSession(current) : current))}
|
onDiscard={() => setJunctionSession((current) => (current ? cancelJunctionSession(current) : current))}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import type { EditHandle } from '../edit/types';
|
|||||||
interface Props {
|
interface Props {
|
||||||
descriptor: JunctionDescriptor;
|
descriptor: JunctionDescriptor;
|
||||||
session: JunctionSession;
|
session: JunctionSession;
|
||||||
|
diagnostics?: Array<{ id: string; message: string; rule: string; severity?: string }>;
|
||||||
|
facilitySummary?: { crosswalks: number; stopLines: number; signals: number };
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onApply: () => void;
|
onApply: () => void;
|
||||||
onDiscard: () => void;
|
onDiscard: () => void;
|
||||||
@@ -26,6 +28,8 @@ export function JunctionWorkspace({
|
|||||||
onApply,
|
onApply,
|
||||||
onDiscard,
|
onDiscard,
|
||||||
onSave,
|
onSave,
|
||||||
|
diagnostics = [],
|
||||||
|
facilitySummary = { crosswalks: 0, stopLines: 0, signals: 0 },
|
||||||
handles = [],
|
handles = [],
|
||||||
onDraft,
|
onDraft,
|
||||||
onSettle,
|
onSettle,
|
||||||
@@ -59,6 +63,23 @@ export function JunctionWorkspace({
|
|||||||
{session.dirty ? '(有未应用草稿)' : ''}
|
{session.dirty ? '(有未应用草稿)' : ''}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
<section className="junction-workspace__validation" aria-label="路口验证">
|
||||||
|
<h3>设施与验证</h3>
|
||||||
|
<p>
|
||||||
|
斑马线 {facilitySummary.crosswalks} · 停止线 {facilitySummary.stopLines} · 信号灯 {facilitySummary.signals}
|
||||||
|
</p>
|
||||||
|
{diagnostics.length ? (
|
||||||
|
<ul>
|
||||||
|
{diagnostics.map((item) => (
|
||||||
|
<li key={item.id} className={item.severity === 'error' ? 'blocking' : ''}>
|
||||||
|
<strong>{item.severity === 'error' ? '阻塞' : '提示'}</strong> {item.message}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
) : (
|
||||||
|
<p>当前路口没有诊断问题。</p>
|
||||||
|
)}
|
||||||
|
</section>
|
||||||
{editable ? (
|
{editable ? (
|
||||||
<>
|
<>
|
||||||
<ParameterPanel
|
<ParameterPanel
|
||||||
|
|||||||
Reference in new issue
Block a user