test: verify published layers stay on pavement

This commit is contained in:
que01 committed 2026-09-14 14:13:02 +08:00
1 parent 0f9dcace3d
commit edadf98df1
2 files changed
+55

No files matched your search

@@ -194,6 +194,10 @@ npm test 中代码、投影、边界反例、设施、编辑与工作台导入
支持范围内的凹形边界、单个或多个安全孔洞、已知排除区侵入检测均由 BoundaryGraph 与 polygon clipping 自动处理,不要求人工移动几何。两个独立孔洞的连通性回归已加入 `test/junction-build-plan-counterexamples.js`;无法确认多个机动车通行区域或需要绕障规划时,系统仍对象级拒绝并发布诊断。剩余需要用户参与的判断是视觉初稿是否合理,以及是否要把车辆轨迹升级为包含车辆扫掠范围和曲率连续性的规划器。
## 2026-09-14 全图层落面回归
`test/index.js` 新增道路附属层落面检查:道路边线、中心线、车道中心线和车道分隔线的每个发布坐标必须位于对应道路面内,或处于 0.3m 标线厚度容差内;所有附属对象仍必须引用已发布道路面,内部 cluster 对象继续不对外发布。该回归覆盖当前五臂复杂路口 fixture;任意曲线、多路口之间的统一边界误差仍不冒称已完全测量。
## 2026-09-14 现有设施联动收口
现有设施范围的 A6 已由 `test/index.js`、`test/workbench-edit-api.js` 和 `test/junction-facility-composition.js` 覆盖:无 crossing 来源时复杂斑马线省略并发布 `complex-junction-crossing-source-missing`,停止线保留 `unknown-no-crossing-source`;匹配 OSM crossing 节点时发布带来源证据的斑马线;已知交通岛作为排除区域保留并纳入结构投影;角部设施缺少有效道路/步行连接时不伪造。导流岛自由编辑、新右转通道和全套过街设施编辑器仍按 PRD 留在后续任务。
+51
View File
@@ -278,6 +278,57 @@ assert.ok(
complexModel.roads.some((road) => !surfacedIds.has(road.id)),
'fixture exercises omitted roads',
);
const pointInRing = (point, ring) => {
let inside = false;
for (let index = 0, previous = ring.length - 1; index < ring.length; previous = index++) {
const [x, y] = ring[index];
const [px, py] = ring[previous];
if (y > point[1] !== py > point[1] && point[0] < ((px - x) * (point[1] - y)) / (py - y) + x) inside = !inside;
}
return inside;
};
const distanceToSegmentMeters = (point, start, end) => {
const scale = 111320 * Math.cos((point[1] * Math.PI) / 180);
const px = point[0] * scale;
const py = point[1] * 111320;
const ax = start[0] * scale;
const ay = start[1] * 111320;
const bx = end[0] * scale;
const by = end[1] * 111320;
const dx = bx - ax;
const dy = by - ay;
const ratio =
dx * dx + dy * dy ? Math.max(0, Math.min(1, ((px - ax) * dx + (py - ay) * dy) / (dx * dx + dy * dy))) : 0;
return Math.hypot(px - (ax + ratio * dx), py - (ay + ratio * dy));
};
const coordinatesOf = (feature) =>
feature.geometry.type === 'Polygon' ? feature.geometry.coordinates.flat() : feature.geometry.coordinates;
const surfaceForRoad = (roadId) =>
exteriorBaseline.roadSurface.features.filter((feature) =>
String(feature.properties.directional_road_ids || '')
.split(',')
.includes(roadId),
);
for (const name of ['edgeLines', 'centerLines', 'laneCenterlines', 'laneSeparators']) {
for (const feature of exteriorBaseline[name].features) {
if (feature.properties.cluster_preview || String(feature.properties.native_id).startsWith('complex-')) continue;
const roadId = feature.properties.road_id || String(feature.properties.directional_road_ids || '').split(',')[0];
const surfaces = surfaceForRoad(roadId);
assert.ok(surfaces.length > 0, `${name} must reference a published road surface`);
for (const point of coordinatesOf(feature)) {
assert.ok(
surfaces.some((surface) => {
const ring = surface.geometry.coordinates[0];
return (
pointInRing(point, ring) ||
ring.some((vertex, index) => distanceToSegmentMeters(point, vertex, ring[index + 1] || ring[0]) <= 0.3)
);
}),
`${name} feature ${feature.properties.native_id} must stay on its road surface`,
);
}
}
}
for (const name of ['edgeLines', 'centerLines', 'laneCenterlines', 'laneSeparators', 'directionArrows', 'turnArrows']) {
for (const feature of exteriorBaseline[name].features) {
if (feature.properties.cluster_preview || String(feature.properties.native_id).startsWith('complex-')) continue;