feat: 移除全量包中的小区数据

This commit is contained in:
nixevol
2026-09-21 09:41:24 +08:00
parent 75af8f9f76
commit cab073bc0c
9 changed files with 25 additions and 59 deletions
+1 -4
View File
@@ -8,7 +8,6 @@ GRID_5G_GPKG = DEFAULT_SOURCE_DIR / "Grid_5G.gpkg" # 5G Grid;竟对信号仅
# 用户量图层停用;以下原代码以注释保留,便于按需恢复。
# GRID_4G_GPKG = DEFAULT_SOURCE_DIR / "Grid_4G.gpkg" # 4G Grid;仅参与竟对用户量合并。
BUILDING_INFO_GPKG = DEFAULT_SOURCE_DIR / "BuildingInfo.gpkg" # 建筑信息 GeoPackage 文件路径,用于结果包 BuildingInfo 分割和楼宇指标 CSV 名称匹配。
CELL_DATA_GPKG = DEFAULT_SOURCE_DIR / "CellData.gpkg" # 小区数据 GeoPackage;仅完整复制到汇总结果包。
GIS_PROJECT_SOURCE = DEFAULT_SOURCE_DIR / "GIS.qgz" # 每个市场网格结果包使用的 QGIS 项目模板来源。
AOI_OUTPUT_FILENAME = "AOI级报表_市场网格匹配.gpkg"
AOI_GPKG = OUTPUT_DIR / AOI_OUTPUT_FILENAME # 已完成市场归属匹配的 AOI 总表。
@@ -30,7 +29,6 @@ MARKET_CODE_FIELD = "fid" # GridMap 市场网格唯一 ID 前缀字段。
MARKET_NAME_FIELD = "Name" # GridMap 市场网格名称字段。
MARKET_ID_SEPARATOR = "-" # 市场网格唯一 ID 拼接符,输出为 fid-name,例如 1-城区蓬江。
BUILDING_INFO_OUTPUT_FILENAME = "BuildingInfo.gpkg" # 每个市场网格结果包内输出的建筑信息拆分文件名。
CELL_DATA_OUTPUT_FILENAME = "CellData.gpkg" # 汇总结果包内的小区数据文件名。
BUILDING_METRICS_CSV_FILENAME = "楼宇指标.csv" # 每个市场网格结果包内输出的楼宇指标 CSV 文件名。
GRID_METRICS_CSV_FILENAME = "栅格指标.csv" # 每个市场网格结果包内输出的栅格指标 CSV 文件名。
CSV_ENCODING = "gbk" # 指标 CSV 输出编码,供 Excel/传统 GIS 工具直接打开。
@@ -58,8 +56,7 @@ COMPETITOR_SIGNAL_RSRP_COLORS = (
(58, 14, 247), # [-74, 0],紫色。
)
SUMMARY_OUTPUT_ENABLED = True # 是否额外生成全部市场网格汇总 TIF 结果包。
# SUMMARY_OUTPUT_FILENAME = "全量网格图层.zip" # 汇总结果包文件名,包含两张 TIF、GIS.qgz、BuildingInfo.gpkg 和 CellData.gpkg。
SUMMARY_OUTPUT_FILENAME = "全量网格图层.zip" # 包含竟对信号 TIF、GIS.qgz、BuildingInfo.gpkg 和 CellData.gpkg。
SUMMARY_OUTPUT_FILENAME = "全量网格图层.zip" # 包含竟对信号 TIF、GIS.qgz 和 BuildingInfo.gpkg。
LEGACY_SUMMARY_OUTPUT_FILENAME = "所有网格汇总.zip" # 旧汇总包文件名;新包成功生成后自动清理。
SUMMARY_MARKET_CODE = "全量网格图层" # 汇总任务在日志和 summary.json 中使用的标识。
SUMMARY_MAX_RASTER_PIXELS = 100_000_000 # 汇总 TIF 最大像元数;提高该值可增强清晰度,但会增加内存、耗时和文件体积。
-9
View File
@@ -101,7 +101,6 @@ def process_market(market, pixel_width, pixel_height, output_dir):
market,
building_info_result["extent"],
competitor_signal_result["raster_extent"],
include_cell_data=False,
aoi_result=aoi_result,
)
building_elapsed = perf_counter() - building_started_at
@@ -208,12 +207,6 @@ def process_summary_grid_outputs(markets, pixel_width, pixel_height, output_dir)
"copied_full_source": True,
"skipped": False,
}
cell_data_path = summary_dir / config.CELL_DATA_OUTPUT_FILENAME
cell_data_result = copy_full_source_file(
config.CELL_DATA_GPKG,
cell_data_path,
summary_market,
)
gis_project_path = summary_dir / config.GIS_PROJECT_OUTPUT_FILENAME
gis_project_result = copy_gis_project_to_market(
config.GIS_PROJECT_SOURCE,
@@ -221,7 +214,6 @@ def process_summary_grid_outputs(markets, pixel_width, pixel_height, output_dir)
summary_market,
building_info_extent,
competitor_signal_result["raster_extent"],
include_cell_data=True,
)
zip_result = write_market_zip(summary_dir, zip_path, summary_market)
legacy_zip_path = output_dir / config.LEGACY_SUMMARY_OUTPUT_FILENAME
@@ -236,7 +228,6 @@ def process_summary_grid_outputs(markets, pixel_width, pixel_height, output_dir)
summary_dir,
),
"building_info_result": rewrite_result_for_zip(building_info_result, zip_path, summary_dir),
"cell_data_result": rewrite_result_for_zip(cell_data_result, zip_path, summary_dir),
"gis_project_result": rewrite_result_for_zip(gis_project_result, zip_path, summary_dir),
"zip_result": zip_result,
"elapsed_seconds": perf_counter() - started_at,
-4
View File
@@ -56,8 +56,6 @@ def main(settings=None, progress=None):
config.GIS_PROJECT_SOURCE,
config.AOI_GPKG,
)
if config.SUMMARY_OUTPUT_ENABLED:
required_files += (config.CELL_DATA_GPKG,)
missing_files = [str(path) for path in required_files if not path.is_file()]
if missing_files:
raise FileNotFoundError(f"缺少输入文件:{', '.join(missing_files)}")
@@ -216,7 +214,6 @@ def main(settings=None, progress=None):
"competitor_signal_results": "competitor_signal_result",
"building_info_results": "building_info_result",
"aoi_results": "aoi_result",
"cell_data_results": "cell_data_result",
"gis_project_results": "gis_project_result",
"zip_results": "zip_result",
}
@@ -229,7 +226,6 @@ def main(settings=None, progress=None):
"building_info_gpkg": str(config.BUILDING_INFO_GPKG),
"aoi_gpkg": str(config.AOI_GPKG),
"aoi_match_field": config.AOI_MARKET_FIELD,
"cell_data_gpkg": str(config.CELL_DATA_GPKG),
"gis_project_source": str(config.GIS_PROJECT_SOURCE),
"rsrp_field": config.RSRP_FIELD,
"excellent_cell_field": config.EXCELLENT_CELL_FIELD,
+3 -4
View File
@@ -145,7 +145,7 @@ def copy_gis_project_to_market(
market,
building_extent,
raster_extent=None,
include_cell_data=True,
include_cell_data=False,
aoi_result=None,
):
if output_path.exists() and not config.OVERWRITE:
@@ -179,8 +179,7 @@ def copy_gis_project_to_market(
if info.filename == project_member:
root = ET.fromstring(data)
remove_qgis_layer(root, config.USER_COUNT_OUTPUT_FILENAME, required=False)
if not include_cell_data:
remove_qgis_layer(root, config.CELL_DATA_OUTPUT_FILENAME)
remove_qgis_layer(root, "CellData.gpkg", required=False)
if aoi_result is not None:
add_market_aoi_layer(root, aoi_result, market.geometry.bounds)
canvas = root.find(".//mapcanvas[@name='theMapCanvas']")
@@ -236,7 +235,7 @@ def copy_gis_project_to_market(
"raster_extent": list(raster_layer_extent),
"canvas_extent": list(canvas_extent),
"padding_ratio": config.PROJECT_EXTENT_PADDING_RATIO,
"includes_cell_data": include_cell_data,
"includes_cell_data": False,
"includes_aoi": aoi_result is not None,
"bytes": output_path.stat().st_size,
"skipped": False,