Measured the grouping of every marking layer. Stop lines are nearly free — same feature builder, same key shape, an existing constraint kind, and a sweep shows the offset tracks one-to-one across its whole range with no dead zone. Arrows are not: neither kind exists and neither is read by the geometry stage. The trap is that crosswalks and stop lines share crossing_node_id on all eight groups, so grouping has to branch on provenance before touching the key or the two merge into one element. That is already how element.ts works and a test holds it. What the data earns is a provenance-keyed registry and nothing more: group keys are single-field, two-field and derived; group sizes run 1 to 230; two element types have no constraint at all. A universal element protocol would be inventing past the evidence, which the PRD rules out. Also records delivery state — steps 1 and 2 done, 3 through 5 not started — so the task is not mistaken for complete. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4.4 KiB
元素模型能推广到哪些标线
日期:2026-08-31
来源:08-28-crosswalk-element-editor 第 1–2 步交付后,对 nantaizihu-9PTsZg 的实测。
各元素的分组结构(实测)
| 图层 | provenance | 分组键 | feature | 组数 | 每组大小 |
|---|---|---|---|---|---|
crosswalks |
native-road-crosswalk/v1 |
crossing_node_id |
48 | 8 | 恒 6 |
vehicleStopLines |
native-road-stop-line/v1 |
crossing_node_id |
8 | 8 | 恒 1 |
turnArrows |
native-road-turn-arrow/v1 |
lane_id + maneuver |
108 | 28 | 3 或 5 |
directionArrows |
native-road-direction-arrow/v1 |
lane_id |
324 | 50 | 2~28 |
laneSeparators |
native-road-lane-separator/v1 |
road_id + 车道对 |
731 | 9 | 26~230 |
关键陷阱:斑马线与停止线共用 crossing_node_id
交集 8/8——两者由同一个 controlFeature() 构造,crossing_node_id 完全重合。
只按该字段分组会把一组斑马线和它的停止线并成一个"元素"。
必须先按 provenance 判类型,再取分组键。 element.ts 已如此实现并有测试守着
(rejects a stop line, which shares the same feature builder)。任何推广都不能绕过这一步。
可编辑性就绪度
| 元素 | 约束 kind | 编译器是否消费 | 实测响应 | 成本 |
|---|---|---|---|---|
| 斑马线 | junction-crosswalk-inset |
✅ | 已修正上界,全程有效 | 已完成 |
| 停止线 | junction-stop-line-offset |
✅ | 全程线性,零死区 | 几乎免费 |
| 转向箭头 | ❌ 无 | ❌ | — | 新 kind + 编译器 |
| 方向箭头 | ❌ 无 | ❌ | — | 新 kind + 编译器 |
| 车道分隔线 | v1 overrides,仅样式 | 仅样式 | 位置不可编辑 | 另一类问题 |
停止线实测:offset 0.5 → 126 位移 0 → 125.36m,增量始终 1:1。
没有斑马线那种死区,可以直接接入。
但它有反向的毛病:声明范围 [0.5, 126.28](approach.length * 0.45),
允许把停止线推到离路口 126 米——而 native-road.js 有
STOP_LINE_MAX_APPROACH_DISTANCE_METERS = 25。范围过宽同样是缺陷,
见 .trellis/spec/backend/direct-edit-api.md §12。
值得建立的抽象(仅此而已)
一个按 provenance 索引的小注册表:
interface ElementSpec {
provenance: string;
kind: ElementKind;
groupKey(properties: Record<string, unknown>): string | null;
constraintKind: ConstraintKind;
}
element.ts 现有的 crosswalkElementIdOf / groupMembers / elementSelectionFor
改为查表即可,选中、选框、拖拽三条链路无需改动。
不要据此建立"所有元素"的通用协议——PRD 明确禁止 (「不提前建立『所有元素』的大而全抽象」)。理由在上表里: 分组键的形态各不相同(单字段 / 双字段 / 派生), 每组大小从 1 到 230,箭头类连约束 kind 都还不存在。 现在能证明的只有「provenance + 分组键 → 组」这一条,注册表恰好只承诺这一条。
推荐顺序
- 停止线——注册表 + 一条 spec 条目。约束现成、编译器已消费、响应已验证。 同时暴露注册表是否够用:它的每组只有 1 个 feature,而斑马线是 6 个, 能验证分组逻辑不依赖"多 part"这个偶然属性。
- 修
affects(原第 3 步)——目前junctionAffects()不含任何标线, 拖拽高亮会亮错一片。停止线接入后这个问题会更明显。 - 转向箭头——需要新 constraint kind,且必须先证明
compileGeometry()读它。 分组键lane_id + maneuver已验证(28 组,每组 3 或 5 个 part)。 - 方向箭头——最贵。分组语义本身待定:按
lane_id是 50 组(编辑间距/整体偏移), 按lane_id + sequence是 324 组(逐个箭头独立摆放)。 这是产品决策,不是实现细节,需先定。 - 车道分隔线——不同类问题。已有 v1 样式 override,缺的是位置,
而位置由
road-lane-divider约束管,属道路横断面而非元素级。
与复杂路口的关系
停止线和转向箭头都是位置类元素,与斑马线同属一个几何类别:
移动它们不改变路口多边形。所以第 1、3 步不会为形状类元素
(approach-width / cutback / corner-radius)提供任何背书——
那仍是独立的、未验证的一类,见 prd.md「试验对象的覆盖边界」。