fix: 修正楼宇边界 GeoPackage 几何编码
This commit is contained in:
@@ -19,7 +19,7 @@ def _encoding(path):
|
||||
raise ValueError("无法识别楼宇结果 CSV 编码")
|
||||
|
||||
def _gpkg_blob(geometry):
|
||||
return b"GP" + bytes((0, 1, 0, 0, 0, 0, 0, 0)) + to_wkb(geometry)
|
||||
return b"GP" + bytes((0, 1)) + (4326).to_bytes(4, "little") + to_wkb(geometry)
|
||||
|
||||
def build_gpkg(data_csv, polygon_csv, output_path):
|
||||
data_csv, polygon_csv, output_path = map(Path, (data_csv, polygon_csv, output_path))
|
||||
@@ -33,9 +33,10 @@ def build_gpkg(data_csv, polygon_csv, output_path):
|
||||
data_encoding = _encoding(data_csv)
|
||||
with data_csv.open(encoding=data_encoding, newline="") as f:
|
||||
reader = csv.DictReader(f)
|
||||
fields = [x for x in (reader.fieldnames or []) if x not in DROP_COLUMNS]
|
||||
fields = list(dict.fromkeys(x for x in (reader.fieldnames or []) if x not in DROP_COLUMNS))
|
||||
if "building_id" not in fields: raise ValueError("楼宇结果 CSV 缺少 building_id 字段")
|
||||
fields.append("WKT")
|
||||
if "WKT" not in fields:
|
||||
fields.append("WKT")
|
||||
rows=[]
|
||||
for row in reader:
|
||||
geometry=polygons.get(str(row.get("building_id", "")).strip())
|
||||
|
||||
Reference in New Issue
Block a user