通用化项目结构:Blender 脚本去硬编码、config 路径占位符、layerPrefix 配置
- blender/generate_nantaizi.py → blender/generate_scene.py(去硬编码路径, --geojson 改为可选,--office-overrides 替代硬编码 way ID) - blender/export_cesium.py CLI 参数改为必传,修复隐藏物体导出崩溃 - blender/README.md 重写为中文通用文档 - config/default.json 路径改为占位符,template.json 新增 blender 配置块 - scripts/build-osm2streets-qgis.js 新增 layerPrefix 配置驱动 QGIS 图层名 - package.json name → osm-gis-pipeline - README.md 重写并增加实际运行示例
This commit is contained in:
172
README.md
172
README.md
@@ -1,19 +1,6 @@
|
||||
# osm2streets QGIS workflow
|
||||
# OSM GIS Pipeline
|
||||
|
||||
把 Overpass/OSM XML 转成接近 osm2streets web 风格的 QGIS 工程。
|
||||
|
||||
当前默认输入输出在 [config/default.json](/Users/que01/osm2streets-qgis-workflow/config/default.json) 里配置:
|
||||
|
||||
- 输入 OSM XML:`/Users/que01/Downloads/osm.xml`
|
||||
- 中间 GeoJSON:`/Users/que01/Downloads/osm2streets_web_out/`
|
||||
- GeoPackage:`/Users/que01/Downloads/osm2streets_webstyle.gpkg`
|
||||
- QGIS 工程:`/Users/que01/Downloads/osm2streets_webstyle.qgz`
|
||||
- 预览图:`/Users/que01/Downloads/osm2streets_webstyle_preview.png`
|
||||
|
||||
已验证的输入案例记录在 [docs/input-cases.md](/Users/que01/osm2streets-qgis-workflow/docs/input-cases.md),变更记录在 [docs/changelog.md](/Users/que01/osm2streets-qgis-workflow/docs/changelog.md)。目前包括:
|
||||
|
||||
- `/Users/que01/Downloads/osm.xml`
|
||||
- `/Users/que01/Desktop/汉阳区区块.osm`
|
||||
把 OSM XML 转为 QGIS 工程(osm2streets 风格道路)和可选的 Blender 3D 场景。
|
||||
|
||||
## 环境
|
||||
|
||||
@@ -21,6 +8,7 @@
|
||||
|
||||
- macOS QGIS:默认 `/Applications/QGIS.app`
|
||||
- Node.js / npm
|
||||
- Blender(可选,用于 3D 场景生成)
|
||||
|
||||
首次使用:
|
||||
|
||||
@@ -29,7 +17,7 @@ cd /Users/que01/osm2streets-qgis-workflow
|
||||
npm install
|
||||
```
|
||||
|
||||
## 运行
|
||||
## QGIS 管线(强依赖 osm2streets)
|
||||
|
||||
使用默认配置:
|
||||
|
||||
@@ -38,77 +26,64 @@ cd /Users/que01/osm2streets-qgis-workflow
|
||||
npm run build
|
||||
```
|
||||
|
||||
使用另一套配置:
|
||||
使用指定配置:
|
||||
|
||||
```bash
|
||||
node scripts/build-osm2streets-qgis.js --config /path/to/config.json
|
||||
```
|
||||
|
||||
汉阳区区块案例:
|
||||
|
||||
```bash
|
||||
node scripts/build-osm2streets-qgis.js --config config/hanyang-block.json
|
||||
```
|
||||
|
||||
创建新区域配置可以从模板复制:
|
||||
|
||||
```bash
|
||||
cp config/examples/template.json config/my-area.json
|
||||
```
|
||||
|
||||
命令行参数可以覆盖配置文件:
|
||||
|
||||
```bash
|
||||
node scripts/build-osm2streets-qgis.js \
|
||||
--input /path/to/osm.xml \
|
||||
--out-dir /path/to/out \
|
||||
--gpkg /path/to/osm2streets_webstyle.gpkg \
|
||||
--project /path/to/osm2streets_webstyle.qgz \
|
||||
--preview /path/to/osm2streets_webstyle_preview.png
|
||||
--gpkg /path/to/output.gpkg \
|
||||
--project /path/to/output.qgz \
|
||||
--preview /path/to/output_preview.png
|
||||
```
|
||||
|
||||
调整箭头大小:
|
||||
创建新区域配置可以从模板复制:
|
||||
|
||||
```bash
|
||||
node scripts/build-osm2streets-qgis.js --arrow-scale 0.8
|
||||
cp config/examples/template.json config/my-area.json
|
||||
```
|
||||
|
||||
当前调好的箭头比例是 `0.8`。如果 QGIS 里仍偏大,试 `0.6`;偏小则试 `1.0`。
|
||||
|
||||
## 配置项
|
||||
|
||||
默认配置文件:
|
||||
### 配置项
|
||||
|
||||
```json
|
||||
{
|
||||
"qgisApp": "/Applications/QGIS.app",
|
||||
"input": "/Users/que01/Downloads/osm.xml",
|
||||
"outDir": "/Users/que01/Downloads/osm2streets_web_out",
|
||||
"gpkg": "/Users/que01/Downloads/osm2streets_webstyle.gpkg",
|
||||
"project": "/Users/que01/Downloads/osm2streets_webstyle.qgz",
|
||||
"preview": "/Users/que01/Downloads/osm2streets_webstyle_preview.png",
|
||||
"input": "/absolute/path/to/input.osm",
|
||||
"outDir": "/absolute/path/to/osm2streets_web_out",
|
||||
"gpkg": "/absolute/path/to/output.gpkg",
|
||||
"project": "/absolute/path/to/output.qgz",
|
||||
"preview": "/absolute/path/to/output_preview.png",
|
||||
"arrowScale": 0.8,
|
||||
"clipPad": 0.002,
|
||||
"canvasPad": 0.001,
|
||||
"previewPad": 0.0007,
|
||||
"canvasExtent": null,
|
||||
"previewExtent": null
|
||||
"previewExtent": null,
|
||||
"layerPrefix": "osm2streets",
|
||||
"osm2streets": {
|
||||
"debug_each_step": false,
|
||||
"dual_carriageway_experiment": false,
|
||||
"sidepath_zipping_experiment": false,
|
||||
"inferred_sidewalks": true,
|
||||
"osm2lanes": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
常用项:
|
||||
- `input`:OSM XML 输入文件路径。
|
||||
- `outDir`:osm2streets GeoJSON 中间产物输出目录。
|
||||
- `gpkg` / `project` / `preview`:最终 GeoPackage、QGIS 工程、预览 PNG 路径。
|
||||
- `layerPrefix`:QGIS 图层显示名称前缀(如 `"osm2streets"` → `"osm2streets road surface"`)。
|
||||
- `arrowScale`:方向箭头几何缩放。
|
||||
- `osm2streets`:osm2streets 引擎选项。
|
||||
|
||||
- `input`:OSM XML 输入。
|
||||
- `outDir`:osm2streets GeoJSON 中间产物目录。
|
||||
- `gpkg`:最终 GeoPackage。
|
||||
- `project`:最终 QGIS 工程。
|
||||
- `preview`:预览 PNG。
|
||||
- `qgisApp`:QGIS.app 路径。
|
||||
- `arrowScale`:方向箭头几何缩放,当前推荐 `0.8`。
|
||||
- `canvasExtent`:QGIS 打开后的初始范围,格式 `"xmin,ymin,xmax,ymax"`;为 `null` 时自动按 OSM bbox 扩展。
|
||||
- `previewExtent`:预览 PNG 范围,格式同上;为 `null` 时自动选第一个箭头附近。
|
||||
|
||||
## 输出图层
|
||||
### 输出图层
|
||||
|
||||
GeoPackage 内会生成:
|
||||
|
||||
@@ -122,10 +97,85 @@ GeoPackage 内会生成:
|
||||
- `lane_arrows_webscale`
|
||||
- `crosswalks`
|
||||
|
||||
QGIS 工程的绘制顺序已经固定为:路段和路口路面在底,车道线、斑马线、停止线和箭头在上。
|
||||
QGIS 工程绘制顺序:路面在最底,车道线、斑马线、停止线和箭头在上。
|
||||
|
||||
## 注意
|
||||
## Blender 3D 场景(可选)
|
||||
|
||||
这套流程复用 osm2streets 的几何输出,再用 QGIS 符号化模拟 web 效果。它不会完全等同 osm2streets web renderer,但能稳定得到路面、人行道、停止线、中心线和方向箭头。
|
||||
osm2streets 道路几何为可选输入;不提供时回退到 OSM highway 折线。
|
||||
|
||||
脚本已经兼容 OSM XML 节点坐标的双引号和单引号属性。Overpass 导出的 XML 和 JOSM 导出的 `.osm` 都已验证过。
|
||||
生成场景:
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background --factory-startup \
|
||||
--python blender/generate_scene.py -- \
|
||||
--osm "/path/to/input.osm" \
|
||||
--geojson "/path/to/osm2streets_web_out" \
|
||||
--output "/path/to/scene.blend" \
|
||||
--render "/path/to/preview.png"
|
||||
```
|
||||
|
||||
`--geojson` 为可选参数。使用 `--office-overrides` 指定应渲染为办公楼的 OSM way ID(逗号分隔)。
|
||||
|
||||
导出为 Cesium GLB:
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background \
|
||||
--python blender/export_cesium.py -- \
|
||||
--blend "/path/to/scene.blend" \
|
||||
--glb "/path/to/scene_cesium.glb" \
|
||||
--metadata "/path/to/scene_cesium.json"
|
||||
```
|
||||
|
||||
详见 [blender/README.md](blender/README.md)。
|
||||
|
||||
## 运行示例
|
||||
|
||||
以下命令已在本机验证通过。
|
||||
|
||||
QGIS 管线(使用汉阳区区块 OSM 数据):
|
||||
|
||||
```bash
|
||||
node scripts/build-osm2streets-qgis.js \
|
||||
--config config/hanyang-block.json
|
||||
```
|
||||
|
||||
Blender 场景(含 osm2streets 道路几何):
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background --factory-startup \
|
||||
--python blender/generate_scene.py -- \
|
||||
--osm "/Users/que01/Desktop/南台子湖创新谷OSM.osm" \
|
||||
--geojson "/Users/que01/osm2streets-qgis-workflow/outputs/nantaizi-lake-innovation-valley/osm2streets_web_out" \
|
||||
--output "/tmp/scene.blend" \
|
||||
--render "/tmp/preview.png"
|
||||
```
|
||||
|
||||
Blender 场景(纯 OSM,无 osm2streets 道路):
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background --factory-startup \
|
||||
--python blender/generate_scene.py -- \
|
||||
--osm "/Users/que01/Desktop/南台子湖创新谷OSM.osm" \
|
||||
--output "/tmp/scene-nogeojson.blend" \
|
||||
--render "/tmp/preview-nogeojson.png"
|
||||
```
|
||||
|
||||
Cesium GLB 导出:
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background \
|
||||
--python blender/export_cesium.py -- \
|
||||
--blend "/tmp/scene.blend" \
|
||||
--glb "/tmp/scene.glb" \
|
||||
--metadata "/tmp/scene.json"
|
||||
```
|
||||
|
||||
## 文档
|
||||
|
||||
- [docs/input-cases.md](docs/input-cases.md) — 已验证的 OSM 输入案例
|
||||
- [docs/changelog.md](docs/changelog.md) — 变更记录
|
||||
Reference in New Issue
Block a user