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
+28 -10
View File
@@ -1,13 +1,31 @@
from app.services.qgis.map_service import MapService
from app.services.qgis.map_exporter import MapExporter
from app.services.qgis.template_modifier import TemplateModifier
from app.services.qgis.template_cache import TemplateCache
from app.services.qgis.layer_filter import LayerFilter
"""
QGIS 服务模块。
注意:此包的核心模块(map_service、template_cache 等)依赖 qgis.core
仅在 QGIS Python 3.12 子进程中可导入。主进程(Python 3.10)不应直接导入
这些模块,而应通过 qgis_runner.py 子进程调用。
安全导入(不依赖 qgis.core):
- qgis_env: 环境检测与子进程配置
- qgis_runner: 子进程入口脚本路径
"""
def _lazy_import(module_name: str, attr: str):
"""延迟导入,仅在子进程中实际使用时才加载"""
import importlib
mod = importlib.import_module(f".{module_name}", package=__name__)
return getattr(mod, attr)
__all__ = [
'MapService',
'MapExporter',
'TemplateModifier',
'TemplateCache',
'LayerFilter',
"MapService",
"MapExporter",
"TemplateModifier",
"TemplateCache",
"LayerFilter",
]
# 不在顶层导入 QGIS 依赖模块,避免主进程崩溃
# 使用方式:
# from app.services.qgis.map_service import MapService (仅在子进程中)
# from app.services.qgis.qgis_env import is_qgis_available (主进程安全)