QGIS完成初步重构

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