fix: preserve exclusions in complex junction pavement
This commit is contained in:
1 parent
e8ecfecbf4
commit
818d91d8b5
15 files changed
+606
-37
No files matched your search
@@ -56,6 +56,13 @@ Missing expected objects fail; never iterate only detected objects and report an
|
||||
empty set as success. Segment coverage partitions at all boundary crossings, so
|
||||
interior notches cannot hide between fixed probes. Polygon holes remain holes.
|
||||
|
||||
The canonical complex-pavement region fills construction pockets before it
|
||||
subtracts explicit `model.exclusionRegions`. A core hole alone is not proof of
|
||||
the published pavement contract: crossing and corner inputs can otherwise fill
|
||||
it again. After subtraction, an empty or disconnected result, or any missing
|
||||
complete approach seam, rejects canonical pavement publication and carries the
|
||||
cluster plus exclusion identities in its diagnostic.
|
||||
|
||||
Dashes do not need white paint across every seam. An outward road starts its
|
||||
dash sequence at the seam, so its first cap must coincide; the other end can
|
||||
leave a residual dash cycle. Current edge/separator cycles are 2 m paint + 2 m
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||
{"file": ".trellis/spec/backend/junction-layer-seams.md", "reason": "接缝 1 cm 与拒绝契约"}
|
||||
{"file": ".trellis/tasks/09-17-junction-exclusion-routing/research.md", "reason": "排除区反例与支持矩阵"}
|
||||
@@ -0,0 +1,15 @@
|
||||
# Phase 3.4 提交批次(用户已确认)
|
||||
|
||||
2026-09-17:用户回复“结束吧”,授权提交并归档本专项。
|
||||
|
||||
1. `fix: preserve exclusions in complex junction pavement`
|
||||
- `src/compile/junction-pavement-region.js`
|
||||
- `src/compile/complex-junction-surfaces.js`
|
||||
- `test/junction-pavement-region.js`
|
||||
- `.trellis/spec/backend/junction-layer-seams.md`
|
||||
- `.trellis/tasks/09-17-junction-exclusion-routing/`(研究、方案、探针、验收证据)
|
||||
|
||||
没有未识别的脏文件;不更新 fixture 快照,不推送远端。
|
||||
确认后提交、归档本专项并写入会话记录。自动绕障和车辆路径规划不在本批次。
|
||||
|
||||
确认要求来源:`.trellis/workflow.md` Phase 3.4 第 5 步,要求一次性展示提交计划并取得确认。
|
||||
@@ -0,0 +1,23 @@
|
||||
# 下一实现单元:最终铺装保留排除区
|
||||
|
||||
目标:让最终权威铺装满足已知排除区域约束,修复实测 1 m² 孔洞被填平。
|
||||
|
||||
在 `junction-pavement-region.js` 的统一装配函数增加可选排除区参数,
|
||||
默认空数组维持现有调用行为。保留施工空洞填补,再通过 polygon difference
|
||||
扣除显式排除区;返回 holes、多区域或空集的真实结果。运算异常纳入原有
|
||||
unsupported 失败路径,不静默回退为填满障碍的面。
|
||||
|
||||
`complex-junction-surfaces.js` 从当前 model 传递排除区域,校验最终面与
|
||||
排除区无正面积交集、必要进口接边没有丢失。单个连通区可带孔洞;为空、
|
||||
断开或必要接边失败则拒绝发布统一面并输出对应 cluster / exclusion 身份。
|
||||
拒绝路径保留结构诊断,不能标记这些输入为成功统一铺装。
|
||||
|
||||
限定文件:上述两个生产模块、`test/junction-pavement-region.js` 及必要的
|
||||
最终发布回归(可独立文件并接入 package.json)、规范和任务证据。
|
||||
不修改轨迹规划、入口重排、车辆扫掠、设施编辑或前端交互。
|
||||
|
||||
必须同时验证:无排除区输出不变;施工假孔洞继续填平;显式孔洞保留;
|
||||
多孔洞/边界相交/完全覆盖/切断区域都有可观察结果;最终发布面的正确性
|
||||
独立测量,不能只测核心面。接缝专项 1 cm 门槛不放宽。
|
||||
|
||||
2026-09-17 用户已确认本方案;实施仅限最终铺装排除区保留。
|
||||
@@ -0,0 +1,32 @@
|
||||
# 最终铺装排除区保留:验收证据
|
||||
|
||||
2026-09-17。完成已确认的最小修复:不实现自动绕障或车辆路径规划。
|
||||
|
||||
此前最终统一铺装在 union 后丢弃所有内环。因此中心 1 m² 已知孔洞虽然
|
||||
从 `complex-core` 扣除,仍被 `complex-pavement-region` 全部填平。现在先填补
|
||||
施工输入之间的假孔洞,随后对显式排除区执行 difference;真实孔洞作为最终
|
||||
MultiPolygon 的内环保留。
|
||||
|
||||
最终面必须为一个连通区域,并完整覆盖每个仍有效进口的内外断面。空集、
|
||||
分裂区域、正面积侵占或必要接边丢失时,不发布统一面。诊断附带 cluster、
|
||||
排除区域 ID 和丢失车行道键。边界仅接触不算侵占。
|
||||
|
||||
验证结果:
|
||||
|
||||
- 真实 OSM 四臂中心 1 m² 孔洞,最终铺装交集从 `1.00000000018 m²` 降至 `0 m²`。
|
||||
- 多孔洞、重叠孔洞、完全覆盖、中心切断、入口阻断及内部缺口均有回归。
|
||||
- 无排除区的四臂、四臂加 T 组合完整输出与修复前基线逐字一致。
|
||||
- 铺装、区域 solver、构建反例、岛体位移和 13 场景 / 1,446 接缝回归通过;
|
||||
TypeScript 检查与变更文件格式检查通过。
|
||||
- `npm test` 在最后仍因既有 `test/fixtures.js` 快照差异失败;此前所有专项与
|
||||
Workbench 导入测试通过,未刷新快照。
|
||||
|
||||
可复现命令:
|
||||
|
||||
```sh
|
||||
node .trellis/tasks/09-17-junction-exclusion-routing/probe.cjs
|
||||
node test/junction-pavement-region.js
|
||||
```
|
||||
|
||||
入口重排绕障、多区域车辆可达性、车辆宽度、扫掠包络和最小转弯半径仍未
|
||||
实现;遇到这些布局时当前版本拒绝统一铺装,不能将面裁切宣称为可驾驶路径。
|
||||
@@ -1 +1,2 @@
|
||||
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||
{"file": ".trellis/spec/backend/junction-layer-seams.md", "reason": "接缝 1 cm 与拒绝契约"}
|
||||
{"file": ".trellis/tasks/09-17-junction-exclusion-routing/research.md", "reason": "排除区反例与支持矩阵"}
|
||||
@@ -0,0 +1,20 @@
|
||||
# 推进清单
|
||||
|
||||
- [x] 保存真实 OSM 孔洞、入口阻断、中心切断与双区域 solver 探针。
|
||||
- [x] 记录当前支持/拒绝矩阵及最终铺装孔洞丢失的实测面积。
|
||||
- [x] 确定下一最小实现单元及后续产品决策边界。
|
||||
- [x] 用户确认最终铺装排除区保留方案,已启动实施。
|
||||
- [x] 补失败回归,再实现装配后的显式排除与连通/接边检查。
|
||||
- [x] 验证无排除区兼容性、施工空洞填补、合法孔洞、拒绝路径与诊断身份。
|
||||
- [x] 运行铺装、区域 solver、构建反例、全图层接缝、岛体位移及 npm test。
|
||||
- [x] 检查变更文件格式、类型和 git diff;更新规范及证据后走提交归档。
|
||||
- [x] 按 Phase 3.4 确认提交批次。
|
||||
- [ ] 提交并归档。
|
||||
|
||||
## 验证记录(2026-09-17)
|
||||
|
||||
- `node test/junction-pavement-region.js` 通过:真实 OSM 的 1 m²、双孔洞和重叠孔洞最终发布面交集均小于 `0.000001 m²`;完全覆盖、切断和入口阻断都拒绝统一面并提供排除区身份。
|
||||
- `node test/junction-region-solver.js`、`node test/junction-build-plan-counterexamples.js`、`node test/junction-island-offset.js` 和 `node test/junction-layer-seams.js` 通过;接缝为 13 个场景、1,446 处测量。
|
||||
- `npm run test:client` 与变更文件的 Prettier 检查通过。`npm test` 仅在既有 `test/fixtures.js:18` 快照不匹配处失败;没有刷新该基线。全仓 `npm run format:check` 仍仅报告既有 `src/compile/junction-facility-composition.js` 格式问题。
|
||||
|
||||
既有 fixture 快照差异、全仓设施文件格式问题单列,不能通过刷新基线隐藏。
|
||||
@@ -8,13 +8,27 @@
|
||||
|
||||
- 审计来源通行关系、排除区与必要入口连接,区分面裁切、连通区域和车辆绕障路径。
|
||||
- 比较支持边界、失败诊断与可行方案,明确是否需要车辆尺寸及转弯半径等输入。
|
||||
- 优先完成 junction-layer-seams;本任务当前仅规划,不恢复已归档父任务。
|
||||
- junction-layer-seams 已完成归档;2026-09-17 用户确认实施最终铺装排除区保留,不恢复已归档父任务。
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] 为接缝被阻断、核心内部障碍和多个隔离通行区提供可重复反例。
|
||||
- [ ] 给出当前求解器的支持/拒绝矩阵和下一实现单元的可观察验收条件。
|
||||
- [ ] 明确需要用户决定的通行语义与安全约束,实施前完成设计和实施计划。
|
||||
- [x] 为接缝被阻断、核心内部障碍和多个隔离通行区提供可重复反例。
|
||||
- [x] 给出当前求解器的支持/拒绝矩阵和下一实现单元的可观察验收条件。
|
||||
- [x] 明确需要用户决定的通行语义与安全约束,实施前完成设计和实施计划。
|
||||
|
||||
## 已确认的实现单元
|
||||
|
||||
最终统一铺装必须保留显式排除区,不得将合法核心孔洞当成施工空洞填平。
|
||||
无排除区行为不变,施工空洞仍填补;扣除排除区后为空、断开或损坏必要
|
||||
接边时明确拒绝统一面。以最终发布面交集面积与完整接边验证,不只测核心。
|
||||
|
||||
验收:1 m² 孔洞最终铺装交集小于 0.000001 m²;多个合法孔洞保留;
|
||||
阻断布局明确诊断而非制造连接;无排除区原场景与 1 cm 接缝回归保持通过。
|
||||
不含自动绕障、入口重排、车辆扫掠或新设施语义;这些另需产品决策。
|
||||
|
||||
- [x] 合法孔洞与多个排除区域在最终发布面保留,交集面积 < 0.000001 m²。
|
||||
- [x] 空集、断开和必要接边受损明确拒绝统一面,诊断保留身份。
|
||||
- [x] 无排除区输出兼容;施工空洞继续填补;既有接缝回归通过。
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
{
|
||||
"cases": [
|
||||
{
|
||||
"name": "interior-hole",
|
||||
"surfaces": [
|
||||
{
|
||||
"kind": "complex-core",
|
||||
"rings": [
|
||||
2
|
||||
],
|
||||
"overlapSquareMeters": 0
|
||||
},
|
||||
{
|
||||
"kind": "complex-pavement-region",
|
||||
"rings": [
|
||||
2
|
||||
],
|
||||
"overlapSquareMeters": 0
|
||||
}
|
||||
],
|
||||
"approachCount": 8,
|
||||
"diagnostics": [
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8024512135/segment%3Away%2F851989492%2F1/road%3Away%2F851989492%3Asegment%2F1%3Aforward|8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-hole,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8024512135/segment%3Away%2F851989492%2F1/road%3Away%2F851989492%3Asegment%2F1%3Aforward|8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8024512145/segment%3Away%2F858770821%2F2/road%3Away%2F858770821%3Asegment%2F2%3Aforward|8024512147/segment%3Away%2F99505317%2F0/road%3Away%2F99505317%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-hole,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8024512145/segment%3Away%2F858770821%2F2/road%3Away%2F858770821%3Asegment%2F2%3Aforward|8024512147/segment%3Away%2F99505317%2F0/road%3Away%2F99505317%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-hole,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-hole,已省略,避免覆盖已知不可通行空间。"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "interior-obstacle",
|
||||
"surfaces": [
|
||||
{
|
||||
"kind": "complex-pavement-region",
|
||||
"rings": [
|
||||
1
|
||||
],
|
||||
"overlapSquareMeters": 0
|
||||
}
|
||||
],
|
||||
"approachCount": 8,
|
||||
"diagnostics": [
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8024512135/segment%3Away%2F851989492%2F1/road%3Away%2F851989492%3Asegment%2F1%3Aforward|8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-obstacle,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8024512135/segment%3Away%2F851989492%2F1/road%3Away%2F851989492%3Asegment%2F1%3Aforward|8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8024512145/segment%3Away%2F858770821%2F2/road%3Away%2F858770821%3Asegment%2F2%3Aforward|8024512147/segment%3Away%2F99505317%2F0/road%3Away%2F99505317%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-obstacle,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8024512145/segment%3Away%2F858770821%2F2/road%3Away%2F858770821%3Asegment%2F2%3Aforward|8024512147/segment%3Away%2F99505317%2F0/road%3Away%2F99505317%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-obstacle,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 protected-obstacle,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-core-closure-unsupported",
|
||||
"subjectId": "junction-cluster:exclusion-probe",
|
||||
"message": "路口中心区域缺少可验证的闭合边(known-exclusion-region),已保留各进口道路面。"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "blocked-entry",
|
||||
"surfaces": [],
|
||||
"approachCount": 6,
|
||||
"diagnostics": [
|
||||
{
|
||||
"rule": "complex-junction-entry-overlaps-known-region",
|
||||
"subjectId": "carriageway:cluster:exclusion-probe:carriageway:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward",
|
||||
"message": "该进口过渡区域侵入已知排除区域,已省略该进口面以保留来源区域。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-entry-overlaps-known-region",
|
||||
"subjectId": "carriageway:cluster:exclusion-probe:carriageway:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward",
|
||||
"message": "该进口过渡区域侵入已知排除区域,已省略该进口面以保留来源区域。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 blocked-entry,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-core-closure-unsupported",
|
||||
"subjectId": "junction-cluster:exclusion-probe",
|
||||
"message": "路口中心区域缺少可验证的闭合边(known-exclusion-region),已保留各进口道路面。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-pavement-region-required-seam-lost",
|
||||
"subjectId": "junction-cluster:exclusion-probe",
|
||||
"message": "统一铺装区域不满足连续通行约束(required-seam-lost),保留结构输入面并拒绝发布统一铺装面。"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "split-core",
|
||||
"surfaces": [],
|
||||
"approachCount": 6,
|
||||
"diagnostics": [
|
||||
{
|
||||
"rule": "complex-junction-entry-overlaps-known-region",
|
||||
"subjectId": "carriageway:cluster:exclusion-probe:carriageway:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward",
|
||||
"message": "该进口过渡区域侵入已知排除区域,已省略该进口面以保留来源区域。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-entry-overlaps-known-region",
|
||||
"subjectId": "carriageway:cluster:exclusion-probe:carriageway:8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward",
|
||||
"message": "该进口过渡区域侵入已知排除区域,已省略该进口面以保留来源区域。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8024512135/segment%3Away%2F851989492%2F1/road%3Away%2F851989492%3Asegment%2F1%3Aforward|8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 split-core,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8024512135/segment%3Away%2F851989492%2F1/road%3Away%2F851989492%3Asegment%2F1%3Aforward|8024512147/segment%3Away%2F858770822%2F2/road%3Away%2F858770822%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8024512145/segment%3Away%2F858770821%2F2/road%3Away%2F858770821%3Asegment%2F2%3Aforward|8024512147/segment%3Away%2F99505317%2F0/road%3Away%2F99505317%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 split-core,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8024512145/segment%3Away%2F858770821%2F2/road%3Away%2F858770821%3Asegment%2F2%3Aforward|8024512147/segment%3Away%2F99505317%2F0/road%3Away%2F99505317%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 split-core,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-corner-exclusion-overlap",
|
||||
"subjectId": "corner:corner:cluster:exclusion-probe:arm:8005332807/segment%3Away%2F253970456%2F1/road%3Away%2F253970456%3Asegment%2F1%3Aforward|8024512145/segment%3Away%2F851986783%2F2/road%3Away%2F851986783%3Asegment%2F2%3Aforward>cluster:exclusion-probe:arm:8005332807/segment%3Away%2F859509947%2F5/road%3Away%2F859509947%3Asegment%2F5%3Aforward|8024512135/segment%3Away%2F858770823%2F2/road%3Away%2F858770823%3Asegment%2F2%3Aforward",
|
||||
"message": "该角部道路补面侵入已知排除区域 split-core,已省略,避免覆盖已知不可通行空间。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-core-closure-unsupported",
|
||||
"subjectId": "junction-cluster:exclusion-probe",
|
||||
"message": "路口中心区域缺少可验证的闭合边(known-exclusion-region),已保留各进口道路面。"
|
||||
},
|
||||
{
|
||||
"rule": "complex-junction-pavement-region-disconnected",
|
||||
"subjectId": "junction-cluster:exclusion-probe",
|
||||
"message": "统一铺装区域不满足连续通行约束(disconnected),保留结构输入面并拒绝发布统一铺装面。"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"splitSolver": {
|
||||
"components": 2,
|
||||
"assemblyStatus": "disconnected"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
// Research probe: --expect-bug reproduces the recorded pre-fix behavior.
|
||||
// Without that flag, verifies the corrected final-pavement contract.
|
||||
// Run from the repository root: node .trellis/tasks/09-17-junction-exclusion-routing/probe.cjs
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const assert = require('assert/strict');
|
||||
const root = process.cwd();
|
||||
const { compileRoadModel, compileGeometry } = require(path.join(root, 'src/compile/native-road'));
|
||||
const { solvePavedRegion } = require(path.join(root, 'src/compile/junction-region-solver'));
|
||||
const { solveComplexPavementRegion } = require(path.join(root, 'src/compile/junction-pavement-region'));
|
||||
const clipping = require(path.join(root, 'node_modules/polygon-clipping'));
|
||||
const model = compileRoadModel(fs.readFileSync(path.join(root, 'inputs/osm/枫树二路.osm'), 'utf8'), { overrides: [] });
|
||||
const cluster = { id: 'exclusion-probe', template: 'complex-junction-v1', coreRadiusMeters: 21, nodeIds: ['8005332807', '8024512135', '8024512145', '8024512147'] };
|
||||
const options = { junctionTemplates: { enabled: true, clusters: [cluster] } };
|
||||
const compile = (exclusionRegions = []) => compileGeometry({ ...model, exclusionRegions }, { overrides: [] }, options);
|
||||
const base = compile();
|
||||
const core = base.roadSurface.features.find((f) => f.properties.kind === 'complex-core');
|
||||
assert.ok(core);
|
||||
const origin = core.properties.center;
|
||||
const scale = 111320 * Math.cos(origin[1] * Math.PI / 180);
|
||||
const xy = (p) => [(p[0] - origin[0]) * scale, (p[1] - origin[1]) * 111320];
|
||||
const ll = (p) => [origin[0] + p[0] / scale, origin[1] + p[1] / 111320];
|
||||
const rectangle = (x1, y1, x2, y2) => [[x1, y1], [x2, y1], [x2, y2], [x1, y2], [x1, y1]];
|
||||
const area = (regions) => regions.reduce((sum, polygon) => sum + polygon.reduce((sum, ring, index) => sum + (index ? -1 : 1) * Math.abs(ring.slice(1).reduce((sum, q, i) => sum + ring[i][0] * q[1] - q[0] * ring[i][1], 0)) / 2, 0), 0);
|
||||
const regions = (feature) => (feature.geometry.type === 'Polygon' ? [feature.geometry.coordinates] : feature.geometry.coordinates).map((p) => p.map((r) => r.map(xy)));
|
||||
const hole = rectangle(-0.5, -0.5, 0.5, 0.5).map(ll);
|
||||
const approach = base.roadSurface.features.find((f) => f.properties.kind === 'complex-approach');
|
||||
const cases = [
|
||||
{ name: 'interior-hole', exclusion: { id: 'protected-hole', isHole: true, ring: hole } },
|
||||
{ name: 'interior-obstacle', exclusion: { id: 'protected-obstacle', ring: hole } },
|
||||
{ name: 'blocked-entry', exclusion: { id: 'blocked-entry', ring: approach.geometry.coordinates[0] } },
|
||||
{ name: 'split-core', exclusion: { id: 'split-core', ring: rectangle(-0.5, -100, 0.5, 100).map(ll) } },
|
||||
];
|
||||
const results = cases.map(({ name, exclusion }) => {
|
||||
const geometry = compile([exclusion]);
|
||||
const surfaces = geometry.roadSurface.features.filter((f) => ['complex-core', 'complex-pavement-region'].includes(f.properties.kind)).map((f) => ({
|
||||
kind: f.properties.kind,
|
||||
rings: regions(f).map((p) => p.length),
|
||||
overlapSquareMeters: area(clipping.intersection(regions(f), [[exclusion.ring.map(xy)]])),
|
||||
}));
|
||||
return { name, surfaces, approachCount: geometry.roadSurface.features.filter((f) => f.properties.kind === 'complex-approach').length, diagnostics: geometry.diagnostics.filter((d) => /exclusion|known-region|closure|pavement-region/.test(d.rule)).map(({ rule, subjectId, message }) => ({ rule, subjectId, message })) };
|
||||
});
|
||||
const holeResult = results[0];
|
||||
assert.equal(holeResult.surfaces.find((f) => f.kind === 'complex-core').overlapSquareMeters, 0);
|
||||
const finalOverlap = holeResult.surfaces.find((f) => f.kind === 'complex-pavement-region').overlapSquareMeters;
|
||||
if (process.argv.includes('--expect-bug')) assert.ok(finalOverlap > 0.99, 'Expected original hole-filling defect');
|
||||
else assert.ok(finalOverlap < 0.000001, 'Final pavement must preserve the explicit hole');
|
||||
const shell = rectangle(-10, -10, 10, 10);
|
||||
const divided = solvePavedRegion(shell, [rectangle(-1, -11, 1, 11)]);
|
||||
assert.equal(divided.length, 2);
|
||||
const assembled = solveComplexPavementRegion(divided.map((p) => p[0]));
|
||||
assert.equal(assembled.status, 'disconnected');
|
||||
console.log(JSON.stringify({ cases: results, splitSolver: { components: divided.length, assemblyStatus: assembled.status } }, null, 2));
|
||||
@@ -12,3 +12,25 @@
|
||||
需要优先澄清的实现风险:complex-junction-surfaces.js 的 appendPavementRegion 只取各面 coordinates[0];junction-pavement-region.js 又以 polygon[0] 填掉所有合并结果孔洞。因而不能由 buildCoreClosure 的孔洞单测推断最终权威铺装保留已知排除区域。后续应先添加最终发布面的排除区反例,区分构建缝隙与已知孔洞,再考虑绕障。当前未声称运行了该最终反例,也未改产品行为。
|
||||
|
||||
建议的实施顺序:最终铺装保留排除区 → 对象级连接/拒绝契约 → 有限障碍布局的区域求解 → 需要来源与车辆约束的路径规划。不能只对凹多边形做裁切后宣称已提供合法车辆绕行。
|
||||
|
||||
## 运行复现(2026-09-17)
|
||||
|
||||
已运行 `node .trellis/tasks/09-17-junction-exclusion-routing/probe.cjs`,结果保存在
|
||||
`probe-results.json`。输入为当前真实 OSM 四臂路口,加可控排除区域。
|
||||
脚本断言当前缺陷仍存在,是研究探针,不得作为修复后的通过回归。
|
||||
|
||||
| 反例 | 核心/最终发布结果 | 结论 |
|
||||
| --- | --- | --- |
|
||||
| 中心 1 m² 的 isHole 孔洞 | 核心 2 个 ring,交集 0;最终铺装 1 个 ring,交集 1.00000000018 m² | 确认孔洞被填平;有角部避障诊断,但没有最终铺装侵占诊断 |
|
||||
| 同位置非 isHole 障碍 | 核心 known-exclusion-region 拒绝;此样本最终面交集 0 | 普通障碍与声明安全孔洞走不同路径,不能由本例推断任意障碍安全 |
|
||||
| 整个入口作为障碍 | 进口从 8 减到 6;核心拒绝,最终面与障碍交集 0 | 省略冲突进口,不自动绕行 |
|
||||
| 贯穿中心的窄障碍 | 核心拒绝,最终面 disconnected 并不发布 | 维持拒绝;没有跨障碍连接能力 |
|
||||
| 纯 solver 矩形被障碍切开 | difference 返回 2 区域,铺装装配返回 disconnected | 面裁切可输出多区域,但未提供车辆通行规划 |
|
||||
|
||||
下一实现单元应只修复最终铺装的排除区保留:先填补施工产生的假孔洞,
|
||||
再显式扣除来源排除区。不可简单取消所有填洞,否则会恢复此前修复的
|
||||
中心铺装空洞;也不能只保留核心 holes,因为过街扫掠和其他补面仍可能
|
||||
覆盖排除区。若扣除后为空、多区域或损坏必要接边,拒绝统一面并说明原因。
|
||||
|
||||
更后续需要产品决定:是否允许重排入口绕障、多区域之间的合法转向关系、
|
||||
车辆宽度/最小转弯半径/扫掠约束。当前局部修复不依赖这些决策。
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "junction-exclusion-routing",
|
||||
"title": "复杂排除区绕行与多通行区求解范围研究",
|
||||
"description": "承接已归档父任务的区域求解遗留;先确定来源通行关系和安全可行域,不将多边形裁切等同于路径规划。",
|
||||
"status": "planning",
|
||||
"status": "in_progress",
|
||||
"dev_type": null,
|
||||
"scope": null,
|
||||
"package": null,
|
||||
@@ -20,7 +20,7 @@
|
||||
"subtasks": [],
|
||||
"children": [],
|
||||
"parent": null,
|
||||
"relatedFiles": [],
|
||||
"notes": "",
|
||||
"relatedFiles": ["src/compile/junction-pavement-region.js", "src/compile/complex-junction-surfaces.js", "test/junction-pavement-region.js"],
|
||||
"notes": "最终铺装排除区保留已实现并通过专项回归;详情见 evidence.md。自动绕障与车辆路径规划仍明确不在本任务范围。用户已确认 Phase 3.4 提交及归档。",
|
||||
"meta": {}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const { solveComplexPavementRegion } = require('./junction-pavement-region');
|
||||
const { solveComplexPavementRegion, segmentCoveredByPolygon } = require('./junction-pavement-region');
|
||||
const { intersection } = require('./junction-polygon-ops');
|
||||
|
||||
function hasPositiveArea(regions) {
|
||||
return regions.some((polygon) =>
|
||||
polygon.some((ring, index) => {
|
||||
const area = Math.abs(
|
||||
ring
|
||||
.slice(1)
|
||||
.reduce(
|
||||
(sum, point, pointIndex) => sum + ring[pointIndex][0] * point[1] - point[0] * ring[pointIndex][1],
|
||||
0,
|
||||
) / 2,
|
||||
);
|
||||
return index === 0 ? area > 1e-16 : false;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function buildCoreSurface({ cluster, helpers, center, nodeIds, arms, carriageways, shape, coreRadius, coreClosure }) {
|
||||
const coreRing = coreClosure.status === 'supported' ? coreClosure.ring : null;
|
||||
@@ -100,13 +117,49 @@ function buildApproachSurfaceFeatures(boundaryParts, model, cluster) {
|
||||
return features;
|
||||
}
|
||||
|
||||
function appendPavementRegion(features, crossingRegions, cluster, center, nodeIds, helpers) {
|
||||
function appendPavementRegion(
|
||||
features,
|
||||
crossingRegions,
|
||||
cluster,
|
||||
center,
|
||||
nodeIds,
|
||||
helpers,
|
||||
exclusionRegions,
|
||||
boundaryParts,
|
||||
topology,
|
||||
) {
|
||||
const cornerDiagnostics = [];
|
||||
// Publish a single canonical pavement region last. The individual approach,
|
||||
// core and corner polygons above remain structural inputs for editing and
|
||||
// diagnostics; they are no longer the visible authority at the junction.
|
||||
const basePavement = features.map((feature) => feature.geometry.coordinates[0]);
|
||||
const pavementRegion = solveComplexPavementRegion(basePavement, crossingRegions);
|
||||
const pavementRegion = solveComplexPavementRegion(
|
||||
basePavement,
|
||||
crossingRegions,
|
||||
exclusionRegions.map((region) => region.ring),
|
||||
);
|
||||
const excludedIds = exclusionRegions.map((region) => String(region.id ?? ''));
|
||||
const missingCarriageways = [];
|
||||
if (exclusionRegions.length && pavementRegion.status === 'supported') {
|
||||
try {
|
||||
if (exclusionRegions.some((region) => hasPositiveArea(intersection(pavementRegion.regions, [region.ring]))))
|
||||
pavementRegion.status = 'exclusion-overlap';
|
||||
for (const item of topology.carriageways) {
|
||||
const part = boundaryParts.find((part) => part.item.key === item.key);
|
||||
if (
|
||||
!part ||
|
||||
!['inner', 'outer'].every((edge) =>
|
||||
segmentCoveredByPolygon(part.section[edge].left, part.section[edge].right, pavementRegion.regions[0]),
|
||||
)
|
||||
)
|
||||
missingCarriageways.push(item.key);
|
||||
}
|
||||
if (missingCarriageways.length) pavementRegion.status = 'required-seam-lost';
|
||||
} catch (error) {
|
||||
pavementRegion.status = 'unsupported';
|
||||
pavementRegion.reason = error.message;
|
||||
}
|
||||
}
|
||||
if (pavementRegion.status === 'supported') {
|
||||
for (const feature of features) feature.properties.pavement_input = true;
|
||||
features.push({
|
||||
@@ -124,21 +177,25 @@ function appendPavementRegion(features, crossingRegions, cluster, center, nodeId
|
||||
},
|
||||
geometry: { type: 'MultiPolygon', coordinates: pavementRegion.regions },
|
||||
});
|
||||
} else
|
||||
cornerDiagnostics.push(
|
||||
helpers.diagnostic(
|
||||
'warning',
|
||||
`junction-cluster:${cluster.id}`,
|
||||
[...nodeIds],
|
||||
pavementRegion.status === 'unsupported'
|
||||
? 'complex-junction-pavement-region-assembly-failed'
|
||||
: 'complex-junction-pavement-region-disconnected',
|
||||
pavementRegion.status === 'unsupported'
|
||||
? '统一铺装区域无法可靠装配,保留结构输入面并拒绝发布统一铺装面。'
|
||||
: '过街与入口无法组成连续铺装区域,保留结构输入面并拒绝发布统一铺装面。',
|
||||
center,
|
||||
),
|
||||
} else {
|
||||
const diagnostic = helpers.diagnostic(
|
||||
'warning',
|
||||
`junction-cluster:${cluster.id}`,
|
||||
[...nodeIds],
|
||||
pavementRegion.status === 'unsupported'
|
||||
? 'complex-junction-pavement-region-assembly-failed'
|
||||
: `complex-junction-pavement-region-${pavementRegion.status}`,
|
||||
pavementRegion.status === 'unsupported'
|
||||
? '统一铺装区域无法可靠装配,保留结构输入面并拒绝发布统一铺装面。'
|
||||
: `统一铺装区域不满足连续通行约束(${pavementRegion.status}),保留结构输入面并拒绝发布统一铺装面。`,
|
||||
center,
|
||||
);
|
||||
if (exclusionRegions.length) {
|
||||
diagnostic.exclusion_region_ids = excludedIds;
|
||||
diagnostic.carriageway_keys = missingCarriageways;
|
||||
}
|
||||
cornerDiagnostics.push(diagnostic);
|
||||
}
|
||||
return cornerDiagnostics;
|
||||
}
|
||||
|
||||
@@ -171,7 +228,19 @@ function assemblePavementSurfaces({
|
||||
// Preserve the structural surface order before publishing canonical pavement.
|
||||
features.push(...cornerFills);
|
||||
if (coreFeature) features.push(coreFeature);
|
||||
diagnostics.push(...appendPavementRegion(features, crossingRegions, cluster, center, nodeIds, helpers));
|
||||
diagnostics.push(
|
||||
...appendPavementRegion(
|
||||
features,
|
||||
crossingRegions,
|
||||
cluster,
|
||||
center,
|
||||
nodeIds,
|
||||
helpers,
|
||||
model.exclusionRegions || [],
|
||||
boundaryParts,
|
||||
topology,
|
||||
),
|
||||
);
|
||||
return { features, diagnostics };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
const { union } = require('./junction-polygon-ops');
|
||||
const { union, difference } = require('./junction-polygon-ops');
|
||||
const { segmentCoveredByRing } = require('./junction-boundary-graph');
|
||||
|
||||
/**
|
||||
* The road layer has one authoritative complex-junction region. Construction
|
||||
* parts are inputs only; crossings contribute their complete rectangular
|
||||
* carriageway footprint rather than disconnected white stripes.
|
||||
*/
|
||||
function solveComplexPavementRegion(parts, crossingRegions = []) {
|
||||
function solveComplexPavementRegion(parts, crossingRegions = [], exclusionRegions = []) {
|
||||
const inputs = [...parts, ...crossingRegions].filter(
|
||||
(ring) => Array.isArray(ring) && ring.length >= 4 && ring.every((point) => point?.every(Number.isFinite)),
|
||||
);
|
||||
let regions;
|
||||
try {
|
||||
regions = union(...inputs.map((ring) => [ring]));
|
||||
// Fill construction pockets first, then restore explicit obstacles. A
|
||||
// crossing footprint or corner fill must not pave a protected core hole.
|
||||
regions = regions.map((polygon) => [polygon[0]]);
|
||||
if (exclusionRegions.length) regions = difference(regions, ...exclusionRegions.map((ring) => [ring]));
|
||||
} catch (error) {
|
||||
// A valid local edit must not make the whole preview endpoint fail merely
|
||||
// because the third-party polygon assembler cannot order this irregular
|
||||
@@ -21,17 +26,59 @@ function solveComplexPavementRegion(parts, crossingRegions = []) {
|
||||
// publishes an object-level diagnostic instead of a false unified surface.
|
||||
return { status: 'unsupported', regions: [], inputCount: inputs.length, reason: error.message };
|
||||
}
|
||||
// Construction polygons can enclose unpaved pockets where approach,
|
||||
// core and corner edges meet. Those pockets are the visible "holes" in a
|
||||
// complex junction; they are not exclusion regions and must be paved.
|
||||
const filledRegions = regions.map((polygon) => [polygon[0]]);
|
||||
return {
|
||||
status: filledRegions.length === 1 ? 'supported' : 'disconnected',
|
||||
regions: filledRegions,
|
||||
status: regions.length === 1 ? 'supported' : regions.length ? 'disconnected' : 'empty',
|
||||
regions,
|
||||
inputCount: inputs.length,
|
||||
};
|
||||
}
|
||||
|
||||
// Complete segment coverage, including interior holes. Split at every hole
|
||||
// crossing instead of checking fixed samples that can miss a narrow obstacle.
|
||||
function segmentCoveredByPolygon(start, end, polygon) {
|
||||
if (!segmentCoveredByRing(start, end, polygon[0])) return false;
|
||||
const scale = 111320 * Math.cos((start[1] * Math.PI) / 180);
|
||||
const xy = (p) => [(p[0] - start[0]) * scale, (p[1] - start[1]) * 111320];
|
||||
const d = xy(end);
|
||||
const cross = (a, b) => a[0] * b[1] - a[1] * b[0];
|
||||
return polygon.slice(1).every((hole) => {
|
||||
const ring = hole.map(xy);
|
||||
const parameters = [0, 1];
|
||||
for (let i = 1; i < ring.length; i++) {
|
||||
const a = ring[i - 1],
|
||||
b = ring[i];
|
||||
const edge = [b[0] - a[0], b[1] - a[1]];
|
||||
const denominator = cross(d, edge);
|
||||
if (Math.abs(denominator) < 1e-12) continue;
|
||||
const t = cross(a, edge) / denominator,
|
||||
u = cross(a, d) / denominator;
|
||||
if (t > 0 && t < 1 && u >= 0 && u <= 1) parameters.push(t);
|
||||
}
|
||||
parameters.sort((a, b) => a - b);
|
||||
return parameters.slice(1).every((t, index) => {
|
||||
const p = d.map((value) => (value * (t + parameters[index])) / 2);
|
||||
let inside = false;
|
||||
for (let i = 1; i < ring.length; i++) {
|
||||
const a = ring[i - 1],
|
||||
b = ring[i];
|
||||
const edge = [b[0] - a[0], b[1] - a[1]];
|
||||
const relative = [p[0] - a[0], p[1] - a[1]];
|
||||
const length = Math.hypot(...edge);
|
||||
if (
|
||||
length &&
|
||||
Math.abs(cross(edge, relative)) / length <= 0.0001 &&
|
||||
relative[0] * edge[0] + relative[1] * edge[1] >= 0 &&
|
||||
relative[0] * edge[0] + relative[1] * edge[1] <= length * length
|
||||
)
|
||||
return true;
|
||||
if (a[1] > p[1] !== b[1] > p[1] && p[0] < ((b[0] - a[0]) * (p[1] - a[1])) / (b[1] - a[1]) + a[0])
|
||||
inside = !inside;
|
||||
}
|
||||
return !inside;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function offset(point, heading, meters) {
|
||||
const radians = (heading * Math.PI) / 180;
|
||||
const scale = 111320 * Math.cos((point[1] * Math.PI) / 180);
|
||||
@@ -46,4 +93,4 @@ function rectangle(center, heading, depth, span) {
|
||||
return [first, second, third, fourth, first];
|
||||
}
|
||||
|
||||
module.exports = { solveComplexPavementRegion, rectangle };
|
||||
module.exports = { solveComplexPavementRegion, segmentCoveredByPolygon, rectangle };
|
||||
@@ -4,6 +4,15 @@ const assert = require('assert/strict');
|
||||
const fs = require('fs');
|
||||
const clipping = require('polygon-clipping');
|
||||
const { compileRoadModel, compileGeometry } = require('../src/compile/native-road');
|
||||
const { solveComplexPavementRegion, segmentCoveredByPolygon } = require('../src/compile/junction-pavement-region');
|
||||
|
||||
const rectangle = (x1, y1, x2, y2) => [
|
||||
[x1, y1],
|
||||
[x2, y1],
|
||||
[x2, y2],
|
||||
[x1, y2],
|
||||
[x1, y1],
|
||||
];
|
||||
|
||||
const ringArea = (ring) =>
|
||||
Math.abs(
|
||||
@@ -90,4 +99,89 @@ for (const [name, nodeIds] of Object.entries({
|
||||
);
|
||||
assert.ok(edited.roadSurface.features.some((feature) => feature.properties.kind === 'complex-corner-fillet'));
|
||||
}
|
||||
// Construction gaps are filled; explicit exclusions are subtracted afterwards,
|
||||
// including when a crossing footprint originally covers the same obstacle.
|
||||
{
|
||||
const parts = [rectangle(0, 0, 10, 2), rectangle(0, 8, 10, 10), rectangle(0, 0, 2, 10), rectangle(8, 0, 10, 10)];
|
||||
assert.equal(multiArea(solveComplexPavementRegion(parts).regions), 100);
|
||||
const holes = [rectangle(3, 3, 4, 4), rectangle(6, 6, 7, 7)];
|
||||
const result = solveComplexPavementRegion(parts, [rectangle(2, 2, 8, 8)], holes);
|
||||
assert.equal(result.status, 'supported');
|
||||
assert.equal(result.regions[0].length, 3);
|
||||
assert.equal(multiArea(result.regions), 98);
|
||||
const overlapping = solveComplexPavementRegion(parts, [], [holes[0], rectangle(3.5, 3, 4.5, 4)]);
|
||||
assert.equal(multiArea(overlapping.regions), 98.5);
|
||||
assert.equal(solveComplexPavementRegion(parts, [], [rectangle(-1, -1, 11, 11)]).status, 'empty');
|
||||
assert.equal(solveComplexPavementRegion(parts, [], [rectangle(4, -1, 6, 11)]).status, 'disconnected');
|
||||
const notch = solveComplexPavementRegion(parts, [], [rectangle(4, -1, 6, 1)]);
|
||||
assert.equal(notch.status, 'supported');
|
||||
assert.equal(multiArea(notch.regions), 98);
|
||||
assert.equal(
|
||||
segmentCoveredByPolygon([2, 3.5], [8, 3.5], result.regions[0]),
|
||||
false,
|
||||
'interior hole must break seam coverage',
|
||||
);
|
||||
assert.equal(segmentCoveredByPolygon([0, 0], [10, 0], result.regions[0]), true);
|
||||
assert.equal(
|
||||
segmentCoveredByPolygon([0, 0], [10, 0], notch.regions[0]),
|
||||
false,
|
||||
'interior notch must break full seam coverage',
|
||||
);
|
||||
}
|
||||
|
||||
// Measure final published OSM pavement in local metres, independently of the
|
||||
// construction solver. Core holes alone did not catch the original defect.
|
||||
{
|
||||
const cluster = {
|
||||
id: 'exclusion-pavement',
|
||||
template: 'complex-junction-v1',
|
||||
coreRadiusMeters: 21,
|
||||
nodeIds: ['8005332807', '8024512135', '8024512145', '8024512147'],
|
||||
};
|
||||
const options = { junctionTemplates: { enabled: true, clusters: [cluster] } };
|
||||
const compile = (exclusionRegions = []) =>
|
||||
compileGeometry({ ...model, exclusionRegions }, { overrides: [] }, options);
|
||||
const pavementOf = (geometry) =>
|
||||
geometry.roadSurface.features.find((feature) => feature.properties.kind === 'complex-pavement-region');
|
||||
const baseline = compile();
|
||||
const origin = pavementOf(baseline).properties.center;
|
||||
const scale = 111320 * Math.cos((origin[1] * Math.PI) / 180);
|
||||
const ll = ([x, y]) => [origin[0] + x / scale, origin[1] + y / 111320];
|
||||
const xy = ([x, y]) => [(x - origin[0]) * scale, (y - origin[1]) * 111320];
|
||||
const mask = (id, bounds) => ({ id, isHole: true, ring: rectangle(...bounds).map(ll) });
|
||||
for (const exclusions of [
|
||||
[mask('one-square-metre', [-0.5, -0.5, 0.5, 0.5])],
|
||||
[mask('first-hole', [-1.5, -0.5, -0.5, 0.5]), mask('second-hole', [0.5, -0.5, 1.5, 0.5])],
|
||||
[mask('overlap-a', [-0.5, -0.5, 0.5, 0.5]), mask('overlap-b', [0, -0.5, 1, 0.5])],
|
||||
]) {
|
||||
const published = pavementOf(compile(exclusions));
|
||||
assert.ok(published, 'safe interior exclusions must retain a canonical pavement');
|
||||
assert.ok(published.geometry.coordinates[0].length > 1, 'canonical pavement must retain explicit holes');
|
||||
const pavementMeters = published.geometry.coordinates.map((polygon) => polygon.map((ring) => ring.map(xy)));
|
||||
for (const exclusion of exclusions)
|
||||
assert.ok(
|
||||
multiArea(clipping.intersection(pavementMeters, [[exclusion.ring.map(xy)]])) < 1e-6,
|
||||
`${exclusion.id} must remain unpaved`,
|
||||
);
|
||||
}
|
||||
const approach = baseline.roadSurface.features.find((feature) => feature.properties.kind === 'complex-approach');
|
||||
for (const exclusion of [
|
||||
mask('fully-covered', [-200, -200, 200, 200]),
|
||||
mask('split-region', [-0.5, -100, 0.5, 100]),
|
||||
{ id: 'blocked-entry', ring: approach.geometry.coordinates[0] },
|
||||
]) {
|
||||
const result = compile([exclusion]);
|
||||
assert.equal(pavementOf(result), undefined, `${exclusion.id} must refuse unified publication`);
|
||||
const diagnostic = result.diagnostics.find((entry) => entry.rule.startsWith('complex-junction-pavement-region-'));
|
||||
assert.ok(diagnostic, `${exclusion.id} requires a pavement rejection diagnostic`);
|
||||
assert.deepEqual(diagnostic.exclusion_region_ids, [exclusion.id]);
|
||||
assert.equal(diagnostic.subjectId, `junction-cluster:${cluster.id}`);
|
||||
assert.equal(
|
||||
result.roadSurface.features.some((feature) => feature.properties.pavement_input),
|
||||
false,
|
||||
);
|
||||
if (exclusion.id === 'blocked-entry')
|
||||
assert.ok(diagnostic.carriageway_keys.length, 'omitted required entry must be identified');
|
||||
}
|
||||
}
|
||||
console.log('junction pavement region tests passed');
|
||||
Reference in new issue
Block a user