feat(junction): expose stage1 structure and standards panel
This commit is contained in:
1 parent
0f804b71d1
commit
fc7fe81eff
15 files changed
+434
-17
No files matched your search
@@ -189,6 +189,9 @@ export interface EditPreviewResponse {
|
||||
diagnostics: EditDiagnostic[];
|
||||
handles: HandleManifest;
|
||||
layers: Partial<Record<PreviewLayerName, GeoJson | null>>;
|
||||
junctionStructure?: import('../types/state').JunctionStructure | null;
|
||||
standardsProfile?: { id: string; label: string };
|
||||
standardsDiagnostics?: import('../types/state').StandardsDiagnostic[];
|
||||
}
|
||||
|
||||
export interface EditStateResponse {
|
||||
@@ -200,6 +203,9 @@ export interface EditStateResponse {
|
||||
constraintStates: ConstraintStateReport[];
|
||||
diagnostics: EditDiagnostic[];
|
||||
handles: HandleManifest;
|
||||
junctionStructure?: import('../types/state').JunctionStructure | null;
|
||||
standardsProfile?: { id: string; label: string };
|
||||
standardsDiagnostics?: import('../types/state').StandardsDiagnostic[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -170,6 +170,8 @@ export function JunctionWorkspace({
|
||||
() => (state ? junctionFacilities(state, descriptor.nodeIds, roads) : []),
|
||||
[descriptor.nodeIds, roads, state],
|
||||
);
|
||||
const structure = state?.junctionStructure;
|
||||
const standardDiagnostics = state?.standardsDiagnostics || [];
|
||||
return (
|
||||
<section className="junction-workspace" aria-label="路口编辑工作区">
|
||||
<header className="junction-workspace__header">
|
||||
@@ -217,6 +219,39 @@ export function JunctionWorkspace({
|
||||
</dd>
|
||||
</dl>
|
||||
<section className="junction-workspace__validation" aria-label="路口验证">
|
||||
{structure ? (
|
||||
<section className="junction-workspace__standards" aria-label="结构与标准">
|
||||
<h3>结构与标准</h3>
|
||||
<p>
|
||||
{state?.standardsProfile?.label || '项目默认标准'} · {structure.shape.label} ·{' '}
|
||||
{structure.shape.effectiveArmCount} 条有效道路臂
|
||||
</p>
|
||||
<dl>
|
||||
<dt>道路臂</dt>
|
||||
<dd>{structure.arms.map((arm) => arm.label).join('、') || '无'}</dd>
|
||||
<dt>角部</dt>
|
||||
<dd>{structure.corners.length ? structure.corners.map((corner) => corner.label).join('、') : '无'}</dd>
|
||||
<dt>设施</dt>
|
||||
<dd>
|
||||
{structure.facilities.length
|
||||
? structure.facilities.map((facility) => facility.label).join('、')
|
||||
: '无'}
|
||||
</dd>
|
||||
</dl>
|
||||
{standardDiagnostics.length ? (
|
||||
<ul aria-label="标准诊断">
|
||||
{standardDiagnostics.map((item) => (
|
||||
<li key={item.id} className={item.severity === 'blocking' ? 'blocking' : undefined}>
|
||||
<strong>
|
||||
{item.severity === 'pass' ? '通过' : item.severity === 'warning' ? '警告' : '阻塞'}
|
||||
</strong>{' '}
|
||||
{item.message}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</section>
|
||||
) : null}
|
||||
{candidate || complexEnabled ? (
|
||||
<div className="junction-workspace__candidate" aria-label="复杂路口候选信息">
|
||||
<strong>{complexEnabled ? '当前复杂路口组成' : '附近可合并节点'}</strong>
|
||||
|
||||
@@ -87,6 +87,27 @@ export interface Diagnostic {
|
||||
geometry?: { type: string; coordinates: unknown };
|
||||
manualCandidates?: Array<{ roadId: string; distanceMeters: number }>;
|
||||
}
|
||||
export interface JunctionStructure {
|
||||
schema: string;
|
||||
junctionKey: string;
|
||||
label: string;
|
||||
shape: { kind: string; label: string; effectiveArmCount: number; throughPairCount: number };
|
||||
arms: Array<{
|
||||
key: string;
|
||||
label: string;
|
||||
directionality: string;
|
||||
carriageway?: { laneCount?: number; effectiveWidthMeters?: number };
|
||||
}>;
|
||||
corners: Array<{ key: string; label: string; fromArmKey: string; toArmKey: string }>;
|
||||
facilities: Array<{ key: string; kind: string; label: string }>;
|
||||
}
|
||||
export interface StandardsDiagnostic {
|
||||
id: string;
|
||||
severity: string;
|
||||
rule: string;
|
||||
objectKey: string;
|
||||
message: string;
|
||||
}
|
||||
export interface WorkbenchState {
|
||||
active?: boolean;
|
||||
areaId: string;
|
||||
@@ -106,4 +127,7 @@ export interface WorkbenchState {
|
||||
junctionClusters?: JunctionClusterConfig[];
|
||||
junctionShapes?: JunctionShapeSummary[];
|
||||
} | null;
|
||||
junctionStructure?: JunctionStructure | null;
|
||||
standardsProfile?: { id: string; label: string };
|
||||
standardsDiagnostics?: StandardsDiagnostic[];
|
||||
}
|
||||
+48
-16
@@ -23,6 +23,7 @@ const {
|
||||
} = require('../src/compile/road-revisions');
|
||||
const { GEOMETRY_VERSION, resolveDirectEditConstraints } = require('../src/compile/direct-edit-solver');
|
||||
const { loadEditDocument, saveEditDocument, validateEditDocument } = require('../src/compile/native-road-edits');
|
||||
const { projectJunctionStructure, standardsDiagnostics } = require('../src/compile/junction-projection');
|
||||
|
||||
function startWorkbench({
|
||||
area = null,
|
||||
@@ -245,6 +246,8 @@ function state(area, junctionReference = null, debug = false) {
|
||||
};
|
||||
const trafficRuntime = runtime(trafficSignals);
|
||||
const compiled = readCompiled(area);
|
||||
const layers = readWorkbenchLayers(nativeDir, osm2streetsRoadSurface);
|
||||
const junctionStructure = projectJunctionStructure({ model: compiled.model, layers, trafficSignals });
|
||||
const junctionShapes = debug
|
||||
? (readLayer(path.join(nativeDir, 'layers', 'road_surface.geojson')).features || [])
|
||||
.filter((feature) => feature.properties?.kind === 'complex-core' && feature.properties?.cluster_id)
|
||||
@@ -273,27 +276,34 @@ function state(area, junctionReference = null, debug = false) {
|
||||
}
|
||||
: null,
|
||||
compiled,
|
||||
junctionStructure,
|
||||
standardsProfile: { id: 'cn-urban-default', label: '中国城市道路(项目默认)' },
|
||||
standardsDiagnostics: standardsDiagnostics(junctionStructure),
|
||||
overrides: loadOverrides(area.outputs.nativeRoadOverrides),
|
||||
trafficSignals,
|
||||
trafficRuntime,
|
||||
comparison: readJson(path.join(nativeDir, 'comparison.json')),
|
||||
junctionReference,
|
||||
layers: {
|
||||
nativeRoadSurface: readLayer(path.join(nativeDir, 'layers', 'road_surface.geojson')),
|
||||
edgeLines: readLayer(path.join(nativeDir, 'layers', 'edge_lines.geojson')),
|
||||
nativeSidewalkSurface: readLayer(path.join(nativeDir, 'layers', 'sidewalk_surface.geojson')),
|
||||
nativeIntersectionSurface: readLayer(path.join(nativeDir, 'layers', 'intersection_surface.geojson')),
|
||||
laneCenterlines: readLayer(path.join(nativeDir, 'layers', 'lane_centerlines.geojson')),
|
||||
laneSeparators: readLayer(path.join(nativeDir, 'layers', 'lane_separators.geojson')),
|
||||
centerLines: readLayer(path.join(nativeDir, 'layers', 'center_lines.geojson')),
|
||||
directionArrows: readLayer(path.join(nativeDir, 'layers', 'direction_arrows.geojson')),
|
||||
turnArrows: readLayer(path.join(nativeDir, 'layers', 'turn_arrows.geojson')),
|
||||
crosswalks: readLayer(path.join(nativeDir, 'layers', 'crosswalks.geojson')),
|
||||
vehicleStopLines: readLayer(path.join(nativeDir, 'layers', 'vehicle_stop_lines.geojson')),
|
||||
connectors: readLayer(path.join(nativeDir, 'layers', 'connectors.geojson')),
|
||||
osm2streetsRoadSurface:
|
||||
osm2streetsRoadSurface && fs.existsSync(osm2streetsRoadSurface) ? readLayer(osm2streetsRoadSurface) : null,
|
||||
},
|
||||
layers,
|
||||
};
|
||||
}
|
||||
|
||||
function readWorkbenchLayers(nativeDir, osm2streetsRoadSurface) {
|
||||
return {
|
||||
nativeRoadSurface: readLayer(path.join(nativeDir, 'layers', 'road_surface.geojson')),
|
||||
edgeLines: readLayer(path.join(nativeDir, 'layers', 'edge_lines.geojson')),
|
||||
nativeSidewalkSurface: readLayer(path.join(nativeDir, 'layers', 'sidewalk_surface.geojson')),
|
||||
nativeIntersectionSurface: readLayer(path.join(nativeDir, 'layers', 'intersection_surface.geojson')),
|
||||
laneCenterlines: readLayer(path.join(nativeDir, 'layers', 'lane_centerlines.geojson')),
|
||||
laneSeparators: readLayer(path.join(nativeDir, 'layers', 'lane_separators.geojson')),
|
||||
centerLines: readLayer(path.join(nativeDir, 'layers', 'center_lines.geojson')),
|
||||
directionArrows: readLayer(path.join(nativeDir, 'layers', 'direction_arrows.geojson')),
|
||||
turnArrows: readLayer(path.join(nativeDir, 'layers', 'turn_arrows.geojson')),
|
||||
crosswalks: readLayer(path.join(nativeDir, 'layers', 'crosswalks.geojson')),
|
||||
vehicleStopLines: readLayer(path.join(nativeDir, 'layers', 'vehicle_stop_lines.geojson')),
|
||||
connectors: readLayer(path.join(nativeDir, 'layers', 'connectors.geojson')),
|
||||
osm2streetsRoadSurface:
|
||||
osm2streetsRoadSurface && fs.existsSync(osm2streetsRoadSurface) ? readLayer(osm2streetsRoadSurface) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -325,6 +335,13 @@ function editState(area, selection = null) {
|
||||
compilerGeometryVersion: GEOMETRY_VERSION,
|
||||
selection,
|
||||
});
|
||||
const compiled = readCompiled(area);
|
||||
const layers = readWorkbenchLayers(area.outputs.nativeRoadDir, null);
|
||||
const junctionStructure = projectJunctionStructure({
|
||||
model: compiled.model,
|
||||
layers,
|
||||
trafficSignals: readJson(area.outputs.nativeTrafficSignals),
|
||||
});
|
||||
return {
|
||||
active: true,
|
||||
areaId: area.id,
|
||||
@@ -334,6 +351,9 @@ function editState(area, selection = null) {
|
||||
constraintStates: resolution.constraintStates,
|
||||
diagnostics: resolution.diagnostics,
|
||||
handles: resolution.handles,
|
||||
junctionStructure,
|
||||
standardsProfile: { id: 'cn-urban-default', label: '中国城市道路(项目默认)' },
|
||||
standardsDiagnostics: standardsDiagnostics(junctionStructure),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -368,6 +388,15 @@ function editPreview(area, body = {}) {
|
||||
directEdit: resolution,
|
||||
});
|
||||
const diagnostics = [...compiled.diagnostics, ...resolution.diagnostics];
|
||||
const junctionStructure = projectJunctionStructure({
|
||||
model,
|
||||
layers: {
|
||||
crosswalks: compiled.crosswalks,
|
||||
vehicleStopLines: compiled.vehicleStopLines,
|
||||
intersectionSurface: compiled.intersectionSurface,
|
||||
},
|
||||
trafficSignals: readJson(area.outputs.nativeTrafficSignals),
|
||||
});
|
||||
const degraded = Date.now() - startedAt > 300;
|
||||
return {
|
||||
ok: true,
|
||||
@@ -378,6 +407,9 @@ function editPreview(area, body = {}) {
|
||||
constraintStates: resolution.constraintStates,
|
||||
diagnostics,
|
||||
handles: resolution.handles,
|
||||
junctionStructure,
|
||||
standardsProfile: { id: 'cn-urban-default', label: '中国城市道路(项目默认)' },
|
||||
standardsDiagnostics: standardsDiagnostics(junctionStructure),
|
||||
layers: {
|
||||
roadSurface: compiled.roadSurface,
|
||||
edgeLines: compiled.edgeLines,
|
||||
|
||||
Reference in new issue
Block a user