fix: return empty raster instead of failing when viewport has no reef data - #13
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the explicit
throw(ErrorException(...))guard inFastRegionalAssessmentHandlerandFastSuitabilityAssessmentHandlerwhen 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:
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_qualityusessize(valid_extent)forregion_dims— safe for 0-row tables, returns an all-zero rasterfind_optimal_site_alignmenthas an existing early-exit:nrow(lookup_tbl) == 0 → return empty DataFrameThe log line is kept (now as an info message) so empty viewports are still observable in logs.