Files
SuiteForge 07a9c3f6dd fix: 测试数据打包进套件 data/,去掉外部输入参数
- 去掉 province/cities 参数,只保留 output_path
- GeoJSON 数据放在 data/ 目录,脚本自动读取
- 版本升到 1.0.1
- MEMORY.md / TOOLS.md 补充 platform 发布参数说明

Ref: SuiteHub/agent-profiles#22
2026-07-21 00:19:00 +08:00

62 lines
1.7 KiB
Python

#!/usr/bin/env python
"""
Step 1: GeoJSON → SHP (arcpy)
从内置 data/ 目录读取 GeoJSON,转为 Shapefile
"""
import sys
import json
import os
import arcpy
arcpy.env.overwriteOutput = True
def get_data_dir():
"""返回内置 data/ 目录路径(相对脚本位置)"""
script_dir = os.path.dirname(os.path.abspath(__file__))
return os.path.normpath(os.path.join(script_dir, "..", "data"))
def main():
output_dir = os.environ.get("PARAM_OUTPUT_DIR", r"C:\temp\output\shp")
if not os.path.isdir(output_dir):
os.makedirs(output_dir)
data_dir = get_data_dir()
# 数据文件映射
geo_files = {
"province": "yunnan.geojson",
"kunming": "kunming.geojson",
"dali": "dali.geojson",
"baise": "baise.geojson",
}
converted = []
for name, filename in geo_files.items():
filepath = os.path.join(data_dir, filename)
if not os.path.isfile(filepath):
print json.dumps({"warn": u"内置数据文件不存在,跳过: " + filepath})
continue
print json.dumps({"msg": u"读取内置数据: " + filename})
shp_path = os.path.join(output_dir, name + ".shp")
arcpy.JSONToFeatures_conversion(filepath, shp_path)
converted.append(name)
print json.dumps({"msg": u"已转换: " + filename + u" → " + shp_path})
if not converted:
print json.dumps({"error": u"未找到任何内置 GeoJSON 数据", "success": False})
sys.exit(1)
result = {
"success": True,
"output_dir": output_dir,
"converted": converted
}
print json.dumps(result)
if __name__ == "__main__":
main()