fix: refine workbench map layers

This commit is contained in:
que01 committed 2026-08-26 15:26:41 +08:00
1 parent 2f2bd6cbf0
commit 3c5f39ed73
6 files changed
+100 -13

No files matched your search

+45 -9
View File
@@ -17,7 +17,6 @@ const layerLabels: Array<[LayerName, string]> = [
['edgeLines', '道路外缘线'],
['controls', '斑马线与停止线'],
['signals', '红绿灯设施'],
['gaodeReference', '高德规整路口参考'],
['reference', 'osm2streets 参考面'],
];
const defaultLayers = Object.fromEntries(
@@ -26,6 +25,50 @@ const defaultLayers = Object.fromEntries(
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));
const overviewMetrics = [
['nativeRoadCount', '方向道路'],
['nativeRoadSurfaceFeatures', '道路面'],
['nativeJunctionSurfaceFeatures', '路口面'],
['nativeLaneCenterlineFeatures', '车道中心线'],
['nativeCenterLineFeatures', '道路中心线'],
['nativeConnectorFeatures', '连接路径'],
['nativeCrosswalkFeatures', '斑马线'],
['nativeVehicleStopLineFeatures', '停止线'],
['unconnectedInteriorRoadEnds', '未连接端点'],
] as const;
function Overview({ comparison }: { comparison: Record<string, unknown> }) {
const severity = comparison.diagnosticsBySeverity as Record<string, number> | undefined;
return (
<section className="overview">
<div className="overview-grid">
{overviewMetrics.map(([key, label]) => (
<div key={key}>
<span>{label}</span>
<strong>{Number(comparison[key] || 0).toLocaleString('zh-CN')}</strong>
</div>
))}
</div>
<div className="overview-status">
<span>osm2streets 参考面</span>
<strong>
{comparison.osm2streetsAvailable === true
? `${Number(comparison.osm2streetsRoadSurfaceFeatures || 0)} 个`
: '未提供'}
</strong>
</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>
);
}
function App() {
const [state, setState] = useState<WorkbenchState>();
const [selected, setSelected] = useState<Road | null>(null);
@@ -137,14 +180,7 @@ function App() {
))}
<hr />
<h1>当前编译概览</h1>
<dl>
{Object.entries(state.comparison).map(([key, value]) => (
<>
<dt key={`${key}-t`}>{key}</dt>
<dd key={`${key}-d`}>{String(value)}</dd>
</>
))}
</dl>
<Overview comparison={state.comparison} />
<hr />
<h1>待检查问题</h1>
<div className="segmented">