32 lines
1018 B
Python
32 lines
1018 B
Python
"""
|
||
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",
|
||
]
|
||
|
||
# 不在顶层导入 QGIS 依赖模块,避免主进程崩溃
|
||
# 使用方式:
|
||
# from app.services.qgis.map_service import MapService (仅在容器子进程中)
|
||
# from app.services.qgis.qgis_env import get_docker_container (主进程检查容器状态)
|