From 2b790850420f8c960c73b94e66d427fce3aa5bb4 Mon Sep 17 00:00:00 2001 From: que01 Date: Fri, 11 Sep 2026 11:31:21 +0800 Subject: [PATCH] feat: publish junction region connectivity metrics --- .trellis/spec/backend/direct-edit-api.md | 4 ++++ .../tasks/09-08-junction-reference-fidelity/implement.md | 1 + src/compile/complex-junction.js | 4 ++++ src/compile/junction-boundary-graph.js | 5 +++++ test/junction-build-plan-counterexamples.js | 5 +++++ 5 files changed, 19 insertions(+) diff --git a/.trellis/spec/backend/direct-edit-api.md b/.trellis/spec/backend/direct-edit-api.md index 02f03ca..f0c1e13 100644 --- a/.trellis/spec/backend/direct-edit-api.md +++ b/.trellis/spec/backend/direct-edit-api.md @@ -369,6 +369,10 @@ then `structureFromTopology(topology, shape, center, features)`. Projection is - Complex road-surface features carry `junction_key`, `object_key` and relevant `arm_key`, `carriageway_key`, `corner_key`. Core (or the first remaining approach when the core fails) carries `junction_structure` for persisted reads. +- A supported complex core publishes measurable region evidence: + `connected_entry_count`, `required_pavement_connected`, `core_ring_area`, + `core_ring_self_intersects`, and the existing shared-seam metrics. A contained + exclusion hole is valid only when it preserves every required entry seam. - Stable keys derive from cluster and sorted source node/segment/road IDs, with corner keys derived from adjacent arms. Display indices and headings are not object identities. `topologyFingerprint` detects source topology changes. diff --git a/.trellis/tasks/09-08-junction-reference-fidelity/implement.md b/.trellis/tasks/09-08-junction-reference-fidelity/implement.md index 762cacf..b54128d 100644 --- a/.trellis/tasks/09-08-junction-reference-fidelity/implement.md +++ b/.trellis/tasks/09-08-junction-reference-fidelity/implement.md @@ -26,6 +26,7 @@ - [ ] 审计 roadSurface、sidewalkSurface、edgeLines、lane/center markings 的每个裁切入口,确保消费同一计划。 - [ ] 出口 A3:接缝≤1 cm,必要区域连通,无自交与排除区侵占;自动测试验证实际几何,不只是参数回显。 - 已验证:3~6 臂核心环闭合、正面积、无自交、共享内边邻接;maxSharedSeamErrorMeters 已测量核心与入口内边端点的实际米制误差,尚不等同于全图层接缝测量;入口 ring 闭合/有限/正面积;短过渡、零长度边、零宽度和排除区相切均有失败回归。 + - 连通性现作为构建产物显式发布:`connectedEntryCount`、`requiredPavementConnected`、`ringArea` 和 `ringSelfIntersects`;安全孔洞回归验证孔洞保留时全部入口仍与核心相连。 - 待完成:凹形/多区域/孔洞、全图层连通性和统一接缝误差测量。 - [ ] 此阶段不通过,不开启新几何控件。 diff --git a/src/compile/complex-junction.js b/src/compile/complex-junction.js index 1e9f40d..fbe8e15 100644 --- a/src/compile/complex-junction.js +++ b/src/compile/complex-junction.js @@ -529,6 +529,10 @@ function buildComplexJunctionGeometry(model, cluster, helpers) { closure_count: coreClosure.closureCount, shared_seam_error_m: coreClosure.maxSharedSeamErrorMeters, shared_seam_errors: coreClosure.sharedSeamErrors, + connected_entry_count: coreClosure.connectedEntryCount, + required_pavement_connected: coreClosure.requiredPavementConnected, + core_ring_area: coreClosure.ringArea, + core_ring_self_intersects: coreClosure.ringSelfIntersects, exclusion_hole_count: (coreClosure.holes || []).length, region_status: coreClosure.holes?.length ? 'supported-with-holes' : 'supported', provenance: 'native-road-complex-junction/v7-shared-entry-core', diff --git a/src/compile/junction-boundary-graph.js b/src/compile/junction-boundary-graph.js index 181c3b7..1aa8193 100644 --- a/src/compile/junction-boundary-graph.js +++ b/src/compile/junction-boundary-graph.js @@ -287,12 +287,17 @@ function buildCoreClosure(topology, graph, center) { return { carriagewayKey: section.carriagewayKey, errorMeters: Math.min(forward, reverse) }; }); const seamErrorMeters = seamErrors.reduce((maximum, item) => Math.max(maximum, item.errorMeters), 0); + const connectedEntryCount = seamErrors.filter((item) => Number.isFinite(item.errorMeters)).length; return { status: 'supported', ring, holes, + ringArea: Math.abs(signedArea(ring)) / 2, + ringSelfIntersects: false, sharedEdgeRefs: [...pairedEdges.keys()].sort(), closureCount: graph.sections.length, + connectedEntryCount, + requiredPavementConnected: connectedEntryCount === graph.sections.length, maxSharedSeamErrorMeters: seamErrorMeters, sharedSeamErrors: seamErrors, }; diff --git a/test/junction-build-plan-counterexamples.js b/test/junction-build-plan-counterexamples.js index 50cba87..440060d 100644 --- a/test/junction-build-plan-counterexamples.js +++ b/test/junction-build-plan-counterexamples.js @@ -172,6 +172,10 @@ for (const [field, value] of [ } assert.equal(teeCore.status, 'supported'); assert.equal(teeCore.sharedEdgeRefs.length, teeBoundaryGraph.sections.length); +assert.equal(teeCore.connectedEntryCount, teeBoundaryGraph.sections.length); +assert.equal(teeCore.requiredPavementConnected, true); +assert.equal(teeCore.ringSelfIntersects, false); +assert.ok(teeCore.ringArea > 0); assert.ok(teeCore.ring.every((coordinate) => coordinate.every(Number.isFinite))); const safeHole = buildJunctionBoundaryGraph( tee.topology, @@ -183,6 +187,7 @@ const safeHole = buildJunctionBoundaryGraph( const holedCore = buildCoreClosure(tee.topology, safeHole, point(0, 0)); assert.equal(holedCore.status, 'supported'); assert.equal(holedCore.holes.length, 1); +assert.equal(holedCore.requiredPavementConnected, true, 'a contained hole must preserve every required entry seam'); const exclusionRing = [point(-1, -1), point(1, -1), point(1, 1), point(-1, 1), point(-1, -1)]; const teeWithIsland = buildJunctionBoundaryGraph( tee.topology,