QGIS完成初步重构

This commit is contained in:
wzy-warehouse
2026-06-20 15:50:24 +08:00
parent d20b5744bb
commit 18d8bcb1a3
45 changed files with 1688 additions and 454 deletions
+10 -10
View File
@@ -22,24 +22,24 @@ async def lifespan(app: FastAPI):
get_earthquake_model()
logger.info("DBN模型预加载完成")
# 初始化 QGIS 环境
# 检测 QGIS 子进程环境
qgis_root = getattr(settings, "QGIS_ROOT", None)
if qgis_root:
try:
from app.services.qgis.qgis_env import init_qgis_env
init_qgis_env(qgis_root)
logger.info("QGIS 环境初始化完成")
from app.services.qgis.qgis_env import is_qgis_available
if is_qgis_available(qgis_root):
logger.info("QGIS 环境检测通过(子进程模式)")
else:
logger.warning("QGIS 环境不可用(未找到 Python 3.12 解释器),专题图功能降级")
except Exception as e:
logger.error(f"QGIS 环境初始化失败(专题图功能不可用): {e}")
logger.error(f"QGIS 环境检测失败: {e}")
yield
# 清理 QGIS 资源
# 清理资源
try:
from app.services.qgis.qgis_env import cleanup_qgis_env
from app.services.qgis.map_service import template_cache
template_cache.cleanup()
cleanup_qgis_env()
from app.api.qgis_map_export import shutdown_thread_pool
shutdown_thread_pool()
except Exception:
pass