Compare commits
41
Commits
main
...
5accc0a4b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5accc0a4b1 | ||
|
|
7204c28161 | ||
|
|
a63a3ae0d8 | ||
|
|
f7e71cfe9c | ||
|
|
e41bfd13ec | ||
|
|
46542c5f4e | ||
|
|
1896884900 | ||
|
|
9bb97d4507 | ||
|
|
bd38aa55d3 | ||
|
|
b318f7b641 | ||
|
|
d065dcdaf3 | ||
|
|
472a83c670 | ||
|
|
bc045177a5 | ||
|
|
8409d2c6c3 | ||
|
|
5f59ad0ef0 | ||
|
|
47efb78f1e | ||
|
|
8bfc02e66e | ||
|
|
9d42181246 | ||
|
|
fb863dafb2 | ||
|
|
7dc5c947a3 | ||
|
|
866b59acf8 | ||
|
|
4c4f4534c0 | ||
|
|
ea8a3622b9 | ||
|
|
03a8d6159b | ||
|
|
1b9829d9ed | ||
|
|
822e6ef936 | ||
|
|
3eea12c6ea | ||
|
|
3d57655497 | ||
|
|
65cf8b96d9 | ||
|
|
e1f3fc10ca | ||
|
|
f43a122ff7 | ||
|
|
3e22a1872e | ||
|
|
1da985c932 | ||
|
|
817e361477 | ||
|
|
25287777f6 | ||
|
|
a556c0fc97 | ||
|
|
1876472bf8 | ||
|
|
707e7f82f9 | ||
|
|
850e9eb344 | ||
|
|
df81a22ce8 | ||
|
|
b5fa4482f0 |
No files matched your search
@@ -132,6 +132,7 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `treeStyle` | `"natural"` | 合法值见 `generate_scene.py` 的 `TREE_STYLES`(`natural`、`procedural`、`shapespark`) |
|
| `treeStyle` | `"natural"` | 合法值见 `generate_scene.py` 的 `TREE_STYLES`(`natural`、`procedural`、`shapespark`) |
|
||||||
| `officeOverrides` | `""` | 旧名 `office_overrides` 仍被接受 |
|
| `officeOverrides` | `""` | 旧名 `office_overrides` 仍被接受 |
|
||||||
|
| `roadProvider` | `"osm2streets"` | Blender 道路来源。`"native"` 时仅使用 `native-road/` 的道路、路口和人行道面;可由 `build:area --road-provider native` 临时覆盖。 |
|
||||||
|
|
||||||
### `compress`
|
### `compress`
|
||||||
|
|
||||||
|
|||||||
@@ -367,6 +367,341 @@ if (!networkSaysIntersection && (roadCounts.get(endpoint.id) || 0) < 3) return n
|
|||||||
fs.writeFileSync(diagnosticsPath, `${JSON.stringify(diagnostics, null, 2)}\n`);
|
fs.writeFileSync(diagnosticsPath, `${JSON.stringify(diagnostics, null, 2)}\n`);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Native 道路标线
|
||||||
|
|
||||||
|
### 1. 范围与触发条件
|
||||||
|
|
||||||
|
`node scripts/compile-native-roads.js --config <area>` 将原生道路标线写入
|
||||||
|
`outputs/<area>/native-road/layers/`。它不读取 osm2streets 渲染几何;只复用
|
||||||
|
`turn-lane-arrows.js` 中已测试的箭头模板。工作台 `GET /api/state` 原样服务这些
|
||||||
|
GeoJSON,native Blender 构建通过 `catalog.NATIVE_ROAD_LAYERS` 消费它们。
|
||||||
|
|
||||||
|
### 2. 图层契约
|
||||||
|
|
||||||
|
| 文件 | 语义 | 必需 provenance | Blender material layer |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `lane_separators.geojson` | 同向相邻车道的分隔线 | `native-road-lane-separator/v1` | `lane_separators` |
|
||||||
|
| `direction_arrows.geojson` | 沿定向车道重复的直行方向箭头 | `native-road-direction-arrow/v1` | `lane_arrows_webscale` |
|
||||||
|
| `turn_arrows.geojson` | 明确 `turn:lanes` 的路口动作箭头 | `native-road-turn-arrow/v1` | `lane_arrows_webscale` |
|
||||||
|
|
||||||
|
方向箭头必须带 `road_id`、`lane_id`、`osm_way_ids`、`direction`、`lane_index`、
|
||||||
|
`sequence`、`distance_along_lane_meters` 和 `placement_interval_meters`。转向箭头
|
||||||
|
必须带 `maneuver` 与 `placement_distance_meters`。两者不能共用 provenance 或假装为
|
||||||
|
彼此:前者表达沿路行驶方向,后者表达路口处允许动作。
|
||||||
|
|
||||||
|
### 3. 放置与错误矩阵
|
||||||
|
|
||||||
|
| 条件 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 车道长度不足以容纳两端 14m 缓冲 | 不生成道路方向箭头 |
|
||||||
|
| 可用车道长度 | 从 14m 起按 32m 间距生成 `through` 箭头 |
|
||||||
|
| OSM 未提供 `turn:lanes` | 不生成路口转向箭头 |
|
||||||
|
| `turn:lanes` 存在但动作不受已测试模板支持 | 记录诊断,不猜测动作 |
|
||||||
|
| native Blender 构建缺任一图层文件 | 在 `ensureNativeRoadLayers()` 失败,不能静默漏画 |
|
||||||
|
|
||||||
|
### 4. 必需测试
|
||||||
|
|
||||||
|
- `npm run test:native-road`:方向箭头的 Polygon、provenance、间距,以及无标签道路
|
||||||
|
不生成路口转向箭头。
|
||||||
|
- `npm run test:road-workbench`:方向箭头开关、选择溯源和概览标签。
|
||||||
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender,cesium,preview --road-provider native`:日志必须列出
|
||||||
|
`direction_arrows` 与 `turn_arrows`,且不运行 `package`。
|
||||||
|
|
||||||
|
### 5. 错误与正确写法
|
||||||
|
|
||||||
|
错误:把默认 `through` 当作路口 `turn:lanes` 动作,统一写入 `turn_arrows.geojson`。
|
||||||
|
|
||||||
|
正确:道路方向箭头进入 `direction_arrows.geojson`;只有 OSM 明确标注的动作进入
|
||||||
|
`turn_arrows.geojson`。工作台用两个开关呈现,Blender 复用同一现有箭头材质。
|
||||||
|
|
||||||
|
## Native 普通路口圆角
|
||||||
|
|
||||||
|
### 1. 范围与触发条件
|
||||||
|
|
||||||
|
`compile-native-roads.js` 为普通 T / 十字路口生成 `intersection_surface.geojson`
|
||||||
|
和 `sidewalk_surface.geojson` 的路口边界。路口道路面必须在同一 cutback 处结束,不能
|
||||||
|
用未裁剪的道路矩形覆盖圆角边界。
|
||||||
|
|
||||||
|
### 2. 几何契约
|
||||||
|
|
||||||
|
- 相邻道路边缘使用两条支持切线的交点作为二次曲线控制点;采样段数由
|
||||||
|
`JUNCTION_CURVE_SEGMENTS` 统一控制。
|
||||||
|
- 机动车路口边界、人行道内侧路缘和人行道外侧边界都必须使用同一切线圆角规则;外侧
|
||||||
|
不能只对内侧采样点做线性偏移,避免内外曲率不一致。
|
||||||
|
- `boundary_mode` 使用 `rounded-approach-envelope`,无法安全构造的角保持确定性直线
|
||||||
|
回退,并写入 `junction-rounded-corner-fallback` warning。
|
||||||
|
- 已发布的 connector 必须包含在最终边界内,边界退化或 connector 越界时才允许使用
|
||||||
|
`connector-convex-fallback`。
|
||||||
|
|
||||||
|
### 3. 校验与错误矩阵
|
||||||
|
|
||||||
|
| 条件 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 支持切线交点有限且曲线不过远 | 生成采样圆角 |
|
||||||
|
| 切线近似平行或交点退化 | 保留该角直线并记录 `junction-rounded-corner-fallback` |
|
||||||
|
| 边界自相交或 connector 越界 | 使用 connector 凸包兜底;仍自相交则不发布路口面 |
|
||||||
|
|
||||||
|
### 4. 必需测试
|
||||||
|
|
||||||
|
- `npm run test:native-road`:普通 T / 十字路口的圆角顶点数、内收方向、内外人行道
|
||||||
|
曲线和 continuation 语义。
|
||||||
|
- `npm run test:road-workbench`:工作台仍能加载 native 路口及人行道图层。
|
||||||
|
- `npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json`。
|
||||||
|
- `npm run road:check -- --config config/areas/nantaizi-lake-innovation-valley.json`。
|
||||||
|
|
||||||
|
### 5. 错误与正确写法
|
||||||
|
|
||||||
|
错误:先对路缘生成圆角,再把外侧边界按每个采样点线性平移;这会导致内外曲率不同,
|
||||||
|
在人行道角落留下不一致的折面。
|
||||||
|
|
||||||
|
正确:对内侧和外侧分别用相同的道路边缘支持切线规则生成曲线,仅在外侧切线退化时
|
||||||
|
使用确定性的偏移回退。
|
||||||
|
|
||||||
|
## Native 道路中心虚线
|
||||||
|
|
||||||
|
### 1. 范围与触发条件
|
||||||
|
|
||||||
|
`node scripts/compile-native-roads.js --config <area>` 为可确认的双向非 service
|
||||||
|
道路段写入 `native-road/layers/center_lines.geojson`。这是原生几何:只能依据
|
||||||
|
canonical OSM 中心线、native 双方向道路模型和 native 路口 cutback 生成,osm2streets
|
||||||
|
的 `center_lines.geojson` 只可作为视觉基准,绝不能作为输入。
|
||||||
|
|
||||||
|
### 2. 调用形式
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:workbench -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender,cesium,preview --road-provider native
|
||||||
|
```
|
||||||
|
|
||||||
|
工作台 `GET /api/state` 通过 `layers.centerLines` 返回该 FeatureCollection;native
|
||||||
|
Blender adapter 必须将 source `center_lines` 映射到既有 `center_lines` material layer。
|
||||||
|
|
||||||
|
### 3. 契约
|
||||||
|
|
||||||
|
- 每一 dash 均为 Polygon,长 `2m`、宽 `0.25m`、确定性间隔 `2m`,使用
|
||||||
|
`native-road-center-line/v1` provenance。
|
||||||
|
- 要素必须含有 `native_id`、`segment_id`、`road_id`、`directional_road_ids`、
|
||||||
|
`osm_way_ids`、`dash_index`、`dash_length_m`、`dash_gap_m` 与 `placement_rule`,以便
|
||||||
|
Workbench 用中文显示“道路中心虚线”并可回溯来源。
|
||||||
|
- 只有同一 `segment_id` 恰有一条 forward 和一条 backward native road 时才生成;单向、
|
||||||
|
`highway=service` 或退化中心线都不能伪造中心线。退化中心线须写
|
||||||
|
`invalid-center-line` diagnostic。
|
||||||
|
- 线段必须先经过 native junction cutback;再与 crosswalk、vehicle stop line 的控制面
|
||||||
|
求冲突,冲突 dash 直接略去。控制标线优先于中心虚线。
|
||||||
|
- `compiled.json.layers.centerLines`、`comparison.json.nativeCenterLineFeatures`、
|
||||||
|
`build-area.js` 的 native input records 与 required-layer 验证必须全部使用
|
||||||
|
`layers/center_lines.geojson`;缺失时在 Blender 启动前失败,不得静默漏画。
|
||||||
|
|
||||||
|
### 4. 校验与错误矩阵
|
||||||
|
|
||||||
|
| 条件 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 可确认的双向普通道路段 | 生成 2m / 0.25m 黄虚线,固定 2m gap |
|
||||||
|
| 单向或 `highway=service` 道路 | 不生成中心虚线 |
|
||||||
|
| 中心线不足两点、长度不可用 | `invalid-center-line` diagnostic,不写畸形 Polygon |
|
||||||
|
| dash 进入 junction cutback | trim 后不生成该范围 dash |
|
||||||
|
| dash 与斑马线或停止线相交 | 不生成冲突 dash |
|
||||||
|
| native Blender 输入缺 `center_lines.geojson` | `ensureNativeRoadLayers()` 抛错 |
|
||||||
|
|
||||||
|
### 5. 正常、基础与错误示例
|
||||||
|
|
||||||
|
- 正常:一条有 forward/backward carriageway 的 residential 段在两个方向道路之间生成黄虚线。
|
||||||
|
- 基础:没有双向证据的道路仍可有车道分隔线,但不产生道路中心虚线。
|
||||||
|
- 错误:从 osm2streets 图层复制或裁剪中心线;这会将渲染器缺陷重新变成 native 数据依赖。
|
||||||
|
|
||||||
|
### 6. 必需测试
|
||||||
|
|
||||||
|
- `npm run test:native-road`:断言双向生成、provenance、2m 尺寸/间隔、单向和 service 跳过。
|
||||||
|
- `npm run test:road-workbench`:断言 `centerLines` API、中文开关、选择溯源和概览计数。
|
||||||
|
- `npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json`:输出合法图层,检查中心线与控制标线不重叠。
|
||||||
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender,cesium,preview --road-provider native`:日志列出 `center_lines`,且不运行 `package`。
|
||||||
|
|
||||||
|
### 7. 错误与正确写法
|
||||||
|
|
||||||
|
错误:只按一条 directional road 生成中心线,或忽略控制标线。
|
||||||
|
|
||||||
|
```js
|
||||||
|
const line = road.centerline;
|
||||||
|
features.push(makeDash(line));
|
||||||
|
```
|
||||||
|
|
||||||
|
正确:先确认成对的双方向道路、做路口裁剪,再排除控制标线冲突。
|
||||||
|
|
||||||
|
```js
|
||||||
|
if (roads.length !== 2 || !forward || !backward || forward.highway === "service") continue;
|
||||||
|
const line = trimLineAtJunctions(forward.centerline, forward.sourceNodeIds, junctionPlans);
|
||||||
|
if (!ringsOverlapControl([ring], [...controls.crosswalks, ...controls.stopLines])) features.push(dash);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Native 道路中心线样式覆写
|
||||||
|
|
||||||
|
### 1. 范围与触发条件
|
||||||
|
|
||||||
|
Road Workbench 选中 `native-road-center-line/v1` 要素后,可为其 `segment_id`
|
||||||
|
保存样式覆写。覆写属于 `native-road-overrides.json`,不是对
|
||||||
|
`center_lines.geojson` 的手工编辑;重新编译必须从覆写重建图层。
|
||||||
|
|
||||||
|
### 2. 调用形式
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "道路中心线:segment:way/123/1",
|
||||||
|
"kind": "center-line-style",
|
||||||
|
"segmentId": "segment:way/123/1",
|
||||||
|
"color": "white",
|
||||||
|
"pattern": "solid"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 契约
|
||||||
|
|
||||||
|
- `color` 只能是 `yellow` 或 `white`;`pattern` 只能是 `dashed` 或 `solid`。
|
||||||
|
目标 `segmentId` 必须属于当前 native road model。
|
||||||
|
- `double: true` 只表示双黄实线,因此只能与 `color: "yellow"`、
|
||||||
|
`pattern: "solid"` 组合。编译器为每段的每个有效实线 mark 写两条相距 0.32m 的
|
||||||
|
平行 Polygon,并记录 `double: true`、`effective_style:
|
||||||
|
"double-yellow-solid"`;不得把它实现为可任意组合的双线开关。
|
||||||
|
- 未覆写段保持黄色虚线(2m dash、2m gap);`solid` 为 0 gap,但相邻的 2m
|
||||||
|
几何块须重叠 `0.04m`,避免投影精度造成可见裂缝。
|
||||||
|
- 每个生成面记录 `color`、`pattern` 和 `effective_style`。Workbench 以这些属性
|
||||||
|
着色;native Blender 将 white centre lines 分派至 `Native Center Line White`,
|
||||||
|
yellow 则继续复用 `Center Line`。
|
||||||
|
- 下拉框变化即暂存覆写,顶部“保存并重新生成”是唯一写盘/重编译动作;不要求用户
|
||||||
|
再点击一个容易遗漏的暂存按钮。
|
||||||
|
|
||||||
|
### 4. 校验与错误矩阵
|
||||||
|
|
||||||
|
| 条件 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 合法颜色、图案和当前 segment | 保存后重新生成有效样式 |
|
||||||
|
| 非法颜色/图案或不存在 segment | `validateOverrides()` 拒绝整个请求 |
|
||||||
|
| 实线块触及控制标线 | 该块略去,不以连续性为由穿过控制标线 |
|
||||||
|
| 白色中心线进入 native Blender | 使用白线材质,不改变 legacy 图层材质 |
|
||||||
|
|
||||||
|
### 5. 正常、基础与错误示例
|
||||||
|
|
||||||
|
- 正常:点选任意 dash,选择“白色实线”,保存重编译后整段显示连续白线。
|
||||||
|
- 基础:选择“黄色虚线(默认)”仍是显式覆写,但几何与默认规则一致。
|
||||||
|
- 错误:只在 Workbench 改填充色;Blender/Cesium 会继续显示旧黄色。
|
||||||
|
|
||||||
|
### 6. 必需测试
|
||||||
|
|
||||||
|
- `npm run test:native-road`:合法/非法样式覆写、solid 属性、控制标线避让。
|
||||||
|
- `npm run test:road-workbench`:中文样式面板、下拉框自动暂存和 API payload。
|
||||||
|
- `python3 -m unittest discover blender/tests`:catalog 仍是可导入的纯 Python。
|
||||||
|
- Nantaizi native `blender,cesium,preview` 构建:既有 yellow centre lines 不回归。
|
||||||
|
|
||||||
|
### 7. 错误与正确写法
|
||||||
|
|
||||||
|
错误:实线块仅以零间隔精确相接,且每块使用高对比 outline。
|
||||||
|
|
||||||
|
正确:小幅重叠相邻块,并让 Workbench 实线 stroke 与 fill 同色。
|
||||||
|
|
||||||
|
## Native 道路外缘线样式覆写
|
||||||
|
|
||||||
|
`edge_lines.geojson` 是车行道最外侧边界标线,使用 `native-road-edge-line/v1`
|
||||||
|
provenance。单向道路生成左右两条外缘线;双向道路每个方向只生成远离道路中心的外缘
|
||||||
|
线,双向道路中间分界由 `center_lines.geojson` 负责。默认是白色实线,必须带
|
||||||
|
`road_id`、`side`(`left` / `right`)、`osm_way_ids`、`color`、`pattern` 与
|
||||||
|
`effective_style`。
|
||||||
|
|
||||||
|
区域配置中的 `nativeRoad.edgeLines` 默认是 `false`;因此 native Blender/Cesium 默认不
|
||||||
|
生成或显示该层。只有明确设置为 `true` 才会发布 `edge_lines.geojson` 并交给下游消费。
|
||||||
|
|
||||||
|
Road Workbench 点选外缘线后以中文显示其方向侧边,可暂存以下 area-local 覆写:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "道路外缘线:road:way/123:forward:left",
|
||||||
|
"kind": "edge-line-style",
|
||||||
|
"roadId": "road:way/123:forward",
|
||||||
|
"side": "left",
|
||||||
|
"color": "white",
|
||||||
|
"pattern": "solid"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`roadId` 必须是当前 directional native road 的精确 ID,`side` 必须为 `left` 或 `right`。
|
||||||
|
实线使用连续 offset line;虚线使用确定性
|
||||||
|
2m mark / 2m gap。工作台的暂存与“保存并重新生成”是唯一的写盘路径,不能只改浏览器填充色;
|
||||||
|
native Blender 将该层映射到既有 `lane_separators` material layer。
|
||||||
|
|
||||||
|
## Native 控制标线
|
||||||
|
|
||||||
|
### 1. 范围与触发条件
|
||||||
|
|
||||||
|
`node scripts/compile-native-roads.js --config <area>` 为 native road provider
|
||||||
|
生成 `crosswalks.geojson` 和 `vehicle_stop_lines.geojson`。这是原生道路的独立
|
||||||
|
产物,禁止读取 osm2streets 的渲染图层作为几何输入。
|
||||||
|
|
||||||
|
### 2. 调用形式
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:workbench -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
```
|
||||||
|
|
||||||
|
工作台 `GET /api/state` 通过 `layers.crosswalks` 和
|
||||||
|
`layers.vehicleStopLines` 返回两个 FeatureCollection。
|
||||||
|
|
||||||
|
### 3. 契约
|
||||||
|
|
||||||
|
- 只有 `highway=crossing` 且 `crossing:markings` 不是 `no`、`none` 或
|
||||||
|
`unmarked` 的 OSM 节点可以生成斑马线。每个安全匹配点生成六条 stripe,带
|
||||||
|
`crossing_node_id`、`road_id`、`lane_id`、`osm_way_ids`、`direction`、
|
||||||
|
`placement_method`、`junction_inset_m` 和 `native-road-crosswalk/v1` provenance。
|
||||||
|
- 停止线还必须对应一个启用的 native arrival endpoint,且过街节点位于该进口到
|
||||||
|
路口的安全距离内;其 provenance 是 `native-road-stop-line/v1`。不能确认进口
|
||||||
|
时保留斑马线并写 `crossing-no-safe-stop-line` diagnostic,不得猜测一条线。停止线
|
||||||
|
必须复用斑马线的 `junction_inset_m`,保持与斑马线的上游间距。
|
||||||
|
- 有安全进口且存在普通路口 plan 时,斑马线中心推进到 cutback 内约 1.5 米;单次
|
||||||
|
最大推进 4 米。`junction_inset_m` 记录实际推进量,避免远离路口的 crossing 被过度
|
||||||
|
移动。
|
||||||
|
- `catalog.NATIVE_ROAD_LAYERS` 将两个源层映射到现有的 `crosswalks` 和
|
||||||
|
`vehicle_stop_lines` 材质层。不得把它们加入 legacy `SCENE_LAYERS`。
|
||||||
|
- 控制标线优先于箭头:默认直行箭头与其相交时跳过;路口转向箭头依次尝试在距路口
|
||||||
|
6、10、14、18、22 米处放置,均冲突时记录 `turn-arrow-control-conflict`。
|
||||||
|
|
||||||
|
### 4. 校验与错误矩阵
|
||||||
|
|
||||||
|
| 条件 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 标记过街没有可匹配 native lane | `crossing-no-native-lane`,不生成任何控制标线 |
|
||||||
|
| 有横道但没有安全进口方向 | 生成斑马线,记录 `crossing-no-safe-stop-line`,不生成停止线 |
|
||||||
|
| 箭头与任一控制标线相交 | 直行箭头跳过;转向箭头后移或记录冲突 diagnostic |
|
||||||
|
| native Blender 输入缺任一控制图层 | `ensureNativeRoadLayers()` 在启动 Blender 前失败 |
|
||||||
|
|
||||||
|
### 5. 正常、基础与错误示例
|
||||||
|
|
||||||
|
- 正常:一个靠近路口的 marked crossing 生成 6 条斑马线和 1 条进口停止线。
|
||||||
|
- 基础:一条孤立的 marked crossing 可以生成斑马线,但不能凭邻近道路方向臆造停止线。
|
||||||
|
- 错误:先生成箭头再叠加停止线,导致两者重叠;控制标线是道路控制语义,必须优先。
|
||||||
|
|
||||||
|
### 6. 必需测试
|
||||||
|
|
||||||
|
- `npm run test:native-road`:断言 marked / unmarked / 无 native lane 的输出,停止线的
|
||||||
|
provenance、斑马线与停止线共享 `junction_inset_m`,以及箭头遇控制标线时后移。
|
||||||
|
- `npm run test:road-workbench`:断言 controls 开关、两条 API layer 和中文选中溯源。
|
||||||
|
- `npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json`:核查两层
|
||||||
|
feature count 及每条停止线都是 native arrival direction。
|
||||||
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender,cesium,preview --road-provider native`:不运行 `package`。
|
||||||
|
|
||||||
|
### 7. 错误与正确写法
|
||||||
|
|
||||||
|
错误:以最近任意方向车道和固定正向偏移生成停止线。
|
||||||
|
|
||||||
|
```js
|
||||||
|
const stopCenter = offsetByMeters(nearestLane.point, nearestLane.axis, 2.7);
|
||||||
|
```
|
||||||
|
|
||||||
|
正确:先确认该方向的终点是一个已启用的路口 arrival,再在人行横道的上游生成停止线。
|
||||||
|
|
||||||
|
```js
|
||||||
|
const approach = candidates.find((item) => arrivalEndpointIds.has(`endpoint:${item.road.id}:end`));
|
||||||
|
const stopCenter = offsetByMeters(laneCenterAtCrossing, approach.placement.axis, -2.7);
|
||||||
|
```
|
||||||
|
|
||||||
## 斑马线与停止线来源
|
## 斑马线与停止线来源
|
||||||
|
|
||||||
### 1. 范围与触发条件
|
### 1. 范围与触发条件
|
||||||
|
|||||||
@@ -120,6 +120,56 @@ SCENE_LAYERS.forEach((layer, index) => {
|
|||||||
|
|
||||||
## Blender 调用
|
## Blender 调用
|
||||||
|
|
||||||
|
### macOS Blender 4.5 的 Metal 启动兼容
|
||||||
|
|
||||||
|
#### 1. Scope / Trigger
|
||||||
|
|
||||||
|
`export_cesium.py` 在 macOS 的 Blender 4.5.12 后台启动时,可能在 Python 脚本加载前的 Metal 扩展探测中崩溃;这不是场景或道路数据错误。
|
||||||
|
|
||||||
|
#### 2. Signatures
|
||||||
|
|
||||||
|
Cesium 阶段的调用参数必须包含:
|
||||||
|
|
||||||
|
```text
|
||||||
|
--background --factory-startup --debug-gpu-force-workarounds --python blender/export_cesium.py -- ...
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Contracts
|
||||||
|
|
||||||
|
`--debug-gpu-force-workarounds` 是 Blender 的官方 CLI 参数。它只约束导出进程的 GPU 扩展探测,不改变 `.blend`、GeoJSON 或导出脚本的输入输出契约。
|
||||||
|
|
||||||
|
#### 4. Validation & Error Matrix
|
||||||
|
|
||||||
|
| 情况 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| 缺少该参数且启动时崩在 Metal 初始化 | 不应归因于道路数据;补齐参数后重跑 Cesium 阶段 |
|
||||||
|
| 参数存在且 `CESIUM_EXPORT_DONE` / stage manifest 写出 | 继续 GLB digest 与预览验证 |
|
||||||
|
|
||||||
|
#### 5. Good / Base / Bad Cases
|
||||||
|
|
||||||
|
- Good: 保留 `--factory-startup`,并在 Cesium 导出加入 workaround。
|
||||||
|
- Base: Blender 场景阶段未受影响时,不额外改变其启动参数。
|
||||||
|
- Bad: 为绕过启动崩溃删除 `--factory-startup`,这会重新引入本机偏好和 addon 的不确定性。
|
||||||
|
|
||||||
|
#### 6. Tests Required
|
||||||
|
|
||||||
|
- `npm run test:build-stages` 断言导出参数仍包含 workaround。
|
||||||
|
- 对目标区域运行 `--stages blender,cesium,preview`,并用 `glb-digest.js` 解析输出。
|
||||||
|
|
||||||
|
#### 7. Wrong vs Correct
|
||||||
|
|
||||||
|
Wrong:
|
||||||
|
|
||||||
|
```text
|
||||||
|
--background --python blender/export_cesium.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Correct:
|
||||||
|
|
||||||
|
```text
|
||||||
|
--background --factory-startup --debug-gpu-force-workarounds --python blender/export_cesium.py
|
||||||
|
```
|
||||||
|
|
||||||
### 两种调用姿势
|
### 两种调用姿势
|
||||||
|
|
||||||
| 阶段 | 参数 | 出处 |
|
| 阶段 | 参数 | 出处 |
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/index.md","reason":"Check command ownership, disk artifact boundaries, and legacy pipeline compatibility."}
|
||||||
|
{"file":".trellis/spec/preview/index.md","reason":"Check browser workbench state, error handling, and no-build browser constraints."}
|
||||||
|
{"file":".trellis/spec/config/index.md","reason":"Check new area output/config normalization and compatibility."}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
# Native Road Compiler Workbench Design
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
The native compiler is an additive pipeline path. It owns a separate output
|
||||||
|
directory under an area and never writes into `osm2streets_web_out/`.
|
||||||
|
|
||||||
|
```text
|
||||||
|
OSM XML + native-road-overrides.json
|
||||||
|
|
|
||||||
|
v
|
||||||
|
Canonical Road Model
|
||||||
|
roads / endpoints / junction candidates / provenance
|
||||||
|
|
|
||||||
|
v
|
||||||
|
Native Geometry Compiler
|
||||||
|
road surfaces / initial junction surfaces / diagnostics
|
||||||
|
|
|
||||||
|
+--> native-road/compiled.json
|
||||||
|
+--> native-road/layers/*.geojson
|
||||||
|
+--> native-road/diagnostics.json
|
||||||
|
+--> native-road/comparison.json
|
||||||
|
|
|
||||||
|
v
|
||||||
|
Road Workbench HTTP service
|
||||||
|
browser map + inspect/edit/save API
|
||||||
|
```
|
||||||
|
|
||||||
|
The canonical model is the authority. Render layers, browser display data, and
|
||||||
|
future Blender compatibility adapters are derived from it.
|
||||||
|
|
||||||
|
## Commands And Ownership
|
||||||
|
|
||||||
|
- `npm run road:compile -- --config <area-config>` performs no browser work.
|
||||||
|
It reads OSM plus the persisted override file, writes a staged native-road
|
||||||
|
result, validates it, and atomically promotes the result directory.
|
||||||
|
- `npm run road:workbench -- --config <area-config>` compiles first unless
|
||||||
|
`--no-compile` is supplied, then starts a local HTTP server scoped to that
|
||||||
|
one area.
|
||||||
|
- The server exposes read-only compiler artifacts and one explicit save API
|
||||||
|
for validated overrides. It does not expose arbitrary filesystem paths.
|
||||||
|
- Existing `build:area`, `intermediates`, QGIS, Blender, Cesium, and package
|
||||||
|
paths remain unchanged in the first iteration.
|
||||||
|
|
||||||
|
## Data Contracts
|
||||||
|
|
||||||
|
### Canonical road model
|
||||||
|
|
||||||
|
Each road direction carries a stable ID derived from OSM identifiers, source
|
||||||
|
way IDs, endpoint node IDs, centerline, explicit/inferred attributes, applied
|
||||||
|
override IDs, and diagnostics. Junction candidates likewise use their OSM node
|
||||||
|
ID when available. Values include provenance such as `tag:lanes:forward`,
|
||||||
|
`inferred:highway-default`, or `override:<id>`.
|
||||||
|
|
||||||
|
Each `Movement` is a stable semantic record joining a connection, source and
|
||||||
|
target road/lane, turn class, provenance, and an optional connector geometry.
|
||||||
|
`geometryStatus="connector"` publishes a connector curve;
|
||||||
|
`geometryStatus="continuous"` means the lane centerlines meet at the node and
|
||||||
|
does not invent a zero-length curve; `deferred-too-long` retains the movement
|
||||||
|
while withholding unsafe geometry.
|
||||||
|
|
||||||
|
### Override file
|
||||||
|
|
||||||
|
`<area>/native-road-overrides.json` is versioned and human-reviewable. It
|
||||||
|
contains an array of uniquely identified changes whose targets are stable road
|
||||||
|
or endpoint IDs. Supported v1 records are `road` parameter overrides and
|
||||||
|
`junction-connection` decisions. The save endpoint validates schema, target
|
||||||
|
existence, finite values, and duplicate/conflicting edits before atomic write.
|
||||||
|
|
||||||
|
### Compiler artifacts
|
||||||
|
|
||||||
|
`<area>/native-road/compiled.json` is the workbench's single read model and
|
||||||
|
contains the canonical `movements` list.
|
||||||
|
`layers/` contains generated GeoJSON with source/provenance properties.
|
||||||
|
`diagnostics.json` contains severity, stable subject ID, source IDs, rule,
|
||||||
|
message, and optional geometry. `comparison.json` reports counts and coverage
|
||||||
|
against available osm2streets layers; it does not claim quality solely from
|
||||||
|
visual differences.
|
||||||
|
|
||||||
|
## Browser Workbench
|
||||||
|
|
||||||
|
The browser uses OpenLayers as its sole GIS runtime, served directly from the
|
||||||
|
local allowlisted `node_modules` packages with a browser import map. The map
|
||||||
|
renders fit-to-data OSM centerlines, native surfaces, optional osm2streets
|
||||||
|
reference layers, diagnostics, selected-object provenance, movements, and
|
||||||
|
overrides. This provides mature map selection and hit detection without a
|
||||||
|
framework or bundler.
|
||||||
|
|
||||||
|
The user can select a road or endpoint, edit only v1 fields, inspect the
|
||||||
|
resulting override record, explicitly save it, and recompile/reload. Saved
|
||||||
|
state is visibly differentiated from unsaved state. The workbench must not
|
||||||
|
offer freehand final-polygon editing, since that would break reproducibility.
|
||||||
|
|
||||||
|
## Geometry And Validation
|
||||||
|
|
||||||
|
V1 produces road segments from projected centerline offsets and terminal
|
||||||
|
cross-sections. It only generates a junction surface when endpoints satisfy
|
||||||
|
the supported ordinary T/cross shape and geometry checks; otherwise it emits a
|
||||||
|
diagnostic rather than inventing an invalid polygon. Validation detects
|
||||||
|
dangling endpoints, unclosed/self-intersecting rings, non-finite coordinates,
|
||||||
|
unsupported multi-level intersections, and source/topology ambiguity. Small
|
||||||
|
numerical cleanup may be explicit and recorded; semantic failures are never
|
||||||
|
silently repaired.
|
||||||
|
|
||||||
|
## Compatibility And Rollout
|
||||||
|
|
||||||
|
The first compiler's layers use existing render-layer names where meaningful,
|
||||||
|
but are stored separately. A later, explicitly enabled Blender provider option
|
||||||
|
may consume native layers after comparison gates pass. Delete/replace behavior
|
||||||
|
is out of scope; rollback is selecting the existing osm2streets pipeline.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/index.md","reason":"Native compiler commands, artifacts, and area config extend the Node pipeline while preserving legacy stages."}
|
||||||
|
{"file":".trellis/spec/preview/index.md","reason":"The browser workbench is a new DOM runtime and must follow local preview loading and state conventions where applicable."}
|
||||||
|
{"file":".trellis/spec/config/index.md","reason":"New native-road output paths and config behavior extend the normalized area contract."}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Add area output/config normalization and command entrypoints for the native
|
||||||
|
compiler, preserving existing stage behavior and paths.
|
||||||
|
2. Implement a shared OSM road parser and canonical road/endpoints model with
|
||||||
|
source provenance, explicit versus inferred properties, and stable IDs.
|
||||||
|
3. Implement v1 override schema, validation, load/apply behavior, atomic save,
|
||||||
|
and focused unit tests.
|
||||||
|
4. Implement projected road segment geometry, supported T/cross junction
|
||||||
|
detection, native GeoJSON artifact emission, diagnostics, and comparison
|
||||||
|
summary.
|
||||||
|
5. Implement a dependency-free local workbench server and browser UI with
|
||||||
|
selection, provenance display, v1 parameter/topology editing, explicit save,
|
||||||
|
compile/reload, and error states.
|
||||||
|
6. Add native compiler tests using focused fixtures plus nantaizi analysis;
|
||||||
|
run existing relevant Node tests to confirm legacy behavior remains intact.
|
||||||
|
7. Compare nantaizi and at least one supplied problematic OSM sample. Record
|
||||||
|
metrics, unsupported cases, and follow-up work in task research.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:workbench -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run test:build-stages
|
||||||
|
npm run test:preflight
|
||||||
|
npm run test:preview-assets
|
||||||
|
```
|
||||||
|
|
||||||
|
Browser validation includes loading the workbench, editing a road parameter,
|
||||||
|
saving, verifying the override file, recompiling, reloading, and confirming
|
||||||
|
provenance identifies the saved override.
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
# Native road compiler workbench
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Build an incremental native road compiler for Chinese urban and campus OSM
|
||||||
|
data that can progressively exceed osm2streets in geometry quality,
|
||||||
|
explainability, and repeatable correction. The existing osm2streets pipeline
|
||||||
|
must remain usable while the native compiler is developed and compared.
|
||||||
|
|
||||||
|
The first deliverable is a browser-based Road Workbench. It must expose the
|
||||||
|
native compiler's source data, generated geometry, and diagnostics, allow
|
||||||
|
users to make small semantic/topology corrections, persist those corrections
|
||||||
|
as versionable overrides, and reload them automatically in later runs.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- Nantaizi currently works relatively well because its OSM data received
|
||||||
|
deliberate supplemental tagging; it still has missing boundaries and
|
||||||
|
polygons that cannot be closed.
|
||||||
|
- Other tested OSM inputs expose osm2streets sensitivity to input structure
|
||||||
|
and leave too much opaque, final-polygon repair work in QGIS.
|
||||||
|
- Existing Blender consumes the nine GeoJSON render layers from
|
||||||
|
`osm2streets_web_out/`; QGIS GeoPackage edits can currently be reimported
|
||||||
|
only as a whole batch.
|
||||||
|
- The repository has no existing interactive browser editing service. Existing
|
||||||
|
Cesium preview is a static, generated verification page.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1: Add a native-road-compiler path without replacing or regressing the
|
||||||
|
existing osm2streets path.
|
||||||
|
- R2: Parse OSM into a canonical, source-traceable road model with stable
|
||||||
|
references to OSM ways and nodes, explicit values versus inferred values,
|
||||||
|
and diagnostics.
|
||||||
|
- R3: Compile at least ordinary road segments and the initial supported
|
||||||
|
junction subset into the existing render-layer contract, allowing existing
|
||||||
|
Blender/Cesium consumers to be reused.
|
||||||
|
- R4: Provide a browser Road Workbench that overlays raw OSM topology,
|
||||||
|
generated geometry, osm2streets comparison geometry when available, and
|
||||||
|
compiler diagnostics.
|
||||||
|
- R5: The workbench must permit scoped user adjustments and save them to an
|
||||||
|
area-local, human-reviewable override file. Future compile and workbench
|
||||||
|
runs must load that file automatically.
|
||||||
|
- R6: Each generated object and diagnostic must be traceable to OSM source
|
||||||
|
IDs, compiler rule/inference evidence, and relevant override IDs.
|
||||||
|
- R7: Validate topology and geometry before publishing generated layers;
|
||||||
|
report unresolved semantic errors instead of silently disguising them as
|
||||||
|
geometric repair.
|
||||||
|
- R8: Develop against nantaizi plus problem inputs and report native versus
|
||||||
|
osm2streets comparison metrics.
|
||||||
|
|
||||||
|
## Scope Boundaries
|
||||||
|
|
||||||
|
- First implementation targets Chinese urban/campus roads, ordinary road
|
||||||
|
segments, T/cross junctions, directed/multi-lane roads, and data already
|
||||||
|
tagged in nantaizi where possible.
|
||||||
|
- Existing Blender, Cesium export, package format, building, vegetation, and
|
||||||
|
water generators are out of scope unless a compatibility adapter requires a
|
||||||
|
narrowly scoped change.
|
||||||
|
- Directly editing final render polygons is not the intended correction model;
|
||||||
|
generated layers remain derived output.
|
||||||
|
- Complex interchanges, arbitrary multilayer junctions, and full worldwide OSM
|
||||||
|
coverage are deferred until driven by concrete samples.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] A native compile command produces a canonical road model, generated
|
||||||
|
layers, diagnostics, and comparison artifacts for a configured area without
|
||||||
|
changing the osm2streets output path.
|
||||||
|
- [ ] A browser command serves a Road Workbench for an area and clearly shows
|
||||||
|
source topology, generated output, diagnostics, provenance, and saved
|
||||||
|
overrides.
|
||||||
|
- [ ] A user can make the agreed first-scope override edits in the browser,
|
||||||
|
save them explicitly, and receive a durable area-local override artifact.
|
||||||
|
- [ ] Re-running compile or reopening the workbench applies saved overrides
|
||||||
|
automatically and exposes their provenance.
|
||||||
|
- [ ] The compiler reports invalid/unclosed geometry, dangling road ends,
|
||||||
|
and unresolved junction/lane ambiguity with source IDs.
|
||||||
|
- [ ] Nantaizi and at least one known problematic area can run through the
|
||||||
|
native analysis/preview path, with comparison metrics captured rather than
|
||||||
|
a claim based only on visual inspection.
|
||||||
|
|
||||||
|
## Key Decisions
|
||||||
|
|
||||||
|
- The first browser editing surface supports road parameters (width, directed
|
||||||
|
lane counts, left/right sidewalk state) plus junction endpoint
|
||||||
|
connect/disconnect decisions.
|
||||||
|
- Turn restrictions, stop lines, and crosswalk placement are deferred until
|
||||||
|
the compiler has a validated road/junction editing loop.
|
||||||
|
- Overrides are a versioned, human-reviewable JSON artifact owned by the area,
|
||||||
|
not edits to generated polygon layers.
|
||||||
|
- Native output and osm2streets output remain parallel during development;
|
||||||
|
neither silently overwrites the other.
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Two-Area Native Road Comparison
|
||||||
|
|
||||||
|
## Runs
|
||||||
|
|
||||||
|
2026-08-14:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run build:area -- --config config/areas/hanyang-block.json --stages intermediates
|
||||||
|
npm run road:compile -- --config config/areas/hanyang-block.json
|
||||||
|
```
|
||||||
|
|
||||||
|
`comparison.json` is a coverage and diagnostic record. Feature counts are not
|
||||||
|
a geometry-quality score: osm2streets and the native compiler segment roads at
|
||||||
|
different levels.
|
||||||
|
|
||||||
|
| Area | Directional roads | Native surfaces | Native junctions | Movements | Internal ends | Manual candidates | osm2streets road surfaces |
|
||||||
|
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
||||||
|
| nantaizi-lake-innovation-valley | 34 | 19 | 6 | 46 | 4 | 2 | 50 |
|
||||||
|
| hanyang-block | 475 | 352 | 20 | 369 | 161 | 83 | 1826 |
|
||||||
|
|
||||||
|
## Observed Failure Modes
|
||||||
|
|
||||||
|
The hanyang osm2streets/QGIS run completed, but its log reported repeated:
|
||||||
|
|
||||||
|
- roads trimmed into oblivion;
|
||||||
|
- degenerate intersections that could not be collapsed because layers, names,
|
||||||
|
highway types, or lane specifications differ;
|
||||||
|
- intersection polygon requests with no roads.
|
||||||
|
|
||||||
|
The native compiler did not hide the related uncertainty. It reported 161
|
||||||
|
internal road ends. Eighty-three have one or more nearby, direction-compatible
|
||||||
|
candidate departures within 35 metres; these remain suggestions for explicit
|
||||||
|
review rather than automatic topology edits. The initial five one-way junctions
|
||||||
|
that lacked connector curves now publish road-surface envelopes based on their
|
||||||
|
semantic movements. Across hanyang, 369 movements are identified: 243 require
|
||||||
|
a connector curve, while 126 are continuous at their OSM node and intentionally
|
||||||
|
have no separate geometry.
|
||||||
|
|
||||||
|
## Resulting Priorities
|
||||||
|
|
||||||
|
1. Keep manual candidate suggestions and semantic overrides as the correction
|
||||||
|
path for near-miss topology. Do not bulk-connect candidates.
|
||||||
|
2. Expand ordinary junction support from 3/4 physical approaches only after
|
||||||
|
identifying a repeated unsupported topology; one-way movements that are
|
||||||
|
continuous at a node are already supported without fake connector geometry.
|
||||||
|
3. Add an inspectable movement artifact so turn geometry is not the only
|
||||||
|
representation of a road-to-road movement.
|
||||||
|
4. Use a visual review of a few explicit hanyang diagnostics before changing
|
||||||
|
connection-distance or road-class rules.
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-compiler",
|
||||||
|
"name": "native-road-compiler",
|
||||||
|
"title": "Native road compiler workbench",
|
||||||
|
"description": "",
|
||||||
|
"status": "in_progress",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-13",
|
||||||
|
"completedAt": null,
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [
|
||||||
|
"08-14-native-road-lane-markings",
|
||||||
|
"08-17-native-road-control-markings",
|
||||||
|
"08-17-native-road-center-lines",
|
||||||
|
"08-17-native-rounded-junctions",
|
||||||
|
"08-18-native-traffic-signal-parity"
|
||||||
|
],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Design
|
||||||
|
|
||||||
|
## Source Of Truth And Migration
|
||||||
|
|
||||||
|
The native compiler owns a versioned area-local signal model and override
|
||||||
|
artifact. It is generated from OSM controls and native geometry inputs, then
|
||||||
|
edited by the Workbench without QGIS. The existing
|
||||||
|
`traffic_signal_assemblies.geojson` is a migration adapter: it can be imported
|
||||||
|
into the native model and exported for legacy QGIS/reimport workflows, but a
|
||||||
|
native compile never requires it to exist.
|
||||||
|
|
||||||
|
The existing `buildTrafficSignalFeatures()` and validation functions remain the
|
||||||
|
compatibility implementation for initial generation and import/export. Imported
|
||||||
|
features retain their legacy `signal_uid` where valid; newly generated native
|
||||||
|
features use the same deterministic identity rule so downstream runtime IDs do
|
||||||
|
not fork.
|
||||||
|
|
||||||
|
## Workbench API And Editing
|
||||||
|
|
||||||
|
`GET /api/state` adds the normalized native signal model, source control
|
||||||
|
metadata, migration provenance, and derived runtime signal records. A signal
|
||||||
|
edit is represented as an atomic replacement of the validated native signal
|
||||||
|
override artifact through a dedicated signal save endpoint. A separate import
|
||||||
|
or export action handles the legacy QGIS collection; road overrides remain in
|
||||||
|
their existing file and schema.
|
||||||
|
|
||||||
|
The browser uses stable `signal_uid` values. It supports:
|
||||||
|
|
||||||
|
- generate: choose an OSM traffic-signal control and arm, then create the
|
||||||
|
deterministic assembly using the existing generator contract;
|
||||||
|
- move: update the Point coordinates while retaining stop-line/source fields;
|
||||||
|
- rotate: update `heading_deg` with normalized degrees;
|
||||||
|
- delete: remove the assembly from the editable collection;
|
||||||
|
- edit enabled state, display ID, mast reach, z offset, and phase group.
|
||||||
|
|
||||||
|
Every save validates uniqueness, identity, finite geometry, source references,
|
||||||
|
and field ranges before an atomic write. Deleted features are absent from the
|
||||||
|
runtime output; disabled features remain in the editable/QGIS layer but are
|
||||||
|
omitted by `buildTrafficSignalsFromFeatures()`.
|
||||||
|
|
||||||
|
## Delivery Flow
|
||||||
|
|
||||||
|
The native road compile result includes signal assemblies and derived runtime
|
||||||
|
metadata without adding them to road geometry layers. Native Blender/Cesium
|
||||||
|
stages consume `traffic_signals.json` and dynamic GLB inputs generated directly
|
||||||
|
from the native model. The legacy QGIS adapter may materialize the old GeoJSON,
|
||||||
|
but it is not in the native build's critical path.
|
||||||
|
|
||||||
|
## Compatibility And Rollback
|
||||||
|
|
||||||
|
QGIS reimport continues to read/export the compatibility GeoJSON while the
|
||||||
|
legacy path remains unchanged. If native signal editing fails validation, the
|
||||||
|
previous atomic native override remains in place and the user receives a
|
||||||
|
field-level error. Rollback is selecting the legacy provider or exporting the
|
||||||
|
last native state to the QGIS adapter.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Define the native signal model/override artifact and migration adapter;
|
||||||
|
reuse existing generation, validation, and deterministic signal UID rules.
|
||||||
|
2. Add QGIS import/export commands that translate
|
||||||
|
`traffic_signal_assemblies.geojson` to/from the native artifact without
|
||||||
|
making native compile depend on QGIS.
|
||||||
|
3. Extend native compile/workbench state to expose signal assemblies, OSM
|
||||||
|
controls/arms, and derived runtime provenance.
|
||||||
|
4. Add validated atomic signal save operations for generate, move, rotate,
|
||||||
|
delete, and field edits; preserve legacy ID compatibility.
|
||||||
|
5. Add Workbench map styling, selection, editing controls, dirty state, save,
|
||||||
|
compile/reload, and clear error handling for signal assemblies.
|
||||||
|
6. Ensure native Blender/Cesium/preview stages consume runtime signal data
|
||||||
|
generated from the native model, while legacy stages remain compatible.
|
||||||
|
7. Add focused traffic-signal, Workbench, migration, and cross-layer round-trip tests;
|
||||||
|
run the existing legacy traffic-signal and preview suites.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:traffic-signals
|
||||||
|
npm run test:preview-assets
|
||||||
|
npm run test:road-workbench
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:check -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Manual acceptance must cover native-only generate/move/rotate/delete -> save ->
|
||||||
|
recompile -> runtime JSON and preview, plus QGIS import/export compatibility;
|
||||||
|
disabled signals must be omitted from runtime output.
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Native traffic signal parity with QGIS
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Move traffic-signal ownership from the QGIS editing chain into the native road
|
||||||
|
compiler and Workbench. Existing QGIS signal assemblies remain import/export
|
||||||
|
compatibility data during migration, but native overrides become the long-term
|
||||||
|
source for generation, editing, and Blender/Cesium/preview delivery.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- QGIS currently edits `traffic_signal_assemblies.geojson`; this is the
|
||||||
|
migration input/output contract, not the desired long-term authority.
|
||||||
|
- `scripts/reimport-gpkg.js` validates and reimports that legacy layer.
|
||||||
|
- `scripts/build-area.js` currently derives runtime `traffic_signals.json` from
|
||||||
|
the edited assemblies; the native path must replace this dependency.
|
||||||
|
- Existing native road layers do not read traffic-signal artifacts. Historical
|
||||||
|
native Cesium work intentionally omitted signal runtime assets.
|
||||||
|
- Stable signal identity and editable fields already include `signal_uid`,
|
||||||
|
enabled state, source/control/approach IDs, arm direction, pose, mast reach,
|
||||||
|
and phase-group/runtime data.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1: Native compile/workbench must own a versioned area-local signal model and
|
||||||
|
override artifact, with an explicit one-time/import compatibility path from
|
||||||
|
existing QGIS assemblies.
|
||||||
|
- R2: Workbench state must expose signal provenance and the existing editable
|
||||||
|
signal fields using stable IDs, and support generating, moving, rotating,
|
||||||
|
and deleting signal assemblies.
|
||||||
|
- R3: Native compile and preview delivery must generate runtime signal data
|
||||||
|
directly from the native model, preserving enabled/disabled state, arm
|
||||||
|
direction/pose, and phase-group data without requiring QGIS.
|
||||||
|
- R4: A compatibility adapter must import/export the existing QGIS assembly
|
||||||
|
format during migration and preserve legacy signal IDs where possible.
|
||||||
|
|
||||||
|
## Scope Boundary
|
||||||
|
|
||||||
|
- Native signal model and overrides are the long-term source of truth.
|
||||||
|
- QGIS GeoJSON/GeoPackage support is transitional compatibility only; do not
|
||||||
|
make native compile depend on QGIS or regenerate native edits from QGIS.
|
||||||
|
- Do not redesign signal geometry, timing logic, or vehicle behavior in this
|
||||||
|
task.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] A native compile/reopen round trip preserves edited signal assemblies,
|
||||||
|
stable IDs, enabled state, and provenance without QGIS running.
|
||||||
|
- [ ] The Road Workbench can generate, inspect, move, rotate, and delete signal
|
||||||
|
assemblies, then save durable edits without breaking QGIS reimport.
|
||||||
|
- [ ] Native Blender/Cesium/preview consume runtime signal data generated from
|
||||||
|
the native model, including disabled signals being omitted from runtime.
|
||||||
|
- [ ] QGIS import/export compatibility and legacy build stages continue to
|
||||||
|
pass while the migration adapter exists.
|
||||||
|
- [ ] Nantaizi has documented native-only and QGIS-imported round trips.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-traffic-signal-parity",
|
||||||
|
"name": "native-traffic-signal-parity",
|
||||||
|
"title": "Align native traffic signals with QGIS",
|
||||||
|
"description": "",
|
||||||
|
"status": "in_progress",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-18",
|
||||||
|
"completedAt": null,
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": "08-13-native-road-compiler",
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Native Lane Markings Design
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
The native compiler remains the source of truth. It derives two new polygon
|
||||||
|
layers alongside its existing surface, sidewalk, lane-centerline, and
|
||||||
|
connector outputs:
|
||||||
|
|
||||||
|
```text
|
||||||
|
canonical directed roads + lane centerlines + junction cutbacks
|
||||||
|
|
|
||||||
|
+-- lane separators: paint polygons between adjacent same-direction lanes
|
||||||
|
|
|
||||||
|
+-- direction arrows: repeated through-arrow template on directed lanes,
|
||||||
|
| outside the reserved junction marking zone
|
||||||
|
|
|
||||||
|
+-- turn arrows: tested existing template, anchored to an incoming lane
|
||||||
|
only when that lane has an explicit supported turn:lanes value
|
||||||
|
```
|
||||||
|
|
||||||
|
No OSM2streets rendered geometry is consumed by this path. The existing arrow
|
||||||
|
template library is reused only as a geometry/style asset, so the native lane
|
||||||
|
ID and OSM tags remain the evidence for placement.
|
||||||
|
|
||||||
|
## Contracts
|
||||||
|
|
||||||
|
- `layers/lane_separators.geojson`: polygon FeatureCollection. Each feature
|
||||||
|
records `native_id`, directed `road_id`, adjacent lane indices, source OSM
|
||||||
|
ways, and `native-road-lane-separator/v1` provenance.
|
||||||
|
- `layers/turn_arrows.geojson`: polygon FeatureCollection. Each feature records
|
||||||
|
its `native_id`, `road_id`, `lane_id`, OSM way IDs, direction, lane index,
|
||||||
|
maneuver, template asset, placement distance, and placement provenance.
|
||||||
|
- Unsupported turn values, a missing usable incoming-lane segment, or an
|
||||||
|
insufficient pre-junction placement distance create a diagnostic and no
|
||||||
|
arrow geometry.
|
||||||
|
- `layers/direction_arrows.geojson`: polygon FeatureCollection. Each feature
|
||||||
|
records the native lane and directed road, OSM way IDs, a stable sequence
|
||||||
|
index, its distance along the lane, and `native-road-direction-arrow/v1`
|
||||||
|
provenance. It uses the tested `through` template but is not a turn claim.
|
||||||
|
- The workbench serves both layers, draws them separately from its current
|
||||||
|
centerline/connector debug layer, and selects them by `native_id`.
|
||||||
|
- `catalog.NATIVE_ROAD_LAYERS` maps the two native sources to the existing
|
||||||
|
`lane_separators` and `lane_arrows_webscale` Blender materials. The native
|
||||||
|
adapter does not extend the osm2streets scene-layer registry.
|
||||||
|
|
||||||
|
## Placement
|
||||||
|
|
||||||
|
An incoming lane is oriented in driving direction. A turn arrow is sampled
|
||||||
|
from that lane's endpoint backwards by the configured safe distance, staying
|
||||||
|
outside the junction cutback. Its template basis uses the sampled lane tangent;
|
||||||
|
therefore it is on and aligned with the lane rather than the OSM centerline or
|
||||||
|
a screen-space direction. Multiple template rings remain separate polygons.
|
||||||
|
|
||||||
|
Lane separators are narrow polygons centered between adjacent lane centerlines
|
||||||
|
on a single directional carriageway. They stop at the same junction cutbacks as
|
||||||
|
the lane centerlines. A one-lane direction produces none.
|
||||||
|
|
||||||
|
Direction arrows are sampled at a fixed road-scale interval along the same
|
||||||
|
directed lane centerline. Their candidates exclude both endpoint buffers and
|
||||||
|
the turn-arrow reserve at the incoming end. This preserves a readable repeated
|
||||||
|
direction cue without overlapping a turn instruction at a junction.
|
||||||
|
|
||||||
|
## Compatibility And Rollback
|
||||||
|
|
||||||
|
All new files are additive under `native-road/layers/`. The existing
|
||||||
|
osm2streets/QGIS layer contract and `package/` are unchanged. Selecting
|
||||||
|
`--road-provider osm2streets` remains rollback. Missing native marking files
|
||||||
|
are a native Blender build error rather than a silent omission.
|
||||||
|
|
||||||
|
## Risks
|
||||||
|
|
||||||
|
- OSM turn tags can be incomplete or incompatible with the inferred lane
|
||||||
|
count. These are diagnostics, not guessed arrows.
|
||||||
|
- Very short approaches can have no safe position before the cutback. They are
|
||||||
|
skipped with a source-traceable diagnostic.
|
||||||
|
- Blender and Cesium need a real native build to verify the mesh/material
|
||||||
|
contract, not only GeoJSON unit tests.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Add reusable template-placement helper to the existing turn-arrow module,
|
||||||
|
preserving its supported-asset gate and output ring shape.
|
||||||
|
2. Extend the native compiler with lane-separator, repeated road-direction
|
||||||
|
arrow, and explicit-turn-arrow polygon generation plus source diagnostics
|
||||||
|
and layer persistence.
|
||||||
|
3. Extend native output records/counts and Blender adapter mappings. Reuse
|
||||||
|
existing `lane_separators` and `lane_arrows_webscale` materials only.
|
||||||
|
4. Add Workbench layers, toggles, selection/provenance inspector entries, and
|
||||||
|
preserve the existing Workbench-only direction triangle behavior.
|
||||||
|
5. Add focused fixtures for supported turn placement, unsupported maneuver,
|
||||||
|
short approach skip, and separator geometry; run native/workbench/build
|
||||||
|
stage tests.
|
||||||
|
6. Build Nantaizi with `blender,cesium,preview --road-provider native`, inspect
|
||||||
|
the final preview, and confirm no `package/` publication occurred.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:native-road
|
||||||
|
npm run test:road-workbench
|
||||||
|
npm run test:turn-lane-arrows
|
||||||
|
npm run test:build-stages
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json \
|
||||||
|
--stages blender,cesium,preview --road-provider native
|
||||||
|
```
|
||||||
|
|
||||||
|
Rollback is selecting `--road-provider osm2streets`; no existing output path
|
||||||
|
is replaced.
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Native road lane markings and turn arrows
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Complete the native-road visual language for Nantaizi before any cross-area
|
||||||
|
migration: lane separators, travel-direction markers, and OSM-backed turn
|
||||||
|
arrows must be inspectable in the Road Workbench and visible in Blender and
|
||||||
|
Cesium output.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- Native output currently contains directed lane centerlines and connector
|
||||||
|
curves, but it does not emit paintable lane-separator or turn-arrow polygons.
|
||||||
|
- The existing osm2streets path has tested arrow templates in
|
||||||
|
`scripts/lib/turn-lane-arrows.js`, the `lane_arrows_webscale` material layer,
|
||||||
|
and a matching Blender material. Reuse these instead of introducing a second
|
||||||
|
arrow style.
|
||||||
|
- Earlier reviews established that direction markers must sit on the OSM / lane
|
||||||
|
centerline, use a clearly directional sharp triangle, and never be treated as
|
||||||
|
a road-surface decoration that drifts sideways.
|
||||||
|
- Turn arrows must follow the actual incoming lane and be placed before its
|
||||||
|
junction, with OSM source way, direction, lane index, and maneuver retained
|
||||||
|
as provenance.
|
||||||
|
- Scope remains Nantaizi only. Existing osm2streets output remains untouched.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1: Native compilation emits polygonal lane-separator markings derived from
|
||||||
|
its own directed lane geometry.
|
||||||
|
- R2: Native compilation emits turn-arrow polygons for supported OSM
|
||||||
|
`turn:lanes` maneuvers, using the existing tested arrow templates and the
|
||||||
|
exact native incoming-lane centerline for placement.
|
||||||
|
- R2a: Native compilation emits repeated straight-ahead direction-arrow
|
||||||
|
polygons along directed lanes, matching the visual role of osm2streets'
|
||||||
|
ordinary road arrows. These are a separate layer from turn arrows, retain
|
||||||
|
their own provenance, and leave a clear buffer around junction turn arrows.
|
||||||
|
- R3: Native output preserves provenance for every marking: native road/lane
|
||||||
|
ID, OSM way IDs, direction, lane number, maneuver, and placement method.
|
||||||
|
- R4: The Workbench renders markings in a separately controllable layer and
|
||||||
|
exposes those provenance fields on selection.
|
||||||
|
- R5: The native Blender adapter consumes native marking layers through the
|
||||||
|
existing lane-separator and lane-arrow material layers; Cesium must receive
|
||||||
|
the same geometry through the exported GLB.
|
||||||
|
- R6: Unsupported, unplaceable, or ambiguous arrow inputs become diagnostics;
|
||||||
|
the compiler must not invent a maneuver.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] Nantaizi native output contains valid polygon GeoJSON for generated lane
|
||||||
|
separators, repeated road direction arrows, and every supported, explicitly
|
||||||
|
tagged turn arrow.
|
||||||
|
- [ ] A Workbench user can toggle, select, and inspect a generated marker and
|
||||||
|
see its lane, OSM, maneuver, and placement provenance.
|
||||||
|
- [ ] A selected direction marker is geometrically aligned to its directed lane
|
||||||
|
centerline; a selected turn arrow is on its incoming lane before the junction.
|
||||||
|
- [ ] Blender scene output and Cesium GLB contain native lane markings and
|
||||||
|
arrows with the existing visual material language.
|
||||||
|
- [ ] Unit tests cover a normal supported arrow, an unsupported maneuver, and
|
||||||
|
an unsafe/too-short placement; native compile and final Nantaizi visual build
|
||||||
|
pass without publishing `package/`.
|
||||||
|
|
||||||
|
## Out Of Scope
|
||||||
|
|
||||||
|
- Inventing turn arrows for untagged lanes, traffic-control semantics, changing
|
||||||
|
QGIS/osm2streets layers, or processing another area.
|
||||||
|
|
||||||
|
## Key Decision
|
||||||
|
|
||||||
|
- Sharp travel-direction triangles remain a Workbench-only inspection aid.
|
||||||
|
They explain raw OSM node order after a road is selected.
|
||||||
|
- Repeated `through` direction arrows are final road markings, distinct from
|
||||||
|
both those debug triangles and OSM-backed junction turn arrows. They are
|
||||||
|
placed on native lane centerlines at a fixed interval and enter the same
|
||||||
|
Blender/Cesium material layer as turn arrows.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-lane-markings",
|
||||||
|
"name": "native-road-lane-markings",
|
||||||
|
"title": "Native road lane markings and turn arrows",
|
||||||
|
"description": "Complete Nantaizi native lane separators, travel direction and turn-arrow geometry through Road Workbench, Blender and Cesium before cross-area migration.",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P1",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-14",
|
||||||
|
"completedAt": "2026-08-14",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": "08-13-native-road-compiler",
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# Native Lane Separator Style Overrides Design
|
||||||
|
|
||||||
|
## Contract
|
||||||
|
|
||||||
|
The override is identified by the stable `roadId` plus the adjacent lane pair:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "车道分隔线:road:way/123:forward:1-2",
|
||||||
|
"kind": "lane-separator-style",
|
||||||
|
"roadId": "road:way/123:forward",
|
||||||
|
"leftLaneIndex": 1,
|
||||||
|
"rightLaneIndex": 2,
|
||||||
|
"color": "white",
|
||||||
|
"pattern": "dashed"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The same `yellow|white` and `dashed|solid` enums are reused. A default is
|
||||||
|
white dashed. The generated Polygon stores `color`, `pattern` and
|
||||||
|
`effective_style`; source IDs remain unchanged.
|
||||||
|
|
||||||
|
## Rendering
|
||||||
|
|
||||||
|
The existing lane separator polygon represents the whole lane-pair path.
|
||||||
|
`solid` retains it as one continuous feature. `dashed` samples regular dash
|
||||||
|
polygons along the shared centreline with deterministic spacing and preserves
|
||||||
|
junction cutback. White uses the existing `lane_separators` material; yellow
|
||||||
|
uses a native-only yellow material route. Workbench separates lane separators
|
||||||
|
from turn arrows so their styles remain selectable and visible.
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
No override means current visual default. Road edges, curbs and centre lines
|
||||||
|
are untouched. Existing `native-road-overrides/v1` files remain valid.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Validate and resolve per-lane-pair style overrides.
|
||||||
|
2. Generate default/dashed/solid style geometry and effective properties.
|
||||||
|
3. Add the native Blender yellow lane-separator material route.
|
||||||
|
4. Add Workbench selection, Chinese editor and automatic staging.
|
||||||
|
5. Test compiler, Workbench, Blender catalog and Nantaizi native build.
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# Native lane separator style overrides
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Make native same-direction lane separators selectable and persistently editable
|
||||||
|
in Road Workbench, using the style override pattern proven for centre lines.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- `compileLaneMarkings()` writes one continuous `0.12m` Polygon separator
|
||||||
|
between each adjacent lane pair, identified by `road_id`, `left_lane_index`
|
||||||
|
and `right_lane_index`.
|
||||||
|
- Lane separators currently have fixed light marking material and are displayed
|
||||||
|
together with turn arrows in Workbench.
|
||||||
|
- `native-road-overrides.json` already supports validated, persistent centre
|
||||||
|
line styles by logical native segment. The new type must not alter road-edge,
|
||||||
|
curb or sidewalk geometry.
|
||||||
|
|
||||||
|
## Initial Requirements
|
||||||
|
|
||||||
|
- Selecting a lane separator must show its lane-pair source and a Chinese
|
||||||
|
style editor.
|
||||||
|
- The first style catalog should mirror centre lines: white/yellow and
|
||||||
|
dashed/solid.
|
||||||
|
- The effective style must be generated into GeoJSON, visible in Workbench,
|
||||||
|
and consumed by native Blender/Cesium.
|
||||||
|
- Default output must remain the current white dashed-style separator.
|
||||||
|
|
||||||
|
## Out Of Scope
|
||||||
|
|
||||||
|
- Road-edge lines, curbs, sidewalks, double lines, partial ranges, lane-specific
|
||||||
|
legal restrictions and osm2streets layers.
|
||||||
|
|
||||||
|
## Key Decision
|
||||||
|
|
||||||
|
Each override applies only to the selected adjacent lane pair. This preserves
|
||||||
|
separate marking semantics on roads with three or more lanes.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] Selecting a separator exposes a Chinese style editor for its adjacent
|
||||||
|
lane pair; choosing a style stages it automatically.
|
||||||
|
- [ ] Save and regeneration preserve the per-pair style across reloads while
|
||||||
|
unedited separators retain the default.
|
||||||
|
- [ ] GeoJSON, Workbench, Blender and Cesium show the same effective style.
|
||||||
|
- [ ] Tests cover validation, defaults, per-pair isolation, automatic staging
|
||||||
|
and native scene consumption.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-lane-separator-styles",
|
||||||
|
"name": "native-lane-separator-styles",
|
||||||
|
"title": "Native lane separator style overrides",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-17",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Native Road Centre-Line Style Overrides Design
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```text
|
||||||
|
Workbench selects a generated centre-line dash
|
||||||
|
-> segment_id identifies the logical road segment
|
||||||
|
-> staged center-line-style override
|
||||||
|
-> native-road-overrides.json
|
||||||
|
-> compileCenterLines resolves default or effective style
|
||||||
|
-> center_lines.geojson polygons with style fields
|
||||||
|
-> Workbench / Blender / Cesium
|
||||||
|
```
|
||||||
|
|
||||||
|
The authoritative edit is a new override kind, not a mutation of
|
||||||
|
`center_lines.geojson`. It has a deterministic ID based on `segmentId`, so a
|
||||||
|
later recompilation replaces the segment's style rather than accumulating
|
||||||
|
records.
|
||||||
|
|
||||||
|
## Override Contract
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "道路中心线:segment:way/123/1",
|
||||||
|
"kind": "center-line-style",
|
||||||
|
"segmentId": "segment:way/123/1",
|
||||||
|
"color": "yellow",
|
||||||
|
"pattern": "dashed"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
`validateOverrides()` accepts only known model segment IDs and the finite
|
||||||
|
string enums `yellow|white` and `dashed|solid`. A style override applies once
|
||||||
|
to the paired forward/backward native roads for that segment. The existing
|
||||||
|
schema version remains `native-road-overrides/v1` because this is an additive
|
||||||
|
kind and old files remain valid.
|
||||||
|
|
||||||
|
## Geometry and Material
|
||||||
|
|
||||||
|
- Default remains yellow dashed: 2m dash, 2m gap, 0.25m width.
|
||||||
|
- `solid` generates deterministic adjacent 2m pieces with no gap. Pieces still
|
||||||
|
undergo the same junction cutback and control-marking exclusion as dashed
|
||||||
|
lines; this avoids creating a solid polygon across an excluded crossing.
|
||||||
|
- Style fields `color`, `pattern`, `dash_length_m`, `dash_gap_m`, and
|
||||||
|
`effective_style` are stored on every generated polygon.
|
||||||
|
- Blender currently maps all `center_lines` to one yellow material, so the
|
||||||
|
native adapter must support a white centre-line material route without
|
||||||
|
changing legacy osm2streets layers. The route must preserve the existing
|
||||||
|
yellow material for default and yellow overrides.
|
||||||
|
|
||||||
|
## Workbench UX
|
||||||
|
|
||||||
|
Selecting a centre-line dash shows a compact Chinese style panel in the
|
||||||
|
existing form area. A select control presents the four named choices. Choosing
|
||||||
|
one stages an override; the existing 保存 / 保存并重新生成 actions remain the
|
||||||
|
only persistence and generation actions. The panel also shows whether the
|
||||||
|
style is default or overridden and identifies the native road segment.
|
||||||
|
|
||||||
|
## Compatibility and Rollback
|
||||||
|
|
||||||
|
Unedited segments generate byte-compatible geometry style defaults apart from
|
||||||
|
the added style properties. Oneway/service filtering and control priority are
|
||||||
|
unchanged. Selecting `--road-provider osm2streets` remains a full rollback.
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Add validated `center-line-style` overrides and a helper which resolves the
|
||||||
|
effective default/override style by segment ID.
|
||||||
|
2. Generate yellow/white and dashed/solid centre-line geometry while retaining
|
||||||
|
cutback and control-marking exclusion behaviour; publish effective style
|
||||||
|
properties.
|
||||||
|
3. Extend the native Blender layer adapter/material handling to distinguish
|
||||||
|
white from yellow centre-line features without affecting legacy layers.
|
||||||
|
4. Add Workbench style controls, staging, Chinese selection evidence, and
|
||||||
|
immediate regenerated-layer display.
|
||||||
|
5. Add focused compiler, override, Workbench, Blender catalog, and build-stage
|
||||||
|
tests; compile/check Nantaizi and build Blender/Cesium/preview without the
|
||||||
|
package stage.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:native-road
|
||||||
|
npm run test:road-workbench
|
||||||
|
python3 -m unittest discover blender/tests
|
||||||
|
npm run test:build-stages
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:check -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender,cesium,preview --road-provider native
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rollback
|
||||||
|
|
||||||
|
Remove the override records or choose `--road-provider osm2streets`; no legacy
|
||||||
|
output is modified.
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# Native road center line style overrides
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Allow a Road Workbench user to select a generated native road centre line and
|
||||||
|
persistently override its marking style, without turning the generated GeoJSON
|
||||||
|
into the source of truth.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- Native `center_lines.geojson` currently contains automatic yellow dashed
|
||||||
|
polygons (`2m` dash, `2m` gap, `0.25m` width), each tied to a `segment_id`.
|
||||||
|
- A displayed dash can already be selected and exposes its segment provenance,
|
||||||
|
but has no editing controls.
|
||||||
|
- `native-road-overrides.json` is the persistent authority for existing road
|
||||||
|
and connection edits. The Workbench already stages, validates, saves, then
|
||||||
|
recompiles those overrides.
|
||||||
|
- The generated layer is consumed by both Workbench and native Blender/Cesium;
|
||||||
|
styling must therefore be compiled geometry and use the existing
|
||||||
|
`center_lines` material path, not a Workbench-only display tint.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1: Selecting a centre-line dash must expose a Chinese style editor for its
|
||||||
|
logical target and show the current effective style.
|
||||||
|
- R2: Supported styles must include at least solid/dashed and white/yellow
|
||||||
|
marking colours.
|
||||||
|
- R3: Style choices must be stored in `native-road-overrides.json`, validated,
|
||||||
|
reapplied during compilation, and survive a future Workbench launch.
|
||||||
|
- R4: The regenerated GeoJSON must carry source traceability and effective
|
||||||
|
style fields so Workbench, Blender and Cesium show the same marking.
|
||||||
|
- R5: Default automatic centre lines remain unchanged for segments without an
|
||||||
|
override; one-way/service exclusions and control-marking avoidance remain
|
||||||
|
authoritative.
|
||||||
|
|
||||||
|
## Initial Scope Boundary
|
||||||
|
|
||||||
|
- Editing individual dash polygons is out of scope: they are derived pieces,
|
||||||
|
not user-owned objects.
|
||||||
|
- Per-segment control is recommended for the first version because current
|
||||||
|
native segments already stop at junctions and have stable IDs.
|
||||||
|
- Double-line semantics, legal `overtaking` inference, hand-drawn partial
|
||||||
|
ranges, and changes to osm2streets output are out of scope unless explicitly
|
||||||
|
accepted during planning.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] A user can select a centre line, choose a supported style in Chinese,
|
||||||
|
save it, regenerate, and see the result immediately in the Workbench.
|
||||||
|
- [ ] After reload and recompilation, the selected segment retains its style
|
||||||
|
while unedited segments retain the automatic yellow dashed default.
|
||||||
|
- [ ] Native Blender/Cesium uses the same effective style and does not require
|
||||||
|
osm2streets geometry.
|
||||||
|
- [ ] Tests cover schema validation, style geometry, default fallback,
|
||||||
|
persistence/API wiring, and Workbench selection/edit controls.
|
||||||
|
|
||||||
|
## Key Decisions
|
||||||
|
|
||||||
|
- The first version applies one override to the complete native segment between
|
||||||
|
junctions. Individual dash and partial-range editing are deferred.
|
||||||
|
- The initial style catalog is four explicit choices: yellow dashed, white
|
||||||
|
dashed, yellow solid, and white solid. Double-line semantics are deferred.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-center-line-styles",
|
||||||
|
"name": "native-road-center-line-styles",
|
||||||
|
"title": "Native road center line style overrides",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-17",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# Native Road Centre Lines Design
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
The native compiler adds one independent polygon layer:
|
||||||
|
|
||||||
|
```text
|
||||||
|
canonical bidirectional segment + trimmed OSM centreline
|
||||||
|
-> repeated 2m x 0.25m dash polygons
|
||||||
|
-> native-road/layers/center_lines.geojson
|
||||||
|
-> Workbench / native Blender adapter / Cesium
|
||||||
|
```
|
||||||
|
|
||||||
|
It does not read osm2streets `center_lines.geojson`. The legacy layer is a
|
||||||
|
visual baseline only.
|
||||||
|
|
||||||
|
## Placement
|
||||||
|
|
||||||
|
- A candidate must have exactly forward and backward native roads for the same
|
||||||
|
`segmentId`, neither be `highway=service`, and have a valid trimmed OSM
|
||||||
|
centreline.
|
||||||
|
- Dashes use the legacy observed dimensions: 2m length, 0.25m width, with a
|
||||||
|
deterministic 2m gap. The first dash starts at a fixed segment-local offset
|
||||||
|
so rebuilds do not drift.
|
||||||
|
- The line is trimmed with the same `junctionPlans` cutback used by native lane
|
||||||
|
centreline generation. Any dash intersecting a crosswalk or stop line is
|
||||||
|
omitted, preserving the control-marking priority already established.
|
||||||
|
- One-way and service segments have no generated feature. A degenerate source
|
||||||
|
line produces a diagnostic rather than malformed geometry.
|
||||||
|
|
||||||
|
## Contracts
|
||||||
|
|
||||||
|
`layers/center_lines.geojson` is a Polygon FeatureCollection. Every feature
|
||||||
|
has `native_id`, `segment_id`, `directional_road_ids`, `osm_way_ids`,
|
||||||
|
`dash_index`, `dash_length_m`, `dash_gap_m`, `placement_rule`, and
|
||||||
|
`provenance="native-road-center-line/v1"`.
|
||||||
|
|
||||||
|
`compiled.json.layers.centerLines`, comparison count
|
||||||
|
`nativeCenterLineFeatures`, and `build-area.js` required native records use the
|
||||||
|
same filename. `catalog.NATIVE_ROAD_LAYERS` maps source `center_lines` to the
|
||||||
|
existing `center_lines` material layer.
|
||||||
|
|
||||||
|
The Workbench loads this source into the marking overlay, exposes a Chinese
|
||||||
|
toggle, and identifies it as `道路中心虚线` on selection.
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
The change is additive within `native-road/`; `--road-provider osm2streets`
|
||||||
|
remains unaffected and is rollback. A native Blender build treats a missing
|
||||||
|
layer as an input error rather than silently omitting it.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Add centre-dash constants and a pure native compiler routine based on the
|
||||||
|
shared bidirectional segment model and junction-trimmed centreline.
|
||||||
|
2. Filter invalid, one-way, service, and control-marking-conflicting dashes;
|
||||||
|
record actionable diagnostics for invalid geometry only.
|
||||||
|
3. Write `center_lines.geojson`, compilation/comparison counts, native build
|
||||||
|
records, required-layer checks, and Blender material adapter mapping.
|
||||||
|
4. Add Workbench API state, Chinese toggle, summary count, rendering, and
|
||||||
|
source evidence for a selected centre dash.
|
||||||
|
5. Add focused native and Workbench tests for generation, skips, control
|
||||||
|
avoidance, provenance, and file/API contracts.
|
||||||
|
6. Run native/unit/workbench/build-stage tests, compile/check Nantaizi, then
|
||||||
|
validate `blender,cesium,preview --road-provider native` without `package`.
|
||||||
|
|
||||||
|
## Rollback
|
||||||
|
|
||||||
|
Choose `--road-provider osm2streets`; no legacy layer or published package is
|
||||||
|
modified.
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# Native road center lines
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Restore the existing osm2streets-style road-centre dashed markings in the
|
||||||
|
native-road provider before treating native output as ready for broader quality
|
||||||
|
gates or new-area validation.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- Nantaizi's existing `osm2streets_web_out/center_lines.geojson` has 885
|
||||||
|
`type="center line"` polygons. Its sampled dash geometry is approximately
|
||||||
|
2.00m long by 0.25m wide.
|
||||||
|
- The legacy extraction excludes centre lines that overlap crosswalk zones and
|
||||||
|
that fall on service driving polygons (`build-osm2streets-qgis.js:474-480`).
|
||||||
|
- Native output currently has only same-direction `lane_separators`; it has no
|
||||||
|
`center_lines.geojson`, so a bidirectional road's directional carriageways
|
||||||
|
lack their visual and semantic divider.
|
||||||
|
- Existing Blender already owns a `center_lines` / `Center Line` material
|
||||||
|
layer. Native must adapt to it rather than creating a second scene registry.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1: For supported non-service, bidirectional native road segments, emit a
|
||||||
|
`center_lines.geojson` dashed centre divider derived from the canonical OSM
|
||||||
|
centreline and the segment's two directional carriageways.
|
||||||
|
- R2: Match the established visual baseline: yellow 0.25m-wide, 2m-long
|
||||||
|
dashes, clipped away from ordinary junction cutbacks and control markings.
|
||||||
|
- R3: Preserve source traceability: each dash records its native segment,
|
||||||
|
source OSM way, involved directional roads, placement interval/rule, and a
|
||||||
|
dedicated provenance value.
|
||||||
|
- R4: Add the layer to compilation records, Road Workbench display/selection
|
||||||
|
in Chinese, and the existing Blender/Cesium `center_lines` material path.
|
||||||
|
- R5: Do not render a centre divider on one-way or `highway=service` segments;
|
||||||
|
report invalid geometry instead of fabricating a divider.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] Native Nantaizi output contains a valid `layers/center_lines.geojson`
|
||||||
|
with source-traceable 2m x 0.25m dashed polygons.
|
||||||
|
- [ ] No native centre dash intersects a generated crosswalk or vehicle stop
|
||||||
|
line, and no dash reaches into the supported junction surface cutback.
|
||||||
|
- [ ] The Workbench can toggle and select centre lines, presenting their
|
||||||
|
source and rule in Chinese rather than calling them lane separators.
|
||||||
|
- [ ] Native `blender,cesium,preview` consumes the layer using the existing
|
||||||
|
`center_lines` material and does not run `package`.
|
||||||
|
- [ ] Tests cover two-way generation, one-way/service skips, control-marking
|
||||||
|
avoidance, provenance, output contract, and Workbench wiring.
|
||||||
|
|
||||||
|
## Out Of Scope
|
||||||
|
|
||||||
|
- Centre-line editing overrides, solid/double-centre-line semantics, arbitrary
|
||||||
|
OSM `overtaking` interpretation, lane colouring changes, and other areas.
|
||||||
|
|
||||||
|
## Key Decision
|
||||||
|
|
||||||
|
This task deliberately matches the existing stable visual layer first. It does
|
||||||
|
not claim to infer a country-wide legal marking taxonomy from sparse OSM tags.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-center-lines",
|
||||||
|
"name": "native-road-center-lines",
|
||||||
|
"title": "Native road center lines",
|
||||||
|
"description": "Align native-road output with the existing center_lines layer before broader quality work.",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-17",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": "08-13-native-road-compiler",
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
# Native Road Control Markings Design
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
The native compiler remains the source of truth. It extends its canonical OSM
|
||||||
|
parse with marked crossing nodes, then derives two additive polygon layers from
|
||||||
|
the crossing evidence, native directed lanes, and native junction plans:
|
||||||
|
|
||||||
|
```text
|
||||||
|
OSM crossing node + native directed lane centerlines + junction plans
|
||||||
|
|
|
||||||
|
+-- crosswalks.geojson: six zebra stripe polygons per safe crossing
|
||||||
|
|
|
||||||
|
+-- vehicle_stop_lines.geojson: one safe approach stop-line polygon
|
||||||
|
```
|
||||||
|
|
||||||
|
No osm2streets GeoJSON is read. Existing crossing geometry helpers may be
|
||||||
|
extracted or adapted only when they operate on native lane data and retain
|
||||||
|
native provenance.
|
||||||
|
|
||||||
|
## Source And Placement
|
||||||
|
|
||||||
|
- A source node is eligible only when `highway=crossing` and
|
||||||
|
`crossing:markings` is not `no`, `none`, or `unmarked`.
|
||||||
|
- The compiler finds native roads containing the crossing's OSM node and uses
|
||||||
|
the nearest compatible directed lane centerline to obtain the road tangent.
|
||||||
|
- Crosswalk stripes are perpendicular to that tangent and constrained to the
|
||||||
|
native road width. Existing fixed zebra dimensions are retained initially:
|
||||||
|
six 0.45m stripes with 0.45m gaps, 0.45m stripe width, and a highway-based
|
||||||
|
stripe length.
|
||||||
|
- A stop line is generated only when the crossing can be associated with a
|
||||||
|
supported junction approach and a safe outside-of-junction side. Otherwise
|
||||||
|
the crosswalk may remain valid but the missing stop line is diagnostic.
|
||||||
|
- Duplicate nearby crossing nodes use a stable cluster representative so one
|
||||||
|
physical crosswalk does not produce duplicate stripes.
|
||||||
|
|
||||||
|
## Contracts
|
||||||
|
|
||||||
|
`layers/crosswalks.geojson` and `layers/vehicle_stop_lines.geojson` are Polygon
|
||||||
|
FeatureCollections. Each feature records its crossing OSM node, source OSM way,
|
||||||
|
native directed road/lane when available, direction, placement method, and
|
||||||
|
`native-road-crosswalk/v1` or `native-road-stop-line/v1` provenance.
|
||||||
|
|
||||||
|
The Workbench API returns both layers as `state.layers.crosswalks` and
|
||||||
|
`state.layers.vehicleStopLines`. Its browser map uses separate toggleable
|
||||||
|
layers and selection evidence; the scene-preview toggle leaves real control
|
||||||
|
markings visible.
|
||||||
|
|
||||||
|
`catalog.NATIVE_ROAD_LAYERS` maps the sources to existing `crosswalks` and
|
||||||
|
`vehicle_stop_lines` material layers. This native adapter must not add them to
|
||||||
|
the osm2streets `ROAD_LAYERS` / `SCENE_LAYERS` registry.
|
||||||
|
|
||||||
|
## Compatibility And Rollback
|
||||||
|
|
||||||
|
The new files are additive under `native-road/layers/`. Existing osm2streets
|
||||||
|
output and QGIS input are unchanged. Selecting `--road-provider osm2streets`
|
||||||
|
remains rollback. A native Blender build treats a missing new layer as an error
|
||||||
|
rather than silently omitting a visible marking.
|
||||||
|
|
||||||
|
## Risks
|
||||||
|
|
||||||
|
- Crossing nodes can be detached from a routable road or lie on an ambiguous
|
||||||
|
multi-road segment. These become diagnostics rather than guessed geometry.
|
||||||
|
- A physical crossing split into several OSM nodes must deduplicate stably.
|
||||||
|
- A crosswalk near a non-supported junction may get stripes but no valid stop
|
||||||
|
line; this difference must be exposed in workbench provenance.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Extend the native OSM parse/model with marked crossing-node evidence while
|
||||||
|
preserving existing road IDs and parser behavior.
|
||||||
|
2. Add native crossing clustering, tangent resolution from directed lane
|
||||||
|
centerlines, stripe geometry, safe stop-line placement, and source
|
||||||
|
diagnostics.
|
||||||
|
3. Persist the two new layers in `compile-native-roads.js`, comparison counts,
|
||||||
|
native build records, required native layer checks, and existing Blender
|
||||||
|
material mappings.
|
||||||
|
4. Add Workbench API/state fields, Chinese layer toggles, selection evidence,
|
||||||
|
and summary counts while retaining scene-preview behavior.
|
||||||
|
5. Add focused fixtures for marked and unmarked crossings, duplicate cluster
|
||||||
|
handling, a missing native-lane diagnostic, and output layer contracts.
|
||||||
|
6. Run native/unit/workbench/build-stage tests, compile/check Nantaizi, then
|
||||||
|
build `blender,cesium,preview --road-provider native` without `package/`.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:native-road
|
||||||
|
npm run test:road-workbench
|
||||||
|
npm run test:build-stages
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:check -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json \
|
||||||
|
--stages blender,cesium,preview --road-provider native
|
||||||
|
```
|
||||||
|
|
||||||
|
Rollback is selecting `--road-provider osm2streets`; no legacy output path is
|
||||||
|
changed.
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# Native road control markings
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Give Nantaizi's native-road provider inspectable, source-traceable crosswalk
|
||||||
|
and vehicle stop-line geometry, so intersection control markings do not depend
|
||||||
|
on the osm2streets render output.
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- Native road output already owns road surfaces, sidewalks, lane separators,
|
||||||
|
repeated direction arrows, and explicit junction-turn arrows.
|
||||||
|
- Nantaizi's OSM input contains explicit marked crossings, including zebra and
|
||||||
|
traffic-signal crossings. The existing osm2streets output currently has 48
|
||||||
|
crosswalk-stripe polygons and 8 stop-line polygons.
|
||||||
|
- `build-osm2streets-qgis.js:1067` derives these markings from crossing nodes
|
||||||
|
plus osm2streets driving lanes. Native must not read that rendered geometry;
|
||||||
|
it can reuse only the tested geometry rules after adapting them to native
|
||||||
|
directed lanes and junction plans.
|
||||||
|
- Existing Blender materials already provide `crosswalks` and
|
||||||
|
`vehicle_stop_lines`; native may map into them without changing the legacy
|
||||||
|
osm2streets layer registry.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1: Native compilation uses explicit marked OSM crossing nodes only, and
|
||||||
|
emits crosswalk-stripe polygons plus approach stop lines only where safe
|
||||||
|
native directed-road placement exists.
|
||||||
|
- R2: Each generated feature preserves crossing node, OSM road, native road or
|
||||||
|
lane, direction, placement method, and relevant junction provenance.
|
||||||
|
- R3: The Road Workbench independently toggles, selects, and describes native
|
||||||
|
crosswalks and stop lines in Chinese.
|
||||||
|
- R4: Native Blender and Cesium builds consume both layers with the existing
|
||||||
|
control-marking materials; no `package/` publication is part of validation.
|
||||||
|
- R5: Missing compatible road context, ambiguous geometry, and unsupported
|
||||||
|
crossing inputs are diagnostics; the compiler must not invent a crossing.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] Nantaizi native output contains valid `crosswalks.geojson` and
|
||||||
|
`vehicle_stop_lines.geojson` features with source-traceable properties,
|
||||||
|
without reading osm2streets rendered layers.
|
||||||
|
- [ ] A Workbench user can toggle and select either marking type and see the
|
||||||
|
crossing node, associated road/direction, and placement evidence.
|
||||||
|
- [ ] Native Blender/Cesium output contains both marking types using existing
|
||||||
|
materials, after `blender,cesium,preview --road-provider native` and without
|
||||||
|
publishing `package/`.
|
||||||
|
- [ ] Tests cover a marked crossing, an unmarked crossing skip, a missing or
|
||||||
|
ambiguous native-road placement skip, and output-layer contract checks.
|
||||||
|
|
||||||
|
## Out Of Scope
|
||||||
|
|
||||||
|
- Hand-placed control-marking overrides, traffic-signal state-machine changes,
|
||||||
|
freehand polygon editing, processing another region, and importing
|
||||||
|
osm2streets-rendered crosswalk geometry.
|
||||||
|
|
||||||
|
## Key Decision
|
||||||
|
|
||||||
|
The first version is explicit-OSM-only. This is feasible for Nantaizi and
|
||||||
|
keeps control markings evidence-backed; missing data remains a diagnostic for
|
||||||
|
OSM improvement rather than a silent geometric guess.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-control-markings",
|
||||||
|
"name": "native-road-control-markings",
|
||||||
|
"title": "Native road control markings",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-17",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": "08-13-native-road-compiler",
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_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."}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Native road edge markings
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
TBD.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- TBD
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] TBD
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Keep `prd.md` focused on requirements, constraints, and acceptance criteria.
|
||||||
|
- Lightweight tasks can remain PRD-only.
|
||||||
|
- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-edge-markings",
|
||||||
|
"name": "native-road-edge-markings",
|
||||||
|
"title": "Native road edge markings",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-17",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/cli-and-stages.md","reason":"Check compiler and workbench marking contracts."}
|
||||||
|
{"file":".trellis/spec/blender/testing.md","reason":"Run required Blender test suite."}
|
||||||
|
{"file":".trellis/spec/guides/cross-layer-thinking-guide.md","reason":"Verify browser, compiler, and Blender consume the same output."}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Design
|
||||||
|
|
||||||
|
The compiler owns marking semantics. `center-line-style` remains segment
|
||||||
|
scoped because a bidirectional road segment shares one centre-line decision.
|
||||||
|
`edge-line-style` is scoped to `{ roadId, side }`, since a directional
|
||||||
|
carriageway has independently editable left and right outside edges.
|
||||||
|
|
||||||
|
`double: true` is valid only with yellow solid centre lines. Generation emits
|
||||||
|
two 0.32m-separated parallel polygons for each normal solid mark, preserving
|
||||||
|
junction cutback and crosswalk/stop-line clearance. This keeps the existing
|
||||||
|
solid line implementation and avoids a separate geometry pipeline.
|
||||||
|
|
||||||
|
Road edge lines use the existing road-edge offset geometry. A solid style is
|
||||||
|
one continuous buffered offset line; a dashed style uses deterministic 2m
|
||||||
|
marks at 4m spacing. Both carry `effective_style`, source IDs, side, and
|
||||||
|
native provenance.
|
||||||
|
|
||||||
|
The Workbench uses one marking form with an explicit selected target type.
|
||||||
|
Only a centre-line target exposes the double-yellow option; lane separators
|
||||||
|
and edge lines retain the ordinary colour/pattern choices. Staged changes pass
|
||||||
|
through the existing save and regenerate flow, so browser, compiler and
|
||||||
|
Blender read the same persisted override.
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/cli-and-stages.md","reason":"Native-road output, override, and stage contracts."}
|
||||||
|
{"file":".trellis/spec/blender/asset-generation.md","reason":"Native provider adapter and Blender output requirements."}
|
||||||
|
{"file":".trellis/spec/guides/artifact-parity-guide.md","reason":"Intentional render-output change validation."}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Implementation
|
||||||
|
|
||||||
|
1. Extend override validation and native marking generation for explicit
|
||||||
|
double-yellow centre lines and per-side edge-line styles.
|
||||||
|
2. Extend the Chinese Workbench selection/form flow without adding another
|
||||||
|
editor or output format.
|
||||||
|
3. Add compiler and Workbench regression coverage for valid and invalid
|
||||||
|
payloads, generated geometry, and layer adapter completeness.
|
||||||
|
4. Compile/check Nantaizi, run native/Workbench/build-stage/Blender tests,
|
||||||
|
then run the native Blender/Cesium/preview chain.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# Native road marking semantics
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Finish the native road marking model so the Nantaizi Road Workbench can
|
||||||
|
persist meaningful centre-line and road-edge-line styles, regenerate native
|
||||||
|
geometry deterministically, and deliver the same result to Blender/Cesium.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Add an explicit double-yellow-solid centre-line semantic. It must not be a
|
||||||
|
generic double-line switch that permits invalid colour/pattern combinations.
|
||||||
|
- Keep all marking edits area-local in `native-road-overrides.json`; generated
|
||||||
|
GeoJSON remains derived output.
|
||||||
|
- Make road edge lines selectable and style-editable in the Chinese Road
|
||||||
|
Workbench, alongside existing centre lines and lane separators.
|
||||||
|
- Preserve the default Nantaizi output unless a user supplies an override.
|
||||||
|
- Native geometry must remain independent of osm2streets render geometry.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] A `center-line-style` override with `double: true`, `yellow`, and
|
||||||
|
`solid` emits two offset centre-line polygons with an explicit effective
|
||||||
|
style, while invalid double combinations are rejected.
|
||||||
|
- [ ] An `edge-line-style` override targets one directional road side and
|
||||||
|
supports white/yellow plus solid/dashed styles.
|
||||||
|
- [ ] The Workbench exposes Chinese selection feedback, stages the correct
|
||||||
|
override payload, and only shows the double-yellow choice for centre lines.
|
||||||
|
- [ ] Nantaizi native compile/check, Workbench/native tests, Blender pure
|
||||||
|
tests, and native Blender/Cesium/preview build pass.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Keep `prd.md` focused on requirements, constraints, and acceptance criteria.
|
||||||
|
- Lightweight tasks can remain PRD-only.
|
||||||
|
- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-road-marking-semantics",
|
||||||
|
"name": "native-road-marking-semantics",
|
||||||
|
"title": "Native road marking semantics",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-17",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/cli-and-stages.md","reason":"Native geometry correctness and output contracts."}
|
||||||
|
{"file":".trellis/spec/blender/testing.md","reason":"Blender validation requirements."}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Design
|
||||||
|
|
||||||
|
Each approach contributes its two carriageway-edge points at the common
|
||||||
|
cutback distance. Points are ordered around the junction node. For each pair
|
||||||
|
from adjacent approaches, the compiler samples a deterministic quadratic
|
||||||
|
Bezier whose control point follows the pedestrian-side curb arc toward the
|
||||||
|
junction. Rounded plans use a larger cutback than the legacy straight envelope
|
||||||
|
so this visible curb shape still contains all turning connectors. Approach road
|
||||||
|
surfaces terminate at the same cutback, so they cannot cover the junction
|
||||||
|
outline in 3D output.
|
||||||
|
|
||||||
|
The curve is accepted only when the support intersection is finite, the pair
|
||||||
|
belongs to different approaches, and the resulting ring remains valid and
|
||||||
|
contains all published connector coordinates. Otherwise the original straight
|
||||||
|
chord remains for that corner and the plan reports a mixed/fallback boundary.
|
||||||
|
|
||||||
|
Lane connectors remain a separate vehicle-path layer. This task changes only
|
||||||
|
the road/intersection outline and sidewalk-corner shape.
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/cli-and-stages.md","reason":"Native geometry and build-stage contracts."}
|
||||||
|
{"file":".trellis/spec/guides/artifact-parity-guide.md","reason":"Intentional geometry output change validation."}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Implementation
|
||||||
|
|
||||||
|
1. Build a rounded junction boundary from ordered approach-edge records with
|
||||||
|
tangent support-line intersections and deterministic curve samples.
|
||||||
|
2. Expose boundary mode/provenance and preserve containment fallback.
|
||||||
|
3. Extend focused native-road tests for curved ordinary intersections.
|
||||||
|
4. Validate Nantaizi compile/check, workbench tests, and native 3D build.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Rounded native road junctions
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
Replace the octagonal native junction outline with smooth, tangentially joined
|
||||||
|
road-edge corners for ordinary Nantaizi T and cross junctions.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Junction surface boundaries must connect adjacent approach carriageway edges
|
||||||
|
with a smooth outward curve rather than a straight octagonal chord.
|
||||||
|
- Sidewalk corner surfaces must use the same rounded boundary concept so road
|
||||||
|
and pedestrian geometry do not disagree visually.
|
||||||
|
- Preserve a deterministic straight-edge fallback and an explicit diagnostic
|
||||||
|
when a corner cannot be safely constructed.
|
||||||
|
- Do not change lane connector semantics or derive geometry from osm2streets.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [x] Ordinary cross/T fixtures generate rounded junction polygons with more
|
||||||
|
than the prior eight straight boundary vertices and `boundary_mode` records
|
||||||
|
the chosen style.
|
||||||
|
- [x] Connector containment remains valid and degenerate geometry falls back
|
||||||
|
without publishing self-intersecting polygons.
|
||||||
|
- [x] Nantaizi compile/check and native Blender/Cesium/preview succeed.
|
||||||
|
|
||||||
|
## Verification Record
|
||||||
|
|
||||||
|
- Native geometry and Workbench tests passed.
|
||||||
|
- Nantaizi native compile/check passed with `ok=true`.
|
||||||
|
- Native Blender/Cesium/preview verification was completed manually in a
|
||||||
|
working Blender environment.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Keep `prd.md` focused on requirements, constraints, and acceptance criteria.
|
||||||
|
- Lightweight tasks can remain PRD-only.
|
||||||
|
- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "native-rounded-junctions",
|
||||||
|
"name": "native-rounded-junctions",
|
||||||
|
"title": "Rounded native road junctions",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-17",
|
||||||
|
"completedAt": "2026-08-18",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "feature/native-road-compiler",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": "08-13-native-road-compiler",
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
<!-- @@@auto:current-status -->
|
<!-- @@@auto:current-status -->
|
||||||
- **Active File**: `journal-1.md`
|
- **Active File**: `journal-1.md`
|
||||||
- **Total Sessions**: 30
|
- **Total Sessions**: 37
|
||||||
- **Last Active**: 2026-08-12
|
- **Last Active**: 2026-08-18
|
||||||
<!-- @@@/auto:current-status -->
|
<!-- @@@/auto:current-status -->
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<!-- @@@auto:active-documents -->
|
<!-- @@@auto:active-documents -->
|
||||||
| File | Lines | Status |
|
| File | Lines | Status |
|
||||||
|------|-------|--------|
|
|------|-------|--------|
|
||||||
| `journal-1.md` | ~642 | Active |
|
| `journal-1.md` | ~803 | Active |
|
||||||
<!-- @@@/auto:active-documents -->
|
<!-- @@@/auto:active-documents -->
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -29,6 +29,13 @@
|
|||||||
<!-- @@@auto:session-history -->
|
<!-- @@@auto:session-history -->
|
||||||
| # | Date | Title | Commits | Branch |
|
| # | Date | Title | Commits | Branch |
|
||||||
|---|------|-------|---------|--------|
|
|---|------|-------|---------|--------|
|
||||||
|
| 37 | 2026-08-18 | Complete rounded native junction verification | `e41bfd1`, `f7e71cf` | `feature/native-road-compiler` |
|
||||||
|
| 36 | 2026-08-17 | Complete native road marking semantics | `9bb97d4` | `feature/native-road-compiler` |
|
||||||
|
| 35 | 2026-08-17 | Complete native lane separator styles | `bc04517` | `feature/native-road-compiler` |
|
||||||
|
| 34 | 2026-08-17 | Add center line style overrides | `47efb78` | `feature/native-road-compiler` |
|
||||||
|
| 33 | 2026-08-17 | Add native road center lines | `fb863da` | `feature/native-road-compiler` |
|
||||||
|
| 32 | 2026-08-17 | Native road control markings | `4c4f453` | `feature/native-road-compiler` |
|
||||||
|
| 31 | 2026-08-14 | Native road lane markings | `1b9829d` | `feature/native-road-compiler` |
|
||||||
| 30 | 2026-08-12 | Add vehicle incident preview cards | `761a526` | `main` |
|
| 30 | 2026-08-12 | Add vehicle incident preview cards | `761a526` | `main` |
|
||||||
| 29 | 2026-08-12 | Publish reusable area asset packages | `f385009`, `c925890`, `db0fba5`, `f2b8d79`, `0102ffb` | `main` |
|
| 29 | 2026-08-12 | Publish reusable area asset packages | `f385009`, `c925890`, `db0fba5`, `f2b8d79`, `0102ffb` | `main` |
|
||||||
| 28 | 2026-08-11 | 默认压缩交付 | `0790cbd` | `main` |
|
| 28 | 2026-08-11 | 默认压缩交付 | `0790cbd` | `main` |
|
||||||
|
|||||||
@@ -640,3 +640,164 @@ Added click-to-open vehicle information cards with normal, breakdown, and accide
|
|||||||
### Status
|
### Status
|
||||||
|
|
||||||
[OK] **Completed**
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 31: Native road lane markings
|
||||||
|
|
||||||
|
**Date**: 2026-08-14
|
||||||
|
**Task**: Native road lane markings
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Implemented native lane separators, repeated road direction arrows, explicit junction turn arrows, Workbench inspection/toggles, and Blender/Cesium adapter support for Nantaizi; validated native compile, checks, tests, and non-package visual build.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `1b9829d` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 32: Native road control markings
|
||||||
|
|
||||||
|
**Date**: 2026-08-17
|
||||||
|
**Task**: Native road control markings
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Added native-source crosswalk and stop-line layers with workbench inspection, Blender/Cesium delivery, and control-marking arrow avoidance.
|
||||||
|
|
||||||
|
### Main Changes
|
||||||
|
|
||||||
|
- Compiled explicit marked OSM crossings into source-traceable native GeoJSON.
|
||||||
|
- Added Chinese workbench control-layer toggle, selection evidence, and summary counts.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `4c4f453` | (see git log) |
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
|
||||||
|
- [OK] Passed native-road, road-workbench, turn-lane-arrows, build-stages, native compile/check, and Blender/Cesium/preview build.
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
### Next Steps
|
||||||
|
|
||||||
|
- Continue native road compiler workbench with the next user-approved priority.
|
||||||
|
|
||||||
|
|
||||||
|
## Session 33: Add native road center lines
|
||||||
|
|
||||||
|
**Date**: 2026-08-17
|
||||||
|
**Task**: Add native road center lines
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Implemented Nantaizi native-road center_lines output, workbench selection/toggle, Blender adapter, control-marking avoidance, and cross-layer verification.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `fb863da` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 34: Add center line style overrides
|
||||||
|
|
||||||
|
**Date**: 2026-08-17
|
||||||
|
**Task**: Add center line style overrides
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Added persistent native road centre-line colour and pattern overrides, automatic Workbench staging, continuous solid-line rendering, and Blender white material support.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `47efb78` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 35: Complete native lane separator styles
|
||||||
|
|
||||||
|
**Date**: 2026-08-17
|
||||||
|
**Task**: Complete native lane separator styles
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Completed per lane-pair separator colour/pattern overrides, Workbench staging, Blender yellow material routing, and centre-line control clearance.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `bc04517` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 36: Complete native road marking semantics
|
||||||
|
|
||||||
|
**Date**: 2026-08-17
|
||||||
|
**Task**: Complete native road marking semantics
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Added explicit double-yellow centre lines and per-side edge-line overrides; made all three marking classes selectable in the Chinese Road Workbench; synchronized Blender adapter coverage and verified Nantaizi native compile, quality gate, Blender/Cesium/preview manifests, and automated tests.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `9bb97d4` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 37: Complete rounded native junction verification
|
||||||
|
|
||||||
|
**Date**: 2026-08-18
|
||||||
|
**Task**: Complete rounded native junction verification
|
||||||
|
**Branch**: `feature/native-road-compiler`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Recorded user-confirmed native Blender/Cesium/preview verification for rounded native junctions, checked off all acceptance criteria, and archived the completed 08-17-native-rounded-junctions task.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `e41bfd1` | (see git log) |
|
||||||
|
| `f7e71cf` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
@@ -96,6 +96,37 @@ npm run preflight:area -- --config config/areas/nantaizi-lake-innovation-valley.
|
|||||||
预检有 error 时退出非零且不会更新记录;通过后写 `preflight.manifest.json`,保留本次
|
预检有 error 时退出非零且不会更新记录;通过后写 `preflight.manifest.json`,保留本次
|
||||||
验证的 config / OSM 文件摘要和检查结果。
|
验证的 config / OSM 文件摘要和检查结果。
|
||||||
|
|
||||||
|
## Native Road Workbench
|
||||||
|
|
||||||
|
`road:compile` 是独立于 osm2streets 的实验性道路编译器入口。它从 OSM 生成可追溯的
|
||||||
|
道路模型、基础道路面、诊断与对比摘要,写入 `outputs/<area-id>/native-road/`,不会覆盖
|
||||||
|
`osm2streets_web_out/` 或影响现有 Blender/Cesium 构建:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run road:compile -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
npm run road:check -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
```
|
||||||
|
|
||||||
|
`road:check` 验证已发布 connector 与语义行驶动作的一致性,并在诊断包含 error、图层缺失或
|
||||||
|
动作/几何对应关系不一致时以非零退出。warning 保留给工作台审查,不会阻止产物打开。
|
||||||
|
|
||||||
|
启动本地浏览器工作台:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run road:workbench -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
```
|
||||||
|
|
||||||
|
工作台默认先编译,并在 `http://127.0.0.1:8787/` 启动基于 OpenLayers 的 GIS 工作台,展示
|
||||||
|
OSM 道路、原生结果、车道、行驶动作、诊断和每个值的来源。可编辑道路宽度、车道数、两侧
|
||||||
|
人行道,以及候选路口端点连接。保存写入
|
||||||
|
`outputs/<area-id>/native-road-overrides.json`;此文件是版本化的可审查输入,下一次编译和
|
||||||
|
启动工作台时会自动加载。编辑不会直接修改最终 polygon。
|
||||||
|
|
||||||
|
道路按行驶方向显示:点击道路面、中心线、车道或转向路径后,蓝色三角形标记当前方向在 OSM
|
||||||
|
原始中心线上的方向;右侧“路口连接”只列出该方向到达终点路口后可驶入的目标道路,并标记为
|
||||||
|
左转、直行、右转或掉头。车道按当前方向从左向右编号。内部断头诊断中的近邻候选不会自动连接,
|
||||||
|
必须由用户显式暂存、保存并重新编译。
|
||||||
|
|
||||||
诊断会输出 OSM bounds、building way / multipolygon relation、显式高度、植被数量、
|
诊断会输出 OSM bounds、building way / multipolygon relation、显式高度、植被数量、
|
||||||
现有产物状态,以及 GLB 的 size / nodes / meshes / materials / images / extensions。
|
现有产物状态,以及 GLB 的 size / nodes / meshes / materials / images / extensions。
|
||||||
缺少已期望的基线产物、异常 building relation、GLB 超过保守预算等会进入 `Warnings`。
|
缺少已期望的基线产物、异常 building relation、GLB 超过保守预算等会进入 `Warnings`。
|
||||||
|
|||||||
@@ -657,6 +657,8 @@ def export(args):
|
|||||||
raise RuntimeError("Dynamic traffic signal collection is empty")
|
raise RuntimeError("Dynamic traffic signal collection is empty")
|
||||||
export_glb(args["dynamic_glb"], dynamic_meshes)
|
export_glb(args["dynamic_glb"], dynamic_meshes)
|
||||||
for group, key in ((0, "countdown_0_glb"), (1, "countdown_1_glb")):
|
for group, key in ((0, "countdown_0_glb"), (1, "countdown_1_glb")):
|
||||||
|
if not args.get(key):
|
||||||
|
continue
|
||||||
if not countdown_meshes[group]:
|
if not countdown_meshes[group]:
|
||||||
raise RuntimeError("Traffic countdown collection %d is empty" % group)
|
raise RuntimeError("Traffic countdown collection %d is empty" % group)
|
||||||
export_glb(args[key], countdown_meshes[group])
|
export_glb(args[key], countdown_meshes[group])
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ TREE_STYLES = frozenset(("natural", "procedural")) | frozenset(_tree.MODEL_STYLE
|
|||||||
|
|
||||||
|
|
||||||
def cli_args():
|
def cli_args():
|
||||||
values = {"osm": None, "geojson": None, "output": None, "render": None,
|
values = {"osm": None, "geojson": None, "native_road": None, "output": None, "render": None,
|
||||||
"office_overrides": "", "tree_style": "natural"}
|
"office_overrides": "", "tree_style": "natural"}
|
||||||
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
||||||
i = 0
|
i = 0
|
||||||
@@ -663,6 +663,10 @@ def build(args):
|
|||||||
layer["id"]: material_from_spec(spec)
|
layer["id"]: material_from_spec(spec)
|
||||||
for layer, spec in zip(catalog.ROAD_LAYERS, catalog.road_material_specs())
|
for layer, spec in zip(catalog.ROAD_LAYERS, catalog.road_material_specs())
|
||||||
}
|
}
|
||||||
|
road_mats["native_center_line_white"] = material_from_spec(
|
||||||
|
catalog.MATERIALS["native_center_line_white"])
|
||||||
|
road_mats["native_lane_separator_yellow"] = material_from_spec(
|
||||||
|
catalog.MATERIALS["native_lane_separator_yellow"])
|
||||||
traffic_signal_mats = {
|
traffic_signal_mats = {
|
||||||
"metal": material_from_spec(catalog.MATERIALS["traffic_signal_metal"]),
|
"metal": material_from_spec(catalog.MATERIALS["traffic_signal_metal"]),
|
||||||
"housing": material_from_spec(catalog.MATERIALS["traffic_signal_housing"]),
|
"housing": material_from_spec(catalog.MATERIALS["traffic_signal_housing"]),
|
||||||
@@ -789,8 +793,36 @@ def build(args):
|
|||||||
_features.dispatch_ways(ways, projector, way_handlers)
|
_features.dispatch_ways(ways, projector, way_handlers)
|
||||||
|
|
||||||
geojson_dir = args.get("geojson")
|
geojson_dir = args.get("geojson")
|
||||||
|
native_road_dir = args.get("native_road")
|
||||||
road_counts = {}
|
road_counts = {}
|
||||||
if geojson_dir and os.path.isdir(geojson_dir):
|
if native_road_dir:
|
||||||
|
if not os.path.isdir(native_road_dir):
|
||||||
|
raise RuntimeError("--native-road directory does not exist: " + native_road_dir)
|
||||||
|
material_layers = {layer["id"]: layer for layer in catalog.ROAD_LAYERS}
|
||||||
|
for source in catalog.NATIVE_ROAD_LAYERS:
|
||||||
|
target = source["material_layer"]
|
||||||
|
layer = material_layers[target]
|
||||||
|
source_path = os.path.join(native_road_dir, "layers", source["source"] + ".geojson")
|
||||||
|
if not os.path.isfile(source_path):
|
||||||
|
raise RuntimeError("Native road layer is missing: " + source_path)
|
||||||
|
if source["source"] == "center_lines":
|
||||||
|
count = _roads.assemble_geojson_layer(
|
||||||
|
source_path, source["source"], projector, roads_c,
|
||||||
|
road_mats[target], layer["z"],
|
||||||
|
lambda props: props.get("color") != "white")
|
||||||
|
count += _roads.assemble_geojson_layer(
|
||||||
|
source_path, source["source"] + "_white", projector, roads_c,
|
||||||
|
road_mats["native_center_line_white"], layer["z"],
|
||||||
|
lambda props: props.get("color") == "white")
|
||||||
|
elif source["source"] == "lane_separators":
|
||||||
|
count = _roads.assemble_geojson_layer(source_path, source["source"], projector, roads_c, road_mats[target], layer["z"], lambda props: props.get("color") != "yellow")
|
||||||
|
count += _roads.assemble_geojson_layer(source_path, source["source"] + "_yellow", projector, roads_c, road_mats["native_lane_separator_yellow"], layer["z"], lambda props: props.get("color") == "yellow")
|
||||||
|
else:
|
||||||
|
count = _roads.assemble_geojson_layer(
|
||||||
|
source_path, source["source"], projector, roads_c,
|
||||||
|
road_mats[target], layer["z"])
|
||||||
|
road_counts[source["source"]] = count
|
||||||
|
elif geojson_dir and os.path.isdir(geojson_dir):
|
||||||
for problem in catalog.check_layers(geojson_dir):
|
for problem in catalog.check_layers(geojson_dir):
|
||||||
print("Layer catalog warning:", problem)
|
print("Layer catalog warning:", problem)
|
||||||
for layer in catalog.ROAD_LAYERS:
|
for layer in catalog.ROAD_LAYERS:
|
||||||
@@ -799,11 +831,11 @@ def build(args):
|
|||||||
os.path.join(geojson_dir, layer_id + ".geojson"), layer_id,
|
os.path.join(geojson_dir, layer_id + ".geojson"), layer_id,
|
||||||
projector, roads_c, road_mats[layer_id], layer["z"])
|
projector, roads_c, road_mats[layer_id], layer["z"])
|
||||||
|
|
||||||
if road_counts.get("road_surface", 0) == 0:
|
if not native_road_dir and road_counts.get("road_surface", 0) == 0:
|
||||||
_roads.assemble_osm_fallback(
|
_roads.assemble_osm_fallback(
|
||||||
ways, projector, roads_c, road_mats["road_surface"])
|
ways, projector, roads_c, road_mats["road_surface"])
|
||||||
|
|
||||||
traffic_signal_path = os.path.join(geojson_dir or "", "traffic_signals.json")
|
traffic_signal_path = args.get("traffic_signals") or os.path.join(geojson_dir or "", "traffic_signals.json")
|
||||||
dynamic_signal_objects = 0
|
dynamic_signal_objects = 0
|
||||||
if os.path.exists(traffic_signal_path):
|
if os.path.exists(traffic_signal_path):
|
||||||
try:
|
try:
|
||||||
@@ -910,6 +942,7 @@ def build(args):
|
|||||||
scene.render.filepath = args["render"]
|
scene.render.filepath = args["render"]
|
||||||
scene["source_osm"] = args["osm"]
|
scene["source_osm"] = args["osm"]
|
||||||
scene["source_geojson"] = geojson_dir or ""
|
scene["source_geojson"] = geojson_dir or ""
|
||||||
|
scene["source_native_road"] = native_road_dir or ""
|
||||||
scene["osm_bounds"] = json.dumps(bounds, ensure_ascii=True)
|
scene["osm_bounds"] = json.dumps(bounds, ensure_ascii=True)
|
||||||
scene["building_count"] = counts["building_count"]
|
scene["building_count"] = counts["building_count"]
|
||||||
scene["industrial_building_count"] = counts["industrial_count"]
|
scene["industrial_building_count"] = counts["industrial_count"]
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ ROAD_LAYERS = [
|
|||||||
|
|
||||||
SCENE_STYLE_FILE = "osm2streets_scene_style.json"
|
SCENE_STYLE_FILE = "osm2streets_scene_style.json"
|
||||||
|
|
||||||
|
# Native-road output intentionally maps into existing scene material layers.
|
||||||
|
# It is a provider adapter, not a second scene-layer registry.
|
||||||
|
NATIVE_ROAD_LAYERS = (
|
||||||
|
{"source": "road_surface", "material_layer": "road_surface"},
|
||||||
|
{"source": "edge_lines", "material_layer": "lane_separators"},
|
||||||
|
{"source": "intersection_surface", "material_layer": "intersection_surface"},
|
||||||
|
{"source": "sidewalk_surface", "material_layer": "sidewalks"},
|
||||||
|
{"source": "lane_separators", "material_layer": "lane_separators"},
|
||||||
|
{"source": "center_lines", "material_layer": "center_lines"},
|
||||||
|
{"source": "direction_arrows", "material_layer": "lane_arrows_webscale"},
|
||||||
|
{"source": "turn_arrows", "material_layer": "lane_arrows_webscale"},
|
||||||
|
{"source": "crosswalks", "material_layer": "crosswalks"},
|
||||||
|
{"source": "vehicle_stop_lines", "material_layer": "vehicle_stop_lines"},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Material specs. `kind` selects the builder:
|
# Material specs. `kind` selects the builder:
|
||||||
# solid — flat base colour
|
# solid — flat base colour
|
||||||
@@ -187,6 +202,12 @@ MATERIALS = {
|
|||||||
"color": (0.04, 0.82, 0.22), "roughness": 0.25,
|
"color": (0.04, 0.82, 0.22), "roughness": 0.25,
|
||||||
"cesium": {"base_color": (0.04, 0.82, 0.22),
|
"cesium": {"base_color": (0.04, 0.82, 0.22),
|
||||||
"emission": ((0.04, 0.82, 0.22), 1.0)}},
|
"emission": ((0.04, 0.82, 0.22), 1.0)}},
|
||||||
|
"native_center_line_white": {"kind": "solid", "name": "Native Center Line White",
|
||||||
|
"color": (0.95, 0.94, 0.82), "roughness": 0.52,
|
||||||
|
"cesium": {"base_color": (0.95, 0.94, 0.82)}},
|
||||||
|
"native_lane_separator_yellow": {"kind": "solid", "name": "Native Lane Separator Yellow",
|
||||||
|
"color": (0.94, 0.58, 0.06), "roughness": 0.52,
|
||||||
|
"cesium": {"base_color": (0.94, 0.58, 0.06)}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ from osmassets.geom import clip_polygon, feature_in_bounds, geometry_rings
|
|||||||
from osmassets.mesh import MeshBatch, add_polyline
|
from osmassets.mesh import MeshBatch, add_polyline
|
||||||
|
|
||||||
|
|
||||||
def assemble_geojson_layer(path, layer_id, projector, collection, material, z):
|
def assemble_geojson_layer(path, layer_id, projector, collection, material, z,
|
||||||
|
property_filter=None):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return 0
|
return 0
|
||||||
with open(path, "r", encoding="utf-8") as handle:
|
with open(path, "r", encoding="utf-8") as handle:
|
||||||
@@ -18,6 +19,8 @@ def assemble_geojson_layer(path, layer_id, projector, collection, material, z):
|
|||||||
xmax, ymax = projector.xy((b["max_lon"], b["max_lat"]))
|
xmax, ymax = projector.xy((b["max_lon"], b["max_lat"]))
|
||||||
count = 0
|
count = 0
|
||||||
for feature in data.get("features", []):
|
for feature in data.get("features", []):
|
||||||
|
if property_filter and not property_filter(feature.get("properties", {})):
|
||||||
|
continue
|
||||||
if not feature_in_bounds(feature, projector):
|
if not feature_in_bounds(feature, projector):
|
||||||
continue
|
continue
|
||||||
for ring in geometry_rings(feature.get("geometry")):
|
for ring in geometry_rings(feature.get("geometry")):
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from osmassets.geom import (
|
|||||||
sample_tree_row,
|
sample_tree_row,
|
||||||
signed_polygon_area,
|
signed_polygon_area,
|
||||||
)
|
)
|
||||||
from osmassets.catalog import ROAD_LAYERS
|
from osmassets.catalog import NATIVE_ROAD_LAYERS, ROAD_LAYERS
|
||||||
from osmassets.osm import Projector, parse_height, parse_osm, tags
|
from osmassets.osm import Projector, parse_height, parse_osm, tags
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +46,31 @@ class RoadLayerCatalogTest(unittest.TestCase):
|
|||||||
self.assertNotEqual(layers["road_surface"]["z"],
|
self.assertNotEqual(layers["road_surface"]["z"],
|
||||||
layers["intersection_surface"]["z"])
|
layers["intersection_surface"]["z"])
|
||||||
|
|
||||||
|
def test_native_provider_maps_to_existing_material_layers(self):
|
||||||
|
layers = {layer["id"] for layer in ROAD_LAYERS}
|
||||||
|
self.assertEqual(
|
||||||
|
[(entry["source"], entry["material_layer"])
|
||||||
|
for entry in NATIVE_ROAD_LAYERS],
|
||||||
|
[("road_surface", "road_surface"),
|
||||||
|
("edge_lines", "lane_separators"),
|
||||||
|
("intersection_surface", "intersection_surface"),
|
||||||
|
("sidewalk_surface", "sidewalks"),
|
||||||
|
("lane_separators", "lane_separators"),
|
||||||
|
("center_lines", "center_lines"),
|
||||||
|
("direction_arrows", "lane_arrows_webscale"),
|
||||||
|
("turn_arrows", "lane_arrows_webscale"),
|
||||||
|
("crosswalks", "crosswalks"),
|
||||||
|
("vehicle_stop_lines", "vehicle_stop_lines")])
|
||||||
|
self.assertTrue(all(entry["material_layer"] in layers
|
||||||
|
for entry in NATIVE_ROAD_LAYERS))
|
||||||
|
|
||||||
|
def test_cesium_export_keeps_signal_assets_optional(self):
|
||||||
|
exporter = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
"..", "export_cesium.py")
|
||||||
|
with open(exporter, encoding="utf-8") as handle:
|
||||||
|
source = handle.read()
|
||||||
|
self.assertIn('if not args.get(key):\n continue', source)
|
||||||
|
|
||||||
|
|
||||||
class GeometryRingsTest(unittest.TestCase):
|
class GeometryRingsTest(unittest.TestCase):
|
||||||
def test_polygon_keeps_only_the_exterior_ring(self):
|
def test_polygon_keeps_only_the_exterior_ring(self):
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
"turnLaneArrows": {
|
"turnLaneArrows": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
"nativeRoad": {
|
||||||
|
"edgeLines": false
|
||||||
|
},
|
||||||
"osm2streets": {
|
"osm2streets": {
|
||||||
"debug_each_step": false,
|
"debug_each_step": false,
|
||||||
"dual_carriageway_experiment": false,
|
"dual_carriageway_experiment": false,
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
"turnLaneArrows": {
|
"turnLaneArrows": {
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
|
"nativeRoad": {
|
||||||
|
"edgeLines": false
|
||||||
|
},
|
||||||
"osm2streets": {
|
"osm2streets": {
|
||||||
"debug_each_step": false,
|
"debug_each_step": false,
|
||||||
"dual_carriageway_experiment": false,
|
"dual_carriageway_experiment": false,
|
||||||
@@ -33,7 +36,8 @@
|
|||||||
},
|
},
|
||||||
"blender": {
|
"blender": {
|
||||||
"treeStyle": "natural",
|
"treeStyle": "natural",
|
||||||
"officeOverrides": ""
|
"officeOverrides": "",
|
||||||
|
"roadProvider": "osm2streets"
|
||||||
},
|
},
|
||||||
"compress": {
|
"compress": {
|
||||||
"textureSize": 768,
|
"textureSize": 768,
|
||||||
|
|||||||
Generated
+206
@@ -9,6 +9,7 @@
|
|||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@inquirer/prompts": "^8.5.2",
|
"@inquirer/prompts": "^8.5.2",
|
||||||
|
"ol": "^10.10.0",
|
||||||
"osm2streets-js-node": "0.1.4"
|
"osm2streets-js-node": "0.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -340,6 +341,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@petamoriken/float16": {
|
||||||
|
"version": "3.9.3",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@petamoriken/float16/-/float16-3.9.3.tgz",
|
||||||
|
"integrity": "sha512-8awtpHXCx/bNpFt4mt2xdkgtgVvKqty8VbjHI/WWWQuEw+KLzFot3f4+LkQY9YmOtq7A5GdOnqoIC8Pdygjk2g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@types/rbush": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@types/rbush/-/rbush-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-+N+2H39P8X+Hy1I5mC6awlTX54k3FhiUmvt7HWzGJZvF+syUAAxP/stwppS8JE84YHqFgRMv6fCy31202CMFxQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@zarrita/storage": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@zarrita/storage/-/storage-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-855ZXqtnds7spnT8vNvD+MXa3QExP1m2GqShe8yt7uZXHnQLgJHgkpVwFjE1B0KDDRO0ki09hmk6OboTaIfPsQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"reference-spec-reader": "^0.2.0",
|
||||||
|
"unzipit": "2.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/chardet": {
|
"node_modules/chardet": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "http://172.16.1.86:4873/chardet/-/chardet-2.2.0.tgz",
|
"resolved": "http://172.16.1.86:4873/chardet/-/chardet-2.2.0.tgz",
|
||||||
@@ -355,6 +378,12 @@
|
|||||||
"node": ">= 12"
|
"node": ">= 12"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/earcut": {
|
||||||
|
"version": "3.2.3",
|
||||||
|
"resolved": "http://172.16.1.86:4873/earcut/-/earcut-3.2.3.tgz",
|
||||||
|
"integrity": "sha512-vnS4AVwp1KHAF13i1vp1/2D5evWy3k5u/iW/B81QVsUZtV8cv2tU0b2VNFlqvh4kYwrFMDdjPCfAmfyJW9y14Q==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
"node_modules/fast-string-truncated-width": {
|
"node_modules/fast-string-truncated-width": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "http://172.16.1.86:4873/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz",
|
"resolved": "http://172.16.1.86:4873/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz",
|
||||||
@@ -379,6 +408,31 @@
|
|||||||
"fast-string-width": "^3.0.2"
|
"fast-string-width": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/fflate": {
|
||||||
|
"version": "0.8.3",
|
||||||
|
"resolved": "http://172.16.1.86:4873/fflate/-/fflate-0.8.3.tgz",
|
||||||
|
"integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/geotiff": {
|
||||||
|
"version": "3.1.0-beta.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/geotiff/-/geotiff-3.1.0-beta.0.tgz",
|
||||||
|
"integrity": "sha512-wbVwOaQYuN+ywly5NoMXn37nHslwkQg5EFHqMeUTtjDACrSag0EEVlFsc+2DK3Pzmmp6XzJW2RTZOamPsBM6ng==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@petamoriken/float16": "^3.9.3",
|
||||||
|
"lerc": "^3.0.0",
|
||||||
|
"pako": "^2.0.4",
|
||||||
|
"parse-headers": "^2.0.2",
|
||||||
|
"quick-lru": "^6.1.1",
|
||||||
|
"web-worker": "^1.5.0",
|
||||||
|
"xml-utils": "^1.10.2",
|
||||||
|
"zstddec": "^0.2.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.19"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/iconv-lite": {
|
"node_modules/iconv-lite": {
|
||||||
"version": "0.7.3",
|
"version": "0.7.3",
|
||||||
"resolved": "http://172.16.1.86:4873/iconv-lite/-/iconv-lite-0.7.3.tgz",
|
"resolved": "http://172.16.1.86:4873/iconv-lite/-/iconv-lite-0.7.3.tgz",
|
||||||
@@ -395,6 +449,12 @@
|
|||||||
"url": "https://opencollective.com/express"
|
"url": "https://opencollective.com/express"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/lerc": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/lerc/-/lerc-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-Rm4J/WaHhRa93nCN2mwWDZFoRVF18G1f47C+kvQWyHGEZxFpTUi73p7lMVSAndyxGt6lJ2/CFbOcf9ra5p8aww==",
|
||||||
|
"license": "Apache-2.0"
|
||||||
|
},
|
||||||
"node_modules/mute-stream": {
|
"node_modules/mute-stream": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "http://172.16.1.86:4873/mute-stream/-/mute-stream-3.0.0.tgz",
|
"resolved": "http://172.16.1.86:4873/mute-stream/-/mute-stream-3.0.0.tgz",
|
||||||
@@ -404,12 +464,121 @@
|
|||||||
"node": "^20.17.0 || >=22.9.0"
|
"node": "^20.17.0 || >=22.9.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/numcodecs": {
|
||||||
|
"version": "0.3.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/numcodecs/-/numcodecs-0.3.2.tgz",
|
||||||
|
"integrity": "sha512-6YSPnmZgg0P87jnNhi3s+FVLOcIn3y+1CTIgUulA3IdASzK9fJM87sUFkpyA+be9GibGRaST2wCgkD+6U+fWKw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"fflate": "^0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ol": {
|
||||||
|
"version": "10.10.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/ol/-/ol-10.10.0.tgz",
|
||||||
|
"integrity": "sha512-tLPKn6zl+6uWdPufYlqG/lQzuVUTVmfwahQqVr5+wZNyZecyAtIhMTyOtKpu7ooNDLY2sEjKZNXw9HL+sOjC1A==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/rbush": "4.0.0",
|
||||||
|
"earcut": "^3.0.0",
|
||||||
|
"geotiff": "^3.1.0-beta.0",
|
||||||
|
"pbf": "5.1.2",
|
||||||
|
"rbush": "^4.0.0",
|
||||||
|
"zarrita": "^0.7.1"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/openlayers"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/osm2streets-js-node": {
|
"node_modules/osm2streets-js-node": {
|
||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/osm2streets-js-node/-/osm2streets-js-node-0.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/osm2streets-js-node/-/osm2streets-js-node-0.1.4.tgz",
|
||||||
"integrity": "sha512-JjS6qJJjrrlEKEZxqV4s/N4qU0YfvdMUasdvfoyYCmZxEpNKAYjpuZeWJWeLEcGOqhu+YuV3YDIk9jgvMU0kKQ==",
|
"integrity": "sha512-JjS6qJJjrrlEKEZxqV4s/N4qU0YfvdMUasdvfoyYCmZxEpNKAYjpuZeWJWeLEcGOqhu+YuV3YDIk9jgvMU0kKQ==",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
|
"node_modules/pako": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/pako/-/pako-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/puzrin"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/nodeca"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "(MIT AND Zlib)"
|
||||||
|
},
|
||||||
|
"node_modules/parse-headers": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "http://172.16.1.86:4873/parse-headers/-/parse-headers-2.0.6.tgz",
|
||||||
|
"integrity": "sha512-Tz11t3uKztEW5FEVZnj1ox8GKblWn+PvHY9TmJV5Mll2uHEwRdR/5Li1OlXoECjLYkApdhWy44ocONwXLiKO5A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/pbf": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/pbf/-/pbf-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-mnvGdvOrIvJOBGUEdGkrVXjN8E/VkIJCkf2eS1DH2yv82ORUlLttmDt0rWY38yYZmVwciZwBUvHM20qxBZf40w==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"resolve-protobuf-schema": "^2.1.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"pbf": "bin/pbf"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/protocol-buffers-schema": {
|
||||||
|
"version": "3.6.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/protocol-buffers-schema/-/protocol-buffers-schema-3.6.1.tgz",
|
||||||
|
"integrity": "sha512-VG2K63Igkiv9p76tk1lilczEK1cT+kCjKtkdhw1dQZV3k3IXJbd3o6Ho8b9zJZaHSnT2hKe4I+ObmX9w6m5SmQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/quick-lru": {
|
||||||
|
"version": "6.1.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/quick-lru/-/quick-lru-6.1.2.tgz",
|
||||||
|
"integrity": "sha512-AAFUA5O1d83pIHEhJwWCq/RQcRukCkn/NSm2QsTEMle5f2hP0ChI2+3Xb051PZCkLryI/Ir1MVKviT2FIloaTQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/quickselect": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/quickselect/-/quickselect-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-XdjUArbK4Bm5fLLvlm5KpTFOiOThgfWWI4axAZDWg4E/0mKdZyI9tNEfds27qCi1ze/vwTR16kvmmGhRra3c2g==",
|
||||||
|
"license": "ISC"
|
||||||
|
},
|
||||||
|
"node_modules/rbush": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/rbush/-/rbush-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-IP0UpfeWQujYC8Jg162rMNc01Rf0gWMMAb2Uxus/Q0qOFw4lCcq6ZnQEZwUoJqWyUGJ9th7JjwI4yIWo+uvoAQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"quickselect": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/reference-spec-reader": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/reference-spec-reader/-/reference-spec-reader-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-q0mfCi5yZSSHXpCyxjgQeaORq3tvDsxDyzaadA/5+AbAUwRyRuuTh0aRQuE/vAOt/qzzxidJ5iDeu1cLHaNBlQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/resolve-protobuf-schema": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"protocol-buffers-schema": "^3.3.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/safer-buffer": {
|
"node_modules/safer-buffer": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "http://172.16.1.86:4873/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "http://172.16.1.86:4873/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
@@ -427,6 +596,43 @@
|
|||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/isaacs"
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/unzipit": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/unzipit/-/unzipit-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-DVeVIWUZCAQPNzm5sB0hpsG1GygTTdBnzNtYYEpInkttx5evkyqRgZi6rTczoySqp8hO5jHVKzrH0f23X8FZLg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/web-worker": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/web-worker/-/web-worker-1.5.0.tgz",
|
||||||
|
"integrity": "sha512-RiMReJrTAiA+mBjGONMnjVDP2u3p9R1vkcGz6gDIrOMT3oGuYwX2WRMYI9ipkphSuE5XKEhydbhNEJh4NY9mlw==",
|
||||||
|
"license": "Apache-2.0"
|
||||||
|
},
|
||||||
|
"node_modules/xml-utils": {
|
||||||
|
"version": "1.10.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/xml-utils/-/xml-utils-1.10.2.tgz",
|
||||||
|
"integrity": "sha512-RqM+2o1RYs6T8+3DzDSoTRAUfrvaejbVHcp3+thnAtDKo8LskR+HomLajEy5UjTz24rpka7AxVBRR3g2wTUkJA==",
|
||||||
|
"license": "CC0-1.0"
|
||||||
|
},
|
||||||
|
"node_modules/zarrita": {
|
||||||
|
"version": "0.7.4",
|
||||||
|
"resolved": "http://172.16.1.86:4873/zarrita/-/zarrita-0.7.4.tgz",
|
||||||
|
"integrity": "sha512-NChufj86SceFj45z4CYjndmI98dphaG7hU8Wj0UGpMyT21o0V3HTY6zo87aSobYWts1tNFivSXzH2AR1AkaWjA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@zarrita/storage": "^0.2.0",
|
||||||
|
"numcodecs": "^0.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zstddec": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/zstddec/-/zstddec-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-oyPnDa1X5c13+Y7mA/FDMNJrn4S8UNBe0KCqtDmor40Re7ALrPN6npFwyYVRRh+PqozZQdeg23QtbcamZnG5rA==",
|
||||||
|
"license": "MIT AND BSD-3-Clause"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,11 @@
|
|||||||
"compress:glb": "node scripts/compress-glb.js",
|
"compress:glb": "node scripts/compress-glb.js",
|
||||||
"diagnose:area": "node scripts/diagnose-area.js",
|
"diagnose:area": "node scripts/diagnose-area.js",
|
||||||
"preflight:area": "node scripts/preflight-area.js",
|
"preflight:area": "node scripts/preflight-area.js",
|
||||||
|
"road:compile": "node scripts/compile-native-roads.js",
|
||||||
|
"road:check": "node scripts/check-native-roads.js",
|
||||||
|
"road:workbench": "node scripts/road-workbench.js",
|
||||||
|
"test:road-workbench": "node scripts/test-road-workbench.js",
|
||||||
|
"test:native-road": "node scripts/test-native-road.js",
|
||||||
"test:preflight": "node scripts/test-area-preflight.js",
|
"test:preflight": "node scripts/test-area-preflight.js",
|
||||||
"test:build-stages": "node scripts/test-build-stages.js",
|
"test:build-stages": "node scripts/test-build-stages.js",
|
||||||
"test:budgets": "node scripts/test-asset-budgets.js",
|
"test:budgets": "node scripts/test-asset-budgets.js",
|
||||||
@@ -24,6 +29,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@inquirer/prompts": "^8.5.2",
|
"@inquirer/prompts": "^8.5.2",
|
||||||
|
"ol": "^10.10.0",
|
||||||
"osm2streets-js-node": "0.1.4"
|
"osm2streets-js-node": "0.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+86
-16
@@ -4,6 +4,7 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { spawnSync } = require("child_process");
|
const { spawnSync } = require("child_process");
|
||||||
const { readAreaConfig } = require("./lib/area-config");
|
const { readAreaConfig } = require("./lib/area-config");
|
||||||
|
const { compileArea: compileNativeRoads } = require("./compile-native-roads");
|
||||||
const { resolveStages } = require("./lib/build-stages");
|
const { resolveStages } = require("./lib/build-stages");
|
||||||
const { validateManifest, addIntegrity } = require("./lib/package-contract");
|
const { validateManifest, addIntegrity } = require("./lib/package-contract");
|
||||||
const { blenderExecutable: resolveBlenderExecutable } = require("./lib/tool-paths");
|
const { blenderExecutable: resolveBlenderExecutable } = require("./lib/tool-paths");
|
||||||
@@ -42,6 +43,10 @@ const requestedStages = args.stages
|
|||||||
? splitList(args.stages)
|
? splitList(args.stages)
|
||||||
: null;
|
: null;
|
||||||
const stages = resolveStages(area.stages, requestedStages);
|
const stages = resolveStages(area.stages, requestedStages);
|
||||||
|
const roadProvider = args.roadProvider || area.blender.roadProvider;
|
||||||
|
if (!new Set(["osm2streets", "native"]).has(roadProvider)) {
|
||||||
|
throw new Error("--road-provider must be \"osm2streets\" or \"native\".");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log(`Area: ${area.id}`);
|
console.log(`Area: ${area.id}`);
|
||||||
@@ -55,10 +60,10 @@ if (stages.reimport) {
|
|||||||
reimportGpkg(area);
|
reimportGpkg(area);
|
||||||
}
|
}
|
||||||
if (stages.blender) {
|
if (stages.blender) {
|
||||||
buildBlenderScene(area);
|
buildBlenderScene(area, roadProvider);
|
||||||
}
|
}
|
||||||
if (stages.cesium) {
|
if (stages.cesium) {
|
||||||
exportCesium(area);
|
exportCesium(area, roadProvider);
|
||||||
}
|
}
|
||||||
if (stages.compress) {
|
if (stages.compress) {
|
||||||
compressCesiumGlb(area);
|
compressCesiumGlb(area);
|
||||||
@@ -208,16 +213,22 @@ function reimportGpkg(area) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildBlenderScene(area) {
|
function buildBlenderScene(area, roadProvider) {
|
||||||
ensureFile(blenderExecutable(area), "Blender executable");
|
ensureFile(blenderExecutable(area), "Blender executable");
|
||||||
ensureFile(path.join(repoRoot, "blender", "generate_scene.py"), "Blender scene generator");
|
ensureFile(path.join(repoRoot, "blender", "generate_scene.py"), "Blender scene generator");
|
||||||
|
if (roadProvider === "osm2streets") {
|
||||||
ensureFile(area.outputs.trafficSignalAssemblies, "Editable traffic signal assemblies");
|
ensureFile(area.outputs.trafficSignalAssemblies, "Editable traffic signal assemblies");
|
||||||
// Blender consumes the editable assembly layer; OSM only initializes it in
|
// Blender consumes the editable assembly layer; OSM only initializes it in
|
||||||
// intermediates, so QGIS edits remain authoritative across later stages.
|
// intermediates, so QGIS edits remain authoritative across later stages.
|
||||||
writeTrafficSignals(area);
|
writeTrafficSignals(area);
|
||||||
ensureFile(area.outputs.trafficSignals, "Traffic signal anchors");
|
ensureFile(area.outputs.trafficSignals, "Traffic signal anchors");
|
||||||
|
}
|
||||||
fs.mkdirSync(path.dirname(area.outputs.blend), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.blend), { recursive: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.render), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.render), { recursive: true });
|
||||||
|
if (roadProvider === "native") {
|
||||||
|
compileNativeRoads(configPath);
|
||||||
|
ensureNativeRoadLayers(area);
|
||||||
|
}
|
||||||
|
|
||||||
const blenderArgs = [
|
const blenderArgs = [
|
||||||
"--background",
|
"--background",
|
||||||
@@ -227,8 +238,6 @@ function buildBlenderScene(area) {
|
|||||||
"--",
|
"--",
|
||||||
"--osm",
|
"--osm",
|
||||||
area.input,
|
area.input,
|
||||||
"--geojson",
|
|
||||||
area.outputs.geojsonDir,
|
|
||||||
"--output",
|
"--output",
|
||||||
area.outputs.blend,
|
area.outputs.blend,
|
||||||
"--render",
|
"--render",
|
||||||
@@ -236,6 +245,12 @@ function buildBlenderScene(area) {
|
|||||||
"--tree-style",
|
"--tree-style",
|
||||||
area.blender.treeStyle,
|
area.blender.treeStyle,
|
||||||
];
|
];
|
||||||
|
if (roadProvider === "native") {
|
||||||
|
blenderArgs.push("--native-road", area.outputs.nativeRoadDir);
|
||||||
|
blenderArgs.push("--traffic-signals", path.join(area.outputs.nativeRoadDir, "traffic-signals.json"));
|
||||||
|
} else {
|
||||||
|
blenderArgs.push("--geojson", area.outputs.geojsonDir);
|
||||||
|
}
|
||||||
if (area.blender.officeOverrides) {
|
if (area.blender.officeOverrides) {
|
||||||
blenderArgs.push("--office-overrides", area.blender.officeOverrides);
|
blenderArgs.push("--office-overrides", area.blender.officeOverrides);
|
||||||
}
|
}
|
||||||
@@ -255,17 +270,20 @@ function buildBlenderScene(area) {
|
|||||||
inputs: {
|
inputs: {
|
||||||
config: fileRecord(configPath),
|
config: fileRecord(configPath),
|
||||||
osm: fileRecord(area.input),
|
osm: fileRecord(area.input),
|
||||||
|
...(roadProvider === "native" ? nativeRoadRecords(area) : sceneGeojsonRecords(area)),
|
||||||
|
...(roadProvider === "osm2streets" ? {
|
||||||
geojsonDir: fileRecord(area.outputs.geojsonDir),
|
geojsonDir: fileRecord(area.outputs.geojsonDir),
|
||||||
...sceneGeojsonRecords(area),
|
|
||||||
trafficSignalAssemblies: fileRecord(area.outputs.trafficSignalAssemblies),
|
trafficSignalAssemblies: fileRecord(area.outputs.trafficSignalAssemblies),
|
||||||
trafficSignals: fileRecord(area.outputs.trafficSignals),
|
trafficSignals: fileRecord(area.outputs.trafficSignals),
|
||||||
|
} : {}),
|
||||||
},
|
},
|
||||||
outputs: {
|
outputs: {
|
||||||
blend: fileRecord(area.outputs.blend),
|
blend: fileRecord(area.outputs.blend),
|
||||||
render: fileRecord(area.outputs.render),
|
render: fileRecord(area.outputs.render),
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
geojson: geojsonFeatureCounts(area),
|
...(roadProvider === "native" ? { nativeRoad: nativeRoadFeatureCounts(area) } : { geojson: geojsonFeatureCounts(area) }),
|
||||||
|
roadProvider,
|
||||||
blendBytes: fileRecord(area.outputs.blend).bytes,
|
blendBytes: fileRecord(area.outputs.blend).bytes,
|
||||||
renderBytes: fileRecord(area.outputs.render).bytes,
|
renderBytes: fileRecord(area.outputs.render).bytes,
|
||||||
},
|
},
|
||||||
@@ -273,23 +291,68 @@ function buildBlenderScene(area) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportCesium(area) {
|
function ensureNativeRoadLayers(area) {
|
||||||
|
ensureFile(path.join(area.outputs.nativeRoadDir, "compiled.json"), "Native road compilation");
|
||||||
|
for (const file of ["road_surface.geojson", "edge_lines.geojson", "intersection_surface.geojson", "sidewalk_surface.geojson", "lane_separators.geojson", "center_lines.geojson", "direction_arrows.geojson", "turn_arrows.geojson", "crosswalks.geojson", "vehicle_stop_lines.geojson"]) {
|
||||||
|
ensureFile(path.join(area.outputs.nativeRoadDir, "layers", file), `Native road layer ${file}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nativeRoadRecords(area) {
|
||||||
|
const root = path.join(area.outputs.nativeRoadDir, "layers");
|
||||||
|
return {
|
||||||
|
nativeRoadCompiled: fileRecord(path.join(area.outputs.nativeRoadDir, "compiled.json")),
|
||||||
|
nativeRoadSurface: fileRecord(path.join(root, "road_surface.geojson")),
|
||||||
|
nativeEdgeLines: fileRecord(path.join(root, "edge_lines.geojson")),
|
||||||
|
nativeIntersectionSurface: fileRecord(path.join(root, "intersection_surface.geojson")),
|
||||||
|
nativeSidewalkSurface: fileRecord(path.join(root, "sidewalk_surface.geojson")),
|
||||||
|
nativeLaneSeparators: fileRecord(path.join(root, "lane_separators.geojson")),
|
||||||
|
nativeCenterLines: fileRecord(path.join(root, "center_lines.geojson")),
|
||||||
|
nativeDirectionArrows: fileRecord(path.join(root, "direction_arrows.geojson")),
|
||||||
|
nativeTurnArrows: fileRecord(path.join(root, "turn_arrows.geojson")),
|
||||||
|
nativeCrosswalks: fileRecord(path.join(root, "crosswalks.geojson")),
|
||||||
|
nativeVehicleStopLines: fileRecord(path.join(root, "vehicle_stop_lines.geojson")),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function nativeRoadFeatureCounts(area) {
|
||||||
|
const root = path.join(area.outputs.nativeRoadDir, "layers");
|
||||||
|
return {
|
||||||
|
roadSurface: featureCount(path.join(root, "road_surface.geojson")),
|
||||||
|
edgeLines: featureCount(path.join(root, "edge_lines.geojson")),
|
||||||
|
intersectionSurface: featureCount(path.join(root, "intersection_surface.geojson")),
|
||||||
|
sidewalkSurface: featureCount(path.join(root, "sidewalk_surface.geojson")),
|
||||||
|
laneSeparators: featureCount(path.join(root, "lane_separators.geojson")),
|
||||||
|
centerLines: featureCount(path.join(root, "center_lines.geojson")),
|
||||||
|
directionArrows: featureCount(path.join(root, "direction_arrows.geojson")),
|
||||||
|
turnArrows: featureCount(path.join(root, "turn_arrows.geojson")),
|
||||||
|
crosswalks: featureCount(path.join(root, "crosswalks.geojson")),
|
||||||
|
vehicleStopLines: featureCount(path.join(root, "vehicle_stop_lines.geojson")),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportCesium(area, roadProvider) {
|
||||||
ensureFile(blenderExecutable(area), "Blender executable");
|
ensureFile(blenderExecutable(area), "Blender executable");
|
||||||
ensureFile(area.outputs.blend, "Blend scene");
|
ensureFile(area.outputs.blend, "Blend scene");
|
||||||
ensureFile(path.join(repoRoot, "blender", "export_cesium.py"), "Cesium exporter");
|
ensureFile(path.join(repoRoot, "blender", "export_cesium.py"), "Cesium exporter");
|
||||||
fs.rmSync(area.outputs.packageStagingDir, { recursive: true, force: true });
|
fs.rmSync(area.outputs.packageStagingDir, { recursive: true, force: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.glb), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.glb), { recursive: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.metadata), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.metadata), { recursive: true });
|
||||||
|
if (roadProvider === "osm2streets") {
|
||||||
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsDynamicGlb), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsDynamicGlb), { recursive: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsCountdown0Glb), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsCountdown0Glb), { recursive: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsCountdown1Glb), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsCountdown1Glb), { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Stage: cesium");
|
console.log("Stage: cesium");
|
||||||
const started = Date.now();
|
const started = Date.now();
|
||||||
const startedAt = new Date(started).toISOString();
|
const startedAt = new Date(started).toISOString();
|
||||||
runCommand(blenderExecutable(area), [
|
const exporterArgs = [
|
||||||
"--background",
|
"--background",
|
||||||
"--factory-startup",
|
"--factory-startup",
|
||||||
|
// Blender 4.5 on this macOS host can crash while probing Metal extensions
|
||||||
|
// before the exporter script runs; this is Blender's documented workaround.
|
||||||
|
"--debug-gpu-force-workarounds",
|
||||||
"--python",
|
"--python",
|
||||||
path.join(repoRoot, "blender", "export_cesium.py"),
|
path.join(repoRoot, "blender", "export_cesium.py"),
|
||||||
"--",
|
"--",
|
||||||
@@ -297,18 +360,22 @@ function exportCesium(area) {
|
|||||||
area.outputs.blend,
|
area.outputs.blend,
|
||||||
"--glb",
|
"--glb",
|
||||||
area.outputs.glb,
|
area.outputs.glb,
|
||||||
"--dynamic-glb",
|
|
||||||
area.outputs.trafficSignalsDynamicGlb,
|
|
||||||
"--countdown-0-glb",
|
|
||||||
area.outputs.trafficSignalsCountdown0Glb,
|
|
||||||
"--countdown-1-glb",
|
|
||||||
area.outputs.trafficSignalsCountdown1Glb,
|
|
||||||
"--metadata",
|
"--metadata",
|
||||||
area.outputs.metadata,
|
area.outputs.metadata,
|
||||||
], "cesium");
|
];
|
||||||
|
if (roadProvider === "osm2streets") {
|
||||||
|
exporterArgs.splice(-2, 0,
|
||||||
|
"--dynamic-glb", area.outputs.trafficSignalsDynamicGlb,
|
||||||
|
"--countdown-0-glb", area.outputs.trafficSignalsCountdown0Glb,
|
||||||
|
"--countdown-1-glb", area.outputs.trafficSignalsCountdown1Glb,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
runCommand(blenderExecutable(area), exporterArgs, "cesium");
|
||||||
|
if (roadProvider === "osm2streets") {
|
||||||
ensureFile(area.outputs.trafficSignalsDynamicGlb, "Dynamic traffic signal GLB");
|
ensureFile(area.outputs.trafficSignalsDynamicGlb, "Dynamic traffic signal GLB");
|
||||||
ensureFile(area.outputs.trafficSignalsCountdown0Glb, "Traffic countdown group 0 GLB");
|
ensureFile(area.outputs.trafficSignalsCountdown0Glb, "Traffic countdown group 0 GLB");
|
||||||
ensureFile(area.outputs.trafficSignalsCountdown1Glb, "Traffic countdown group 1 GLB");
|
ensureFile(area.outputs.trafficSignalsCountdown1Glb, "Traffic countdown group 1 GLB");
|
||||||
|
}
|
||||||
const semanticAssets = semanticAssetRecords(area);
|
const semanticAssets = semanticAssetRecords(area);
|
||||||
const finished = Date.now();
|
const finished = Date.now();
|
||||||
const digest = glbDigest(area.outputs.glb);
|
const digest = glbDigest(area.outputs.glb);
|
||||||
@@ -325,12 +392,15 @@ function exportCesium(area) {
|
|||||||
outputs: {
|
outputs: {
|
||||||
glb: fileRecord(area.outputs.glb),
|
glb: fileRecord(area.outputs.glb),
|
||||||
metadata: fileRecord(area.outputs.metadata),
|
metadata: fileRecord(area.outputs.metadata),
|
||||||
|
...(roadProvider === "osm2streets" ? {
|
||||||
trafficSignalsDynamicGlb: fileRecord(area.outputs.trafficSignalsDynamicGlb),
|
trafficSignalsDynamicGlb: fileRecord(area.outputs.trafficSignalsDynamicGlb),
|
||||||
|
} : {}),
|
||||||
semanticAssets,
|
semanticAssets,
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
glb: glbSummary(digest),
|
glb: glbSummary(digest),
|
||||||
budget: evaluateGlbBudget(digest, area.budget),
|
budget: evaluateGlbBudget(digest, area.budget),
|
||||||
|
roadProvider,
|
||||||
},
|
},
|
||||||
warnings: glbBudgetWarnings("Cesium", digest, area.budget),
|
warnings: glbBudgetWarnings("Cesium", digest, area.budget),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const { readAreaConfig } = require("./lib/area-config");
|
||||||
|
const { compileArea, parseArgs } = require("./compile-native-roads");
|
||||||
|
|
||||||
|
const repoRoot = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
|
function checkArea(configPath, options = {}) {
|
||||||
|
if (options.compile) compileArea(configPath);
|
||||||
|
const area = readAreaConfig(configPath, { repoRoot });
|
||||||
|
const root = area.outputs.nativeRoadDir;
|
||||||
|
const compiledPath = path.join(root, "compiled.json");
|
||||||
|
if (!fs.existsSync(compiledPath)) throw new Error(`Native road output is missing: ${compiledPath}`);
|
||||||
|
const compiled = readJson(compiledPath);
|
||||||
|
const connectors = readJson(path.join(root, "layers", "connectors.geojson"));
|
||||||
|
const published = new Set(connectors.features.map((feature) => feature.properties.movement_id));
|
||||||
|
const failures = [];
|
||||||
|
for (const movement of compiled.movements || []) {
|
||||||
|
if (movement.geometryPublished && !published.has(movement.id)) failures.push(`Published movement has no connector: ${movement.id}`);
|
||||||
|
if (!movement.geometryPublished && published.has(movement.id)) failures.push(`Non-published movement has a connector: ${movement.id}`);
|
||||||
|
if (!movement.geometryStatus) failures.push(`Movement has no geometry status: ${movement.id}`);
|
||||||
|
}
|
||||||
|
const errors = (compiled.diagnostics || []).filter((item) => item.severity === "error");
|
||||||
|
const warnings = (compiled.diagnostics || []).filter((item) => item.severity === "warning");
|
||||||
|
return { schema: "native-road-check/v1", areaId: area.id, ok: failures.length === 0 && errors.length === 0, movementCount: (compiled.movements || []).length, connectorCount: connectors.features.length, errors: errors.map((item) => ({ id: item.id, rule: item.rule, message: item.message })), warningCount: warnings.length, failures };
|
||||||
|
}
|
||||||
|
|
||||||
|
function readJson(file) { return JSON.parse(fs.readFileSync(file, "utf8")); }
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const args = parseArgs(process.argv.slice(2));
|
||||||
|
const configPath = path.resolve(args.config || path.join(repoRoot, "config", "areas", "nantaizi-lake-innovation-valley.json"));
|
||||||
|
const result = checkArea(configPath, { compile: args.compile === "true" });
|
||||||
|
console.log(`NATIVE_ROAD_CHECK_DONE ${JSON.stringify(result)}`);
|
||||||
|
if (!result.ok) process.exitCode = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require.main === module) main();
|
||||||
|
|
||||||
|
module.exports = { checkArea };
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const { readAreaConfig } = require("./lib/area-config");
|
||||||
|
const { compileRoadModel, compileGeometry, loadOverrides, validateOverrides, writeJsonAtomic } = require("./lib/native-road");
|
||||||
|
const { loadOrGenerate, runtime } = require("./lib/native-traffic-signals");
|
||||||
|
|
||||||
|
const repoRoot = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
|
function parseArgs(argv) {
|
||||||
|
const result = {};
|
||||||
|
for (let index = 0; index < argv.length; index += 1) {
|
||||||
|
if (!argv[index].startsWith("--")) continue;
|
||||||
|
const key = argv[index].slice(2).replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
||||||
|
result[key] = argv[index + 1] && !argv[index + 1].startsWith("--") ? argv[++index] : "true";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function compileArea(configPath) {
|
||||||
|
const area = readAreaConfig(configPath, { repoRoot });
|
||||||
|
const overrides = loadOverrides(area.outputs.nativeRoadOverrides);
|
||||||
|
const model = compileRoadModel(fs.readFileSync(area.input, "utf8"), overrides);
|
||||||
|
validateOverrides(overrides, model);
|
||||||
|
fs.mkdirSync(area.outputs.pipelineDir, { recursive: true });
|
||||||
|
const compiled = compileGeometry(model, overrides, { edgeLines: area.nativeRoad.edgeLines });
|
||||||
|
const signalDocument = loadOrGenerate(area.outputs.nativeTrafficSignals, fs.readFileSync(area.input, "utf8"), compiled.vehicleStopLines, compiled.intersectionSurface);
|
||||||
|
const signalRuntime = runtime(signalDocument);
|
||||||
|
// Persist validation normalization, including one-time legacy heading migration.
|
||||||
|
writeJsonAtomic(area.outputs.nativeTrafficSignals, signalDocument);
|
||||||
|
const staging = fs.mkdtempSync(path.join(area.outputs.pipelineDir, "native-road-"));
|
||||||
|
try {
|
||||||
|
const result = {
|
||||||
|
schema: "native-road-compiled/v1",
|
||||||
|
areaId: area.id,
|
||||||
|
source: { osm: area.input, overrides: area.outputs.nativeRoadOverrides, trafficSignals: area.outputs.nativeTrafficSignals },
|
||||||
|
model: { roads: model.roads, endpoints: model.endpoints, connections: model.connections },
|
||||||
|
movements: compiled.movements,
|
||||||
|
trafficSignals: { assemblies: "traffic-signal-assemblies.json", runtime: "traffic-signals.json", count: signalRuntime.signals.length },
|
||||||
|
diagnostics: compiled.diagnostics,
|
||||||
|
layers: { roadSurface: "layers/road_surface.geojson", edgeLines: "layers/edge_lines.geojson", sidewalkSurface: "layers/sidewalk_surface.geojson", intersectionSurface: "layers/intersection_surface.geojson", laneCenterlines: "layers/lane_centerlines.geojson", laneSeparators: "layers/lane_separators.geojson", centerLines: "layers/center_lines.geojson", directionArrows: "layers/direction_arrows.geojson", turnArrows: "layers/turn_arrows.geojson", crosswalks: "layers/crosswalks.geojson", vehicleStopLines: "layers/vehicle_stop_lines.geojson", connectors: "layers/connectors.geojson" },
|
||||||
|
};
|
||||||
|
const comparison = compareOsm2Streets(area, result.model, compiled);
|
||||||
|
writeJsonAtomic(path.join(staging, "compiled.json"), result);
|
||||||
|
writeJsonAtomic(path.join(staging, "diagnostics.json"), { schema: "native-road-diagnostics/v1", diagnostics: compiled.diagnostics });
|
||||||
|
writeJsonAtomic(path.join(staging, "comparison.json"), comparison);
|
||||||
|
writeJsonAtomic(path.join(staging, "traffic-signal-assemblies.json"), signalDocument.assemblies);
|
||||||
|
writeJsonAtomic(path.join(staging, "traffic-signals.json"), signalRuntime);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "road_surface.geojson"), compiled.roadSurface);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "edge_lines.geojson"), compiled.edgeLines);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "sidewalk_surface.geojson"), compiled.sidewalkSurface);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "intersection_surface.geojson"), compiled.intersectionSurface);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "lane_centerlines.geojson"), compiled.laneCenterlines);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "lane_separators.geojson"), compiled.laneSeparators);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "center_lines.geojson"), compiled.centerLines);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "direction_arrows.geojson"), compiled.directionArrows);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "turn_arrows.geojson"), compiled.turnArrows);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "crosswalks.geojson"), compiled.crosswalks);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "vehicle_stop_lines.geojson"), compiled.vehicleStopLines);
|
||||||
|
writeJsonAtomic(path.join(staging, "layers", "connectors.geojson"), compiled.connectors);
|
||||||
|
fs.rmSync(area.outputs.nativeRoadDir, { recursive: true, force: true });
|
||||||
|
fs.renameSync(staging, area.outputs.nativeRoadDir);
|
||||||
|
return { area, result, comparison };
|
||||||
|
} catch (error) {
|
||||||
|
fs.rmSync(staging, { recursive: true, force: true });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function compareOsm2Streets(area, model, compiled) {
|
||||||
|
const source = path.join(area.outputs.geojsonDir, "road_surface.geojson");
|
||||||
|
let featureCount = null;
|
||||||
|
if (fs.existsSync(source)) {
|
||||||
|
const collection = JSON.parse(fs.readFileSync(source, "utf8"));
|
||||||
|
featureCount = Array.isArray(collection.features) ? collection.features.length : null;
|
||||||
|
}
|
||||||
|
const diagnosticsBySeverity = {};
|
||||||
|
const diagnosticsByRule = {};
|
||||||
|
for (const item of compiled.diagnostics) {
|
||||||
|
diagnosticsBySeverity[item.severity] = (diagnosticsBySeverity[item.severity] || 0) + 1;
|
||||||
|
diagnosticsByRule[item.rule] = (diagnosticsByRule[item.rule] || 0) + 1;
|
||||||
|
}
|
||||||
|
const dangling = compiled.diagnostics.filter((item) => item.rule === "unconnected-interior-road-end");
|
||||||
|
const junctions = compiled.intersectionSurface.features;
|
||||||
|
const fallbackJunctions = junctions.filter((feature) => feature.properties.boundary_mode === "connector-convex-fallback");
|
||||||
|
return {
|
||||||
|
schema: "native-road-comparison/v2",
|
||||||
|
nativeRoadCount: model.roads.length,
|
||||||
|
nativeRoadSurfaceFeatures: compiled.roadSurface.features.length,
|
||||||
|
nativeSidewalkSurfaceFeatures: compiled.sidewalkSurface.features.length,
|
||||||
|
nativeJunctionSurfaceFeatures: compiled.intersectionSurface.features.length,
|
||||||
|
nativeApproachEnvelopeJunctions: junctions.length - fallbackJunctions.length,
|
||||||
|
nativeFallbackJunctions: fallbackJunctions.length,
|
||||||
|
nativeMaxJunctionExpansionRatio: junctions.reduce((maximum, feature) => Math.max(maximum, Number(feature.properties.expansion_ratio) || 0), 0),
|
||||||
|
nativeLaneCenterlineFeatures: compiled.laneCenterlines.features.length,
|
||||||
|
nativeLaneSeparatorFeatures: compiled.laneSeparators.features.length,
|
||||||
|
nativeCenterLineFeatures: compiled.centerLines.features.length,
|
||||||
|
nativeDirectionArrowFeatures: compiled.directionArrows.features.length,
|
||||||
|
nativeTurnArrowFeatures: compiled.turnArrows.features.length,
|
||||||
|
nativeCrosswalkFeatures: compiled.crosswalks.features.length,
|
||||||
|
nativeVehicleStopLineFeatures: compiled.vehicleStopLines.features.length,
|
||||||
|
nativeConnectorFeatures: compiled.connectors.features.length,
|
||||||
|
nativeMovementCount: compiled.movements.length,
|
||||||
|
nativePublishedMovementCount: compiled.movements.filter((movement) => movement.geometryPublished).length,
|
||||||
|
nativeConnectionCount: model.connections.length,
|
||||||
|
unconnectedInteriorRoadEnds: dangling.length,
|
||||||
|
unconnectedEndsWithManualCandidates: dangling.filter((item) => item.manualCandidates?.length).length,
|
||||||
|
diagnosticsBySeverity,
|
||||||
|
diagnosticsByRule,
|
||||||
|
osm2streetsRoadSurfaceFeatures: featureCount,
|
||||||
|
osm2streetsAvailable: featureCount !== null,
|
||||||
|
note: "Counts are coverage evidence only; geometry quality requires diagnostic and visual review.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const args = parseArgs(process.argv.slice(2));
|
||||||
|
const configPath = path.resolve(args.config || path.join(repoRoot, "config", "areas", "nantaizi-lake-innovation-valley.json"));
|
||||||
|
const { area, result, comparison } = compileArea(configPath);
|
||||||
|
console.log(`NATIVE_ROAD_COMPILE_DONE ${JSON.stringify({ areaId: area.id, roads: result.model.roads.length, endpoints: result.model.endpoints.length, diagnostics: result.diagnostics.length, output: area.outputs.nativeRoadDir, comparison })}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require.main === module) main();
|
||||||
|
|
||||||
|
module.exports = { compileArea, parseArgs };
|
||||||
@@ -32,9 +32,13 @@ function normalizeAreaConfig(raw, options = {}) {
|
|||||||
const packageStagingRuntimeDir = path.resolve(outputOverrides.packageStagingRuntimeDir || path.join(packageStagingDir, "runtime"));
|
const packageStagingRuntimeDir = path.resolve(outputOverrides.packageStagingRuntimeDir || path.join(packageStagingDir, "runtime"));
|
||||||
const previewDir = path.resolve(outputOverrides.previewDir || path.join(areaDir, "_preview"));
|
const previewDir = path.resolve(outputOverrides.previewDir || path.join(areaDir, "_preview"));
|
||||||
const geojsonDir = path.resolve(outputOverrides.geojsonDir || path.join(areaDir, "osm2streets_web_out"));
|
const geojsonDir = path.resolve(outputOverrides.geojsonDir || path.join(areaDir, "osm2streets_web_out"));
|
||||||
|
const nativeRoadDir = path.resolve(outputOverrides.nativeRoadDir || path.join(areaDir, "native-road"));
|
||||||
const outputs = {
|
const outputs = {
|
||||||
areaDir,
|
areaDir,
|
||||||
geojsonDir,
|
geojsonDir,
|
||||||
|
nativeRoadDir,
|
||||||
|
nativeRoadOverrides: path.resolve(outputOverrides.nativeRoadOverrides || path.join(areaDir, "native-road-overrides.json")),
|
||||||
|
nativeTrafficSignals: path.resolve(outputOverrides.nativeTrafficSignals || path.join(areaDir, "native-traffic-signals.json")),
|
||||||
gpkg: path.resolve(outputOverrides.gpkg || path.join(areaDir, `${fileStem}.gpkg`)),
|
gpkg: path.resolve(outputOverrides.gpkg || path.join(areaDir, `${fileStem}.gpkg`)),
|
||||||
qgisProject: path.resolve(outputOverrides.qgisProject || path.join(areaDir, `${fileStem}.qgz`)),
|
qgisProject: path.resolve(outputOverrides.qgisProject || path.join(areaDir, `${fileStem}.qgz`)),
|
||||||
qgisPreview: path.resolve(outputOverrides.qgisPreview || path.join(areaDir, `${fileStem}-preview.png`)),
|
qgisPreview: path.resolve(outputOverrides.qgisPreview || path.join(areaDir, `${fileStem}-preview.png`)),
|
||||||
@@ -104,6 +108,9 @@ function normalizeAreaConfig(raw, options = {}) {
|
|||||||
turnLaneArrows: {
|
turnLaneArrows: {
|
||||||
enabled: booleanOption(raw.turnLaneArrows?.enabled, false, "turnLaneArrows.enabled"),
|
enabled: booleanOption(raw.turnLaneArrows?.enabled, false, "turnLaneArrows.enabled"),
|
||||||
},
|
},
|
||||||
|
nativeRoad: {
|
||||||
|
edgeLines: booleanOption(raw.nativeRoad?.edgeLines, false, "nativeRoad.edgeLines"),
|
||||||
|
},
|
||||||
osm2streets: raw.osm2streets || {
|
osm2streets: raw.osm2streets || {
|
||||||
debug_each_step: false,
|
debug_each_step: false,
|
||||||
dual_carriageway_experiment: false,
|
dual_carriageway_experiment: false,
|
||||||
@@ -114,6 +121,7 @@ function normalizeAreaConfig(raw, options = {}) {
|
|||||||
blender: {
|
blender: {
|
||||||
treeStyle: raw.blender?.treeStyle || "natural",
|
treeStyle: raw.blender?.treeStyle || "natural",
|
||||||
officeOverrides: raw.blender?.officeOverrides || raw.blender?.office_overrides || "",
|
officeOverrides: raw.blender?.officeOverrides || raw.blender?.office_overrides || "",
|
||||||
|
roadProvider: roadProviderOption(raw.blender?.roadProvider),
|
||||||
},
|
},
|
||||||
compress,
|
compress,
|
||||||
budget,
|
budget,
|
||||||
@@ -169,6 +177,14 @@ function numberOption(value, fallback, label, min, max) {
|
|||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function roadProviderOption(value) {
|
||||||
|
const provider = value ?? "osm2streets";
|
||||||
|
if (provider !== "osm2streets" && provider !== "native") {
|
||||||
|
throw new Error("blender.roadProvider must be \"osm2streets\" or \"native\".");
|
||||||
|
}
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
function integerOption(value, fallback, label) {
|
function integerOption(value, fallback, label) {
|
||||||
const number = value === undefined ? fallback : Number(value);
|
const number = value === undefined ? fallback : Number(value);
|
||||||
if (!Number.isInteger(number) || number < 1) {
|
if (!Number.isInteger(number) || number < 1) {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,33 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const { parseOsm } = require("./osm");
|
||||||
|
const {
|
||||||
|
buildTrafficSignalFeatures,
|
||||||
|
buildTrafficSignalsFromFeatures,
|
||||||
|
validateTrafficSignalFeatures,
|
||||||
|
validateTrafficSignalSourceReferences,
|
||||||
|
} = require("./traffic-signals");
|
||||||
|
|
||||||
|
const SCHEMA = "native-traffic-signals/v1";
|
||||||
|
|
||||||
|
function loadOrGenerate(file, osmText, stopLines, intersections) {
|
||||||
|
if (fs.existsSync(file)) return validateDocument(JSON.parse(fs.readFileSync(file, "utf8")), osmText);
|
||||||
|
return generate(osmText, stopLines, intersections);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate(osmText, stopLines, intersections) {
|
||||||
|
const controls = parseOsm(osmText).trafficSignalControls;
|
||||||
|
return { schema: SCHEMA, provenance: "generated:osm-controls", assemblies: buildTrafficSignalFeatures(stopLines, intersections, controls) };
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateDocument(value, osmText) {
|
||||||
|
if (value?.schema !== SCHEMA) throw new Error(`Expected ${SCHEMA} signal document`);
|
||||||
|
const assemblies = validateTrafficSignalFeatures(value.assemblies);
|
||||||
|
if (osmText) validateTrafficSignalSourceReferences(assemblies, parseOsm(osmText).trafficSignalControls);
|
||||||
|
return { schema: SCHEMA, provenance: value.provenance || "native", assemblies };
|
||||||
|
}
|
||||||
|
|
||||||
|
function runtime(document) { return buildTrafficSignalsFromFeatures(document.assemblies); }
|
||||||
|
|
||||||
|
module.exports = { SCHEMA, generate, loadOrGenerate, validateDocument, runtime };
|
||||||
@@ -59,7 +59,11 @@ function buildTrafficSignalFeatures(stopLines, intersections, controls = []) {
|
|||||||
properties: {
|
properties: {
|
||||||
signal_uid: signalUid, display_id: signalUid, control_id: String(control.id),
|
signal_uid: signalUid, display_id: signalUid, control_id: String(control.id),
|
||||||
approach_id: approachId, source_way_id: sourceWayId,
|
approach_id: approachId, source_way_id: sourceWayId,
|
||||||
heading_deg: candidate.headingDegrees, phase_group: groups[index],
|
// These are independent assembly controls. heading_deg remains a
|
||||||
|
// migration hint for older native documents only.
|
||||||
|
mast_heading_deg: normalizeDegrees(candidate.headingDegrees - 90),
|
||||||
|
face_heading_deg: normalizeDegrees(candidate.headingDegrees + 180),
|
||||||
|
phase_group: groups[index],
|
||||||
mast_reach_m: MAST_REACH_METERS,
|
mast_reach_m: MAST_REACH_METERS,
|
||||||
stop_lon: candidate.center[0], stop_lat: candidate.center[1],
|
stop_lon: candidate.center[0], stop_lat: candidate.center[1],
|
||||||
enabled: true, z_offset_m: 0,
|
enabled: true, z_offset_m: 0,
|
||||||
@@ -114,13 +118,30 @@ function validateTrafficSignalFeatures(collection) {
|
|||||||
if (!approachId.startsWith(`${sourceWayId}:`)) throw new Error(`${label}: approach_id does not match source_way_id`);
|
if (!approachId.startsWith(`${sourceWayId}:`)) throw new Error(`${label}: approach_id does not match source_way_id`);
|
||||||
const expectedUid = `osm-${controlId}-${approachId.replace(":", "-")}`;
|
const expectedUid = `osm-${controlId}-${approachId.replace(":", "-")}`;
|
||||||
if (signalUid !== expectedUid) throw new Error(`${label}: signal_uid does not match source identity (expected '${expectedUid}')`);
|
if (signalUid !== expectedUid) throw new Error(`${label}: signal_uid does not match source identity (expected '${expectedUid}')`);
|
||||||
|
const legacyHeading = input.heading_deg == null || input.heading_deg === "" ? null : normalizeDegrees(number("heading_deg"));
|
||||||
|
if (legacyHeading == null && (input.mast_heading_deg == null || input.mast_heading_deg === "")) {
|
||||||
|
throw new Error(`${label}: missing mast_heading_deg`);
|
||||||
|
}
|
||||||
|
if (legacyHeading == null && (input.face_heading_deg == null || input.face_heading_deg === "")) {
|
||||||
|
throw new Error(`${label}: missing face_heading_deg`);
|
||||||
|
}
|
||||||
|
const mastHeading = input.mast_heading_deg == null || input.mast_heading_deg === ""
|
||||||
|
? normalizeDegrees((legacyHeading == null ? 0 : legacyHeading) - 90)
|
||||||
|
: normalizeDegrees(number("mast_heading_deg"));
|
||||||
|
const faceHeading = input.face_heading_deg == null || input.face_heading_deg === ""
|
||||||
|
? normalizeDegrees((legacyHeading == null ? 0 : legacyHeading) + 180)
|
||||||
|
: normalizeDegrees(number("face_heading_deg"));
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
geometry: { type: "Point", coordinates: feature.geometry.coordinates.slice(0, 2).map(Number) },
|
geometry: { type: "Point", coordinates: feature.geometry.coordinates.slice(0, 2).map(Number) },
|
||||||
properties: {
|
properties: {
|
||||||
...input, signal_uid: signalUid, display_id: displayId,
|
...input, signal_uid: signalUid, display_id: displayId,
|
||||||
control_id: controlId, approach_id: approachId,
|
control_id: controlId, approach_id: approachId,
|
||||||
source_way_id: sourceWayId, heading_deg: normalizeDegrees(number("heading_deg")),
|
source_way_id: sourceWayId,
|
||||||
|
// Retain the legacy value only for migration compatibility. Runtime
|
||||||
|
// geometry is entirely defined by mast_heading_deg and face_heading_deg.
|
||||||
|
heading_deg: legacyHeading,
|
||||||
|
mast_heading_deg: mastHeading, face_heading_deg: faceHeading,
|
||||||
phase_group: phaseGroup, mast_reach_m: number("mast_reach_m", { min: 0.1, max: 30 }),
|
phase_group: phaseGroup, mast_reach_m: number("mast_reach_m", { min: 0.1, max: 30 }),
|
||||||
stop_lon: number("stop_lon", { min: -180, max: 180 }),
|
stop_lon: number("stop_lon", { min: -180, max: 180 }),
|
||||||
stop_lat: number("stop_lat", { min: -90, max: 90 }),
|
stop_lat: number("stop_lat", { min: -90, max: 90 }),
|
||||||
@@ -136,16 +157,20 @@ function buildTrafficSignalsFromFeatures(collection) {
|
|||||||
const signals = normalized.features.filter((feature) => feature.properties.enabled).map((feature) => {
|
const signals = normalized.features.filter((feature) => feature.properties.enabled).map((feature) => {
|
||||||
const p = feature.properties;
|
const p = feature.properties;
|
||||||
const point = feature.geometry.coordinates;
|
const point = feature.geometry.coordinates;
|
||||||
const axis = headingVector(p.heading_deg);
|
const mastAxis = headingVector(p.mast_heading_deg);
|
||||||
return {
|
return {
|
||||||
id: p.signal_uid, signalUid: p.signal_uid, displayId: p.display_id,
|
id: p.signal_uid, signalUid: p.signal_uid, displayId: p.display_id,
|
||||||
nodeKey: signalNodeKey(p.signal_uid),
|
nodeKey: signalNodeKey(p.signal_uid),
|
||||||
controlId: p.control_id, approachId: p.approach_id, sourceWayId: p.source_way_id,
|
controlId: p.control_id, approachId: p.approach_id, sourceWayId: p.source_way_id,
|
||||||
phaseGroup: p.phase_group, longitude: point[0], latitude: point[1],
|
phaseGroup: p.phase_group, longitude: point[0], latitude: point[1],
|
||||||
stopLongitude: p.stop_lon, stopLatitude: p.stop_lat,
|
stopLongitude: p.stop_lon, stopLatitude: p.stop_lat,
|
||||||
headingDegrees: p.heading_deg, mastReachMeters: p.mast_reach_m,
|
// Existing Blender readers require headingDegrees. It is a compatibility
|
||||||
|
// alias only; the independent mast/face fields below define all geometry.
|
||||||
|
headingDegrees: p.heading_deg == null ? p.mast_heading_deg : p.heading_deg,
|
||||||
|
mastHeadingDegrees: p.mast_heading_deg,
|
||||||
|
faceHeadingDegrees: p.face_heading_deg, mastReachMeters: p.mast_reach_m,
|
||||||
zOffsetMeters: p.z_offset_m,
|
zOffsetMeters: p.z_offset_m,
|
||||||
pose: buildSignalPose(point, axis, p.mast_reach_m, p.z_offset_m),
|
pose: buildSignalPose(point, mastAxis, p.face_heading_deg, p.mast_reach_m, p.z_offset_m),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return { version: 3, layout: SIGNAL_LAYOUT, signals };
|
return { version: 3, layout: SIGNAL_LAYOUT, signals };
|
||||||
@@ -235,12 +260,13 @@ function phaseGroups(arms) {
|
|||||||
groups[main[0]] = 0; groups[main[1]] = 0; return groups;
|
groups[main[0]] = 0; groups[main[1]] = 0; return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSignalPose(pole, axis, mastReach, zOffset = 0) {
|
function buildSignalPose(pole, mastAxis, faceHeadingDegrees, mastReach, zOffset = 0) {
|
||||||
const lateral = [axis[1], -axis[0]]; const face = [-axis[0], -axis[1]];
|
const face = headingVector(faceHeadingDegrees);
|
||||||
const head = moveMeters(pole, lateral, -mastReach); const faceHeadingDegrees = Math.atan2(face[0], face[1]) * 180 / Math.PI;
|
const head = moveMeters(pole, mastAxis, mastReach);
|
||||||
const position = (point, height) => ({ longitude: point[0], latitude: point[1], height: height + zOffset });
|
const position = (point, height) => ({ longitude: point[0], latitude: point[1], height: height + zOffset });
|
||||||
const lensPoint = moveMeters(head, face, SIGNAL_LAYOUT.lensFaceOffsetMeters);
|
const lensPoint = moveMeters(head, face, SIGNAL_LAYOUT.lensFaceOffsetMeters);
|
||||||
const board = moveMeters(moveMeters(head, lateral, SIGNAL_LAYOUT.countdownLateralMeters), face, SIGNAL_LAYOUT.countdownFaceOffsetMeters);
|
const faceRight = [-face[1], face[0]];
|
||||||
|
const board = moveMeters(moveMeters(head, faceRight, SIGNAL_LAYOUT.countdownLateralMeters), face, SIGNAL_LAYOUT.countdownFaceOffsetMeters);
|
||||||
return { pole: position(pole, 0), arm: { from: position(pole, SIGNAL_LAYOUT.mastHeightMeters), to: position(head, SIGNAL_LAYOUT.mastHeightMeters) }, head: { ...position(head, SIGNAL_LAYOUT.headCenterHeightMeters), faceHeadingDegrees }, lenses: ["red", "yellow", "green"].map((state, index) => ({ state, ...position(lensPoint, SIGNAL_LAYOUT.headCenterHeightMeters + SIGNAL_LAYOUT.lensVerticalOffsetsMeters[index]) })), countdown: { ...position(board, SIGNAL_LAYOUT.mastHeightMeters), faceHeadingDegrees } };
|
return { pole: position(pole, 0), arm: { from: position(pole, SIGNAL_LAYOUT.mastHeightMeters), to: position(head, SIGNAL_LAYOUT.mastHeightMeters) }, head: { ...position(head, SIGNAL_LAYOUT.headCenterHeightMeters), faceHeadingDegrees }, lenses: ["red", "yellow", "green"].map((state, index) => ({ state, ...position(lensPoint, SIGNAL_LAYOUT.headCenterHeightMeters + SIGNAL_LAYOUT.lensVerticalOffsetsMeters[index]) })), countdown: { ...position(board, SIGNAL_LAYOUT.mastHeightMeters), faceHeadingDegrees } };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -358,6 +358,18 @@ function addMeters(center, axis, axisDistance, right, rightDistance, meters) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arrowRingsAt(maneuver, center, axis, manifest = loadManifest()) {
|
||||||
|
const normalized = normalizeManeuver(maneuver);
|
||||||
|
if (!supportedAssets(manifest).has(normalized) || !Array.isArray(center) || !Array.isArray(axis)) return [];
|
||||||
|
const meters = metersForLat(center[1]);
|
||||||
|
const length = Math.hypot(axis[0], axis[1]);
|
||||||
|
if (!Number.isFinite(length) || length < 0.001) return [];
|
||||||
|
const forward = [axis[0] / length, axis[1] / length];
|
||||||
|
const right = [forward[1], -forward[0]];
|
||||||
|
return templateFor(normalized, manifest).map((template) => template.map(([rightMeters, forwardMeters]) =>
|
||||||
|
addMeters(center, forward, forwardMeters, right, rightMeters, meters)));
|
||||||
|
}
|
||||||
|
|
||||||
function templateFor(assetId, manifest = loadManifest()) {
|
function templateFor(assetId, manifest = loadManifest()) {
|
||||||
const asset = supportedAssets(manifest).get(assetId);
|
const asset = supportedAssets(manifest).get(assetId);
|
||||||
if (!asset) throw new Error(`Unsupported or untested turn-lane asset: ${assetId}`);
|
if (!asset) throw new Error(`Unsupported or untested turn-lane asset: ${assetId}`);
|
||||||
@@ -487,4 +499,4 @@ function strokePolygon(points, width) {
|
|||||||
return [...left, ...right, left[0]];
|
return [...left, ...right, left[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { buildCustomTurnLaneArrows, loadManifest, normalizeManeuver, supportedAssets, templateFor };
|
module.exports = { arrowRingsAt, buildCustomTurnLaneArrows, loadManifest, normalizeManeuver, supportedAssets, templateFor };
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const http = require("http");
|
||||||
|
const path = require("path");
|
||||||
|
const { readAreaConfig } = require("./lib/area-config");
|
||||||
|
const { loadOverrides, validateOverrides, writeJsonAtomic } = require("./lib/native-road");
|
||||||
|
const { generate, validateDocument, runtime } = require("./lib/native-traffic-signals");
|
||||||
|
const { compileArea, parseArgs } = require("./compile-native-roads");
|
||||||
|
|
||||||
|
const repoRoot = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const args = parseArgs(process.argv.slice(2));
|
||||||
|
const configPath = path.resolve(args.config || path.join(repoRoot, "config", "areas", "nantaizi-lake-innovation-valley.json"));
|
||||||
|
if (args.noCompile !== "true") compileArea(configPath);
|
||||||
|
const area = readAreaConfig(configPath, { repoRoot });
|
||||||
|
const port = Number(args.port || 8787);
|
||||||
|
if (!Number.isInteger(port) || port < 1024 || port > 65535) throw new Error("--port must be an integer in [1024, 65535].");
|
||||||
|
const server = http.createServer((request, response) => handle(request, response, area, configPath));
|
||||||
|
server.on("error", (error) => {
|
||||||
|
console.error(`Road Workbench failed to listen: ${error.message}`);
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
||||||
|
server.listen(port, "127.0.0.1", () => console.log(`Road Workbench: http://127.0.0.1:${port}/`));
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle(request, response, area, configPath) {
|
||||||
|
const url = new URL(request.url, "http://127.0.0.1");
|
||||||
|
if (request.method === "GET" && url.pathname === "/") return sendFile(response, path.join(repoRoot, "scripts", "workbench", "index.html"), "text/html; charset=utf-8");
|
||||||
|
if (request.method === "GET" && url.pathname === "/app.js") return sendFile(response, path.join(repoRoot, "scripts", "workbench", "app.js"), "text/javascript; charset=utf-8");
|
||||||
|
if (request.method === "GET" && url.pathname === "/app.css") return sendFile(response, path.join(repoRoot, "scripts", "workbench", "app.css"), "text/css; charset=utf-8");
|
||||||
|
if (request.method === "GET" && url.pathname.startsWith("/vendor/")) return sendVendorFile(response, url.pathname);
|
||||||
|
if (request.method === "GET" && url.pathname === "/api/state") return sendJson(response, 200, state(area));
|
||||||
|
if (request.method === "POST" && url.pathname === "/api/traffic-signals") return readBody(request).then((body) => {
|
||||||
|
const document = validateDocument(body, fs.readFileSync(area.input, "utf8"));
|
||||||
|
writeJsonAtomic(area.outputs.nativeTrafficSignals, document);
|
||||||
|
sendJson(response, 200, { ok: true, trafficSignals: document, runtime: runtime(document) });
|
||||||
|
}).catch((error) => sendJson(response, 400, { ok: false, error: error.message }));
|
||||||
|
if (request.method === "POST" && url.pathname === "/api/traffic-signals/generate") return Promise.resolve().then(() => {
|
||||||
|
const compiled = readCompiled(area);
|
||||||
|
const generated = generate(fs.readFileSync(area.input, "utf8"), readLayer(path.join(area.outputs.nativeRoadDir, "layers", "vehicle_stop_lines.geojson")), readLayer(path.join(area.outputs.nativeRoadDir, "layers", "intersection_surface.geojson")));
|
||||||
|
const current = validateDocument(readJson(area.outputs.nativeTrafficSignals), fs.readFileSync(area.input, "utf8"));
|
||||||
|
const present = new Set(current.assemblies.features.map((feature) => feature.properties.signal_uid));
|
||||||
|
current.assemblies.features.push(...generated.assemblies.features.filter((feature) => !present.has(feature.properties.signal_uid)));
|
||||||
|
writeJsonAtomic(area.outputs.nativeTrafficSignals, current);
|
||||||
|
sendJson(response, 200, { ok: true, trafficSignals: current, runtime: runtime(current), generated: generated.assemblies.features.length, compiled: Boolean(compiled) });
|
||||||
|
}).catch((error) => sendJson(response, 400, { ok: false, error: error.message }));
|
||||||
|
if (request.method === "POST" && url.pathname === "/api/overrides") return readBody(request).then((body) => {
|
||||||
|
const compiled = readCompiled(area);
|
||||||
|
const overrides = validateOverrides(body, { roads: compiled.model.roads, endpoints: compiled.model.endpoints });
|
||||||
|
writeJsonAtomic(area.outputs.nativeRoadOverrides, overrides);
|
||||||
|
sendJson(response, 200, { ok: true, overrides });
|
||||||
|
}).catch((error) => sendJson(response, 400, { ok: false, error: error.message }));
|
||||||
|
if (request.method === "POST" && url.pathname === "/api/compile") return Promise.resolve().then(() => {
|
||||||
|
compileArea(configPath);
|
||||||
|
sendJson(response, 200, state(area));
|
||||||
|
}).catch((error) => sendJson(response, 500, { ok: false, error: error.message }));
|
||||||
|
sendJson(response, 404, { error: "Not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function state(area) {
|
||||||
|
const nativeDir = area.outputs.nativeRoadDir;
|
||||||
|
const osm2streetsRoadSurface = path.join(area.outputs.geojsonDir, "road_surface.geojson");
|
||||||
|
const trafficSignals = fs.existsSync(area.outputs.nativeTrafficSignals)
|
||||||
|
? validateDocument(readJson(area.outputs.nativeTrafficSignals), fs.readFileSync(area.input, "utf8"))
|
||||||
|
: { schema: "native-traffic-signals/v1", provenance: "empty", assemblies: { type: "FeatureCollection", features: [] } };
|
||||||
|
const trafficRuntime = runtime(trafficSignals);
|
||||||
|
return { areaId: area.id, compiled: readCompiled(area), overrides: loadOverrides(area.outputs.nativeRoadOverrides), trafficSignals, trafficRuntime, comparison: readJson(path.join(nativeDir, "comparison.json")), layers: { nativeRoadSurface: readLayer(path.join(nativeDir, "layers", "road_surface.geojson")), edgeLines: readLayer(path.join(nativeDir, "layers", "edge_lines.geojson")), nativeSidewalkSurface: readLayer(path.join(nativeDir, "layers", "sidewalk_surface.geojson")), nativeIntersectionSurface: readLayer(path.join(nativeDir, "layers", "intersection_surface.geojson")), laneCenterlines: readLayer(path.join(nativeDir, "layers", "lane_centerlines.geojson")), laneSeparators: readLayer(path.join(nativeDir, "layers", "lane_separators.geojson")), centerLines: readLayer(path.join(nativeDir, "layers", "center_lines.geojson")), directionArrows: readLayer(path.join(nativeDir, "layers", "direction_arrows.geojson")), turnArrows: readLayer(path.join(nativeDir, "layers", "turn_arrows.geojson")), crosswalks: readLayer(path.join(nativeDir, "layers", "crosswalks.geojson")), vehicleStopLines: readLayer(path.join(nativeDir, "layers", "vehicle_stop_lines.geojson")), connectors: readLayer(path.join(nativeDir, "layers", "connectors.geojson")), osm2streetsRoadSurface: fs.existsSync(osm2streetsRoadSurface) ? readLayer(osm2streetsRoadSurface) : null } };
|
||||||
|
}
|
||||||
|
function readCompiled(area) { return readJson(path.join(area.outputs.nativeRoadDir, "compiled.json")); }
|
||||||
|
function readJson(file) { return JSON.parse(fs.readFileSync(file, "utf8")); }
|
||||||
|
function readLayer(file) { return fs.existsSync(file) ? readJson(file) : { type: "FeatureCollection", features: [] }; }
|
||||||
|
function readBody(request) { return new Promise((resolve, reject) => { let body = ""; request.setEncoding("utf8"); request.on("data", (part) => { body += part; if (body.length > 1024 * 1024) request.destroy(); }); request.on("end", () => { try { resolve(JSON.parse(body)); } catch (_) { reject(new Error("Request body must be JSON.")); } }); request.on("error", reject); }); }
|
||||||
|
function sendFile(response, file, type) { response.writeHead(200, { "Content-Type": type, "Cache-Control": "no-store" }); fs.createReadStream(file).pipe(response); }
|
||||||
|
function sendVendorFile(response, pathname) {
|
||||||
|
const match = /^\/vendor\/(ol|rbush|quickselect)\/(.+)$/.exec(pathname);
|
||||||
|
if (!match) return sendJson(response, 404, { error: "Not found" });
|
||||||
|
const root = path.join(repoRoot, "node_modules", match[1]);
|
||||||
|
const file = path.resolve(root, match[2]);
|
||||||
|
if (!file.startsWith(`${root}${path.sep}`) || !fs.existsSync(file) || !fs.statSync(file).isFile()) return sendJson(response, 404, { error: "Not found" });
|
||||||
|
return sendFile(response, file, file.endsWith(".css") ? "text/css; charset=utf-8" : "text/javascript; charset=utf-8");
|
||||||
|
}
|
||||||
|
function sendJson(response, status, value) { response.writeHead(status, { "Content-Type": "application/json; charset=utf-8", "Cache-Control": "no-store" }); response.end(`${JSON.stringify(value)}\n`); }
|
||||||
|
if (require.main === module) main();
|
||||||
@@ -11,9 +11,12 @@ const { digestGltf } = require("./glb-digest");
|
|||||||
const { evaluateGlbBudget, BUDGETS, fileRecord, writeStageManifest } = require("./lib/stage-manifest");
|
const { evaluateGlbBudget, BUDGETS, fileRecord, writeStageManifest } = require("./lib/stage-manifest");
|
||||||
|
|
||||||
const qgisBuildSource = fs.readFileSync(path.join(__dirname, "build-osm2streets-qgis.js"), "utf8");
|
const qgisBuildSource = fs.readFileSync(path.join(__dirname, "build-osm2streets-qgis.js"), "utf8");
|
||||||
|
const areaBuildSource = fs.readFileSync(path.join(__dirname, "build-area.js"), "utf8");
|
||||||
assert.match(qgisBuildSource, /QgsFieldConstraints\.Constraint\.ConstraintNotNull/);
|
assert.match(qgisBuildSource, /QgsFieldConstraints\.Constraint\.ConstraintNotNull/);
|
||||||
assert.match(qgisBuildSource, /QgsFieldConstraints\.ConstraintNotNull/);
|
assert.match(qgisBuildSource, /QgsFieldConstraints\.ConstraintNotNull/);
|
||||||
assert.doesNotMatch(qgisBuildSource, /setFieldConstraint\(index, 1\)/);
|
assert.doesNotMatch(qgisBuildSource, /setFieldConstraint\(index, 1\)/);
|
||||||
|
assert.match(areaBuildSource, /exportCesium\(area, roadProvider\)/);
|
||||||
|
assert.match(areaBuildSource, /if \(roadProvider === "osm2streets"\) \{\n exporterArgs\.splice/);
|
||||||
|
|
||||||
const gltf = {
|
const gltf = {
|
||||||
nodes: [
|
nodes: [
|
||||||
@@ -51,6 +54,12 @@ assert.equal(
|
|||||||
path.join(tempDir, "test-area", "osm2streets_web_out", "traffic_signal_assemblies.geojson"),
|
path.join(tempDir, "test-area", "osm2streets_web_out", "traffic_signal_assemblies.geojson"),
|
||||||
);
|
);
|
||||||
assert.equal(normalizeAreaConfig({ ...base, budget: { nodes: 800 } }).budget.glbNodes, 800);
|
assert.equal(normalizeAreaConfig({ ...base, budget: { nodes: 800 } }).budget.glbNodes, 800);
|
||||||
|
assert.equal(normalizeAreaConfig(base).blender.roadProvider, "osm2streets");
|
||||||
|
assert.equal(normalizeAreaConfig({ ...base, blender: { roadProvider: "native" } }).blender.roadProvider, "native");
|
||||||
|
assert.throws(
|
||||||
|
() => normalizeAreaConfig({ ...base, blender: { roadProvider: "other" } }),
|
||||||
|
/blender\.roadProvider/,
|
||||||
|
);
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => normalizeAreaConfig({ ...base, budget: { nodes: 1200 } }),
|
() => normalizeAreaConfig({ ...base, budget: { nodes: 1200 } }),
|
||||||
/budget.reason is required/,
|
/budget.reason is required/,
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
"use strict";
|
"use strict";
|
||||||
const assert = require("assert");
|
const assert = require("assert");
|
||||||
|
const fs = require("fs");
|
||||||
const { resolveStages, canonicalStages } = require("./lib/build-stages");
|
const { resolveStages, canonicalStages } = require("./lib/build-stages");
|
||||||
assert.deepEqual(canonicalStages(resolveStages({}, ["compress", "blender", "preview"])), ["blender", "compress", "preview"]);
|
assert.deepEqual(canonicalStages(resolveStages({}, ["compress", "blender", "preview"])), ["blender", "compress", "preview"]);
|
||||||
assert.deepEqual(canonicalStages(resolveStages({}, ["all"])), ["intermediates", "blender", "cesium", "compress", "package", "preview"]);
|
assert.deepEqual(canonicalStages(resolveStages({}, ["all"])), ["intermediates", "blender", "cesium", "compress", "package", "preview"]);
|
||||||
assert.deepEqual(canonicalStages(resolveStages({ intermediates: true, blender: true, cesium: true, compress: true, package: true })), ["intermediates", "blender", "cesium", "compress", "package"]);
|
assert.deepEqual(canonicalStages(resolveStages({ intermediates: true, blender: true, cesium: true, compress: true, package: true })), ["intermediates", "blender", "cesium", "compress", "package"]);
|
||||||
assert.throws(() => resolveStages({}, ["intermediates", "reimport"]), /mutually exclusive/);
|
assert.throws(() => resolveStages({}, ["intermediates", "reimport"]), /mutually exclusive/);
|
||||||
|
const buildAreaSource = fs.readFileSync(require("path").join(__dirname, "build-area.js"), "utf8");
|
||||||
|
assert.match(buildAreaSource, /"--debug-gpu-force-workarounds"/);
|
||||||
console.log("Build stage tests passed.");
|
console.log("Build stage tests passed.");
|
||||||
@@ -0,0 +1,217 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const assert = require("assert");
|
||||||
|
const fs = require("fs");
|
||||||
|
const os = require("os");
|
||||||
|
const path = require("path");
|
||||||
|
const { compileRoadModel, compileGeometry, validateOverrides } = require("./lib/native-road");
|
||||||
|
const { compileArea } = require("./compile-native-roads");
|
||||||
|
const { checkArea } = require("./check-native-roads");
|
||||||
|
|
||||||
|
const osm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.001" lat="30"/><node id="3" lon="114.001" lat="30.001"/><way id="10"><nd ref="1"/><nd ref="2"/><tag k="highway" v="residential"/><tag k="lanes" v="2"/><tag k="sidewalk" v="both"/></way><way id="11"><nd ref="2"/><nd ref="3"/><tag k="highway" v="residential"/><tag k="oneway" v="yes"/></way></osm>`;
|
||||||
|
const empty = { schema: "native-road-overrides/v1", overrides: [] };
|
||||||
|
const initial = compileRoadModel(osm, empty);
|
||||||
|
assert.equal(initial.roads.length, 3);
|
||||||
|
const target = initial.roads.find((road) => road.id === "road:way/10:forward");
|
||||||
|
const overrides = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "road-width", kind: "road", roadId: target.id, widthMeters: 9, laneCount: 2, sidewalkLeft: false }] }, initial);
|
||||||
|
const model = compileRoadModel(osm, overrides);
|
||||||
|
const edited = model.roads.find((road) => road.id === target.id);
|
||||||
|
assert.equal(edited.widthMeters, 9);
|
||||||
|
assert.equal(edited.provenance.widthMeters, "override:road-width");
|
||||||
|
assert.equal(edited.sidewalkLeft, false);
|
||||||
|
const geometry = compileGeometry(model);
|
||||||
|
assert.equal(geometry.roadSurface.features.length, 2);
|
||||||
|
assert.equal(compileGeometry(model, empty, { edgeLines: false }).edgeLines.features.length, 0);
|
||||||
|
assert.ok(geometry.roadSurface.features.every((feature) => feature.geometry.coordinates[0].length >= 5));
|
||||||
|
assert.equal(geometry.sidewalkSurface.features.length, 2);
|
||||||
|
assert.ok(geometry.sidewalkSurface.features.every((feature) => feature.geometry.coordinates[0].length >= 5));
|
||||||
|
assert.equal(geometry.laneCenterlines.features.length, model.roads.reduce((sum, road) => sum + road.laneCount, 0));
|
||||||
|
assert.ok(geometry.laneSeparators.features.every((feature) => feature.geometry.type === "Polygon" && feature.properties.provenance === "native-road-lane-separator/v1"));
|
||||||
|
const separator = geometry.laneSeparators.features[0];
|
||||||
|
const separatorOverride = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "separator-style", kind: "lane-separator-style", roadId: separator.properties.road_id, leftLaneIndex: separator.properties.left_lane_index, rightLaneIndex: separator.properties.right_lane_index, color: "yellow", pattern: "solid" }] }, model);
|
||||||
|
const styledSeparators = compileGeometry(model, separatorOverride).laneSeparators.features.filter((feature) => feature.properties.road_id === separator.properties.road_id && feature.properties.left_lane_index === separator.properties.left_lane_index);
|
||||||
|
assert.ok(styledSeparators.length > 0 && styledSeparators.every((feature) => feature.properties.effective_style === "yellow-solid"));
|
||||||
|
assert.ok(geometry.centerLines.features.length > 0);
|
||||||
|
assert.ok(geometry.centerLines.features.every((feature) => feature.geometry.type === "Polygon" && feature.properties.provenance === "native-road-center-line/v1" && feature.properties.dash_length_m === 2 && feature.properties.dash_gap_m === 2));
|
||||||
|
for (const feature of geometry.centerLines.features) {
|
||||||
|
const ring = feature.geometry.coordinates[0];
|
||||||
|
const lengths = [distance(ring[0], ring[1]), distance(ring[1], ring[2])].sort((a, b) => a - b);
|
||||||
|
assert.ok(Math.abs(lengths[0] - .25) < .01 && Math.abs(lengths[1] - 2) < .01);
|
||||||
|
assert.ok(feature.properties.segment_id && feature.properties.directional_road_ids && feature.properties.osm_way_ids && feature.properties.placement_rule);
|
||||||
|
}
|
||||||
|
const centerLineOverride = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "center-white-solid", kind: "center-line-style", segmentId: target.segmentId, color: "white", pattern: "solid" }] }, model);
|
||||||
|
const styledCenterLines = compileGeometry(model, centerLineOverride).centerLines.features.filter((feature) => feature.properties.segment_id === target.segmentId);
|
||||||
|
assert.ok(styledCenterLines.length > 0);
|
||||||
|
assert.ok(styledCenterLines.every((feature) => feature.properties.color === "white" && feature.properties.pattern === "solid" && feature.properties.effective_style === "white-solid" && feature.properties.dash_gap_m === 0));
|
||||||
|
const doubleCenterOverride = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "center-double-yellow", kind: "center-line-style", segmentId: target.segmentId, color: "yellow", pattern: "solid", double: true }] }, model);
|
||||||
|
const doubleCenterLines = compileGeometry(model, doubleCenterOverride).centerLines.features.filter((feature) => feature.properties.segment_id === target.segmentId);
|
||||||
|
assert.equal(doubleCenterLines.length, styledCenterLines.length * 2);
|
||||||
|
assert.ok(doubleCenterLines.every((feature) => feature.properties.double === true && feature.properties.effective_style === "double-yellow-solid"));
|
||||||
|
assert.equal(new Set(doubleCenterLines.map((feature) => feature.properties.dash_index)).size, styledCenterLines.length);
|
||||||
|
for (const dashIndex of new Set(doubleCenterLines.map((feature) => feature.properties.dash_index))) {
|
||||||
|
const pair = doubleCenterLines.filter((feature) => feature.properties.dash_index === dashIndex);
|
||||||
|
const centers = pair.map((feature) => feature.geometry.coordinates[0].slice(0, 4).reduce((sum, point) => [sum[0] + point[0] / 4, sum[1] + point[1] / 4], [0, 0]));
|
||||||
|
assert.ok(Math.hypot((centers[0][0] - centers[1][0]) * 96400, (centers[0][1] - centers[1][1]) * 111320) > .25);
|
||||||
|
}
|
||||||
|
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "bad-double-center", kind: "center-line-style", segmentId: target.segmentId, color: "white", pattern: "solid", double: true }] }, model), /Invalid center line style override/);
|
||||||
|
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "bad-center", kind: "center-line-style", segmentId: target.segmentId, color: "blue", pattern: "solid" }] }, model), /Invalid center line style override/);
|
||||||
|
const edgeLine = geometry.edgeLines.features[0];
|
||||||
|
assert.ok(edgeLine && edgeLine.properties.effective_style === "white-solid");
|
||||||
|
const twoWayEdgeLines = geometry.edgeLines.features.filter((feature) => feature.properties.road_id.includes("way/10"));
|
||||||
|
assert.ok(twoWayEdgeLines.length > 0 && twoWayEdgeLines.every((feature) => feature.properties.side === "right"));
|
||||||
|
const edgeOverride = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "edge-yellow-dashed", kind: "edge-line-style", roadId: edgeLine.properties.road_id, side: edgeLine.properties.side, color: "yellow", pattern: "dashed" }] }, model);
|
||||||
|
const styledEdgeLines = compileGeometry(model, edgeOverride).edgeLines.features.filter((feature) => feature.properties.road_id === edgeLine.properties.road_id && feature.properties.side === edgeLine.properties.side);
|
||||||
|
assert.ok(styledEdgeLines.length > 1 && styledEdgeLines.every((feature) => feature.properties.effective_style === "yellow-dashed"));
|
||||||
|
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "bad-edge", kind: "edge-line-style", roadId: edgeLine.properties.road_id, side: "middle", color: "yellow", pattern: "solid" }] }, model), /Invalid edge line style override/);
|
||||||
|
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "missing-edge-road", kind: "edge-line-style", roadId: "road:way/missing:forward", side: "left", color: "yellow", pattern: "solid" }] }, model), /Invalid edge line style override/);
|
||||||
|
assert.ok(geometry.directionArrows.features.every((feature) => feature.geometry.type === "Polygon" && feature.properties.provenance === "native-road-direction-arrow/v1" && feature.properties.placement_interval_meters === 32));
|
||||||
|
assert.ok(geometry.turnArrows.features.every((feature) => feature.geometry.type === "Polygon" && feature.properties.provenance === "native-road-turn-arrow/v1"));
|
||||||
|
assert.ok(geometry.connectors.features.length > 0);
|
||||||
|
assert.ok(geometry.connectors.features.every((feature) => feature.geometry.coordinates.length === 13));
|
||||||
|
assert.ok(geometry.connectors.features.every((feature) => feature.properties.node_id));
|
||||||
|
assert.ok(geometry.movements.length >= geometry.connectors.features.length);
|
||||||
|
assert.ok(geometry.movements.every((movement) => movement.id.startsWith("movement:") && movement.connectorId.startsWith("connector:")));
|
||||||
|
assert.ok(geometry.movements.every((movement) => ["connector", "continuous", "deferred-too-long"].includes(movement.geometryStatus)));
|
||||||
|
assert.ok(geometry.intersectionSurface.features.every((feature) => feature.properties.rule === "junction-shared-cutback/v3"));
|
||||||
|
assert.ok(geometry.intersectionSurface.features.every((feature) => ["approach-envelope", "rounded-approach-envelope", "connector-convex-fallback"].includes(feature.properties.boundary_mode)));
|
||||||
|
assert.ok(geometry.intersectionSurface.features.every((feature) => feature.properties.approach_area_m2 > 0 && feature.properties.surface_area_m2 > 0 && feature.properties.expansion_ratio >= 1));
|
||||||
|
for (const feature of geometry.intersectionSurface.features.filter((item) => item.properties.boundary_mode === "connector-convex-fallback")) assert.ok(geometry.diagnostics.some((item) => item.subjectId === feature.properties.native_id && item.rule === "junction-connector-envelope-fallback"));
|
||||||
|
const controlOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.00080" lat="30"><tag k="highway" v="crossing"/><tag k="crossing:markings" v="zebra"/></node><node id="3" lon="114.001" lat="30"/><node id="4" lon="114.002" lat="30"><tag k="highway" v="crossing"/><tag k="crossing:markings" v="unmarked"/></node><node id="5" lon="114.0035" lat="30"><tag k="highway" v="crossing"/></node><node id="6" lon="114.004" lat="30"/><node id="7" lon="114.001" lat="30.001"/><way id="60"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><tag k="highway" v="residential"/></way><way id="61"><nd ref="5"/><nd ref="6"/><tag k="highway" v="footway"/></way><way id="62"><nd ref="3"/><nd ref="7"/><tag k="highway" v="residential"/></way></osm>`;
|
||||||
|
const controlGeometry = compileGeometry(compileRoadModel(controlOsm, empty));
|
||||||
|
assert.equal(controlGeometry.crosswalks.features.length, 6);
|
||||||
|
assert.equal(controlGeometry.vehicleStopLines.features.length, 1);
|
||||||
|
assert.ok(controlGeometry.crosswalks.features.every((feature) => feature.properties.crossing_node_id === "2" && feature.properties.provenance === "native-road-crosswalk/v1"));
|
||||||
|
assert.ok(controlGeometry.vehicleStopLines.features.every((feature) => feature.properties.crossing_node_id === "2" && feature.properties.provenance === "native-road-stop-line/v1"));
|
||||||
|
assert.ok(controlGeometry.crosswalks.features.every((feature) => feature.properties.junction_inset_m > 0));
|
||||||
|
assert.equal(controlGeometry.vehicleStopLines.features[0].properties.junction_inset_m, controlGeometry.crosswalks.features[0].properties.junction_inset_m);
|
||||||
|
assert.ok(controlGeometry.diagnostics.some((item) => item.rule === "crossing-no-native-lane" && item.sourceIds.includes("5")));
|
||||||
|
assert.ok(controlGeometry.centerLines.features.length > 0);
|
||||||
|
assert.ok(controlGeometry.centerLines.features.every((dash) => ![...controlGeometry.crosswalks.features, ...controlGeometry.vehicleStopLines.features].some((control) => ringsOverlap(dash.geometry.coordinates[0], control.geometry.coordinates[0]))));
|
||||||
|
const solidControlLines = compileGeometry(compileRoadModel(controlOsm, empty), { schema: "native-road-overrides/v1", overrides: [{ id: "solid-control", kind: "center-line-style", segmentId: controlGeometry.centerLines.features[0].properties.segment_id, color: "yellow", pattern: "solid" }] }).centerLines.features;
|
||||||
|
assert.ok(solidControlLines.every((dash) => ![...controlGeometry.crosswalks.features, ...controlGeometry.vehicleStopLines.features].some((control) => ringsOverlap(dash.geometry.coordinates[0], control.geometry.coordinates[0]))));
|
||||||
|
const arrowControlOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.00095" lat="30"><tag k="highway" v="crossing"/><tag k="crossing:markings" v="zebra"/></node><node id="3" lon="114.001" lat="30"/><way id="63"><nd ref="1"/><nd ref="2"/><nd ref="3"/><tag k="highway" v="residential"/><tag k="oneway" v="yes"/><tag k="lanes" v="1"/><tag k="turn:lanes" v="through"/></way></osm>`;
|
||||||
|
const arrowControlGeometry = compileGeometry(compileRoadModel(arrowControlOsm, empty));
|
||||||
|
assert.ok(arrowControlGeometry.turnArrows.features.length > 0);
|
||||||
|
assert.ok(arrowControlGeometry.turnArrows.features.every((feature) => feature.properties.placement_distance_meters > 6));
|
||||||
|
assert.equal(arrowControlGeometry.centerLines.features.length, 0);
|
||||||
|
const serviceCenterLineOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.001" lat="30"/><way id="64"><nd ref="1"/><nd ref="2"/><tag k="highway" v="service"/></way></osm>`;
|
||||||
|
assert.equal(compileGeometry(compileRoadModel(serviceCenterLineOsm, empty)).centerLines.features.length, 0);
|
||||||
|
const crossOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.001" lat="30"/><node id="3" lon="114.002" lat="30"/><node id="4" lon="114.001" lat="30.001"/><node id="5" lon="114.001" lat="29.999"/><way id="40"><nd ref="1"/><nd ref="2"/><tag k="highway" v="residential"/><tag k="sidewalk" v="both"/></way><way id="41"><nd ref="2"/><nd ref="3"/><tag k="highway" v="residential"/><tag k="sidewalk" v="both"/></way><way id="42"><nd ref="5"/><nd ref="2"/><tag k="highway" v="residential"/><tag k="sidewalk" v="both"/></way><way id="43"><nd ref="2"/><nd ref="4"/><tag k="highway" v="residential"/><tag k="sidewalk" v="both"/></way></osm>`;
|
||||||
|
const crossCenter = [114.001, 30];
|
||||||
|
const crossGeometry = compileGeometry(compileRoadModel(crossOsm, empty));
|
||||||
|
assert.equal(crossGeometry.intersectionSurface.features.length, 1);
|
||||||
|
assert.equal(crossGeometry.intersectionSurface.features[0].properties.boundary_mode, "rounded-approach-envelope");
|
||||||
|
assert.ok(crossGeometry.intersectionSurface.features[0].geometry.coordinates[0].length > 9);
|
||||||
|
const crossBoundary = crossGeometry.intersectionSurface.features[0].geometry.coordinates[0];
|
||||||
|
const crossRadius = (point) => Math.hypot((point[0] - crossCenter[0]) * 96400, (point[1] - crossCenter[1]) * 111320);
|
||||||
|
// The sampled tangent arc must cut inward from its old straight chord; an
|
||||||
|
// outward-bowed control point leaks asphalt into the pedestrian corner.
|
||||||
|
const firstCurveEnd = crossBoundary[8];
|
||||||
|
assert.ok(crossRadius(crossBoundary[4]) < crossRadius([(crossBoundary[0][0] + firstCurveEnd[0]) / 2, (crossBoundary[0][1] + firstCurveEnd[1]) / 2]));
|
||||||
|
assert.equal(crossGeometry.turnArrows.features.length, 0);
|
||||||
|
assert.ok(crossGeometry.directionArrows.features.length > 0);
|
||||||
|
assert.ok(crossGeometry.directionArrows.features.every((feature) => feature.properties.maneuver === "through" && feature.properties.provenance === "native-road-direction-arrow/v1"));
|
||||||
|
// Approach asphalt ends at the shared cutback; the rounded junction surface
|
||||||
|
// exclusively owns the central road area so its boundary remains visible.
|
||||||
|
assert.ok(crossGeometry.roadSurface.features.every((feature) => Math.min(...feature.geometry.coordinates[0].map((point) => Math.hypot((point[0] - crossCenter[0]) * 96400, (point[1] - crossCenter[1]) * 111320))) > 4));
|
||||||
|
const exteriorRings = (geometry) => geometry.type === "Polygon" ? [geometry.coordinates[0]] : geometry.coordinates.map((polygon) => polygon[0]);
|
||||||
|
assert.ok(crossGeometry.sidewalkSurface.features.every((feature) => Math.min(...exteriorRings(feature.geometry).flat().map((point) => Math.hypot((point[0] - crossCenter[0]) * 96400, (point[1] - crossCenter[1]) * 111320))) > 5));
|
||||||
|
const crossSidewalkCorners = crossGeometry.sidewalkSurface.features.filter((feature) => feature.properties.kind === "corner");
|
||||||
|
assert.equal(crossSidewalkCorners.length, 4);
|
||||||
|
// A rounded sidewalk corner must sample both the curb and outer boundaries.
|
||||||
|
// The legacy wedge had five closing-ring points; two curved edges need more.
|
||||||
|
assert.ok(crossSidewalkCorners.every((feature) => feature.geometry.coordinates[0].length > 9));
|
||||||
|
assert.ok(crossSidewalkCorners.every((feature) => {
|
||||||
|
const ring = feature.geometry.coordinates[0];
|
||||||
|
const outerStart = ring[1];
|
||||||
|
const outerCurvePoint = ring[2];
|
||||||
|
const outerEnd = ring[(ring.length - 1) / 2];
|
||||||
|
const twiceArea = (outerEnd[0] - outerStart[0]) * (outerCurvePoint[1] - outerStart[1]) - (outerEnd[1] - outerStart[1]) * (outerCurvePoint[0] - outerStart[0]);
|
||||||
|
return Math.abs(twiceArea) > 1e-12;
|
||||||
|
}));
|
||||||
|
assert.ok(crossSidewalkCorners.every((feature) => {
|
||||||
|
const ring = feature.geometry.coordinates[0];
|
||||||
|
const curbStart = ring[10];
|
||||||
|
const curbCurvePoint = ring[11];
|
||||||
|
const curbEnd = ring[0];
|
||||||
|
const twiceArea = (curbEnd[0] - curbStart[0]) * (curbCurvePoint[1] - curbStart[1]) - (curbEnd[1] - curbStart[1]) * (curbCurvePoint[0] - curbStart[0]);
|
||||||
|
return Math.abs(twiceArea) > 1e-12;
|
||||||
|
}));
|
||||||
|
const sharedInteriorNodeOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.001" lat="30"/><node id="3" lon="114.002" lat="30"/><node id="4" lon="114.001" lat="30.001"/><way id="50"><nd ref="1"/><nd ref="2"/><nd ref="3"/><tag k="highway" v="residential"/><tag k="sidewalk" v="both"/></way><way id="51"><nd ref="4"/><nd ref="2"/><tag k="highway" v="residential"/><tag k="sidewalk" v="both"/></way></osm>`;
|
||||||
|
const sharedInteriorModel = compileRoadModel(sharedInteriorNodeOsm, empty);
|
||||||
|
assert.equal(sharedInteriorModel.roads.length, 6);
|
||||||
|
assert.ok(sharedInteriorModel.roads.some((road) => road.id === "road:way/50:segment/1:forward"));
|
||||||
|
assert.ok(sharedInteriorModel.roads.some((road) => road.id === "road:way/50:segment/2:forward"));
|
||||||
|
const sharedInteriorGeometry = compileGeometry(sharedInteriorModel);
|
||||||
|
assert.equal(sharedInteriorGeometry.intersectionSurface.features.length, 1);
|
||||||
|
assert.equal(sharedInteriorGeometry.intersectionSurface.features[0].properties.osm_node_id, "2");
|
||||||
|
assert.equal(sharedInteriorGeometry.intersectionSurface.features[0].properties.kind, "t");
|
||||||
|
assert.ok(sharedInteriorGeometry.connectors.features.length >= 4);
|
||||||
|
assert.ok(sharedInteriorGeometry.sidewalkSurface.features.some((feature) => feature.properties.kind === "continuation" && /segment:way\/50\/1:.*->segment:way\/50\/2:/.test(feature.properties.native_id)));
|
||||||
|
const connection = initial.connections[0];
|
||||||
|
assert.ok(initial.connections.every((item) => item.fromEndpointId.endsWith(":end") && item.toEndpointId.endsWith(":start")));
|
||||||
|
assert.equal(initial.connections.length, new Set(initial.connections.map((item) => `${item.fromEndpointId}->${item.toEndpointId}`)).size);
|
||||||
|
const connectionOverrides = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "disconnect", kind: "junction-connection", fromEndpointId: connection.fromEndpointId, toEndpointId: connection.toEndpointId, enabled: false }] }, initial);
|
||||||
|
assert.equal(validateOverrides(connectionOverrides).overrides.length, 1);
|
||||||
|
assert.equal(compileRoadModel(osm, connectionOverrides).connections.find((item) => item.id === connection.id).enabled, false);
|
||||||
|
assert.ok(compileGeometry(compileRoadModel(osm, connectionOverrides)).connectors.features.length < geometry.connectors.features.length);
|
||||||
|
const disconnectedOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.001" lat="30"/><node id="3" lon="114.00105" lat="30"/><node id="4" lon="114.002" lat="30"/><way id="20"><nd ref="1"/><nd ref="2"/><tag k="highway" v="residential"/><tag k="oneway" v="yes"/></way><way id="21"><nd ref="3"/><nd ref="4"/><tag k="highway" v="residential"/><tag k="oneway" v="yes"/></way></osm>`;
|
||||||
|
const disconnected = compileRoadModel(disconnectedOsm, empty);
|
||||||
|
const from = disconnected.endpoints.find((endpoint) => endpoint.roadId === "road:way/20:forward" && endpoint.side === "end");
|
||||||
|
const to = disconnected.endpoints.find((endpoint) => endpoint.roadId === "road:way/21:forward" && endpoint.side === "start");
|
||||||
|
const manualOverrides = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "manual", kind: "junction-connection", fromEndpointId: from.id, toEndpointId: to.id, enabled: true }] }, disconnected);
|
||||||
|
assert.ok(compileRoadModel(disconnectedOsm, manualOverrides).connections.some((item) => item.fromEndpointId === from.id && item.toEndpointId === to.id));
|
||||||
|
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "same-way", kind: "junction-connection", fromEndpointId: initial.endpoints.find((endpoint) => endpoint.roadId === "road:way/10:forward" && endpoint.side === "end").id, toEndpointId: initial.endpoints.find((endpoint) => endpoint.roadId === "road:way/10:backward" && endpoint.side === "start").id, enabled: true }] }, initial), /manual junction connection/);
|
||||||
|
const turnOsm = `<osm><node id="1" lon="114" lat="30"/><node id="2" lon="114.001" lat="30"/><node id="3" lon="114.001" lat="30.001"/><way id="30"><nd ref="1"/><nd ref="2"/><tag k="highway" v="primary"/><tag k="oneway" v="yes"/><tag k="lanes" v="3"/><tag k="turn:lanes" v="left|through|right"/></way><way id="31"><nd ref="2"/><nd ref="3"/><tag k="highway" v="primary"/><tag k="oneway" v="yes"/><tag k="lanes" v="3"/></way></osm>`;
|
||||||
|
const turnModel = compileRoadModel(turnOsm, empty);
|
||||||
|
const turnGeometry = compileGeometry(turnModel);
|
||||||
|
assert.equal(turnGeometry.sidewalkSurface.features.length, 0);
|
||||||
|
assert.ok(turnGeometry.directionArrows.features.length > 0);
|
||||||
|
assert.ok(turnGeometry.turnArrows.features.length > 0);
|
||||||
|
assert.ok(turnGeometry.turnArrows.features.every((feature) => feature.properties.provenance === "native-road-turn-arrow/v1"));
|
||||||
|
const sidewalkOverride = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "add-sidewalk", kind: "road", roadId: "road:way/30:forward", sidewalkLeft: true }] }, turnModel);
|
||||||
|
assert.ok(compileGeometry(compileRoadModel(turnOsm, sidewalkOverride)).sidewalkSurface.features.some((feature) => feature.properties.native_id === "sidewalk:way/30:left"));
|
||||||
|
assert.equal(turnGeometry.connectors.features.length, 1);
|
||||||
|
assert.match(turnGeometry.connectors.features[0].properties.from_lane_id, /road:way\/30:forward:1$/);
|
||||||
|
assert.match(turnGeometry.connectors.features[0].properties.to_lane_id, /road:way\/31:forward:1$/);
|
||||||
|
const laneOverrides = validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "block-left", kind: "lane-connection", fromLaneId: turnGeometry.connectors.features[0].properties.from_lane_id, toLaneId: turnGeometry.connectors.features[0].properties.to_lane_id, enabled: false }] }, turnModel);
|
||||||
|
assert.equal(compileGeometry(turnModel, laneOverrides).connectors.features.length, 0);
|
||||||
|
assert.equal(compileGeometry(turnModel, laneOverrides).movements.length, 0);
|
||||||
|
assert.throws(() => validateOverrides({ schema: "native-road-overrides/v1", overrides: [{ id: "bad", kind: "road", roadId: "missing", widthMeters: 4 }] }, initial), /Unknown road/);
|
||||||
|
const freshArea = fs.mkdtempSync(path.join(os.tmpdir(), "native-road-fresh-area-"));
|
||||||
|
try {
|
||||||
|
const input = path.join(freshArea, "input.osm");
|
||||||
|
const outputRoot = path.join(freshArea, "outputs");
|
||||||
|
const config = path.join(freshArea, "area.json");
|
||||||
|
fs.writeFileSync(input, osm);
|
||||||
|
fs.writeFileSync(config, JSON.stringify({ id: "fresh", input, outputRoot }));
|
||||||
|
const compiledArea = compileArea(config);
|
||||||
|
assert.equal(compiledArea.result.areaId, "fresh");
|
||||||
|
assert.ok(fs.existsSync(path.join(outputRoot, "fresh", "native-road", "compiled.json")));
|
||||||
|
const centerLineLayer = JSON.parse(fs.readFileSync(path.join(outputRoot, "fresh", "native-road", "layers", "center_lines.geojson"), "utf8"));
|
||||||
|
const edgeLineLayer = JSON.parse(fs.readFileSync(path.join(outputRoot, "fresh", "native-road", "layers", "edge_lines.geojson"), "utf8"));
|
||||||
|
assert.equal(centerLineLayer.type, "FeatureCollection");
|
||||||
|
assert.equal(centerLineLayer.features.length, compiledArea.comparison.nativeCenterLineFeatures);
|
||||||
|
assert.equal(edgeLineLayer.features.length, 0);
|
||||||
|
assert.equal(compiledArea.comparison.schema, "native-road-comparison/v2");
|
||||||
|
assert.equal(compiledArea.comparison.nativeRoadCount, compiledArea.result.model.roads.length);
|
||||||
|
assert.equal(compiledArea.comparison.nativePublishedMovementCount, compiledArea.result.movements.filter((movement) => movement.geometryPublished).length);
|
||||||
|
assert.equal(compiledArea.comparison.nativeCrosswalkFeatures, 0);
|
||||||
|
assert.equal(compiledArea.comparison.nativeVehicleStopLineFeatures, 0);
|
||||||
|
assert.equal(compiledArea.comparison.nativeApproachEnvelopeJunctions + compiledArea.comparison.nativeFallbackJunctions, compiledArea.comparison.nativeJunctionSurfaceFeatures);
|
||||||
|
assert.ok(compiledArea.comparison.nativeMaxJunctionExpansionRatio >= 0);
|
||||||
|
assert.equal(checkArea(config).ok, true);
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(freshArea, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
function distance(a, b) {
|
||||||
|
return Math.hypot((b[0] - a[0]) * 111320 * Math.cos(a[1] * Math.PI / 180), (b[1] - a[1]) * 111320);
|
||||||
|
}
|
||||||
|
function ringsOverlap(first, second) {
|
||||||
|
const bounds = (ring) => [Math.min(...ring.map((point) => point[0])), Math.min(...ring.map((point) => point[1])), Math.max(...ring.map((point) => point[0])), Math.max(...ring.map((point) => point[1]))];
|
||||||
|
const a = bounds(first); const b = bounds(second);
|
||||||
|
return !(a[0] > b[2] || a[2] < b[0] || a[1] > b[3] || a[3] < b[1]);
|
||||||
|
}
|
||||||
|
console.log("native road tests passed");
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const assert = require("assert");
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const html = fs.readFileSync(path.join(__dirname, "workbench", "index.html"), "utf8");
|
||||||
|
assert.match(html, /id="width" type="number" min="1" step="0\.01"/);
|
||||||
|
assert.match(html, /data-layer="sidewalks" type="checkbox" checked> 路缘与步行带/);
|
||||||
|
assert.match(html, /id="scene-preview" type="checkbox"/);
|
||||||
|
assert.match(html, /id="selected-junction" hidden/);
|
||||||
|
const app = fs.readFileSync(path.join(__dirname, "workbench", "app.js"), "utf8");
|
||||||
|
assert.match(app, /async function saveStagedChanges\(\)/);
|
||||||
|
assert.match(app, /if \(!await saveStagedChanges\(\)\) return;/);
|
||||||
|
assert.match(app, /function stageRoadOverride\(road, changes\)/);
|
||||||
|
assert.match(app, /road\.segmentId === selectedRoad\.segmentId/);
|
||||||
|
assert.match(app, /sidewalkLeft: rightInput\.checked, sidewalkRight: leftInput\.checked/);
|
||||||
|
assert.match(app, /function nativeSurfaceStyle\(feature\)/);
|
||||||
|
assert.match(app, /reference: new VectorLayer\(\{ source: source\(\), visible: false/);
|
||||||
|
assert.match(app, /scene mode must render fills only/);
|
||||||
|
assert.match(app, /scenePreviewToggle\.onchange/);
|
||||||
|
assert.match(app, /layers\.sidewalks\.setVisible\(document\.querySelector\('\[data-layer="sidewalks"\]'\)\.checked\)/);
|
||||||
|
assert.match(app, /function selectJunction\(feature\)/);
|
||||||
|
assert.match(app, /candidate\.get\("native_id"\) === item\.subjectId/);
|
||||||
|
assert.match(app, /外缘扩张倍率/);
|
||||||
|
assert.match(app, /最大外缘扩张/);
|
||||||
|
assert.match(app, /道路方向箭头/);
|
||||||
|
assert.match(app, /native-road-direction-arrow\/v1/);
|
||||||
|
assert.match(app, /data-layer="centerLines" type="checkbox" checked> 道路中心线/);
|
||||||
|
assert.match(app, /centerLines: new VectorLayer/);
|
||||||
|
assert.match(app, /state\.layers\.centerLines/);
|
||||||
|
assert.match(app, /native-road-center-line\/v1/);
|
||||||
|
assert.match(app, /lane-separator-style/);
|
||||||
|
assert.match(app, /车道分隔线/);
|
||||||
|
assert.match(app, /center-line-style/);
|
||||||
|
assert.match(app, /centerLineStyleInput\.onchange = stageSelectedCenterLineStyle/);
|
||||||
|
assert.match(html, /道路中心线样式/);
|
||||||
|
assert.match(html, /white-solid/);
|
||||||
|
assert.match(app, /double-yellow-solid/);
|
||||||
|
assert.match(app, /const double = parts\[0\] === "double"/);
|
||||||
|
assert.match(app, /function selectEdgeLine\(feature\)/);
|
||||||
|
assert.match(app, /edge-line-style/);
|
||||||
|
assert.match(app, /道路外缘线样式/);
|
||||||
|
assert.match(app, /data-layer="edgeLines" type="checkbox"> 道路外缘线/);
|
||||||
|
assert.match(app, /edgeLines: new VectorLayer\(\{ source: source\(\), visible: false/);
|
||||||
|
assert.match(html, /id="marking-style-heading"/);
|
||||||
|
assert.match(app, /data-layer="controls" type="checkbox" checked> 斑马线与停止线/);
|
||||||
|
assert.match(app, /controls: new VectorLayer/);
|
||||||
|
assert.match(app, /state\.layers\.crosswalks/);
|
||||||
|
assert.match(app, /state\.layers\.vehicleStopLines/);
|
||||||
|
assert.match(app, /native-road-crosswalk\/v1/);
|
||||||
|
assert.match(app, /native-road-stop-line\/v1/);
|
||||||
|
assert.match(app, /term\.textContent = label; detail\.textContent = value; summary\.append\(term, detail\)/);
|
||||||
|
assert.match(app, /原生红绿灯/);
|
||||||
|
assert.match(app, /function selectSignal\(feature\)/);
|
||||||
|
assert.match(app, /\/api\/traffic-signals/);
|
||||||
|
assert.match(app, /从 OSM 生成缺失信号灯/);
|
||||||
|
assert.match(app, /data-layer="signals" type="checkbox" checked> 红绿灯设施/);
|
||||||
|
assert.match(app, /红绿灯设施/);
|
||||||
|
assert.match(app, /signalAssemblyStyle/);
|
||||||
|
assert.match(app, /signal_component: "mast"/);
|
||||||
|
assert.match(app, /signal_component: "face"/);
|
||||||
|
assert.match(app, /signal_component: "head"/);
|
||||||
|
assert.match(app, /faceHeadingDegrees/);
|
||||||
|
assert.match(app, /横杆方向(度)/);
|
||||||
|
assert.match(app, /横杆长度(米)/);
|
||||||
|
assert.match(app, /灯面朝向(度)/);
|
||||||
|
assert.match(app, /检查信号灯<select name="signal-picker">/);
|
||||||
|
assert.match(app, /signalPicker\.onchange/);
|
||||||
|
assert.match(app, /map\.getView\(\)\.fit\(\[x - 25, y - 25, x \+ 25, y \+ 25\]/);
|
||||||
|
assert.match(app, /fromLonLat/);
|
||||||
|
assert.match(app, /armFeatures\.push\(new Feature/);
|
||||||
|
assert.match(app, /headFeatures\.push\(new Feature/);
|
||||||
|
assert.match(app, /faceFeatures\.push\(new Feature/);
|
||||||
|
const server = fs.readFileSync(path.join(__dirname, "road-workbench.js"), "utf8");
|
||||||
|
assert.match(server, /\/api\/traffic-signals\/generate/);
|
||||||
|
assert.doesNotMatch(app, /导入 QGIS|导出 QGIS/);
|
||||||
|
assert.doesNotMatch(server, /traffic-signals\/(?:import|export)-qgis/);
|
||||||
|
console.log("road workbench tests passed");
|
||||||
@@ -47,6 +47,9 @@ const originalStop = [first.properties.stop_lon, first.properties.stop_lat];
|
|||||||
first.geometry.coordinates[0] += 0.0001;
|
first.geometry.coordinates[0] += 0.0001;
|
||||||
first.properties.display_id = "A-01";
|
first.properties.display_id = "A-01";
|
||||||
first.properties.heading_deg = 42;
|
first.properties.heading_deg = 42;
|
||||||
|
first.properties.mast_heading_deg = 17;
|
||||||
|
first.properties.mast_reach_m = 8.5;
|
||||||
|
first.properties.face_heading_deg = 203;
|
||||||
first.properties.z_offset_m = 1.25;
|
first.properties.z_offset_m = 1.25;
|
||||||
const runtime = buildTrafficSignalsFromFeatures(edited);
|
const runtime = buildTrafficSignalsFromFeatures(edited);
|
||||||
assert.equal(new Set(runtime.signals.map((signal) => signal.nodeKey)).size, runtime.signals.length);
|
assert.equal(new Set(runtime.signals.map((signal) => signal.nodeKey)).size, runtime.signals.length);
|
||||||
@@ -61,9 +64,22 @@ const changed = runtime.signals.find((signal) => signal.id === first.properties.
|
|||||||
assert.equal(changed.displayId, "A-01");
|
assert.equal(changed.displayId, "A-01");
|
||||||
assert.equal(changed.longitude, first.geometry.coordinates[0]);
|
assert.equal(changed.longitude, first.geometry.coordinates[0]);
|
||||||
assert.equal(changed.headingDegrees, 42);
|
assert.equal(changed.headingDegrees, 42);
|
||||||
|
assert.equal(changed.mastHeadingDegrees, 17);
|
||||||
|
assert.equal(changed.faceHeadingDegrees, 203);
|
||||||
|
assert.equal(changed.mastReachMeters, 8.5);
|
||||||
assert.deepEqual([changed.stopLongitude, changed.stopLatitude], originalStop, "moving a pole preserves the stop point");
|
assert.deepEqual([changed.stopLongitude, changed.stopLatitude], originalStop, "moving a pole preserves the stop point");
|
||||||
assert.equal(changed.pose.pole.height, 1.25);
|
assert.equal(changed.pose.pole.height, 1.25);
|
||||||
assert.equal(changed.pose.arm.from.height, 7.5);
|
assert.equal(changed.pose.arm.from.height, 7.5);
|
||||||
|
assert.ok(changed.pose.arm.to.latitude > changed.pose.arm.from.latitude, "mast direction controls the arm independently");
|
||||||
|
assert.equal(changed.pose.head.faceHeadingDegrees, 203, "face direction is independent from mast direction");
|
||||||
|
|
||||||
|
const legacy = structuredClone(cross);
|
||||||
|
legacy.features[0].properties.heading_deg = 42;
|
||||||
|
delete legacy.features[0].properties.mast_heading_deg;
|
||||||
|
delete legacy.features[0].properties.face_heading_deg;
|
||||||
|
const migrated = validateTrafficSignalFeatures(legacy).features[0].properties;
|
||||||
|
assert.equal(migrated.mast_heading_deg, 312, "legacy heading preserves the historic mast direction");
|
||||||
|
assert.equal(migrated.face_heading_deg, 222, "legacy heading preserves the historic face direction");
|
||||||
|
|
||||||
edited.features[1].properties.enabled = "0";
|
edited.features[1].properties.enabled = "0";
|
||||||
assert.equal(buildTrafficSignalsFromFeatures(edited).signals.length, 3, "disabled assemblies are omitted");
|
assert.equal(buildTrafficSignalsFromFeatures(edited).signals.length, 3, "disabled assemblies are omitted");
|
||||||
@@ -100,7 +116,7 @@ for (const disabledValue of [false, 0, "0", "false", "no"]) {
|
|||||||
disabled.features[0].properties.enabled = disabledValue;
|
disabled.features[0].properties.enabled = disabledValue;
|
||||||
assert.equal(buildTrafficSignalsFromFeatures(disabled).signals.length, 3);
|
assert.equal(buildTrafficSignalsFromFeatures(disabled).signals.length, 3);
|
||||||
}
|
}
|
||||||
for (const key of ["heading_deg", "phase_group", "stop_lon", "stop_lat", "z_offset_m"]) {
|
for (const key of ["phase_group", "stop_lon", "stop_lat", "z_offset_m"]) {
|
||||||
const missingNumber = structuredClone(cross);
|
const missingNumber = structuredClone(cross);
|
||||||
missingNumber.features[0].properties[key] = null;
|
missingNumber.features[0].properties[key] = null;
|
||||||
assert.throws(
|
assert.throws(
|
||||||
@@ -109,5 +125,8 @@ for (const key of ["heading_deg", "phase_group", "stop_lon", "stop_lat", "z_offs
|
|||||||
`${key} must not silently coerce null to zero`,
|
`${key} must not silently coerce null to zero`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const missingDirections = structuredClone(cross);
|
||||||
|
for (const key of ["heading_deg", "mast_heading_deg", "face_heading_deg"]) missingDirections.features[0].properties[key] = null;
|
||||||
|
assert.throws(() => validateTrafficSignalFeatures(missingDirections), /missing mast_heading_deg/);
|
||||||
|
|
||||||
console.log("Traffic signal tests passed.");
|
console.log("Traffic signal tests passed.");
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const assert = require("assert");
|
const assert = require("assert");
|
||||||
const { buildCustomTurnLaneArrows, loadManifest, normalizeManeuver, supportedAssets, templateFor } = require("./lib/turn-lane-arrows");
|
const { arrowRingsAt, buildCustomTurnLaneArrows, loadManifest, normalizeManeuver, supportedAssets, templateFor } = require("./lib/turn-lane-arrows");
|
||||||
|
|
||||||
function node(id, lon, lat) { return { id, lon, lat, tags: {} }; }
|
function node(id, lon, lat) { return { id, lon, lat, tags: {} }; }
|
||||||
function way(id, refs, tags) { return { id, refs, tags }; }
|
function way(id, refs, tags) { return { id, refs, tags }; }
|
||||||
@@ -35,6 +35,9 @@ assert.ok(Math.abs((Math.min(...shaftXs) + Math.max(...shaftXs)) / 2) < 1e-9, "t
|
|||||||
const rightXs = templateFor("right", manifest).flat().map(([x]) => x);
|
const rightXs = templateFor("right", manifest).flat().map(([x]) => x);
|
||||||
assert.ok(Math.max(...rightXs) - Math.min(...rightXs) < 1.7, "source SVG scale stays comparable to existing lane arrows");
|
assert.ok(Math.max(...rightXs) - Math.min(...rightXs) < 1.7, "source SVG scale stays comparable to existing lane arrows");
|
||||||
assert.equal(templateFor("through;left;right", manifest).length, 5, "triple maneuver has a shared straight shaft and two branches");
|
assert.equal(templateFor("through;left;right", manifest).length, 5, "triple maneuver has a shared straight shaft and two branches");
|
||||||
|
const nativePlacement = arrowRingsAt("left", [114, 30], [0, 1], manifest);
|
||||||
|
assert.ok(nativePlacement.length > 0 && nativePlacement.every((ring) => ring.every((point) => Number.isFinite(point[0]) && Number.isFinite(point[1]))));
|
||||||
|
assert.deepEqual(arrowRingsAt("slight_left", [114, 30], [0, 1], manifest), []);
|
||||||
const disabled = buildCustomTurnLaneArrows(osm, { enabled: false, manifest });
|
const disabled = buildCustomTurnLaneArrows(osm, { enabled: false, manifest });
|
||||||
assert.equal(disabled.features.length, 0);
|
assert.equal(disabled.features.length, 0);
|
||||||
assert.equal(disabled.diagnostics[0].reason, "disabled");
|
assert.equal(disabled.diagnostics[0].reason, "disabled");
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
*{box-sizing:border-box}body{margin:0;background:#eef1ef;color:#202523;font:14px system-ui,sans-serif}header{height:50px;display:flex;gap:12px;align-items:center;padding:0 16px;background:#183a32;color:#fff}header span{color:#c9d8d2}#dirty-state.dirty{color:#ffe08a;font-weight:700}button{border:1px solid #82988f;background:#fff;color:#1d392f;padding:7px 10px;border-radius:3px;cursor:pointer}button:disabled{cursor:default;opacity:.55}header button:first-of-type{margin-left:auto}main{display:grid;grid-template-columns:260px minmax(0,1fr) 320px;height:calc(100vh - 50px)}aside{overflow:auto;background:#fff;padding:16px}.issues{border-right:1px solid #d5dfda}.inspector{border-left:1px solid #d5dfda}.map{position:relative;background:#d7e2de;min-height:400px}canvas{width:100%;height:100%;display:block}.legend{position:absolute;bottom:12px;left:12px;background:#fff;padding:8px;box-shadow:0 1px 4px #0003}.legend i{display:inline-block;width:18px;height:7px;margin:0 4px -1px 10px}.reference{background:#a5b0b5}.native{background:#296654}.line{height:3px!important;background:#263630}.junction{width:10px!important;height:10px!important;background:#0e7860;border-radius:50%}.warning{width:10px!important;height:10px!important;background:#d49318;border-radius:50%}h1{font-size:16px;margin:0 0 8px}h2{font-size:14px;margin:12px 0 8px}.muted,output,pre{color:#52615b}.issues ul{list-style:none;padding:0;margin:0}.issues button{width:100%;text-align:left;margin:4px 0;background:#fff7e5;border-color:#e7c67b;color:#693c00}.issues button.error{background:#fff0ee;border-color:#e3a49b;color:#8d261a}.segmented{display:flex;margin:0 0 8px}.segmented button{flex:1;border-radius:0;padding:6px 4px;font-size:12px}.segmented button+button{border-left:0}.segmented button:first-child{border-radius:3px 0 0 3px}.segmented button:last-child{border-radius:0 3px 3px 0}.segmented button.active{background:#286956;border-color:#286956;color:#fff}label{display:block;margin:10px 0}input[type=number]{display:block;width:100%;padding:7px;border:1px solid #aab8b2;border-radius:2px}output,pre{display:block;white-space:pre-wrap;overflow-wrap:anywhere}form button{margin-top:8px;background:#286956;color:white;border:0}dl{display:grid;grid-template-columns:1fr auto;gap:5px 10px;margin:0}dt{color:#52615b}dd{margin:0;font-variant-numeric:tabular-nums}hr{border:0;border-top:1px solid #dde4e1;margin:16px 0}details{margin-top:16px}summary{cursor:pointer;font-weight:600}@media(max-width:900px){main{grid-template-columns:minmax(0,1fr)}.issues{display:none}.inspector{position:absolute;right:0;bottom:0;width:min(360px,100%);max-height:55vh;border-top:1px solid #d5dfda}}
|
||||||
@@ -0,0 +1,327 @@
|
|||||||
|
import Map from "/vendor/ol/Map.js";
|
||||||
|
import View from "/vendor/ol/View.js";
|
||||||
|
import VectorLayer from "/vendor/ol/layer/Vector.js";
|
||||||
|
import VectorSource from "/vendor/ol/source/Vector.js";
|
||||||
|
import GeoJSON from "/vendor/ol/format/GeoJSON.js";
|
||||||
|
import Feature from "/vendor/ol/Feature.js";
|
||||||
|
import LineString from "/vendor/ol/geom/LineString.js";
|
||||||
|
import Point from "/vendor/ol/geom/Point.js";
|
||||||
|
import Style from "/vendor/ol/style/Style.js";
|
||||||
|
import Fill from "/vendor/ol/style/Fill.js";
|
||||||
|
import Stroke from "/vendor/ol/style/Stroke.js";
|
||||||
|
import CircleStyle from "/vendor/ol/style/Circle.js";
|
||||||
|
import RegularShape from "/vendor/ol/style/RegularShape.js";
|
||||||
|
import Select from "/vendor/ol/interaction/Select.js";
|
||||||
|
import { click } from "/vendor/ol/events/condition.js";
|
||||||
|
import { fromLonLat } from "/vendor/ol/proj.js";
|
||||||
|
|
||||||
|
const geojson = new GeoJSON();
|
||||||
|
const areaLabel = document.querySelector("#area");
|
||||||
|
const status = document.querySelector("#status");
|
||||||
|
const form = document.querySelector("#road-form");
|
||||||
|
const hint = document.querySelector("#hint");
|
||||||
|
const roadName = document.querySelector("#road-name");
|
||||||
|
const movementSummary = document.querySelector("#movement-summary");
|
||||||
|
const laneConvention = document.querySelector("#lane-convention");
|
||||||
|
const selectedMovementPanel = document.querySelector("#selected-movement");
|
||||||
|
const movementDetail = document.querySelector("#movement-detail");
|
||||||
|
const directionSwitch = document.querySelector("#direction-switch");
|
||||||
|
const widthInput = document.querySelector("#width");
|
||||||
|
const lanesInput = document.querySelector("#lanes");
|
||||||
|
const leftInput = document.querySelector("#left");
|
||||||
|
const rightInput = document.querySelector("#right");
|
||||||
|
const centerLineForm = document.querySelector("#center-line-form");
|
||||||
|
const centerLineSegment = document.querySelector("#center-line-segment");
|
||||||
|
const markingStyleHeading = document.querySelector("#marking-style-heading");
|
||||||
|
const centerLineStyleInput = document.querySelector("#center-line-style");
|
||||||
|
const doubleYellowOption = document.createElement("option");
|
||||||
|
doubleYellowOption.value = "double-yellow-solid"; doubleYellowOption.textContent = "双黄实线"; centerLineStyleInput.append(doubleYellowOption);
|
||||||
|
const evidence = document.querySelector("#evidence");
|
||||||
|
const diagnostics = document.querySelector("#diagnostics");
|
||||||
|
const diagnosticFilters = document.querySelector("#diagnostic-filters");
|
||||||
|
const summary = document.querySelector("#summary");
|
||||||
|
const connectionsBox = document.querySelector("#connections");
|
||||||
|
const addConnectionButton = document.querySelector("#add-connection");
|
||||||
|
const saveButton = document.querySelector("#save");
|
||||||
|
const compileButton = document.querySelector("#compile");
|
||||||
|
const dirtyState = document.querySelector("#dirty-state");
|
||||||
|
const scenePreviewToggle = document.querySelector("#scene-preview");
|
||||||
|
const selectedJunctionPanel = document.querySelector("#selected-junction");
|
||||||
|
const junctionDetail = document.querySelector("#junction-detail");
|
||||||
|
const directionArrowsToggle = document.createElement("label");
|
||||||
|
directionArrowsToggle.innerHTML = '<input data-layer="directionArrows" type="checkbox" checked> 道路方向箭头';
|
||||||
|
const markingsToggle = document.createElement("label");
|
||||||
|
markingsToggle.innerHTML = '<input data-layer="markings" type="checkbox" checked> 车道分隔线与路口转向箭头';
|
||||||
|
const centerLinesToggle = document.createElement("label");
|
||||||
|
centerLinesToggle.innerHTML = '<input data-layer="centerLines" type="checkbox" checked> 道路中心线';
|
||||||
|
const edgeLinesToggle = document.createElement("label");
|
||||||
|
edgeLinesToggle.innerHTML = '<input data-layer="edgeLines" type="checkbox"> 道路外缘线';
|
||||||
|
const controlsToggle = document.createElement("label");
|
||||||
|
controlsToggle.innerHTML = '<input data-layer="controls" type="checkbox" checked> 斑马线与停止线';
|
||||||
|
const signalsToggle = document.createElement("label");
|
||||||
|
signalsToggle.innerHTML = '<input data-layer="signals" type="checkbox" checked> 红绿灯设施';
|
||||||
|
document.querySelector('[data-layer="lanes"]').closest("label").after(directionArrowsToggle, markingsToggle, centerLinesToggle, edgeLinesToggle, controlsToggle, signalsToggle);
|
||||||
|
|
||||||
|
let state;
|
||||||
|
let selectedRoad = null;
|
||||||
|
let selectedMovement = null;
|
||||||
|
let selectedJunction = null;
|
||||||
|
let staged = [];
|
||||||
|
let manualFromEndpoint = null;
|
||||||
|
let diagnosticFilter = "all";
|
||||||
|
let scenePreview = false;
|
||||||
|
let selectedCenterLineSegment = null;
|
||||||
|
let selectedLaneSeparator = null;
|
||||||
|
let selectedEdgeLine = null;
|
||||||
|
let selectedSignal = null;
|
||||||
|
const signalPanel = document.createElement("section");
|
||||||
|
signalPanel.innerHTML = '<hr><h2>原生红绿灯</h2><button type="button" data-signal="generate">从 OSM 生成缺失信号灯</button><label>检查信号灯<select name="signal-picker"><option value="">选择设施</option></select></label><form hidden><output></output><label>灯杆经度<input name="lon" type="number" min="-180" max="180" step="0.000001"></label><label>灯杆纬度<input name="lat" type="number" min="-90" max="90" step="0.000001"></label><label>横杆方向(度)<input name="mastHeading" type="number" min="0" max="360" step="1"></label><label>横杆长度(米)<input name="mastReach" type="number" min="0.1" max="30" step="0.1"></label><label>灯面朝向(度)<input name="faceHeading" type="number" min="0" max="360" step="1"></label><label>相位组<input name="phase" type="number" min="0" max="1" step="1"></label><label><input name="enabled" type="checkbox"> 启用</label><button type="submit">保存信号灯</button><button type="button" data-signal="delete">删除信号灯</button></form>';
|
||||||
|
document.querySelector(".inspector").insertBefore(signalPanel, document.querySelector(".inspector details"));
|
||||||
|
const signalForm = signalPanel.querySelector("form");
|
||||||
|
const signalOutput = signalForm.querySelector("output");
|
||||||
|
const signalPicker = signalPanel.querySelector('[name="signal-picker"]');
|
||||||
|
const source = () => new VectorSource();
|
||||||
|
const layers = {
|
||||||
|
reference: new VectorLayer({ source: source(), visible: false, style: new Style({ fill: new Fill({ color: "rgba(123, 140, 148, .28)" }), stroke: new Stroke({ color: "#8999a0", width: 1 }) }) }),
|
||||||
|
native: new VectorLayer({ source: source(), style: nativeSurfaceStyle }),
|
||||||
|
edgeLines: new VectorLayer({ source: source(), visible: false, style: markingStyle }),
|
||||||
|
sidewalks: new VectorLayer({ source: source(), style: sidewalkSurfaceStyle }),
|
||||||
|
osm: new VectorLayer({ source: source(), style: (feature) => new Style({ stroke: new Stroke({ color: feature.get("road_id") === selectedRoad?.id ? "#006e91" : "#263630", width: feature.get("road_id") === selectedRoad?.id ? 5 : 2 }) }) }),
|
||||||
|
lanes: new VectorLayer({ source: source(), style: laneStyle }),
|
||||||
|
directionArrows: new VectorLayer({ source: source(), style: markingStyle }),
|
||||||
|
markings: new VectorLayer({ source: source(), style: markingStyle }),
|
||||||
|
centerLines: new VectorLayer({ source: source(), style: centerLineStyle }),
|
||||||
|
controls: new VectorLayer({ source: source(), style: markingStyle }),
|
||||||
|
signals: new VectorLayer({ source: source(), style: signalAssemblyStyle, zIndex: 30 }),
|
||||||
|
osmDirection: new VectorLayer({ source: source(), style: (feature) => new Style({ image: new RegularShape({ points: 3, radius: 9, rotation: feature.get("rotation"), fill: new Fill({ color: "#006e91" }), stroke: new Stroke({ color: "#fff", width: 1.5 }) }) }), zIndex: 11 }),
|
||||||
|
connectors: new VectorLayer({ source: source(), style: (feature) => effectiveConnectorEnabled(feature.getProperties()) ? new Style({ stroke: new Stroke({ color: roadIdFromLane(feature.get("from_lane_id")) === selectedRoad?.id ? "#d1226f" : "#ad3a76", width: roadIdFromLane(feature.get("from_lane_id")) === selectedRoad?.id ? 4 : 2, lineDash: [7, 5] }) }) : null }),
|
||||||
|
diagnostics: new VectorLayer({ source: source(), style: (feature) => new Style({ image: new CircleStyle({ radius: 6, fill: new Fill({ color: feature.get("severity") === "error" ? "#bf3b2e" : "#d49318" }), stroke: new Stroke({ color: "#fff", width: 1 }) }) }) }),
|
||||||
|
selectedRoad: new VectorLayer({ source: source(), style: new Style({ stroke: new Stroke({ color: "#00a5cf", width: 8 }) }), zIndex: 10 }),
|
||||||
|
selectedMovement: new VectorLayer({ source: source(), style: new Style({ stroke: new Stroke({ color: "#f0b323", width: 6 }) }), zIndex: 12 }),
|
||||||
|
};
|
||||||
|
const map = new Map({ target: "map", layers: [layers.reference, layers.native, layers.edgeLines, layers.sidewalks, layers.osm, layers.lanes, layers.directionArrows, layers.markings, layers.centerLines, layers.controls, layers.signals, layers.connectors, layers.diagnostics, layers.selectedRoad, layers.osmDirection, layers.selectedMovement], view: new View({ center: [0, 0], zoom: 2 }) });
|
||||||
|
const select = new Select({ condition: click, layers: (layer) => manualFromEndpoint ? layer === layers.osm : [layers.osm, layers.lanes, layers.directionArrows, layers.markings, layers.centerLines, layers.edgeLines, layers.controls, layers.signals, layers.connectors, layers.native, layers.diagnostics].includes(layer), hitTolerance: 12, style: null });
|
||||||
|
map.addInteraction(select);
|
||||||
|
select.on("select", ({ selected }) => {
|
||||||
|
const feature = selected[0];
|
||||||
|
if (!feature) return;
|
||||||
|
if (feature.get("signal_uid")) return selectSignal(poleFeatureForSignal(feature.get("signal_uid")) || feature);
|
||||||
|
if (manualFromEndpoint) return chooseManualTarget(roadForFeature(feature));
|
||||||
|
const junction = junctionForFeature(feature);
|
||||||
|
if (junction) return selectJunction(junction);
|
||||||
|
const provenance = feature.get("provenance");
|
||||||
|
if (provenance?.startsWith("native-road-")) {
|
||||||
|
const road = roadForFeature(feature);
|
||||||
|
const directionArrow = provenance === "native-road-direction-arrow/v1";
|
||||||
|
const turnArrow = provenance === "native-road-turn-arrow/v1";
|
||||||
|
const centerLine = provenance === "native-road-center-line/v1";
|
||||||
|
const edgeLine = provenance === "native-road-edge-line/v1";
|
||||||
|
const crosswalk = provenance === "native-road-crosswalk/v1";
|
||||||
|
const stopLine = provenance === "native-road-stop-line/v1";
|
||||||
|
const markingType = centerLine ? "道路中心线" : edgeLine ? "道路外缘线" : crosswalk ? "斑马线" : stopLine ? "停止线" : directionArrow ? "道路方向箭头" : turnArrow ? "路口转向箭头" : "车道分隔线";
|
||||||
|
selectRoad(road);
|
||||||
|
if (centerLine) selectCenterLine(feature); else if (edgeLine) selectEdgeLine(feature); else if (provenance === "native-road-lane-separator/v1") selectLaneSeparator(feature); else clearCenterLineSelection();
|
||||||
|
evidence.textContent = JSON.stringify({
|
||||||
|
标线类型: markingType,
|
||||||
|
人行横道节点: crosswalk || stopLine ? feature.get("crossing_node_id") : null,
|
||||||
|
OSM道路: feature.get("osm_way_ids"),
|
||||||
|
原生道路: feature.get("road_id"),
|
||||||
|
道路段: centerLine ? feature.get("segment_id") : null,
|
||||||
|
方向: feature.get("direction"),
|
||||||
|
车道: feature.get("lane_id") || feature.get("lane_index") || `${feature.get("left_lane_index")} 与 ${feature.get("right_lane_index")} 之间`,
|
||||||
|
转向: turnArrow ? feature.get("maneuver") : null,
|
||||||
|
样式: centerLine || edgeLine || provenance === "native-road-lane-separator/v1" ? feature.get("effective_style") : null,
|
||||||
|
放置方法: feature.get("placement_method") || null,
|
||||||
|
道路内距离米: feature.get("distance_along_lane_meters") || null,
|
||||||
|
路口前距离米: feature.get("placement_distance_meters") || null,
|
||||||
|
来源: provenance,
|
||||||
|
}, null, 2);
|
||||||
|
return message(`已选中${markingType}`);
|
||||||
|
}
|
||||||
|
const movement = state.compiled.movements?.find((item) => item.id === feature.get("movement_id")) || null;
|
||||||
|
selectRoad(roadForFeature(feature), undefined, movement);
|
||||||
|
});
|
||||||
|
map.on("pointermove", (event) => { map.getTargetElement().style.cursor = map.hasFeatureAtPixel(event.pixel, { hitTolerance: 8 }) ? "pointer" : ""; });
|
||||||
|
|
||||||
|
function message(text) { status.textContent = text; }
|
||||||
|
function updateDirtyState() {
|
||||||
|
const count = staged.length;
|
||||||
|
dirtyState.textContent = count ? `未保存修改 ${count} 项` : "所有修改已保存";
|
||||||
|
dirtyState.classList.toggle("dirty", count > 0);
|
||||||
|
saveButton.disabled = count === 0;
|
||||||
|
}
|
||||||
|
function roadLabel(road) { return road.tags.name || `${road.highway}(OSM ${road.osmWayIds.join(", ")})`; }
|
||||||
|
function osmDirectionLabel(road) { return road?.direction === "forward" ? "沿 OSM 方向" : "逆 OSM 方向"; }
|
||||||
|
function roadIdFromLane(laneId) { return typeof laneId === "string" ? laneId.slice(5, laneId.lastIndexOf(":")) : ""; }
|
||||||
|
function laneIndex(laneId) { return Number(String(laneId).split(":").at(-1)); }
|
||||||
|
function lanePositionLabel(road, index) { return road?.laneCount === 1 ? "唯一车道" : `左起第 ${index} 车道`; }
|
||||||
|
function laneStyle(feature) { const selected = feature.get("road_id") === selectedRoad?.id; return new Style({ stroke: new Stroke({ color: selected ? "#006e91" : "#f5f6ee", width: selected ? 3 : 1.3, lineDash: [5, 4] }) }); }
|
||||||
|
function markingStyle(feature) { const yellow = feature?.get("color") === "yellow"; return new Style({ fill: new Fill({ color: yellow ? "#f5be2a" : "#f5f6ee" }), stroke: new Stroke({ color: yellow ? "#d29d16" : "#d9dacf", width: 1 }) }); }
|
||||||
|
function signalAssemblyStyle(feature) { const component = feature.get("signal_component"); if (component === "mast") return [new Style({ stroke: new Stroke({ color: "#fff", width: 9 }) }), new Style({ stroke: new Stroke({ color: "#007f99", width: 5 }) })]; if (component === "face") return [new Style({ stroke: new Stroke({ color: "#fff", width: 7 }) }), new Style({ stroke: new Stroke({ color: "#df2435", width: 3 }) })]; if (component === "head") { const heading = Number(feature.get("face_heading_deg")) || 0; return new Style({ image: new RegularShape({ points: 3, radius: 8, rotation: heading * Math.PI / 180, fill: new Fill({ color: "#df2435" }), stroke: new Stroke({ color: "#fff", width: 2 }) }) }); } return new Style({ image: new RegularShape({ points: 4, radius: 6, angle: Math.PI / 4, fill: new Fill({ color: "#263630" }), stroke: new Stroke({ color: "#fff", width: 2 }) }) }); }
|
||||||
|
function centerLineStyle(feature) { const white = feature.get("color") === "white"; const color = white ? "#faf9ee" : "#f5be2a"; return new Style({ fill: new Fill({ color }), stroke: new Stroke({ color: feature.get("pattern") === "solid" ? color : white ? "#aeb0aa" : "#d29d16", width: feature.get("pattern") === "solid" ? .25 : .8 }) }); }
|
||||||
|
function nativeSurfaceStyle(feature) {
|
||||||
|
// Split road features meet at OSM junction nodes. Their per-feature outlines
|
||||||
|
// are editing aids, not physical seams, so scene mode must render fills only.
|
||||||
|
if (scenePreview) return new Style({ fill: new Fill({ color: "#3f4b50" }) });
|
||||||
|
return feature.get("native_id")?.startsWith("junction:")
|
||||||
|
? new Style({ fill: new Fill({ color: "rgba(12, 116, 91, .38)" }), stroke: new Stroke({ color: "#0e785f", width: 1.5 }) })
|
||||||
|
: new Style({ fill: new Fill({ color: "rgba(40, 105, 86, .35)" }), stroke: new Stroke({ color: "#296956", width: 1 }) });
|
||||||
|
}
|
||||||
|
function sidewalkSurfaceStyle() {
|
||||||
|
return scenePreview
|
||||||
|
? new Style({ fill: new Fill({ color: "#b7b9ad" }) })
|
||||||
|
: new Style({ fill: new Fill({ color: "rgba(218, 191, 137, .6)" }), stroke: new Stroke({ color: "#9b7c40", width: 1 }) });
|
||||||
|
}
|
||||||
|
function directionArrowFeature(geometry) { const middle = geometry.getCoordinateAt(.5); const before = geometry.getCoordinateAt(.48); const after = geometry.getCoordinateAt(.52); const length = Math.hypot(after[0] - before[0], after[1] - before[1]); if (length < .01) return null; return new Feature({ geometry: new Point(middle), rotation: Math.atan2(after[1] - before[1], after[0] - before[0]) }); }
|
||||||
|
function refreshOsmDirection() { const directionSource = layers.osmDirection.getSource(); directionSource.clear(); if (!selectedRoad) return; const centerline = new LineString(selectedRoad.centerline).transform("EPSG:4326", "EPSG:3857"); const arrow = directionArrowFeature(centerline); if (arrow) directionSource.addFeature(arrow); }
|
||||||
|
function refreshSelectedMovement() { const movementSource = layers.selectedMovement.getSource(); movementSource.clear(); if (!selectedMovement?.geometryPublished || !effectiveConnectorEnabled({ connection_id: selectedMovement.connectionId, fromLaneId: selectedMovement.fromLaneId, toLaneId: selectedMovement.toLaneId })) return; const feature = layers.connectors.getSource().getFeatures().find((candidate) => candidate.get("movement_id") === selectedMovement.id); if (feature) movementSource.addFeature(new Feature({ geometry: feature.getGeometry().clone() })); }
|
||||||
|
function roadForFeature(feature) {
|
||||||
|
const properties = feature.getProperties();
|
||||||
|
const roadId = properties.road_id || properties.subjectId || roadIdFromLane(properties.from_lane_id) || properties.directional_road_ids?.split(",")[0];
|
||||||
|
return state.compiled.model.roads.find((road) => road.id === roadId) || null;
|
||||||
|
}
|
||||||
|
function junctionForFeature(feature) { const id = feature.get("native_id"); return id?.startsWith("junction:") ? layers.native.getSource().getFeatures().find((item) => item.get("native_id") === id) : null; }
|
||||||
|
function endpointFor(road, side) { return state.compiled.model.endpoints.find((endpoint) => endpoint.roadId === road?.id && endpoint.side === side) || null; }
|
||||||
|
function endpointsCompatible(from, to) { if (!from || !to || from.roadId === to.roadId || from.side !== "end" || to.side !== "start") return false; if (from.nodeId === to.nodeId) return true; const dx = (from.coordinate[0] - to.coordinate[0]) * 111320 * Math.cos(from.coordinate[1] * Math.PI / 180); const dy = (from.coordinate[1] - to.coordinate[1]) * 111320; return Math.hypot(dx, dy) <= 35; }
|
||||||
|
function readFeatures(collection) { return geojson.readFeatures(collection || { type: "FeatureCollection", features: [] }, { dataProjection: "EPSG:4326", featureProjection: "EPSG:3857" }); }
|
||||||
|
function rawRoadFeatures() { return state.compiled.model.roads.map((road) => new Feature({ geometry: new LineString(road.centerline).transform("EPSG:4326", "EPSG:3857"), road_id: road.id })); }
|
||||||
|
function updateSources() {
|
||||||
|
layers.reference.getSource().clear(); layers.reference.getSource().addFeatures(readFeatures(state.layers.osm2streetsRoadSurface));
|
||||||
|
layers.native.getSource().clear(); layers.native.getSource().addFeatures([...readFeatures(state.layers.nativeRoadSurface), ...readFeatures(state.layers.nativeIntersectionSurface)]);
|
||||||
|
layers.sidewalks.getSource().clear(); layers.sidewalks.getSource().addFeatures(readFeatures(state.layers.nativeSidewalkSurface));
|
||||||
|
layers.osm.getSource().clear(); layers.osm.getSource().addFeatures(rawRoadFeatures());
|
||||||
|
layers.lanes.getSource().clear(); layers.lanes.getSource().addFeatures(readFeatures(state.layers.laneCenterlines));
|
||||||
|
layers.edgeLines.getSource().clear(); layers.edgeLines.getSource().addFeatures(readFeatures(state.layers.edgeLines));
|
||||||
|
layers.directionArrows.getSource().clear(); layers.directionArrows.getSource().addFeatures(readFeatures(state.layers.directionArrows));
|
||||||
|
layers.markings.getSource().clear(); layers.markings.getSource().addFeatures([...readFeatures(state.layers.laneSeparators), ...readFeatures(state.layers.turnArrows)]);
|
||||||
|
layers.centerLines.getSource().clear(); layers.centerLines.getSource().addFeatures(readFeatures(state.layers.centerLines));
|
||||||
|
layers.controls.getSource().clear(); layers.controls.getSource().addFeatures([...readFeatures(state.layers.crosswalks), ...readFeatures(state.layers.vehicleStopLines)]);
|
||||||
|
const signalFeatures = readFeatures(state.trafficSignals?.assemblies || { type: "FeatureCollection", features: [] }); const armFeatures = []; const faceFeatures = []; const headFeatures = []; for (const signal of state.trafficRuntime?.signals || []) { const arm = signal.pose?.arm; const head = signal.pose?.head; if (!arm || !head) continue; const properties = { signal_uid: signal.id }; const headPoint = fromLonLat([head.longitude, head.latitude]); const radians = Number(head.faceHeadingDegrees) * Math.PI / 180; const faceEnd = [headPoint[0] + Math.sin(radians) * 2.5, headPoint[1] + Math.cos(radians) * 2.5]; armFeatures.push(new Feature({ geometry: new LineString([fromLonLat([arm.from.longitude, arm.from.latitude]), fromLonLat([arm.to.longitude, arm.to.latitude])]), signal_component: "mast", ...properties })); faceFeatures.push(new Feature({ geometry: new LineString([headPoint, faceEnd]), signal_component: "face", ...properties })); headFeatures.push(new Feature({ geometry: new Point(faceEnd), signal_component: "head", face_heading_deg: head.faceHeadingDegrees, ...properties })); } layers.signals.getSource().clear(); layers.signals.getSource().addFeatures([...armFeatures, ...faceFeatures, ...signalFeatures, ...headFeatures]); const pickerValue = signalPicker.value; signalPicker.replaceChildren(new Option("选择设施", "")); signalFeatures.forEach((feature) => signalPicker.add(new Option(feature.get("display_id") || feature.get("signal_uid"), feature.get("signal_uid")))); signalPicker.value = pickerValue;
|
||||||
|
layers.connectors.getSource().clear(); layers.connectors.getSource().addFeatures(readFeatures(state.layers.connectors));
|
||||||
|
layers.diagnostics.getSource().clear(); layers.diagnostics.getSource().addFeatures(readFeatures({ type: "FeatureCollection", features: state.compiled.diagnostics.filter((item) => item.geometry).map(({ geometry, ...properties }) => ({ type: "Feature", properties, geometry })) }));
|
||||||
|
const extent = layers.osm.getSource().getExtent(); if (Number.isFinite(extent[0])) map.getView().fit(extent, { padding: [48, 48, 48, 48], maxZoom: 19 });
|
||||||
|
}
|
||||||
|
function laneId(connection, side) { return connection[side === "from" ? "fromLaneId" : "toLaneId"] || connection[side === "from" ? "from_lane_id" : "to_lane_id"]; }
|
||||||
|
function effectiveLaneEnabled(connector) { const id = `车道连接:${laneId(connector, "from")}->${laneId(connector, "to")}`; const override = [...staged, ...state.overrides.overrides].find((item) => item.id === id); return override ? override.enabled : connector.enabled !== false; }
|
||||||
|
function effectiveConnectionEnabled(connection) { const id = `连接:${connection.id}`; const override = [...staged, ...state.overrides.overrides].find((item) => item.id === id); return override ? override.enabled : connection.enabled; }
|
||||||
|
function effectiveConnectorEnabled(connector) { const connection = state?.compiled.model.connections.find((item) => item.id === connector.connection_id); return effectiveLaneEnabled(connector) && (!connection || effectiveConnectionEnabled(connection)); }
|
||||||
|
|
||||||
|
function selectRoad(road, note, movement = null) {
|
||||||
|
selectedRoad = road; selectedMovement = movement; selectedJunction = null; selectedJunctionPanel.hidden = true; layers.osm.changed(); layers.lanes.changed(); layers.connectors.changed(); refreshOsmDirection(); refreshSelectedMovement();
|
||||||
|
layers.selectedRoad.getSource().clear(); if (road) layers.selectedRoad.getSource().addFeature(new Feature({ geometry: new LineString(road.centerline).transform("EPSG:4326", "EPSG:3857") }));
|
||||||
|
form.hidden = !road; hint.hidden = Boolean(road); if (!road) return;
|
||||||
|
roadName.textContent = `${roadLabel(road)}(${osmDirectionLabel(road)})`;
|
||||||
|
widthInput.value = road.widthMeters; lanesInput.value = road.laneCount; leftInput.checked = road.sidewalkLeft; rightInput.checked = road.sidewalkRight;
|
||||||
|
evidence.textContent = JSON.stringify({ OSM道路: road.osmWayIds, 当前方向节点顺序: road.sourceNodeIds, 参数来源: road.provenance, 已应用修改: road.appliedOverrideIds, 原始标签: road.tags }, null, 2);
|
||||||
|
laneConvention.textContent = road.laneCount === 1 ? "蓝色箭头在 OSM 原始中心线上,表示当前方向;“沿 OSM 方向”即节点顺序。本方向只有一条车道。" : "蓝色箭头在 OSM 原始中心线上,表示当前方向;“沿 OSM 方向”即节点顺序。车道按行驶方向从左向右编号。";
|
||||||
|
renderDirectionSwitch(road); renderMovementSummary(road); renderSelectedMovement(); renderConnections(road); message(note || (selectedMovement ? `已选中行驶动作:${turnLabel(selectedMovement.turn)}` : `已选中:${roadLabel(road)}`));
|
||||||
|
}
|
||||||
|
function selectJunction(feature) {
|
||||||
|
selectedJunction = feature; selectedRoad = null; selectedMovement = null; form.hidden = true; hint.hidden = true; selectedJunctionPanel.hidden = false;
|
||||||
|
const properties = feature.getProperties(); const roadIds = String(properties.source_road_ids || "").split(",").filter(Boolean);
|
||||||
|
const roads = roadIds.map((id) => state.compiled.model.roads.find((road) => road.id === id)).filter(Boolean);
|
||||||
|
junctionDetail.textContent = JSON.stringify({ OSM节点: properties.osm_node_id, 类型: properties.kind === "t" ? "T字路口" : "十字路口", 参与方向道路: roads.map((road) => ({ 道路: roadLabel(road), OSM道路: road.osmWayIds, 节点顺序: road.sourceNodeIds })), 构面规则: properties.rule, 边界策略: properties.boundary_mode, 基础截面面积平方米: properties.approach_area_m2, 最终路口面积平方米: properties.surface_area_m2, 外缘扩张倍率: properties.expansion_ratio, 路口退让距离米: properties.cutback_m, 行驶动作数: properties.movement_count, 已绘制连接数: properties.connector_count }, null, 2);
|
||||||
|
message(`已选中路口:OSM 节点 ${properties.osm_node_id}`);
|
||||||
|
}
|
||||||
|
function selectSignal(feature) {
|
||||||
|
selectedSignal = feature.get("signal_uid"); const p = feature.getProperties(); signalPicker.value = selectedSignal;
|
||||||
|
const [x, y] = feature.getGeometry().getCoordinates();
|
||||||
|
map.getView().fit([x - 25, y - 25, x + 25, y + 25], { padding: [80, 80, 80, 360], maxZoom: 22, duration: 250 });
|
||||||
|
signalForm.hidden = false; signalOutput.textContent = `${p.display_id || p.signal_uid}(${p.signal_uid})`;
|
||||||
|
signalForm.lon.value = feature.getGeometry().clone().transform("EPSG:3857", "EPSG:4326").getCoordinates()[0];
|
||||||
|
signalForm.lat.value = feature.getGeometry().clone().transform("EPSG:3857", "EPSG:4326").getCoordinates()[1];
|
||||||
|
signalForm.mastHeading.value = p.mast_heading_deg; signalForm.mastReach.value = p.mast_reach_m; signalForm.faceHeading.value = p.face_heading_deg; signalForm.phase.value = p.phase_group; signalForm.enabled.checked = p.enabled;
|
||||||
|
evidence.textContent = JSON.stringify({ 信号灯: p.signal_uid, 控制节点: p.control_id, 路口方向: p.approach_id, 来源: state.trafficSignals.provenance }, null, 2); message("已选中原生红绿灯");
|
||||||
|
}
|
||||||
|
function poleFeatureForSignal(signalUid) { return layers.signals.getSource().getFeatures().find((item) => item.get("signal_uid") === signalUid && !item.get("signal_component")); }
|
||||||
|
async function saveSignals(document) { const response = await fetch("/api/traffic-signals", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(document) }); const result = await response.json(); if (!result.ok) throw new Error(result.error); state.trafficSignals = result.trafficSignals; state.trafficRuntime = result.runtime; updateSources(); renderSummary(); }
|
||||||
|
function signalDocumentWithChange(change) { const document = structuredClone(state.trafficSignals); document.assemblies.features = change(document.assemblies.features); return document; }
|
||||||
|
signalForm.onsubmit = async (event) => { event.preventDefault(); try { await saveSignals(signalDocumentWithChange((features) => features.map((feature) => feature.properties.signal_uid !== selectedSignal ? feature : { ...feature, geometry: { type: "Point", coordinates: [Number(signalForm.lon.value), Number(signalForm.lat.value)] }, properties: { ...feature.properties, mast_heading_deg: Number(signalForm.mastHeading.value), mast_reach_m: Number(signalForm.mastReach.value), face_heading_deg: Number(signalForm.faceHeading.value), phase_group: Number(signalForm.phase.value), enabled: signalForm.enabled.checked } }))); message("红绿灯已保存"); } catch (error) { message(error.message); } };
|
||||||
|
signalPanel.querySelector('[data-signal="delete"]').onclick = async () => { try { await saveSignals(signalDocumentWithChange((features) => features.filter((feature) => feature.properties.signal_uid !== selectedSignal))); signalForm.hidden = true; selectedSignal = null; message("红绿灯已删除"); } catch (error) { message(error.message); } };
|
||||||
|
signalPanel.querySelector('[data-signal="generate"]').onclick = async () => { try { const response = await fetch("/api/traffic-signals/generate", { method: "POST" }); const result = await response.json(); if (!result.ok) throw new Error(result.error); state.trafficSignals = result.trafficSignals; state.trafficRuntime = result.runtime; updateSources(); message("已补充 OSM 信号灯"); } catch (error) { message(error.message); } };
|
||||||
|
signalPicker.onchange = () => { const feature = poleFeatureForSignal(signalPicker.value); if (feature) selectSignal(feature); };
|
||||||
|
function turnLabel(turn) { return { left: "左转", through: "直行", right: "右转", uturn: "掉头" }[turn] || turn; }
|
||||||
|
function renderSelectedMovement() { selectedMovementPanel.hidden = !selectedMovement; if (!selectedMovement) return; const targetRoad = state.compiled.model.roads.find((road) => road.id === selectedMovement.toRoadId); const geometry = selectedMovement.geometryStatus === "connector" ? "已绘制路径" : selectedMovement.geometryStatus === "continuous" ? "节点连续" : "路径过长未绘制"; movementDetail.textContent = `${turnLabel(selectedMovement.turn)}:${lanePositionLabel(selectedRoad, laneIndex(selectedMovement.fromLaneId))} → ${lanePositionLabel(targetRoad, laneIndex(selectedMovement.toLaneId))}\n目标:${roadLabel(targetRoad)}(${osmDirectionLabel(targetRoad)})\n来源端点:${selectedRoad.sourceNodeIds.at(-1)};目标端点:${targetRoad.sourceNodeIds[0]}\n路口节点:${selectedMovement.nodeId}\n状态:${geometry}\n来源:${selectedMovement.provenance}`; }
|
||||||
|
function renderDirectionSwitch(road) {
|
||||||
|
directionSwitch.innerHTML = ""; const alternatives = state.compiled.model.roads.filter((item) => item.osmWayIds.join(",") === road.osmWayIds.join(","));
|
||||||
|
if (alternatives.length < 2) { directionSwitch.textContent = "单向道路"; return; }
|
||||||
|
for (const item of alternatives) { const button = document.createElement("button"); button.type = "button"; button.textContent = osmDirectionLabel(item); button.disabled = item.id === road.id; button.onclick = () => selectRoad(item); directionSwitch.append(button); }
|
||||||
|
}
|
||||||
|
function renderMovementSummary(road) { const movements = state.compiled.movements?.filter((movement) => movement.fromRoadId === road.id && effectiveConnectorEnabled({ connection_id: movement.connectionId, fromLaneId: movement.fromLaneId, toLaneId: movement.toLaneId })) || []; const turns = movements.reduce((result, item) => { result[item.turn] = (result[item.turn] || 0) + 1; return result; }, {}); const labels = { left: "左转", through: "直行", right: "右转", uturn: "掉头" }; const published = movements.filter((movement) => movement.geometryPublished).length; movementSummary.textContent = movements.length ? `已识别 ${movements.length} 个行驶动作,${published} 条已绘制路径:${Object.entries(turns).map(([key, value]) => `${labels[key] || key} ${value}`).join(",")}` : "当前方向没有已识别的行驶动作"; }
|
||||||
|
function renderConnections(road) {
|
||||||
|
connectionsBox.innerHTML = ""; const endpoint = state.compiled.model.endpoints.find((item) => item.roadId === road.id && item.side === "end"); addConnectionButton.hidden = !endpoint; const rows = state.compiled.model.connections.filter((connection) => connection.fromEndpointId === endpoint?.id);
|
||||||
|
if (!rows.length) connectionsBox.textContent = "当前方向到达终点后没有已识别的驶出道路。";
|
||||||
|
for (const connection of rows) { const target = state.compiled.model.roads.find((item) => item.id === state.compiled.model.endpoints.find((endpointItem) => endpointItem.id === connection.toEndpointId)?.roadId); if (!target) continue; const label = document.createElement("label"); const input = document.createElement("input"); input.type = "checkbox"; input.checked = effectiveConnectionEnabled(connection); input.onchange = () => { stageConnection(connection, input.checked); selectRoad(road, "有未保存修改:转向路径已即时更新"); }; label.append(input, ` ${turnName(road, target)}:${roadLabel(target)}(${osmDirectionLabel(target)})`); connectionsBox.append(label); renderLaneControls(connection); }
|
||||||
|
renderManualCandidates(endpoint, road);
|
||||||
|
}
|
||||||
|
function renderManualCandidates(endpoint, road) { const candidates = state.compiled.diagnostics.find((item) => item.endpointId === endpoint?.id)?.manualCandidates || []; if (!candidates.length) return; const title = document.createElement("p"); title.textContent = "附近可手工连接的驶出方向"; connectionsBox.append(title); for (const candidate of candidates) { const target = state.compiled.model.roads.find((item) => item.id === candidate.roadId); if (!target) continue; const button = document.createElement("button"); button.type = "button"; button.textContent = `${roadLabel(target)}(${candidate.distanceMeters} 米)`; button.onclick = () => { stageConnection({ id: `connection:${endpoint.id}:${candidate.toEndpointId}`, fromEndpointId: endpoint.id, toEndpointId: candidate.toEndpointId }, true); selectRoad(road, "有未保存修改:手工连接已暂存;保存并重新生成后会出现转向路径"); }; connectionsBox.append(button); } }
|
||||||
|
function renderLaneControls(connection) { const rows = state.compiled.movements?.filter((movement) => movement.connectionId === connection.id) || []; for (const row of rows) { const targetRoad = state.compiled.model.roads.find((road) => road.id === row.toRoadId); const label = document.createElement("label"); const input = document.createElement("input"); input.type = "checkbox"; input.checked = effectiveLaneEnabled(row); input.onchange = () => { stageLaneConnection(row, input.checked); selectRoad(selectedRoad, "有未保存修改:转向路径已即时更新"); }; const geometryNote = row.geometryStatus === "continuous" ? ",节点连续" : row.geometryStatus === "deferred-too-long" ? ",路径过长未绘制" : ""; label.append(input, ` ${lanePositionLabel(selectedRoad, laneIndex(row.fromLaneId))} → ${lanePositionLabel(targetRoad, laneIndex(row.toLaneId))}(${osmDirectionLabel(targetRoad)}${geometryNote})`); connectionsBox.append(label); } }
|
||||||
|
function turnName(from, to) { const heading = (a, b) => Math.atan2(b[0] - a[0], b[1] - a[1]) * 180 / Math.PI; const delta = ((heading(to.centerline[0], to.centerline[1]) - heading(from.centerline.at(-2), from.centerline.at(-1)) + 540) % 360) - 180; return Math.abs(delta) >= 150 ? "掉头" : Math.abs(delta) <= 30 ? "直行" : delta > 0 ? "右转" : "左转"; }
|
||||||
|
function stageConnection(connection, enabled) { const id = `连接:${connection.id}`; staged = staged.filter((item) => item.id !== id); staged.push({ id, kind: "junction-connection", fromEndpointId: connection.fromEndpointId, toEndpointId: connection.toEndpointId, enabled }); layers.connectors.changed(); updateDirtyState(); }
|
||||||
|
function stageLaneConnection(connector, enabled) { const fromLaneId = laneId(connector, "from"); const toLaneId = laneId(connector, "to"); const id = `车道连接:${fromLaneId}->${toLaneId}`; staged = staged.filter((item) => item.id !== id); staged.push({ id, kind: "lane-connection", fromLaneId, toLaneId, enabled }); layers.connectors.changed(); updateDirtyState(); }
|
||||||
|
function chooseManualTarget(targetRoad) { const toEndpoint = endpointFor(targetRoad, "start"); if (!endpointsCompatible(manualFromEndpoint, toEndpoint)) return message("该方向的起点与当前道路终点不兼容:必须是同一路口,或相距不超过 35 米。"); const connection = { id: `connection:${manualFromEndpoint.id}:${toEndpoint.id}`, fromEndpointId: manualFromEndpoint.id, toEndpointId: toEndpoint.id }; manualFromEndpoint = null; stageConnection(connection, true); selectRoad(selectedRoad, "有未保存修改:手工连接已暂存;保存并重新生成后会出现转向路径"); }
|
||||||
|
addConnectionButton.onclick = () => { const endpoint = endpointFor(selectedRoad, "end"); if (!endpoint) return; manualFromEndpoint = endpoint; select.getFeatures().clear(); message("请在地图上点击目标方向的 OSM 中心线;仅同一路口或 35 米内的驶出方向可连接。"); };
|
||||||
|
function focusDiagnostic(item) { const feature = layers.diagnostics.getSource().getFeatures().find((candidate) => candidate.get("id") === item.id); if (feature) map.getView().fit(feature.getGeometry().getExtent(), { padding: [80, 80, 80, 360], maxZoom: 18, duration: 250 }); const junction = layers.native.getSource().getFeatures().find((candidate) => candidate.get("native_id") === item.subjectId); if (junction) return selectJunction(junction); selectRoad(state.compiled.model.roads.find((road) => road.id === item.subjectId), `已定位:${item.message}`); }
|
||||||
|
function diagnosticLabel(item) { const road = state.compiled.model.roads.find((candidate) => candidate.id === item.subjectId); if (item.rule !== "unconnected-interior-road-end" || !road) return item.message; const candidateCount = item.manualCandidates?.length || 0; return `${roadLabel(road)}(${osmDirectionLabel(road)},节点 ${item.sourceIds[0]}):内部端点未连接${candidateCount ? `,附近有 ${candidateCount} 个可手工连接候选` : ""}`; }
|
||||||
|
function renderDiagnostics() { const all = state.compiled.diagnostics.filter((diagnostic) => diagnostic.rule !== "ordinary-junction-surface"); const counts = { all: all.length, candidates: all.filter((item) => item.manualCandidates?.length).length, other: all.filter((item) => !item.manualCandidates?.length).length }; for (const button of diagnosticFilters.querySelectorAll("button")) { const filter = button.dataset.diagnosticFilter; button.classList.toggle("active", filter === diagnosticFilter); button.textContent = `${filter === "all" ? "全部" : filter === "candidates" ? "可连接" : "其他"}(${counts[filter]})`; } const visible = all.filter((item) => diagnosticFilter === "all" || diagnosticFilter === "candidates" ? Boolean(item.manualCandidates?.length) : !item.manualCandidates?.length).sort((a, b) => (b.manualCandidates?.length || 0) - (a.manualCandidates?.length || 0)); diagnostics.innerHTML = ""; for (const item of visible) { const button = document.createElement("button"); button.textContent = diagnosticLabel(item); button.onclick = () => focusDiagnostic(item); diagnostics.append(button); } }
|
||||||
|
function renderSummary() {
|
||||||
|
const comparison = state.comparison;
|
||||||
|
const rows = [
|
||||||
|
["方向道路", comparison.nativeRoadCount],
|
||||||
|
["路缘与步行带", comparison.nativeSidewalkSurfaceFeatures],
|
||||||
|
["路口面", comparison.nativeJunctionSurfaceFeatures],
|
||||||
|
["普通构面路口", comparison.nativeApproachEnvelopeJunctions],
|
||||||
|
["兜底构面路口", comparison.nativeFallbackJunctions],
|
||||||
|
["最大外缘扩张", comparison.nativeMaxJunctionExpansionRatio],
|
||||||
|
["道路中心虚线", comparison.nativeCenterLineFeatures],
|
||||||
|
["道路方向箭头", comparison.nativeDirectionArrowFeatures],
|
||||||
|
["路口转向箭头", comparison.nativeTurnArrowFeatures],
|
||||||
|
["斑马线条带", comparison.nativeCrosswalkFeatures],
|
||||||
|
["停止线", comparison.nativeVehicleStopLineFeatures],
|
||||||
|
["红绿灯设施", state.trafficSignals?.assemblies?.features?.length || 0],
|
||||||
|
["行驶动作", comparison.nativeMovementCount],
|
||||||
|
["已绘制路径", comparison.nativePublishedMovementCount],
|
||||||
|
["可手工复核", comparison.unconnectedEndsWithManualCandidates],
|
||||||
|
["内部断头", comparison.unconnectedInteriorRoadEnds],
|
||||||
|
["osm2streets 参考", comparison.osm2streetsAvailable ? comparison.osm2streetsRoadSurfaceFeatures : "无"],
|
||||||
|
];
|
||||||
|
summary.innerHTML = "";
|
||||||
|
for (const [label, value] of rows) {
|
||||||
|
const term = document.createElement("dt"); const detail = document.createElement("dd");
|
||||||
|
term.textContent = label; detail.textContent = value; summary.append(term, detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function stageRoadOverride(road, changes) { const id = `道路:${road.id}`; const existing = staged.find((item) => item.id === id) || state.overrides.overrides.find((item) => item.id === id); staged = staged.filter((item) => item.id !== id); staged.push({ ...existing, id, kind: "road", roadId: road.id, ...changes }); }
|
||||||
|
function setMarkingStyleForm(title, target, style, allowsDouble) { centerLineForm.hidden = false; markingStyleHeading.textContent = title; centerLineSegment.textContent = target; doubleYellowOption.hidden = !allowsDouble; centerLineStyleInput.value = style || "yellow-dashed"; }
|
||||||
|
function selectCenterLine(feature) { selectedCenterLineSegment = feature.get("segment_id"); selectedLaneSeparator = null; setMarkingStyleForm("道路中心线样式", `道路段:${selectedCenterLineSegment}`, feature.get("effective_style"), true); }
|
||||||
|
function selectLaneSeparator(feature) { selectedCenterLineSegment = null; selectedLaneSeparator = feature.getProperties(); setMarkingStyleForm("车道分隔线样式", `第 ${selectedLaneSeparator.left_lane_index} 与第 ${selectedLaneSeparator.right_lane_index} 车道之间`, selectedLaneSeparator.effective_style || "white-dashed", false); }
|
||||||
|
function selectEdgeLine(feature) { selectedCenterLineSegment = null; selectedLaneSeparator = null; selectedEdgeLine = feature.getProperties(); setMarkingStyleForm("道路外缘线样式", `${selectedEdgeLine.side === "left" ? "左" : "右"}侧外缘`, selectedEdgeLine.effective_style || "white-solid", false); }
|
||||||
|
function clearCenterLineSelection() { selectedCenterLineSegment = null; selectedLaneSeparator = null; selectedEdgeLine = null; centerLineForm.hidden = true; }
|
||||||
|
function stageCenterLineStyle(segmentId, style) { const parts = style.split("-"); const double = parts[0] === "double"; const [color, pattern] = double ? parts.slice(1) : parts; const id = `道路中心线:${segmentId}`; const existing = staged.find((item) => item.id === id) || state.overrides.overrides.find((item) => item.id === id); staged = staged.filter((item) => item.id !== id); staged.push({ ...existing, id, kind: "center-line-style", segmentId, color, pattern, double }); }
|
||||||
|
form.onsubmit = (event) => { event.preventDefault(); const roadChanges = { widthMeters: Number(widthInput.value), laneCount: Number(lanesInput.value), sidewalkLeft: leftInput.checked, sidewalkRight: rightInput.checked }; stageRoadOverride(selectedRoad, roadChanges); const opposite = state.compiled.model.roads.find((road) => road.id !== selectedRoad.id && road.segmentId === selectedRoad.segmentId); if (opposite) stageRoadOverride(opposite, { sidewalkLeft: rightInput.checked, sidewalkRight: leftInput.checked }); updateDirtyState(); message(opposite ? "有未保存修改:双向道路的路缘与步行带已按实际侧边同步" : "有未保存修改"); };
|
||||||
|
function stageSelectedCenterLineStyle() { if (!selectedCenterLineSegment && !selectedLaneSeparator && !selectedEdgeLine) return; if (selectedCenterLineSegment) stageCenterLineStyle(selectedCenterLineSegment, centerLineStyleInput.value); else { const [color, pattern] = centerLineStyleInput.value.split("-"); const item = selectedLaneSeparator || selectedEdgeLine; const id = selectedLaneSeparator ? `车道分隔线:${item.road_id}:${item.left_lane_index}-${item.right_lane_index}` : `道路外缘线:${item.road_id}:${item.side}`; staged = staged.filter((change) => change.id !== id); staged.push(selectedLaneSeparator ? { id, kind: "lane-separator-style", roadId: item.road_id, leftLaneIndex: item.left_lane_index, rightLaneIndex: item.right_lane_index, color, pattern } : { id, kind: "edge-line-style", roadId: item.road_id, side: item.side, color, pattern }); } updateDirtyState(); message("有未保存修改:线样式"); }
|
||||||
|
centerLineForm.onsubmit = (event) => { event.preventDefault(); stageSelectedCenterLineStyle(); };
|
||||||
|
centerLineStyleInput.onchange = stageSelectedCenterLineStyle;
|
||||||
|
async function saveStagedChanges() { if (!staged.length) return true; const existing = state.overrides.overrides.filter((item) => !staged.some((change) => change.id === item.id)); const response = await fetch("/api/overrides", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ schema: "native-road-overrides/v1", overrides: [...existing, ...staged] }) }); const result = await response.json(); if (!result.ok) { message(result.error); return false; } state.overrides = result.overrides; staged = []; updateDirtyState(); return true; }
|
||||||
|
saveButton.onclick = async () => { if (await saveStagedChanges()) message("已保存,点击“保存并重新生成”写入几何"); };
|
||||||
|
compileButton.onclick = async () => { if (!await saveStagedChanges()) return; message("正在保存修改并重新生成..."); const response = await fetch("/api/compile", { method: "POST" }); state = await response.json(); staged = []; updateDirtyState(); updateSources(); renderDiagnostics(); renderSummary(); selectRoad(selectedRoad ? state.compiled.model.roads.find((road) => road.id === selectedRoad.id) : null); message("已保存并重新生成"); };
|
||||||
|
for (const input of document.querySelectorAll("[data-layer]")) input.onchange = () => { const visible = input.checked; layers[input.dataset.layer].setVisible(visible); if (input.dataset.layer === "osm") layers.osmDirection.setVisible(visible); };
|
||||||
|
scenePreviewToggle.onchange = () => {
|
||||||
|
scenePreview = scenePreviewToggle.checked;
|
||||||
|
for (const input of document.querySelectorAll("[data-layer]")) {
|
||||||
|
const layer = input.dataset.layer;
|
||||||
|
if (["osm", "lanes", "reference"].includes(layer)) layers[layer].setVisible(!scenePreview && input.checked);
|
||||||
|
}
|
||||||
|
layers.osmDirection.setVisible(!scenePreview && document.querySelector('[data-layer="osm"]').checked);
|
||||||
|
layers.connectors.setVisible(!scenePreview && document.querySelector('[data-layer="lanes"]').checked);
|
||||||
|
layers.sidewalks.setVisible(document.querySelector('[data-layer="sidewalks"]').checked);
|
||||||
|
layers.centerLines.setVisible(document.querySelector('[data-layer="centerLines"]').checked);
|
||||||
|
layers.controls.setVisible(document.querySelector('[data-layer="controls"]').checked);
|
||||||
|
const signalsVisible = document.querySelector('[data-layer="signals"]').checked;
|
||||||
|
layers.signals.setVisible(signalsVisible);
|
||||||
|
layers.diagnostics.setVisible(!scenePreview);
|
||||||
|
layers.native.changed(); layers.sidewalks.changed();
|
||||||
|
message(scenePreview ? "场景效果预览:当前编译面" : "编辑图层预览");
|
||||||
|
};
|
||||||
|
for (const button of diagnosticFilters.querySelectorAll("button")) button.onclick = () => { diagnosticFilter = button.dataset.diagnosticFilter; renderDiagnostics(); };
|
||||||
|
fetch("/api/state").then((response) => response.json()).then((value) => { state = value; updateDirtyState(); updateSources(); renderDiagnostics(); renderSummary(); areaLabel.textContent = state.areaId; const signalUid = new URLSearchParams(location.search).get("signal"); const signal = signalUid && poleFeatureForSignal(signalUid); if (signal) selectSignal(signal); message(`已加载 ${state.compiled.model.roads.length} 条方向道路`); }).catch((error) => message(error.message));
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>道路编译工作台</title><link rel="stylesheet" href="/vendor/ol/ol.css"><link rel="stylesheet" href="/app.css"></head>
|
||||||
|
<body><header><strong>道路编译工作台</strong><span id="area"></span><span id="status"></span><span id="dirty-state" aria-live="polite"></span><label style="display:inline;margin:0 0 0 auto;white-space:nowrap"><input id="scene-preview" type="checkbox"> 场景效果</label><button id="save">保存修改</button><button id="compile">保存并重新生成</button></header>
|
||||||
|
<main><aside class="issues"><h1>图层</h1><label><input data-layer="osm" type="checkbox" checked> OSM 道路中心线</label><label><input data-layer="native" type="checkbox" checked> 自研道路与路口面</label><label><input data-layer="sidewalks" type="checkbox" checked> 路缘与步行带</label><label><input data-layer="lanes" type="checkbox" checked> 车道与转向路径</label><label><input data-layer="reference" type="checkbox"> osm2streets 参考面</label><hr><h1>当前编译概览</h1><dl id="summary"></dl><hr><h1>待检查问题</h1><div id="diagnostic-filters" class="segmented"><button data-diagnostic-filter="all" type="button">全部</button><button data-diagnostic-filter="candidates" type="button">可连接</button><button data-diagnostic-filter="other" type="button">其他</button></div><ul id="diagnostics"></ul></aside><section id="map" class="map"></section><aside class="inspector"><h1>当前道路设置</h1><p id="hint">点击道路、车道、转向路径或路口面以查看详情。</p><section id="selected-junction" hidden><h2>当前路口</h2><output id="junction-detail"></output></section><form id="road-form" hidden><label>道路</label><output id="road-name"></output><output id="movement-summary"></output><output id="lane-convention"></output><section id="selected-movement" hidden><h2>当前行驶动作</h2><output id="movement-detail"></output></section><div id="direction-switch"></div><label>本方向道路宽度(米)<input id="width" type="number" min="1" step="0.01"></label><label>本方向车道数<input id="lanes" type="number" min="1" step="1"></label><label><input id="left" type="checkbox"> 左侧有路缘与步行带</label><label><input id="right" type="checkbox"> 右侧有路缘与步行带</label><button type="submit">暂存本道路修改</button></form><form id="center-line-form" hidden><h2 id="marking-style-heading">道路中心线样式</h2><output id="center-line-segment"></output><label>样式<select id="center-line-style"><option value="yellow-dashed">黄色虚线(默认)</option><option value="white-dashed">白色虚线</option><option value="yellow-solid">黄色实线</option><option value="white-solid">白色实线</option></select></label><button type="submit">暂存标线样式</button></form><hr><h2>路口连接</h2><div id="connections">请选择一条道路。</div><button id="add-connection" type="button" hidden>手工新增驶出连接</button><details><summary>技术详情与来源</summary><pre id="evidence">无</pre></details></aside></main><script type="importmap">{"imports":{"rbush":"/vendor/rbush/index.js","quickselect":"/vendor/quickselect/index.js"}}</script><script type="module" src="/app.js"></script></body></html>
|
||||||
Reference in new issue
Block a user