Files
road-compiler/.trellis/tasks/08-28-crosswalk-element-editor/design.md

60 lines
2.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 斑马线元素级编辑器设计
## 架构边界
本实验扩展现有直接编辑链路,而非建立画布对象存储:
```text
crosswalk feature 点击
-> elementId
-> element manifest (anchor + parameters + legal controls)
-> native-road-edits/v2 constraint
-> resolveDirectEditConstraints
-> compileControlMarkings
-> preview / save / recompile
```
`elementId` 是选择和分组标识;持久化仍使用稳定语义 anchor 上的 constraint。它不能是 GeoJSON 数组下标、屏幕坐标或临时 UUID。
## 选择合同
斑马线的每一条 stripe feature 必须包含 `native_id``element_id` 与可回链的 crossing / approach 身份。选择适配层只读取 `element_id`,再向服务器取得选中元素的权威 manifest。客户端不会据条带数量、空间距离或渲染顺序自行聚类。
元素 manifest 至少包含:
```ts
interface EditableElement {
elementId: string
kind: 'crosswalk'
anchor: { type: 'junction-approach'; nodeId: string; segmentId: string }
featureIds: string[]
controls: Array<{
kind: 'position' | 'length' | 'width'
value: { current: number; min: number; max: number; unit: 'meter' }
axisAzimuth?: number
}>
fields: Array<{ key: string; value: number; min: number; max: number; unit: 'meter' | 'count' }>
}
```
第一阶段只发布 `position` 及其现有 `junction-crosswalk-inset` 回写规则。第二阶段再加入尺寸和条带参数,避免在实验开始前规定尚未验证的通用元素协议。
## 编辑与预览
- 选择由 `MapCanvas` 的 feature 事件产生,但选择状态由 App/编辑会话持有,不能写入 baseline source。
- 元素控件写入的是 manifest 指定的 constraint kind/value表单复用同一写入器。
- 选中框和控件只是 `editHandles` / `editGhost` 层的临时 UI权威预览仍由服务端返回baseline source 不被客户端改写。
- 空白点击会清除元素选择;道路选择可继续决定道路级 handle manifest。斑马线元素选中与道路选择可并存但两组控件不得重叠或竞争同一 pointer 手势。
## 数据演进
第一阶段不新增 persisted schema位置继续使用已有 `junction-crosswalk-inset`。第二阶段如果确实需要尺寸参数,新增一个专属 kind 或扩展同一 kind 的严格 schema 校验;具体选择以第一阶段运行结果为准,不预先固化。
缺省参数必须字节级保持现有斑马线输出。参数越界、条带间互相重叠或越过可用进口范围均返回 blocking diagnostic不在客户端静默钳制真实约束。
## 兼容与回滚
- 无新 constraint 时,编译输出与当前版本一致。
- `directEdit` 关闭时不请求 element manifest、不安装元素选择交互、不产生额外图层。
- 第一阶段每个步骤独立提交;回滚元素 UI 或 manifest 不影响既有道路级控制。