feat(junction): establish stable complex junction structure

This commit is contained in:
que01 committed 2026-09-08 11:25:57 +08:00
1 parent bd8b55e58b
commit 0a5a229ce3
22 files changed
+1386 -125

No files matched your search

@@ -10,6 +10,7 @@ import type { WorkbenchState } from '../types/state';
import type { Coordinate } from '../edit/meters';
import { junctionLabelForHandle, junctionRoadName } from './labels';
import { junctionFacilities } from './facilities';
import { junctionCapabilityReason, structureForJunction } from './structure';
import { SignalEditor } from '../components/ElementEditors';
interface Props {
@@ -175,7 +176,7 @@ export function JunctionWorkspace({
() => (state ? junctionFacilities(state, descriptor.nodeIds, roads) : []),
[descriptor.nodeIds, roads, state],
);
const structure = state?.junctionStructure;
const structure = structureForJunction(state, descriptor.ref);
const standardDiagnostics = state?.standardsDiagnostics || [];
return (
<section className="junction-workspace" aria-label="路口编辑工作区">
@@ -237,6 +238,7 @@ export function JunctionWorkspace({
{state.junctionReference.source || '已加载参考文件'}
</p>
) : null}
{structure.capability?.reason ? <p>{junctionCapabilityReason(structure.capability.reason)}</p> : null}
<dl>
<dt>道路臂</dt>
<dd>
@@ -248,6 +250,8 @@ export function JunctionWorkspace({
key={arm.key}
className={selectedObjectKey === arm.key ? 'is-selected' : undefined}
onClick={() => onSelectObject?.(arm.key)}
aria-pressed={selectedObjectKey === arm.key}
title={junctionCapabilityReason(arm.capability?.reason)}
>
{arm.label}
</button>
@@ -258,7 +262,26 @@ export function JunctionWorkspace({
)}
</dd>
<dt>角部</dt>
<dd>{structure.corners.length ? structure.corners.map((corner) => corner.label).join('、') : '无'}</dd>
<dd>
{structure.corners.length ? (
<span className="junction-workspace__object-list">
{structure.corners.map((corner) => (
<button
type="button"
key={corner.key}
className={selectedObjectKey === corner.key ? 'is-selected' : undefined}
aria-pressed={selectedObjectKey === corner.key}
title={junctionCapabilityReason(corner.capability?.reason)}
onClick={() => onSelectObject?.(corner.key)}
>
{corner.label}
</button>
))}
</span>
) : (
'无'
)}
</dd>
<dt>设施</dt>
<dd>
{structure.facilities.length ? (
@@ -270,7 +293,16 @@ export function JunctionWorkspace({
<summary>已识别 {structure.facilities.length} 项设施</summary>
<ul>
{structure.facilities.map((facility) => (
<li key={facility.key}>{facility.label}</li>
<li key={facility.key}>
<button
type="button"
aria-pressed={selectedObjectKey === facility.key}
title={junctionCapabilityReason(facility.capability?.reason)}
onClick={() => onSelectObject?.(facility.key)}
>
{facility.label}
</button>
</li>
))}
</ul>
</details>