QGIS完成初步重构

This commit is contained in:
wzy-warehouse
2026-06-20 16:58:14 +08:00
parent f3c38bbb57
commit 4fb65f7f53
+36 -37
View File
@@ -1,53 +1,52 @@
@echo off
REM ============================================================
REM QGIS 子进程启动脚本(Windows
REM 需要 QGIS_ROOT 环境变量指向 QGIS 安装目录
REM 自动检测 qgis-ltr 或 qgis 应用目录
REM 自动检测 QGIS 安装结构,支持 qgis-ltr/qgis + Python312/Python39
REM ============================================================
setlocal enabledelayedexpansion
if not defined QGIS_ROOT (
echo [ERROR] QGIS_ROOT 环境变量未设置
exit /b 1
)
if "%QGIS_ROOT%"=="" goto :no_root
if not exist "%QGIS_ROOT%" goto :no_root_dir
if not exist "%QGIS_ROOT%" (
echo [ERROR] QGIS_ROOT 目录不存在: %QGIS_ROOT%
exit /b 1
)
REM --- 检测 QGIS 应用目录 ---
set "QGIS_APP=%QGIS_ROOT%\apps\qgis-ltr"
if not exist "%QGIS_APP%" set "QGIS_APP=%QGIS_ROOT%\apps\qgis"
if not exist "%QGIS_APP%" goto :no_qgis_app
REM 自动检测 QGIS 应用目录(qgis-ltr 或 qgis
set "QGIS_APP_DIR="
if exist "%QGIS_ROOT%\apps\qgis-ltr" (
set "QGIS_APP_DIR=%QGIS_ROOT%\apps\qgis-ltr"
) else if exist "%QGIS_ROOT%\apps\qgis" (
set "QGIS_APP_DIR=%QGIS_ROOT%\apps\qgis"
) else (
echo [ERROR] 未找到 QGIS 应用目录 (apps\qgis-ltr 或 apps\qgis)
exit /b 1
)
REM --- 检测 Python 目录 ---
set "PY=%QGIS_ROOT%\apps\Python312"
if not exist "%PY%" set "PY=%QGIS_ROOT%\apps\Python39"
if not exist "%PY%" set "PY=%QGIS_ROOT%\apps\Python310"
if not exist "%PY%" set "PY=%QGIS_ROOT%\apps\Python311"
if not exist "%PY%" goto :no_python
REM 自动检测 Python 版本目录(Python312 / Python39 / Python3
set "PYTHONHOME="
for /d %%d in ("%QGIS_ROOT%\apps\Python3*") do set "PYTHONHOME=%%d"
if "%PYTHONHOME%"=="" (
echo [ERROR] 未找到 QGIS Python 目录
exit /b 1
)
set "PYTHONPATH=%QGIS_APP_DIR%\python"
set "QGIS_PREFIX_PATH=%QGIS_APP_DIR%"
set "QT_PLUGIN_PATH=%QGIS_APP_DIR%\qtplugins;%QGIS_ROOT%\apps\Qt5\plugins"
REM --- 设置环境 ---
set "PYTHONHOME=%PY%"
set "PYTHONPATH=%QGIS_APP%\python"
set "QGIS_PREFIX_PATH=%QGIS_APP%"
set "QT_PLUGIN_PATH=%QGIS_APP%\qtplugins;%QGIS_ROOT%\apps\Qt5\plugins"
set "GDAL_DATA=%QGIS_ROOT%\apps\gdal\share\gdal"
set "PYTHONUTF8=1"
set "GDAL_FILENAME_IS_UTF8=YES"
set "VSI_CACHE=TRUE"
set "VSI_CACHE_SIZE=1000000"
set "PATH=%QGIS_APP_DIR%\bin;%QGIS_ROOT%\apps\Qt5\bin;%QGIS_ROOT%\apps\gdal\lib;%PATH%"
set "PATH=%QGIS_APP%\bin;%QGIS_ROOT%\apps\Qt5\bin;%QGIS_ROOT%\apps\gdal\lib;%PATH%"
if not exist "%PYTHONHOME%\python3.exe" (
echo [ERROR] QGIS Python 不存在: %PYTHONHOME%\python3.exe
REM --- 启动 ---
"%PY%\python3.exe" %*
exit /b %ERRORLEVEL%
:no_root
echo [ERROR] QGIS_ROOT 环境变量未设置
exit /b 1
)
"%PYTHONHOME%\python3.exe" %*
:no_root_dir
echo [ERROR] QGIS_ROOT 目录不存在: %QGIS_ROOT%
exit /b 1
:no_qgis_app
echo [ERROR] 未找到 QGIS 应用目录
exit /b 1
:no_python
echo [ERROR] 未找到 QGIS Python 目录
exit /b 1