feat(junction): classify complex junction shapes

This commit is contained in:
que01 committed 2026-09-07 10:52:12 +08:00
1 parent 38ea779d9b
commit a359f88edc
13 files changed
+440 -14

No files matched your search

+61
View File
@@ -211,3 +211,64 @@ Rules:
itself. Equal is fine and honest: it says there is no headroom.
- A range wide enough to produce nonsense (a stop line 126m from its junction) is
as much a defect as one that is dead.
## 13. Complex junction shape summary
### 1. Scope / Trigger
Complex-junction compilation publishes a structural classification which the
JunctionTools page displays. This crosses the compiler, the persisted GeoJSON
layer, `/api/state`, and the typed browser state.
### 2. Signatures
```js
GET /api/state?debug=1
// debug.junctionShapes?: Array<{
// clusterId: string, kind: string, label: string,
// armCount: number, throughPairCount: number
// }>
```
### 3. Contracts
- `complex-core` is published in `layers/road_surface.geojson`, not
`intersection_surface.geojson`.
- Its `shape_kind`, `shape_label`, `arm_count`, and `through_pair_count`
properties are the compiler authority. The service must project them without
reclassifying from node count.
- `debug.junctionShapes` is present only for debug state. An absent matching
entry means the client shows its ordinary cluster context, not an invented
shape.
### 4. Validation & Error Matrix
| Condition | Required behavior |
| --- | --- |
| No complex core for a configured cluster | Omit its summary; do not emit a false shape |
| Shape is unsupported | Compiler emits a normal-junction fallback diagnostic and no `complex-core` |
| GeoJSON properties are missing | Use `unsupported` and the readable fallback label only while projecting an existing core |
### 5. Good / Base / Bad Cases
- Good: a five-node cluster with five external arms returns `5 臂非规则路口`.
- Base: debug is off, so no shape summaries are returned.
- Bad: reading `intersection_surface.geojson` returns no complex cores and makes
the UI falsely appear to lack classification.
### 6. Tests Required
- Compiler: assert `complex-core` has the expected shape kind and arm count for
a real OSM cluster.
- Service/UI: assert debug state reads the road-surface core and the workspace
renders the received label without node-count inference.
### 7. Wrong vs Correct
```js
// Wrong: complex cores are not stored in this layer.
readLayer('layers/intersection_surface.geojson')
// Correct: project compiler-owned properties from their published layer.
readLayer('layers/road_surface.geojson')
```
@@ -260,3 +260,14 @@ one. `handle.constraintId` — present only when a constraint exists — is also
- [ ] Every input channel meets at the shared exits, not a parallel path
- [ ] Displayed bounds round inward, so an offered extreme is accepted
- [ ] A focused field is not rewritten by an arriving preview
## 15. Complex shape display is server-owned
`WorkbenchState.debug.junctionShapes` is a debug-only read model keyed by
`clusterId`. JunctionTools may display `label` and `armCount` for the currently
opened cluster, but it must not derive T/十字/偏置 shapes from `nodeIds.length`.
The same internal node layout can resolve to different external-arm topology.
If no summary exists, omit the shape row and retain normal cluster context; do
not show an inferred fallback. The compiler's safe fallback has no complex core
and therefore no summary.