fix: 多项稳定性修复与打包优化
- PyInstaller: runtime hook 预加载 osgeo DLL 避免 Qt5 符号冲突; spec 纳入 osgeo .py 文件 + 运行时 DLL 依赖 (ffi/lzma/bz2/expat/sqlite3); 移除 DLL 双副本防止 segfault - GDAL 环境: 新增 _MEIPASS/osgeo/data/gdal 路径搜索,改善打包后 GDAL_DATA 检测 - 预览生成器: 掩膜与底图同分辨率时跳过 Warp 加速读取 - 专题图: ConvexHull 坐标中心化修复 UTM 大坐标精度退化; 边界采样兜底防止外扩点为空; TIFF 已含 NaN 掩膜时跳过矢量擦除; 形态学闭运算填充掩膜小孔洞 - NDWI: int16→float32 防止减法溢出 - 面板注册表: 步骤模块分组重构 (模块一/二/三/四重划分)
This commit is contained in:
@ -215,19 +215,29 @@ def _warp_mask_to_image(mask_path: str,
|
||||
minx, maxx = min(corners_x), max(corners_x)
|
||||
miny, maxy = min(corners_y), max(corners_y)
|
||||
|
||||
# ---- 读取掩膜的原始 NoData 并传递到 Warp ----
|
||||
# ---- 读取掩膜 ----
|
||||
mask_ds = gdal.Open(mask_path, gdal.GA_ReadOnly)
|
||||
if mask_ds is None:
|
||||
raise ValueError(f"无法打开掩膜文件: {mask_path}")
|
||||
|
||||
src_nodata = None
|
||||
mask_gt = mask_ds.GetGeoTransform()
|
||||
mask_proj = mask_ds.GetProjection()
|
||||
try:
|
||||
src_nodata = mask_ds.GetRasterBand(1).GetNoDataValue()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ── 快速通道:掩膜与底图同分辨率同范围时跳过 Warp ──
|
||||
mask_gt = mask_ds.GetGeoTransform()
|
||||
mask_w, mask_h = mask_ds.RasterXSize, mask_ds.RasterYSize
|
||||
if (mask_w == base_w and mask_h == base_h
|
||||
and abs(mask_gt[1] - base_gt[1]) < 1e-9
|
||||
and abs(mask_gt[5] - base_gt[5]) < 1e-9):
|
||||
data = mask_ds.GetRasterBand(1).ReadAsArray().astype(np.float32)
|
||||
mask_ds = None
|
||||
print("[预览] 掩膜与底图分辨率一致,跳过 Warp 直接读取")
|
||||
return _normalize_mask(data, nodata_value=src_nodata), nodata_output
|
||||
mask_proj = mask_ds.GetProjection()
|
||||
|
||||
# ---- 构建 Warp 选项 ----
|
||||
warp_kwargs = {
|
||||
'format': 'MEM',
|
||||
|
||||
Reference in New Issue
Block a user