Skip to content

fix: return empty raster instead of failing when viewport has no reef data - #13

Merged
ConnectedSystems merged 1 commit into
mainfrom
fix/empty-viewport-returns-zero-raster
Aug 2, 2026
Merged

fix: return empty raster instead of failing when viewport has no reef data#13
ConnectedSystems merged 1 commit into
mainfrom
fix/empty-viewport-returns-zero-raster

Conversation

@ConnectedSystems

Copy link
Copy Markdown
Collaborator

Summary

Removes the explicit throw(ErrorException(...)) guard in FastRegionalAssessmentHandler and FastSuitabilityAssessmentHandler when the scoped slope table is empty (i.e. the user's viewport contains no reef data).

Problem

When a user panned to an area with no reef data (e.g. Trunk Reef area in Cairns-Cooktown), the fast handlers would throw:

No reef data found within the requested scope for region '...'.
Try selecting a larger area or an area that overlaps with known reef data.

This caused the job to be marked as failed rather than returning an empty/zero result, which was confusing UX.

Fix

Remove both guards. The downstream functions already handle empty tables gracefully:

  • assess_region_quality uses size(valid_extent) for region_dims — safe for 0-row tables, returns an all-zero raster
  • find_optimal_site_alignment has an existing early-exit: nrow(lookup_tbl) == 0 → return empty DataFrame

The log line is kept (now as an info message) so empty viewports are still observable in logs.

… 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.
@ConnectedSystems
ConnectedSystems merged commit 604cc6a into main Aug 2, 2026
1 check passed
@ConnectedSystems
ConnectedSystems deleted the fix/empty-viewport-returns-zero-raster branch August 2, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant