feat(junction): add reference geometry comparison layer
This commit is contained in:
1 parent
4519cad562
commit
92ab2edd96
11 files changed
+107
-5
No files matched your search
@@ -67,6 +67,7 @@ import {
|
||||
|
||||
const layerLabels: Array<[LayerName, string]> = [
|
||||
['osm', '方向道路参考线'],
|
||||
['reference', '参考几何叠加'],
|
||||
['native', '自研道路与路口面'],
|
||||
['sidewalks', '路缘与步行带'],
|
||||
['lanes', '车道与转向路径'],
|
||||
@@ -78,10 +79,9 @@ const layerLabels: Array<[LayerName, string]> = [
|
||||
['signals', '红绿灯设施'],
|
||||
['junctionHotspots', '路口编辑热区'],
|
||||
];
|
||||
const defaultLayers = Object.fromEntries(layerLabels.map(([key]) => [key, key !== 'edgeLines'])) as Record<
|
||||
LayerName,
|
||||
boolean
|
||||
>;
|
||||
const defaultLayers = Object.fromEntries(
|
||||
layerLabels.map(([key]) => [key, key !== 'edgeLines' && key !== 'reference']),
|
||||
) as Record<LayerName, boolean>;
|
||||
const direction = (road: Road) => (road.direction === 'forward' ? '沿 OSM 方向' : '逆 OSM 方向');
|
||||
const label = (road: Road) => road.tags.name || `${road.highway}(OSM ${road.osmWayIds.join(', ')})`;
|
||||
const laneIndex = (id: string) => Number(id.split(':').at(-1));
|
||||
@@ -89,6 +89,7 @@ function App() {
|
||||
const [state, setState] = useState<WorkbenchState>();
|
||||
const [selected, setSelected] = useState<Road | null>(null);
|
||||
const [layers, setLayers] = useState(defaultLayers);
|
||||
const [referenceOpacity, setReferenceOpacity] = useState(0.55);
|
||||
const [scene, setScene] = useState(false);
|
||||
const [junctionHotspots, setJunctionHotspots] = useState(true);
|
||||
const [status, setStatus] = useState('正在加载工作台...');
|
||||
@@ -1003,6 +1004,19 @@ function App() {
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
{state.junctionReference ? (
|
||||
<label>
|
||||
参考透明度
|
||||
<input
|
||||
type="range"
|
||||
min="0.1"
|
||||
max="1"
|
||||
step="0.05"
|
||||
value={referenceOpacity}
|
||||
onChange={(event) => setReferenceOpacity(Number(event.target.value))}
|
||||
/>
|
||||
</label>
|
||||
) : null}
|
||||
<hr />
|
||||
<hr />
|
||||
<details className="issues-details">
|
||||
@@ -1051,6 +1065,7 @@ function App() {
|
||||
scene={scene}
|
||||
junctionHotspots={junctionHotspots}
|
||||
junctionNodeMarkers={junctionNodeMarkers}
|
||||
referenceOpacity={referenceOpacity}
|
||||
onJunctionHotspot={(ref: JunctionRef, _coordinate, descriptor) => {
|
||||
openJunction(ref);
|
||||
const approachRoad = descriptor.approachRoadIds
|
||||
|
||||
@@ -78,6 +78,7 @@ interface Props {
|
||||
junctionHotspots?: boolean;
|
||||
onJunctionHotspot?: (ref: JunctionRef, coordinate: Coordinate, descriptor: JunctionDescriptor) => void;
|
||||
junctionNodeMarkers?: Array<{ coordinate: Coordinate; label: string; selected: boolean }>;
|
||||
referenceOpacity?: number;
|
||||
}
|
||||
export function MapCanvas({
|
||||
state,
|
||||
@@ -114,6 +115,7 @@ export function MapCanvas({
|
||||
junctionHotspots = true,
|
||||
onJunctionHotspot,
|
||||
junctionNodeMarkers = [],
|
||||
referenceOpacity = 0.55,
|
||||
}: Props) {
|
||||
const target = useRef<HTMLDivElement>(null);
|
||||
const mapRef = useRef<Map | null>(null);
|
||||
@@ -611,5 +613,8 @@ export function MapCanvas({
|
||||
layers.native.changed();
|
||||
layers.sidewalks.changed();
|
||||
}, [visible, scene]);
|
||||
useEffect(() => {
|
||||
layersRef.current?.reference.setOpacity(referenceOpacity);
|
||||
}, [referenceOpacity]);
|
||||
return <div className="map" ref={target} aria-label="道路地图" />;
|
||||
}
|
||||
@@ -230,6 +230,12 @@ export function JunctionWorkspace({
|
||||
{state?.standardsProfile?.label || '项目默认标准'} · {structure.shape.label} ·{' '}
|
||||
{structure.shape.effectiveArmCount} 条有效道路臂
|
||||
</p>
|
||||
{state?.junctionReference ? (
|
||||
<p className="junction-workspace__reference-summary">
|
||||
参考层:{state.junctionReference.coordinateSystem || 'GCJ-02'} → WGS84 ·{' '}
|
||||
{state.junctionReference.source || '已加载参考文件'}
|
||||
</p>
|
||||
) : null}
|
||||
<dl>
|
||||
<dt>道路臂</dt>
|
||||
<dd>
|
||||
|
||||
@@ -20,6 +20,7 @@ export type LayerName =
|
||||
| 'native'
|
||||
| 'sidewalks'
|
||||
| 'osm'
|
||||
| 'reference'
|
||||
| 'lanes'
|
||||
| 'edgeLines'
|
||||
| 'directionArrows'
|
||||
@@ -66,6 +67,15 @@ export function createLayers(
|
||||
: undefined,
|
||||
}),
|
||||
}),
|
||||
reference: new VectorLayer({
|
||||
source: source(),
|
||||
visible: false,
|
||||
opacity: 0.55,
|
||||
style: new Style({
|
||||
fill: new Fill({ color: '#7c3aed22' }),
|
||||
stroke: new Stroke({ color: '#7c3aed', width: 2, lineDash: [6, 4] }),
|
||||
}),
|
||||
}),
|
||||
lanes: new VectorLayer({
|
||||
source: source(),
|
||||
style: new Style({ stroke: new Stroke({ color: '#f5f6ee', width: 1.5, lineDash: [5, 4] }) }),
|
||||
@@ -224,6 +234,7 @@ export function updateLayers(
|
||||
);
|
||||
put('osm', { type: 'FeatureCollection', features: [] });
|
||||
get('osm').addFeatures(roads);
|
||||
put('reference', state.junctionReference?.converted);
|
||||
put('lanes', state.layers.laneCenterlines);
|
||||
put('edgeLines', state.layers.edgeLines);
|
||||
put('directionArrows', state.layers.directionArrows);
|
||||
|
||||
@@ -121,7 +121,12 @@ export interface WorkbenchState {
|
||||
trafficRuntime: { signals: unknown[] };
|
||||
comparison: Record<string, unknown>;
|
||||
layers: Record<string, GeoJson | null>;
|
||||
junctionReference?: { converted: GeoJson };
|
||||
junctionReference?: {
|
||||
source?: string;
|
||||
coordinateSystem?: string;
|
||||
converted: GeoJson;
|
||||
comparison?: Record<string, unknown>;
|
||||
};
|
||||
debug?: {
|
||||
junctionCandidates: JunctionCandidate[];
|
||||
junctionClusters?: JunctionClusterConfig[];
|
||||
|
||||
Reference in new issue
Block a user