From 3f5a1a74e2e8ddaa2d8b200f5c6d6aa1e164b9b6 Mon Sep 17 00:00:00 2001 From: ConnectedSystems Date: Sun, 2 Aug 2026 18:13:20 +1000 Subject: [PATCH] fix: return empty raster instead of failing when viewport has no reef data When a FAST_REGIONAL_ASSESSMENT or FAST_SUITABILITY_ASSESSMENT scope does not intersect any reef pixels (e.g. a viewport over open water), the handlers were throwing ErrorException, marking the job as FAILED. assess_region_quality and find_optimal_site_alignment both handle empty slope tables gracefully: - assess_region_quality uses size(valid_extent) for region_dims (not maximum(lon_idx), which would throw), and the loop over quality_indicator simply runs 0 iterations. - find_optimal_site_alignment already has an early-exit for nrow==0. Remove the guards and log the row count at INFO level instead. The job now succeeds with an all-zero raster / empty geojson rather than failing. --- src/job_worker/handlers.jl | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/job_worker/handlers.jl b/src/job_worker/handlers.jl index 1a669cc..654650f 100644 --- a/src/job_worker/handlers.jl +++ b/src/job_worker/handlers.jl @@ -621,18 +621,8 @@ function handle_job( ) @info "Done setting up scoped regional assessment data" - # Guard: if the scope doesn't intersect any reef data, fail with a clear message - # rather than crashing inside assess_region_quality. - scoped_slope_table = regional_data.regions[input.region].slope_table - if nrow(scoped_slope_table) == 0 - throw( - ErrorException( - "No reef data found within the requested scope for region '$(input.region)'. " * - "Try selecting a larger area or an area that overlaps with known reef data." - ) - ) - end - @info "Scoped slope table has $(nrow(scoped_slope_table)) rows" + scoped_row_count = nrow(regional_data.regions[input.region].slope_table) + @info "Scoped slope table has $(scoped_row_count) rows (0 = no reef data in viewport)" @info "Compiling regional assessment parameters from regional data and input data" params = build_regional_assessment_parameters( @@ -699,17 +689,8 @@ function handle_job( ) @info "Done setting up scoped regional assessment data" - # Guard: if the scope doesn't intersect any reef data, fail with a clear message. - scoped_slope_table = regional_data.regions[input.region].slope_table - if nrow(scoped_slope_table) == 0 - throw( - ErrorException( - "No reef data found within the requested scope for region '$(input.region)'. " * - "Try selecting a larger area or an area that overlaps with known reef data." - ) - ) - end - @info "Scoped slope table has $(nrow(scoped_slope_table)) rows" + scoped_row_count = nrow(regional_data.regions[input.region].slope_table) + @info "Scoped slope table has $(scoped_row_count) rows (0 = no reef data in viewport)" @info "Compiling suitability assessment parameters from regional data and job inputs" params::ReefGuide.SuitabilityAssessmentParameters = build_suitability_assessment_parameters(