Files
xian_algorithm_new/app/services/qgis/__init__.py
T

32 lines
1018 B
Python
Raw Normal View History

2026-06-20 15:50:24 +08:00
"""
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)
2026-06-19 17:04:03 +08:00
__all__ = [
2026-06-20 15:50:24 +08:00
"MapService",
"MapExporter",
"TemplateModifier",
"TemplateCache",
"LayerFilter",
2026-06-19 17:04:03 +08:00
]
2026-06-20 15:50:24 +08:00
# 不在顶层导入 QGIS 依赖模块,避免主进程崩溃
# 使用方式:
2026-06-21 22:30:04 +08:00
# from app.services.qgis.map_service import MapService (仅在容器子进程中)
# from app.services.qgis.qgis_env import get_docker_container (主进程检查容器状态)