feat: 市场出图改为按图层分步选择

未勾选生成的图层会跳过对应计算,也不会进入成果工程;导入页只列出仍需要的数据源。
This commit is contained in:
nixevol
2026-10-15 15:15:45 +08:00
parent 8ce1b78e58
commit e8c8218d11
11 changed files with 595 additions and 267 deletions
+72
View File
@@ -0,0 +1,72 @@
"""市场出图可选图层,以及它们依赖的数据源。"""
# 顺序与成果工程从上到下一致。visible 是默认是否在 QGIS 中勾选。
LAYERS = (
{"key": "building", "name": "移动C端采样点比例_楼宇", "visible": False, "sources": ("NR_BUILDINGS_DATA_CSV", "BUILDING_INFO_GPKG")},
{"key": "aoi", "name": "移动C端采样点比例_AOI", "visible": False, "sources": ("AOI_CSV",)},
{"key": "sample", "name": "采样点图层", "visible": True, "sources": ("GRID_5G_GPKG", "GRID_4G_GPKG")},
{"key": "competitor", "name": "竞对信号", "visible": False, "sources": ("GRID_5G_GPKG",)},
{"key": "buildinfo", "name": "BuildInfo", "visible": False, "sources": ("BUILDING_INFO_GPKG",)},
{"key": "boundary", "name": "市场边界", "visible": True, "sources": ()},
{"key": "google", "name": "GoogleCN", "visible": True, "sources": ()},
{"key": "bing", "name": "必应地图", "visible": False, "sources": ()},
{"key": "online", "name": "online", "visible": True, "sources": ()},
)
ALWAYS_SOURCES = ("MARKET_GPKG", "GIS_PROJECT_SOURCE")
_BY_KEY = {item["key"]: item for item in LAYERS}
def default_plan():
return {item["key"]: {"enabled": True, "visible": item["visible"]} for item in LAYERS}
def normalize(raw):
plan = default_plan()
if not isinstance(raw, dict):
return plan
for key, value in raw.items():
if key not in plan or not isinstance(value, dict):
continue
if "enabled" in value:
plan[key]["enabled"] = bool(value["enabled"])
if "visible" in value:
plan[key]["visible"] = bool(value["visible"])
if not plan[key]["enabled"]:
plan[key]["visible"] = False
return plan
def active_plan():
from . import config
return normalize(config.OUTPUT_LAYERS)
def enabled(plan, key):
return bool(plan[key]["enabled"])
def checked_state(plan, key):
return "Qt::Checked" if plan[key]["enabled"] and plan[key]["visible"] else "Qt::Unchecked"
def layer_name(key, market_name=""):
if key == "boundary":
return f"{market_name}边界"
return _BY_KEY[key]["name"]
def needed_sources(plan):
keys = set(ALWAYS_SOURCES)
for item in LAYERS:
if plan[item["key"]]["enabled"]:
keys.update(item["sources"])
return keys
def catalog():
return [{
"key": item["key"],
"name": item["name"],
"visible": item["visible"],
"sources": list(item["sources"]),
} for item in LAYERS]