From 101bcb3792841632e653f64ea30a4b63a80e3583 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 9 Sep 2026 17:53:32 +0800 Subject: [PATCH] fix: constrain complex junction corner and crossing publication --- .../implement.md | 12 +++++- src/compile/complex-junction.js | 33 ++++++++++++++- src/compile/junction-boundary-graph.js | 2 +- test/index.js | 40 +++++++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) diff --git a/.trellis/tasks/09-08-junction-reference-fidelity/implement.md b/.trellis/tasks/09-08-junction-reference-fidelity/implement.md index 1a8b685..0e33bee 100644 --- a/.trellis/tasks/09-08-junction-reference-fidelity/implement.md +++ b/.trellis/tasks/09-08-junction-reference-fidelity/implement.md @@ -90,4 +90,14 @@ complex-junction.js / native-road.js:构建与全部消费者;direct-edit-so 回归证据:真实 OSM fixture 的可配对外部道路面接缝实际误差 ≤1 cm;过渡车道起点与外断面一致;局部展宽保持外部道路面、边线、人行道、中心线和车道发布线不变;不可构建过渡不发布悬空预览车道线。npm test、客户端类型检查、188 项客户端单测、11 项浏览器测试、格式检查通过。 -仍未关闭阶段 2:外侧偏移曲线的顶点切向统一、短道路被整体吞入路口时所有附属图层的发布一致性、角部步行带独立半径与 overrun 拼接、凹形/多区域/孔洞连通性仍需处理。当前回归证明了现有 fixture 的接缝,不冒称任意曲线与相邻多路口已全部满足 A3。父任务保持进行中。 +仍未关闭阶段 2:外侧偏移曲线的顶点切向统一、凹形/多区域/孔洞连通性仍需处理。当前回归证明了现有 fixture 的接缝,不冒称任意曲线与相邻多路口已全部满足 A3。父任务保持进行中。 + +## 附属图层与已知排除区域发布约束 + +`79f2ee5` 已将角部人行道端点接到实际发布的外部人行道完整接缝,并覆盖带人行道的非空 fixture;短道路的道路边线、中心线、车道标线和人行道遵循道路面的发布集合。 + +本轮进一步补齐两个遗漏:角部道路补面、人行道转角复用 BoundaryGraph 的区域相交判定,侵入已知排除区域时省略并给出角部对象级诊断;复杂过街仅在所属道路臂全部车行道过渡面有效时发布,避免短道路已经无效却继续输出斑马线。短道路回归现在包含 crosswalks、vehicleStopLines 以及缺接缝诊断的对象和来源 ID。排除区回归覆盖实际生成的道路圆角和人行道转角。 + +此处采用明确省略冲突对象,尚未实现绕排除区域重新求解、孔洞或多区域连通;不能据此关闭 A3/A6。下一步需建立区域级共享边界与连通性验证,再推进剩余接入位姿/左右边界编辑,最后做真实数据视觉验收。 + +本轮验证:npm test、客户端类型检查、188 项客户端单元测试、11 项 E2E(含生产构建)、format:check 与 git diff --check 全部通过。构建保留既有 bundle 大小提示。 diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index 231dc1b..8c25b20 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -3,7 +3,7 @@ const fs = require('fs'); const { structureFromTopology } = require('./junction-topology'); const { resolveJunctionBuildPlan, stationAtDistanceFrom } = require('./junction-build-plan'); -const { buildJunctionBoundaryGraph, buildCoreClosure } = require('./junction-boundary-graph'); +const { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap } = require('./junction-boundary-graph'); const { complexJunctionMetrics: calculateComplexJunctionMetrics } = require('./junction-metrics'); const { convertGeoJson, boundsOf } = require('../reference/gaode'); const metricsCache = new WeakMap(); @@ -220,7 +220,21 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { // The four support lines provide a common corner frame, but each long // crossing remains clipped to its OSM-derived road envelope. Corner islands // fill the remaining frame gaps; crossings must never do that job. + const publishedCarriageways = new Set(boundaryParts.map(({ item }) => item.key)); for (const arm of arms) { + if (!arm.members.every((item) => publishedCarriageways.has(item.key))) { + transitionDiagnostics.push( + helpers.diagnostic( + 'warning', + `crossing:${arm.key}`, + arm.members.flatMap((item) => item.approach.roadIds.map(String)), + 'complex-junction-crosswalk-pavement-unavailable', + '该过街缺少完整可发布的车行道过渡面,已省略标线,避免跨越无效进口。', + center, + ), + ); + continue; + } const armCrosswalkRadius = armCrosswalkRadiusFor(arm); arm.crosswalkRadius = armCrosswalkRadius; const envelope = armEnvelopeAtRadius(arm, armCrosswalkRadius, center, helpers); @@ -325,6 +339,21 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { const cornerFills = []; const sidewalkCorners = []; const cornerDiagnostics = []; + const cornerOverlapsExclusion = (ring, cornerKey, part) => { + const region = boundaryGraph.exclusionRegions.find((region) => ringsOverlap(region.ring, ring)); + if (!region) return false; + cornerDiagnostics.push( + helpers.diagnostic( + 'warning', + `corner:${cornerKey}`, + [String(region.id)], + 'complex-junction-corner-exclusion-overlap', + `该角部${part}侵入已知排除区域 ${region.id},已省略,避免覆盖已知不可通行空间。`, + center, + ), + ); + return true; + }; for (const arm of arms) { if (!arm.crosswalkFrame || arm.crosswalkEvidence.kind !== 'inferred-road-envelope') continue; cornerDiagnostics.push( @@ -394,6 +423,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { const curve = quadraticCurve(tangents[0], apex, tangents[1], CORNER_FILLET_SEGMENTS); const ring = [...curve, center, curve[0]]; if (!ring.every((point) => point.every(Number.isFinite))) continue; + if (cornerOverlapsExclusion(ring, first.cornerKey, '道路补面')) continue; cornerFills.push({ type: 'Feature', properties: { @@ -453,6 +483,7 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { ); continue; } + if (cornerOverlapsExclusion(sidewalkRing, first.cornerKey, '人行道')) continue; sidewalkCorners.push({ type: 'Feature', properties: { diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index c4b2bba..86852f5 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -268,4 +268,4 @@ function buildCoreClosure(topology, graph, center) { }; } -module.exports = { buildJunctionBoundaryGraph, buildCoreClosure }; +module.exports = { buildJunctionBoundaryGraph, buildCoreClosure, ringsOverlap }; diff --git a/test/index.js b/test/index.js index 1542d94..a2bf785 100644 --- a/test/index.js +++ b/test/index.js @@ -330,6 +330,30 @@ for (const corner of corners) { ); } } +// Every generated corner surface must respect the same known exclusion regions +// as the core and entry surfaces, including containment without edge crossings. +for (const target of [ + sidewalkGeometry.roadSurface.features.find((feature) => feature.properties.kind === 'complex-corner-fillet'), + corners[0], +]) { + assert.ok(target, 'fixture exercises both corner pavement and sidewalk'); + const protectedRing = target.geometry.coordinates[0]; + const excludedGeometry = compiler.nativeRoad.compileGeometry( + { ...sidewalkModel, exclusionRegions: [{ id: 'corner-protection', ring: protectedRing }] }, + { overrides: [] }, + { junctionTemplates: boundaryEditOptions.junctionTemplates }, + ); + const { ringsOverlap } = require('../src/compile/junction-boundary-graph'); + const publishedCorners = [ + ...excludedGeometry.roadSurface.features, + ...excludedGeometry.sidewalkSurface.features, + ].filter((feature) => ['complex-corner-fillet', 'complex-sidewalk-corner'].includes(feature.properties.kind)); + assert.ok(publishedCorners.every((feature) => !ringsOverlap(protectedRing, feature.geometry.coordinates[0]))); + assert.ok( + excludedGeometry.diagnostics.some((item) => item.rule === 'complex-junction-corner-exclusion-overlap'), + 'omitted corner surfaces report their exclusion conflict', + ); +} // Empty pavement is a real result, not a signal to disable attachment checks. const shortPoints = [ [1, -1, 0], @@ -370,8 +394,24 @@ for (const name of [ 'directionArrows', 'turnArrows', 'sidewalkSurface', + 'crosswalks', + 'vehicleStopLines', ]) assert.equal(shortGeometry[name].features.length, 0, `${name} must remain empty when all source roads are swallowed`); +assert.ok( + shortGeometry.diagnostics.some((item) => item.rule === 'complex-junction-crosswalk-pavement-unavailable'), + 'unsupported crossings explain their missing pavement', +); +const missingSidewalkSeams = shortGeometry.diagnostics.filter( + (item) => item.rule === 'complex-junction-sidewalk-seam-unavailable', +); +assert.ok(missingSidewalkSeams.length > 0, 'omitted corner sidewalks must explain their missing exterior seams'); +for (const item of missingSidewalkSeams) { + assert.equal(item.severity, 'warning'); + assert.ok(item.subjectId.startsWith('corner:'), 'missing seams must identify the affected corner'); + assert.ok(item.sourceIds.length > 0); + assert.ok(item.sourceIds.every((id) => shortModel.roads.some((road) => road.id === id))); +} const complexFeatures = Object.values(complexGeometry).flatMap((layer) => layer?.features || []); assert.equal( complexFeatures.some((feature) => feature.properties?.kind === 'complex-corner-island'),