|
@@ -175,14 +175,24 @@ async def recalculate_land_data(
|
|
|
|
|
|
cleaned_csv, shapefile, tif_file, map_output, hist_output, used_coeff = results
|
|
|
|
|
|
- # 检查关键文件是否存在(shapefile可以为None,因为使用的是内存处理)
|
|
|
- if not tif_file or not map_output or not hist_output:
|
|
|
- logger.error(f"重新计算土地数据失败,关键文件缺失: {land_type}")
|
|
|
- logger.error(f"GeoTIFF: {tif_file}, 地图: {map_output}, 直方图: {hist_output}")
|
|
|
+ # 检查关键输出文件是否存在(只检查最终输出的地图和直方图)
|
|
|
+ if not map_output or not hist_output:
|
|
|
+ logger.error(f"重新计算土地数据失败,关键输出文件缺失: {land_type}")
|
|
|
+ logger.error(f"地图: {map_output}, 直方图: {hist_output}")
|
|
|
raise HTTPException(
|
|
|
status_code=500,
|
|
|
detail=f"重新计算土地数据失败: {land_type}"
|
|
|
)
|
|
|
+
|
|
|
+ # 验证输出文件实际存在
|
|
|
+ if not os.path.exists(map_output) or not os.path.exists(hist_output):
|
|
|
+ logger.error(f"生成的输出文件不存在: {land_type}")
|
|
|
+ logger.error(f"地图文件存在: {os.path.exists(map_output) if map_output else False}")
|
|
|
+ logger.error(f"直方图文件存在: {os.path.exists(hist_output) if hist_output else False}")
|
|
|
+ raise HTTPException(
|
|
|
+ status_code=500,
|
|
|
+ detail=f"生成的输出文件不存在: {land_type}"
|
|
|
+ )
|
|
|
|
|
|
# 定义默认路径
|
|
|
default_map_path = os.path.join(raster_dir, f"{land_type}_Cd含量地图.jpg")
|