refactor(workbench): split editor state and components
This commit is contained in:
1 parent
caa3cb843f
commit
834470cfa1
23 files changed
+1219
-878
No files matched your search
@@ -0,0 +1,297 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { ElementSelection } from '../edit/element';
|
||||
import type { GeoFeature, Override, WorkbenchState } from '../types/state';
|
||||
import { Button } from '../ui/button';
|
||||
|
||||
const maneuverOptions: Array<[string, string]> = [
|
||||
['', '无箭头'],
|
||||
['through', '直行'],
|
||||
['left', '左转'],
|
||||
['right', '右转'],
|
||||
['through;left', '直行或左转'],
|
||||
['through;right', '直行或右转'],
|
||||
['through;left;right', '直行、左转或右转'],
|
||||
];
|
||||
|
||||
const laneIndex = (id: string) => Number(id.split(':').at(-1));
|
||||
|
||||
export function LaneManeuverEditor({
|
||||
element,
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
element: ElementSelection | null;
|
||||
value?: { maneuver?: string; placementDistanceMeters?: number };
|
||||
onChange: (maneuver: string, placementDistanceMeters: number) => void;
|
||||
}) {
|
||||
if (!element || element.kind !== 'lane-maneuver') return null;
|
||||
const maneuver = value?.maneuver ?? element.maneuver;
|
||||
const placementDistanceMeters = value?.placementDistanceMeters ?? element.placementDistanceMeters ?? 6;
|
||||
return (
|
||||
<form className="element-form">
|
||||
<h2>车道转向箭头</h2>
|
||||
<p className="form-context">第 {laneIndex(element.laneId)} 车道。拖曳地图中的虚线箭头可粗调位置。</p>
|
||||
<label>
|
||||
转向
|
||||
<select value={maneuver} onChange={(event) => onChange(event.target.value, placementDistanceMeters)}>
|
||||
{maneuverOptions.map(([optionValue, label]) => (
|
||||
<option value={optionValue} key={optionValue}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
距路口端(米)
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.25"
|
||||
value={placementDistanceMeters}
|
||||
onChange={(event) => {
|
||||
const next = Number(event.target.value);
|
||||
if (Number.isFinite(next) && next >= 0) onChange(maneuver, next);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<p className="form-hint">保存并重新生成时会避开停止线、斑马线和车道端点。</p>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export function MarkingEditor({
|
||||
marking,
|
||||
stage,
|
||||
}: {
|
||||
marking: Record<string, unknown> | null;
|
||||
stage: (item: Override) => void;
|
||||
}) {
|
||||
const style = typeof marking?.effective_style === 'string' ? marking.effective_style : '';
|
||||
const [value, setValue] = useState(style || 'yellow-dashed');
|
||||
useEffect(() => setValue(style || 'yellow-dashed'), [style]);
|
||||
if (!style || !marking) return null;
|
||||
const roadId = String(marking.road_id);
|
||||
const segment = marking.segment_id;
|
||||
const kind = String(marking.provenance || '');
|
||||
const save = () => {
|
||||
const [color, pattern] = value.replace('double-', '').split('-');
|
||||
if (segment)
|
||||
stage({
|
||||
id: `道路中心线:${segment}`,
|
||||
kind: 'center-line-style',
|
||||
segmentId: segment,
|
||||
color,
|
||||
pattern,
|
||||
double: value.startsWith('double-'),
|
||||
});
|
||||
else if (kind.includes('edge-line'))
|
||||
stage({
|
||||
id: `道路外缘线:${roadId}:${marking.side}`,
|
||||
kind: 'edge-line-style',
|
||||
roadId,
|
||||
side: marking.side,
|
||||
color,
|
||||
pattern,
|
||||
});
|
||||
else
|
||||
stage({
|
||||
id: `车道分隔线:${roadId}:${marking.left_lane_index}-${marking.right_lane_index}`,
|
||||
kind: 'lane-separator-style',
|
||||
roadId,
|
||||
leftLaneIndex: marking.left_lane_index,
|
||||
rightLaneIndex: marking.right_lane_index,
|
||||
color,
|
||||
pattern,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<form
|
||||
className="element-form"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
save();
|
||||
}}
|
||||
>
|
||||
<h2>标线样式</h2>
|
||||
<label>
|
||||
样式
|
||||
<select value={value} onChange={(event) => setValue(event.target.value)}>
|
||||
<option value="yellow-dashed">黄色虚线</option>
|
||||
<option value="white-dashed">白色虚线</option>
|
||||
<option value="yellow-solid">黄色实线</option>
|
||||
<option value="white-solid">白色实线</option>
|
||||
{segment ? <option value="double-yellow-solid">双黄实线</option> : null}
|
||||
</select>
|
||||
</label>
|
||||
<Button type="submit">暂存标线样式</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export function SignalEditor({
|
||||
state,
|
||||
signal,
|
||||
status,
|
||||
update,
|
||||
}: {
|
||||
state: WorkbenchState;
|
||||
signal?: GeoFeature;
|
||||
status: (text: string) => void;
|
||||
update: (features: GeoFeature[]) => Promise<void>;
|
||||
}) {
|
||||
const [selected, setSelected] = useState('');
|
||||
useEffect(() => setSelected(String(signal?.properties?.signal_uid || '')), [signal]);
|
||||
const feature = state.trafficSignals.assemblies.features.find((item) => item.properties?.signal_uid === selected);
|
||||
const coordinates =
|
||||
feature?.geometry?.type === 'Point' && Array.isArray(feature.geometry.coordinates)
|
||||
? (feature.geometry.coordinates as [number, number])
|
||||
: null;
|
||||
const saveField = (key: string, value: unknown) => {
|
||||
if (!feature) return;
|
||||
const mastHeading = key === 'mast_heading_deg' ? ((Number(value) % 360) + 360) % 360 : null;
|
||||
void update(
|
||||
state.trafficSignals.assemblies.features.map((item) =>
|
||||
item === feature
|
||||
? {
|
||||
...item,
|
||||
properties: {
|
||||
...item.properties,
|
||||
[key]: mastHeading ?? value,
|
||||
...(mastHeading === null ? {} : { face_heading_deg: (((mastHeading - 90) % 360) + 360) % 360 }),
|
||||
},
|
||||
}
|
||||
: item,
|
||||
),
|
||||
);
|
||||
};
|
||||
const saveCoordinate = (index: 0 | 1, value: number) => {
|
||||
if (!feature || !coordinates || !Number.isFinite(value)) return;
|
||||
const nextCoordinates: [number, number] = [...coordinates];
|
||||
nextCoordinates[index] = value;
|
||||
void update(
|
||||
state.trafficSignals.assemblies.features.map((item) =>
|
||||
item === feature
|
||||
? { ...item, geometry: { ...item.geometry, type: 'Point', coordinates: nextCoordinates } }
|
||||
: item,
|
||||
),
|
||||
);
|
||||
};
|
||||
return (
|
||||
<section className="element-form">
|
||||
<h2>原生红绿灯</h2>
|
||||
<label>
|
||||
检查信号灯
|
||||
<select value={selected} onChange={(event) => setSelected(event.target.value)}>
|
||||
<option value="">选择设施</option>
|
||||
{state.trafficSignals.assemblies.features.map((item) => (
|
||||
<option key={String(item.properties?.signal_uid)} value={String(item.properties?.signal_uid)}>
|
||||
{String(item.properties?.display_id || item.properties?.signal_uid)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{feature ? (
|
||||
<>
|
||||
<label>
|
||||
灯杆经度
|
||||
<input
|
||||
type="number"
|
||||
step="0.000001"
|
||||
value={coordinates?.[0] ?? 0}
|
||||
onChange={(event) => saveCoordinate(0, Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
灯杆纬度
|
||||
<input
|
||||
type="number"
|
||||
step="0.000001"
|
||||
value={coordinates?.[1] ?? 0}
|
||||
onChange={(event) => saveCoordinate(1, Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
横杆方向(度)
|
||||
<input
|
||||
type="number"
|
||||
value={Number(feature.properties?.mast_heading_deg || 0)}
|
||||
onChange={(event) => saveField('mast_heading_deg', Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
横杆长度(米)
|
||||
<input
|
||||
type="number"
|
||||
value={Number(feature.properties?.mast_reach_m || 0)}
|
||||
onChange={(event) => saveField('mast_reach_m', Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
灯面朝向(度)
|
||||
<input type="number" value={Number(feature.properties?.face_heading_deg || 0)} readOnly />
|
||||
</label>
|
||||
<label>
|
||||
相位组
|
||||
<select
|
||||
value={Number(feature.properties?.phase_group || 0)}
|
||||
onChange={(event) => saveField('phase_group', Number(event.target.value))}
|
||||
>
|
||||
<option value={0}>组 0</option>
|
||||
<option value={1}>组 1</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
高程偏移(米)
|
||||
<input
|
||||
type="number"
|
||||
step="0.1"
|
||||
min="-20"
|
||||
max="100"
|
||||
value={Number(feature.properties?.z_offset_m || 0)}
|
||||
onChange={(event) => saveField('z_offset_m', Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<p className="form-hint">
|
||||
控制进口:{String(feature.properties?.approach_id || '未绑定')}
|
||||
<br />
|
||||
来源道路:{String(feature.properties?.source_way_id || '未绑定')}
|
||||
</p>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={Boolean(feature.properties?.enabled)}
|
||||
onChange={(event) => saveField('enabled', event.target.checked)}
|
||||
/>{' '}
|
||||
启用
|
||||
</label>
|
||||
<Button
|
||||
onClick={() =>
|
||||
void update(state.trafficSignals.assemblies.features.filter((item) => item !== feature)).then(() => {
|
||||
setSelected('');
|
||||
status('红绿灯已删除');
|
||||
})
|
||||
}
|
||||
>
|
||||
删除信号灯
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function Candidates({ state, onAccept }: { state: WorkbenchState; onAccept: (index: number) => void }) {
|
||||
const candidates = state.debug?.junctionCandidates || [];
|
||||
if (!candidates.length) return null;
|
||||
return (
|
||||
<section>
|
||||
<hr />
|
||||
<h2>复杂路口候选(debug)</h2>
|
||||
{candidates.map((candidate) => (
|
||||
<Button key={candidate.id} onClick={() => onAccept(candidate.index)}>
|
||||
加入候选 #{candidate.index}({candidate.nodeCount} 节点,{candidate.diameterMeters} 米)
|
||||
</Button>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { useState } from 'react';
|
||||
import { Upload } from 'lucide-react';
|
||||
import type { WorkbenchState } from '../types/state';
|
||||
import { Button } from '../ui/button';
|
||||
|
||||
export function ImportScreen({
|
||||
status,
|
||||
onImport,
|
||||
}: {
|
||||
status: string;
|
||||
onImport: (file: File) => Promise<WorkbenchState>;
|
||||
}) {
|
||||
const [file, setFile] = useState<File>();
|
||||
const [busy, setBusy] = useState(false);
|
||||
return (
|
||||
<section className="import-screen">
|
||||
<form
|
||||
onSubmit={async (event) => {
|
||||
event.preventDefault();
|
||||
if (!file) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await onImport(file);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<h1>导入 OSM 地图</h1>
|
||||
<p>{status}</p>
|
||||
<input
|
||||
type="file"
|
||||
accept=".osm,application/xml,text/xml"
|
||||
onChange={(event) => setFile(event.target.files?.[0])}
|
||||
required
|
||||
/>
|
||||
<Button type="submit" disabled={!file || busy}>
|
||||
<Upload size={16} /> {busy ? '正在导入并编译...' : '导入并编译'}
|
||||
</Button>
|
||||
</form>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
const metrics = [
|
||||
['nativeRoadCount', '方向道路'],
|
||||
['nativeRoadSurfaceFeatures', '道路面'],
|
||||
['nativeJunctionSurfaceFeatures', '路口面'],
|
||||
['nativeCenterLineFeatures', '道路中心线'],
|
||||
['nativeConnectorFeatures', '连接路径'],
|
||||
['nativeCrosswalkFeatures', '斑马线'],
|
||||
['nativeVehicleStopLineFeatures', '停止线'],
|
||||
['unconnectedInteriorRoadEnds', '未连接端点'],
|
||||
] as const;
|
||||
|
||||
export function Overview({ comparison }: { comparison: Record<string, unknown> }) {
|
||||
const severity = comparison.diagnosticsBySeverity as Record<string, number> | undefined;
|
||||
return (
|
||||
<section className="overview">
|
||||
<div className="overview-grid">
|
||||
{metrics.map(([key, label]) => (
|
||||
<div key={key}>
|
||||
<span>{label}</span>
|
||||
<strong>{Number(comparison[key] || 0).toLocaleString('zh-CN')}</strong>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{severity && (
|
||||
<div className="overview-diagnostics">
|
||||
<span>编译诊断</span>
|
||||
{Object.entries(severity).map(([level, count]) => (
|
||||
<strong key={level}>
|
||||
{level === 'error' ? '错误' : level === 'warning' ? '警告' : '提示'} {count}
|
||||
</strong>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
import { useEffect, useState, type ReactNode } from 'react';
|
||||
import { Candidates, LaneManeuverEditor, MarkingEditor, SignalEditor } from './ElementEditors';
|
||||
import { InspectorSection } from './InspectorSection';
|
||||
import type { EditSession } from '../edit/session';
|
||||
import type { ElementSelection } from '../edit/element';
|
||||
import type { Override, GeoFeature, Road, WorkbenchState } from '../types/state';
|
||||
import { Button } from '../ui/button';
|
||||
const laneIndex = (id: string) => Number(id.split(':').at(-1));
|
||||
const direction = (road: Road) => (road.direction === 'forward' ? '沿 OSM 方向' : '逆 OSM 方向');
|
||||
const label = (road: Road) => road.tags.name || `${road.highway}(OSM ${road.osmWayIds.join(', ')})`;
|
||||
export function WorkbenchInspector({
|
||||
road,
|
||||
state,
|
||||
staged,
|
||||
marking,
|
||||
element,
|
||||
stage,
|
||||
status,
|
||||
session,
|
||||
onLaneManeuverChange,
|
||||
updateSignal,
|
||||
onAcceptCandidate,
|
||||
children,
|
||||
}: {
|
||||
road: Road | null;
|
||||
state: WorkbenchState;
|
||||
staged: Override[];
|
||||
marking: Record<string, unknown> | null;
|
||||
element: ElementSelection | null;
|
||||
stage: (item: Override) => void;
|
||||
status: (value: string) => void;
|
||||
session: EditSession | null;
|
||||
onLaneManeuverChange: (maneuver: string, placementDistanceMeters: number) => void;
|
||||
updateSignal: (features: GeoFeature[]) => Promise<void>;
|
||||
onAcceptCandidate: (index: number) => void;
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
const [width, setWidth] = useState(0);
|
||||
const [lanes, setLanes] = useState(1);
|
||||
const [left, setLeft] = useState(false);
|
||||
const [right, setRight] = useState(false);
|
||||
useEffect(() => {
|
||||
if (road) {
|
||||
setWidth(road.widthMeters);
|
||||
setLanes(road.laneCount);
|
||||
setLeft(road.sidewalkLeft);
|
||||
setRight(road.sidewalkRight);
|
||||
}
|
||||
}, [road]);
|
||||
const endpoint = state.compiled.model.endpoints.find((item) => item.roadId === road?.id && item.side === 'end');
|
||||
const movements = state.compiled.movements?.filter((item) => item.fromRoadId === road?.id) || [];
|
||||
const effective = (id: string, fallback: boolean) =>
|
||||
((staged.find((item) => item.id === id) || state.overrides.overrides.find((item) => item.id === id))?.enabled as
|
||||
boolean | undefined) ?? fallback;
|
||||
const signalUid = typeof marking?.signal_uid === 'string' ? marking.signal_uid : '';
|
||||
const signal = state.trafficSignals.assemblies.features.find((item) => item.properties?.signal_uid === signalUid);
|
||||
const [open, setOpen] = useState<'road' | 'element' | 'connections' | 'advanced' | null>('road');
|
||||
useEffect(() => {
|
||||
if (element || marking) setOpen('element');
|
||||
else if (road) setOpen('road');
|
||||
}, [element, marking, road]);
|
||||
const section = (name: NonNullable<typeof open>) => () => setOpen((current) => (current === name ? null : name));
|
||||
const selectedLabel =
|
||||
element?.kind === 'lane-maneuver'
|
||||
? `第 ${laneIndex(element.laneId)} 车道`
|
||||
: marking
|
||||
? '已选标线或设施'
|
||||
: road
|
||||
? label(road)
|
||||
: '未选择对象';
|
||||
return (
|
||||
<section className="workbench-inspector">
|
||||
<div className="inspector-summary">
|
||||
<span>编辑工作台</span>
|
||||
<strong>{selectedLabel}</strong>
|
||||
<small>{staged.length ? `已暂存 ${staged.length} 项修改` : '没有待保存的覆盖修改'}</small>
|
||||
</div>
|
||||
<InspectorSection
|
||||
title="道路"
|
||||
summary={road ? `${road.laneCount} 车道` : '选择道路'}
|
||||
open={open === 'road'}
|
||||
onToggle={section('road')}
|
||||
>
|
||||
{road ? (
|
||||
<form
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
stage({
|
||||
id: `道路:${road.id}`,
|
||||
kind: 'road',
|
||||
roadId: road.id,
|
||||
widthMeters: width,
|
||||
laneCount: lanes,
|
||||
sidewalkLeft: left,
|
||||
sidewalkRight: right,
|
||||
});
|
||||
const opposite = state.compiled.model.roads.find(
|
||||
(item) => item.id !== road.id && item.segmentId === road.segmentId,
|
||||
);
|
||||
if (opposite)
|
||||
stage({
|
||||
id: `道路:${opposite.id}`,
|
||||
kind: 'road',
|
||||
roadId: opposite.id,
|
||||
sidewalkLeft: right,
|
||||
sidewalkRight: left,
|
||||
});
|
||||
status('有未保存修改');
|
||||
}}
|
||||
>
|
||||
<label>道路</label>
|
||||
<output>
|
||||
{label(road)}({direction(road)})
|
||||
</output>
|
||||
<output>
|
||||
{movements.length
|
||||
? `已识别 ${movements.length} 个行驶动作,${movements.filter((item) => item.geometryPublished).length} 条已绘制路径`
|
||||
: '当前方向没有已识别的行驶动作'}
|
||||
</output>
|
||||
<label>
|
||||
本方向道路宽度(米)
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
step="0.01"
|
||||
value={width}
|
||||
onChange={(event) => setWidth(Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
本方向车道数
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
step="1"
|
||||
value={lanes}
|
||||
onChange={(event) => setLanes(Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" checked={left} onChange={(event) => setLeft(event.target.checked)} />{' '}
|
||||
左侧有路缘与步行带
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" checked={right} onChange={(event) => setRight(event.target.checked)} />{' '}
|
||||
右侧有路缘与步行带
|
||||
</label>
|
||||
<Button type="submit">暂存本道路修改</Button>
|
||||
</form>
|
||||
) : (
|
||||
<p>点击道路、车道、标线、转向路径或路口面以查看详情。</p>
|
||||
)}
|
||||
{children}
|
||||
</InspectorSection>
|
||||
<InspectorSection
|
||||
title="元素"
|
||||
summary={element ? selectedLabel : '箭头、标线与信号'}
|
||||
open={open === 'element'}
|
||||
onToggle={section('element')}
|
||||
>
|
||||
<LaneManeuverEditor
|
||||
element={element}
|
||||
value={
|
||||
element?.kind === 'lane-maneuver'
|
||||
? (session
|
||||
?.constraints()
|
||||
.find(
|
||||
(item) =>
|
||||
item.kind === 'lane-maneuver' &&
|
||||
item.anchor.type === 'lane' &&
|
||||
item.anchor.laneId === element.laneId,
|
||||
)?.value as { maneuver?: string; placementDistanceMeters?: number } | undefined)
|
||||
: undefined
|
||||
}
|
||||
onChange={onLaneManeuverChange}
|
||||
/>
|
||||
<MarkingEditor marking={marking} stage={stage} />
|
||||
<SignalEditor state={state} signal={signal} status={status} update={updateSignal} />
|
||||
</InspectorSection>
|
||||
<InspectorSection
|
||||
title="连接"
|
||||
summary={road ? `${movements.length} 个行驶动作` : '选择道路'}
|
||||
open={open === 'connections'}
|
||||
onToggle={section('connections')}
|
||||
>
|
||||
{road ? (
|
||||
<div className="connections-list">
|
||||
{state.compiled.model.connections
|
||||
.filter((connection) => connection.fromEndpointId === endpoint?.id)
|
||||
.map((connection) => (
|
||||
<label key={connection.id}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={effective(`连接:${connection.id}`, connection.enabled)}
|
||||
onChange={(event) =>
|
||||
stage({
|
||||
id: `连接:${connection.id}`,
|
||||
kind: 'junction-connection',
|
||||
fromEndpointId: connection.fromEndpointId,
|
||||
toEndpointId: connection.toEndpointId,
|
||||
enabled: event.target.checked,
|
||||
})
|
||||
}
|
||||
/>{' '}
|
||||
{connection.id}
|
||||
</label>
|
||||
))}
|
||||
{movements.map((movement) => (
|
||||
<label key={movement.id}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={effective(`车道连接:${movement.fromLaneId}->${movement.toLaneId}`, true)}
|
||||
onChange={(event) =>
|
||||
stage({
|
||||
id: `车道连接:${movement.fromLaneId}->${movement.toLaneId}`,
|
||||
kind: 'lane-connection',
|
||||
fromLaneId: movement.fromLaneId,
|
||||
toLaneId: movement.toLaneId,
|
||||
enabled: event.target.checked,
|
||||
})
|
||||
}
|
||||
/>{' '}
|
||||
{movement.turn}:第 {laneIndex(movement.fromLaneId)} 车道 → 第 {laneIndex(movement.toLaneId)} 车道(
|
||||
{movement.geometryStatus || 'connector'})
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="form-context">选择一条道路以管理其驶入路口的连接。</p>
|
||||
)}
|
||||
{endpoint &&
|
||||
state.compiled.diagnostics
|
||||
.find((item) => item.endpointId === endpoint.id)
|
||||
?.manualCandidates?.map((candidate) => {
|
||||
const target = state.compiled.model.roads.find((item) => item.id === candidate.roadId);
|
||||
const targetEndpoint = state.compiled.model.endpoints.find(
|
||||
(item) => item.roadId === candidate.roadId && item.side === 'start',
|
||||
);
|
||||
return target && targetEndpoint ? (
|
||||
<Button
|
||||
key={candidate.roadId}
|
||||
onClick={() => {
|
||||
stage({
|
||||
id: `连接:connection:${endpoint.id}:${targetEndpoint.id}`,
|
||||
kind: 'junction-connection',
|
||||
fromEndpointId: endpoint.id,
|
||||
toEndpointId: targetEndpoint.id,
|
||||
enabled: true,
|
||||
});
|
||||
status('手工连接已暂存;保存并重新生成后会出现转向路径');
|
||||
}}
|
||||
>
|
||||
新增:{label(target)}({candidate.distanceMeters} 米)
|
||||
</Button>
|
||||
) : null;
|
||||
})}
|
||||
</InspectorSection>
|
||||
<InspectorSection title="高级" summary="候选与来源" open={open === 'advanced'} onToggle={section('advanced')}>
|
||||
<Candidates state={state} onAccept={onAcceptCandidate} />
|
||||
<details>
|
||||
<summary>技术详情与来源</summary>
|
||||
<pre>
|
||||
{JSON.stringify(
|
||||
road ? { OSM道路: road.osmWayIds, 当前方向节点顺序: road.sourceNodeIds, 原始标签: road.tags } : marking,
|
||||
null,
|
||||
2,
|
||||
)}
|
||||
</pre>
|
||||
</details>
|
||||
</InspectorSection>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user