Initial osm2streets QGIS workflow
This commit is contained in:
129
README.md
Normal file
129
README.md
Normal file
@@ -0,0 +1,129 @@
|
||||
# osm2streets QGIS workflow
|
||||
|
||||
把 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`
|
||||
|
||||
## 环境
|
||||
|
||||
需要:
|
||||
|
||||
- macOS QGIS:默认 `/Applications/QGIS.app`
|
||||
- Node.js / npm
|
||||
|
||||
首次使用:
|
||||
|
||||
```bash
|
||||
cd /Users/que01/osm2streets-qgis-workflow
|
||||
npm install
|
||||
```
|
||||
|
||||
## 运行
|
||||
|
||||
使用默认配置:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
调整箭头大小:
|
||||
|
||||
```bash
|
||||
node scripts/build-osm2streets-qgis.js --arrow-scale 0.8
|
||||
```
|
||||
|
||||
当前调好的箭头比例是 `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",
|
||||
"arrowScale": 0.8,
|
||||
"clipPad": 0.002,
|
||||
"canvasPad": 0.001,
|
||||
"previewPad": 0.0007,
|
||||
"canvasExtent": null,
|
||||
"previewExtent": null
|
||||
}
|
||||
```
|
||||
|
||||
常用项:
|
||||
|
||||
- `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 内会生成:
|
||||
|
||||
- `road_surface`
|
||||
- `sidewalks`
|
||||
- `sidewalk_corners`
|
||||
- `lane_separators`
|
||||
- `center_lines`
|
||||
- `vehicle_stop_lines`
|
||||
- `lane_arrows_webscale`
|
||||
|
||||
QGIS 工程的绘制顺序已经固定为:路面在底,箭头、停止线、中心线在上。
|
||||
|
||||
## 注意
|
||||
|
||||
这套流程复用 osm2streets 的几何输出,再用 QGIS 符号化模拟 web 效果。它不会完全等同 osm2streets web renderer,但能稳定得到路面、人行道、停止线、中心线和方向箭头。
|
||||
|
||||
脚本已经兼容 OSM XML 节点坐标的双引号和单引号属性。Overpass 导出的 XML 和 JOSM 导出的 `.osm` 都已验证过。
|
||||
Reference in New Issue
Block a user