Files
gis-actions/suites/test-linux/workflow.yaml
T

114 lines
3.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: 云南省界叠加分析(Linux 测试)
description: |
验证 GIS Actions 4.0 **Linux 双平台**Docker + Python3)执行链路的官方测试套件。
---
**内置测试数据**
套件包内置 4 个 GeoJSON 文件,开箱即用:
| 文件 | 内容 | 角色 |
|------|------|------|
| `yunnan.geojson` | 云南省界(面) | 叠加分析的目标区域 |
| `kunming.geojson` | 昆明市界(面) | 预期在省内 → 通过 |
| `dali.geojson` | 大理州界(面) | 预期在省内 → 通过 |
| `baise.geojson` | 广西百色市界(面) | 预期不在省内 → 不通过 |
**▎执行流程**
| 步骤 | 运行时 | 功能 |
|------|--------|------|
| 1. GeoJSON → SHP | Dockergeopandas | 内置 GeoJSON 转为 Shapefile |
| 2. 叠加分析 | Dockergeopandas | 空间判断城市是否在省界内 |
| 3. Excel 输出 | Python3openpyxl | 格式化报表含条件高亮 |
**▎预期输出**
输出 Excel 工作簿包含 **叠加分析结果** 工作表:
| 城市 | 城市代码 | 城市名称 | 人口 | 在省内 | 相交 | 状态 |
|------|----------|----------|------|--------|------|------|
| kunming | 530100 | 昆明市 | 8,500,000 | 是 | 是 | 通过 ✅ |
| dali | 532900 | 大理州 | 3,300,000 | 是 | 是 | 通过 ✅ |
| baise | 451000 | 百色市 | 3,600,000 | 否 | 是 | 不通过 ❌ |
**条件格式:** 通过行绿色背景,不通过行红色背景。
**▎环境要求**
- 依赖 `gis-base:latest` 镜像(内含 geopandas、openpyxl
- Step 1、2 在 Docker 容器中隔离执行
- Step 3 使用本机 Python3 运行时
version: 1.0.2
author: Robert
platform: linux
slug: test-yunnan-overlay-linux
tags: [测试, 叠加分析, Linux, 云南省, 验证套件]
category: 测试验证
params:
output_path:
type: string
required: true
desc: |
输出 Excel 文件路径,例如 `/home/user/output/result.xlsx`。
输出文件包含一张 **叠加分析结果** 工作表,表头加粗、蓝色底白色字;
通过行绿色高亮,不通过行红色高亮。
base_image: gis-base:latest
steps:
- id: geojson_to_shp
name: 内置数据 → 转为 Shapefile
description: |
从套件包内置 `data/` 目录读取 4 个 GeoJSON 文件(云南省界 + 昆明/大理/百色),
使用 **geopandas** 逐文件读取,转为 ESRI Shapefile 格式,
输出至共享工作目录 `/tmp/output/shp/`。
runtime: docker
script_id: convert
params:
output_dir: /tmp/output/shp
- id: overlay
name: 叠加分析(空间判断)
description: |
读取省界 Shapefile,读取各城市 Shapefile。
使用投影坐标系 **EPSG:3857(Web 墨卡托)** 计算每个城市的几何中心点,
判断中心点是否落在省界多边形内(`contains`),
同时检查面面相交(`intersects`)作为辅助信息。
分析结果以 JSON 格式输出到 `/tmp/output/result/`。
**预期结果:**
- 昆明市 → 在省内 ✅
- 大理州 → 在省内 ✅
- 百色市 → 不在省内 ❌(验证"不过"分支)
runtime: docker
script_id: overlay
depends_on: [geojson_to_shp]
params:
province_shp: /tmp/output/shp/province.shp
cities_dir: /tmp/output/shp
output_dir: /tmp/output/result
- id: export_excel
name: 输出 Excel 报表
description: |
读取上一步产生的叠加分析结果 JSON,使用 **openpyxl** 生成格式化的 Excel 工作簿。
**格式细节:**
- 表头:加粗、白色字体、蓝色背景(#4472C4)
- 通过行:绿色背景(#E2EFDA)
- 不通过行:红色背景(#FCE4EC)
- 自动调整列宽
输出文件写入用户指定的 `output_path`。
runtime: python3
script_id: excel
depends_on: [overlay]
params:
result_dir: /tmp/output/result
output_path: $params.output_path