Files
xian_algorithm_new/app/script/run_qgis.bat
T
2026-06-20 16:34:49 +08:00

54 lines
1.6 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
REM ============================================================
REM QGIS 子进程启动脚本(Windows
REM 需要 QGIS_ROOT 环境变量指向 QGIS 安装目录
REM 自动检测 qgis-ltr 或 qgis 应用目录
REM ============================================================
setlocal enabledelayedexpansion
if not defined QGIS_ROOT (
echo [ERROR] QGIS_ROOT 环境变量未设置
exit /b 1
)
if not exist "%QGIS_ROOT%" (
echo [ERROR] QGIS_ROOT 目录不存在: %QGIS_ROOT%
exit /b 1
)
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 版本目录(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"
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%"
if not exist "%PYTHONHOME%\python3.exe" (
echo [ERROR] QGIS Python 不存在: %PYTHONHOME%\python3.exe
exit /b 1
)
"%PYTHONHOME%\python3.exe" %*