Improve pairing planning and statistics visibility
This commit is contained in:
@@ -329,6 +329,7 @@ async def find_pairs_endpoint(
|
||||
network_run_id=pairing_metadata.get("network_run_id"),
|
||||
candidate_count=int(pairing_metadata.get("candidate_count") or 0),
|
||||
selected_edge_count=int(pairing_metadata.get("selected_edge_count") or 0),
|
||||
coverage=None,
|
||||
)
|
||||
except Exception as e:
|
||||
if isinstance(e, HTTPException):
|
||||
@@ -339,6 +340,66 @@ async def find_pairs_endpoint(
|
||||
raise HTTPException(status_code=500, detail="处理 AOI 或查找干涉对时发生错误,请查看后端日志")
|
||||
|
||||
|
||||
@router.post("/pairing/coverage-plan", response_model=PairingResponse)
|
||||
async def build_coverage_pairing_plan_endpoint(
|
||||
params: PairingRequest = Depends(get_pairing_request_from_form),
|
||||
target_date_from: str = Form(...),
|
||||
target_date_to: str = Form(...),
|
||||
extension_days: int = Form(15),
|
||||
max_pairs: int = Form(200),
|
||||
target_coverage_ratio: float = Form(0.98),
|
||||
min_new_coverage_ratio: float = Form(0.0005),
|
||||
files: Optional[List[UploadFile]] = File(None),
|
||||
aoi_geojson: Optional[str] = Form(None),
|
||||
require_orbit_data: bool = Form(True),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
try:
|
||||
resolved_aoi = await _parse_aoi_from_files(files)
|
||||
if resolved_aoi is None:
|
||||
resolved_aoi = _parse_aoi_geojson_form_value(aoi_geojson)
|
||||
|
||||
if files and resolved_aoi is None:
|
||||
raise HTTPException(status_code=400, detail="Uploaded files must include a valid SHP or GeoJSON AOI.")
|
||||
|
||||
aoi_wkt = resolved_aoi[0] if resolved_aoi else None
|
||||
response_aoi_geojson = resolved_aoi[1] if resolved_aoi else None
|
||||
if not aoi_wkt:
|
||||
raise HTTPException(status_code=400, detail="区域空间覆盖规划必须选择行政区或上传 AOI。")
|
||||
coverage_params = params.model_copy(update={"strategy": "dinsar_province_coverage"})
|
||||
pairs, runtime_warnings, pairing_metadata = await spatial_service.find_dinsar_coverage_pairs(
|
||||
db,
|
||||
coverage_params,
|
||||
target_date_from=target_date_from,
|
||||
target_date_to=target_date_to,
|
||||
extension_days=extension_days,
|
||||
max_pairs=max_pairs,
|
||||
target_coverage_ratio=target_coverage_ratio,
|
||||
min_new_coverage_ratio=min_new_coverage_ratio,
|
||||
aoi_wkt=aoi_wkt,
|
||||
require_orbit_data=require_orbit_data,
|
||||
)
|
||||
return PairingResponse(
|
||||
pairs=pairs,
|
||||
aoi_geojson=response_aoi_geojson,
|
||||
warnings=runtime_warnings,
|
||||
fallback_used=bool(pairing_metadata.get("fallback_used")),
|
||||
degraded=bool(pairing_metadata.get("degraded")),
|
||||
policy_version=pairing_metadata.get("policy_version"),
|
||||
network_run_id=pairing_metadata.get("network_run_id"),
|
||||
candidate_count=int(pairing_metadata.get("candidate_count") or 0),
|
||||
selected_edge_count=int(pairing_metadata.get("selected_edge_count") or 0),
|
||||
coverage=pairing_metadata.get("coverage"),
|
||||
)
|
||||
except Exception as e:
|
||||
if isinstance(e, HTTPException):
|
||||
raise e
|
||||
if isinstance(e, (RuntimeError, ValueError)):
|
||||
raise HTTPException(status_code=409, detail=str(e))
|
||||
logger.exception("Failed to build D-InSAR coverage pairing plan")
|
||||
raise HTTPException(status_code=500, detail="Failed to build D-InSAR coverage pairing plan.")
|
||||
|
||||
|
||||
@router.post("/find-ps-timeseries", response_model=Dict[str, List[RadarData]])
|
||||
async def find_ps_timeseries_endpoint(
|
||||
params: PsRequest = Depends(get_ps_request_from_form),
|
||||
|
||||
Reference in New Issue
Block a user