feat: add complex junction selection markers

This commit is contained in:
que01 committed 2026-09-04 17:09:32 +08:00
1 parent 57248f1aa4
commit 38ea779d9b
18 files changed
+685 -48

No files matched your search

+41 -11
View File
@@ -54,7 +54,7 @@ import { Button } from './ui/button';
import type { GeoFeature, GeoJson, Road, WorkbenchState } from './types/state';
import type { LayerName } from './map/layers';
import type { JunctionRef } from './junction/hotspots';
import { junctionDescriptors, hotspotAt } from './junction/hotspots';
import { candidateForJunction, junctionDescriptors, hotspotAt } from './junction/hotspots';
import { JunctionWorkspace } from './junction/JunctionWorkspace';
import { localJunctionPreview, localJunctionState } from './junction/local-state';
import {
@@ -211,6 +211,9 @@ function App() {
: preview,
[junctionDescriptor, junctionRoute, preview, state],
);
const [junctionNodeMarkers, setJunctionNodeMarkers] = useState<
Array<{ coordinate: Coordinate; label: string; selected: boolean }>
>([]);
// A deep link starts without a map click, so it has no selected approach from
// which the existing manifest loader can scope its request. Pick the first
// descriptor-owned approach here as well as in the click path; this is a
@@ -891,6 +894,7 @@ function App() {
discardJunctionDraft();
} else return;
}
setJunctionNodeMarkers([]);
window.history.pushState({}, '', '/');
setJunctionRoute(null);
};
@@ -991,6 +995,7 @@ function App() {
);
})}
<hr />
<hr />
<details className="issues-details">
<summary>待检查问题({diagnostics.length})</summary>
<div className="issue-tabs" role="tablist" aria-label="问题筛选">
@@ -1036,6 +1041,7 @@ function App() {
visible={layers}
scene={scene}
junctionHotspots={junctionHotspots}
junctionNodeMarkers={junctionNodeMarkers}
onJunctionHotspot={(ref: JunctionRef, _coordinate, descriptor) => {
openJunction(ref);
const approachRoad = descriptor.approachRoadIds
@@ -1128,16 +1134,6 @@ function App() {
session={session}
onLaneManeuverChange={applyLaneManeuver}
updateSignal={updateSignal}
onAcceptCandidate={(index) =>
void api
.acceptJunctionCandidate(index)
.then((next) => {
setState(next);
signalSavedRef.current = next.trafficSignals.assemblies.features;
setStatus(`已加入 ${next.added.id} 并重新编译`);
})
.catch((error: Error) => setStatus(error.message))
}
>
{editMode ? (
<ParameterPanel
@@ -1162,6 +1158,40 @@ function App() {
diagnostics={junctionDiagnostics}
facilitySummary={junctionFacilitySummary}
onClose={closeJunction}
onEnableComplex={
candidateForJunction(state, junctionDescriptor)
? (selectedNodeIds) => {
const candidate = candidateForJunction(state, junctionDescriptor);
if (!candidate) {
setStatus('候选已过期,请刷新后重试。');
return;
}
void api
.acceptJunctionCandidate(candidate.id, selectedNodeIds)
.then((next) => {
setState(next);
signalSavedRef.current = next.trafficSignals.assemblies.features;
const ref = { type: 'cluster' as const, id: next.added.id };
window.history.replaceState({}, '', `/junction/cluster/${encodeURIComponent(ref.id)}`);
setJunctionRoute(ref);
setStatus('已启用复杂路口渲染');
})
.catch((error: Error) => setStatus(`启用失败:${error.message}`));
}
: undefined
}
onUpdateComplexNodes={(nodeIds) => {
if (junctionDescriptor.ref.type !== 'cluster') return;
void api
.updateJunctionCluster(junctionDescriptor.ref.id, nodeIds)
.then((next) => {
setState(next);
signalSavedRef.current = next.trafficSignals.assemblies.features;
setStatus('已更新复杂路口参与节点并重新编译');
})
.catch((error: Error) => setStatus(`更新失败:${error.message}`));
}}
onCandidateMarkersChange={setJunctionNodeMarkers}
onApply={() => setJunctionSession((current) => (current ? applyJunctionDraft(current) : current))}
onDiscard={discardJunctionDraft}
onSave={() =>