Draft
Conversation
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.
Seed-Based Constrained Flood Fill for Sea Cell Identification
Closes #159
Summary
Implements a seed-based constrained flood-fill algorithm to fix incorrect identification of sea cells in landward depressions.
Previously, the algorithm could mark isolated depressions behind dunes as "sea" even when water could not physically reach them. The new approach only expands through cells below still water level (SWL) from validated seed points, ensuring hydrological connectivity.
Problem Addressed
Before: Simple flood-fill used topological connectivity (adjacent cells) rather than hydrological connectivity (water can flow there), causing depressions behind barriers to be incorrectly flagged as sea.
After: Constrained flood-fill validates that water can physically reach cells by only expanding from known sea locations through cells below SWL.
Implementation
Two-Phase Algorithm
Phase 1: Seed Point Identification
omit_search_*_edgeconfigurationPhase 2: Constrained Flood-Fill
Configuration
New optional parameter in
.dat/.yamlfiles:If not specified, algorithm uses grid edges (original behavior with enhanced constraints).
Changes
Modified Files
src/locate_coast.cpp(~236 lines modified)FindAllSeaCells()to use seed-based approachCellByCellFillSea()with elevation constraint enforcementsrc/gis_vector.cpp(+101 lines)nReadSeaFloodSeedShapefile()to parse seed point shapefilesrc/read_input.cpp(+31 lines)SEA_FLOOD_SEED_LOCATION_SHAPEFILEparametersrc/configuration.h(+13 lines)m_strSeaFloodSeedShapefile(shapefile path)m_VSeaFloodSeedPoint(vector of seed points in grid CRS)src/simulation.h(+7 lines)nReadSeaFloodSeedShapefile()methodsrc/simulation.cpp(+10 lines)Total: +275 insertions, -123 deletions
Benefits
Testing Recommendations
Synthetic Test Cases
Simple depression: Beach → Dune → Depression
Dune with breach: Beach → Dune with gap → Depression
Seed point validation: Place seed in elevated area
Example Configuration
Migration Notes
Breaking change: Results may differ from previous versions as isolated depressions will no longer be incorrectly identified as sea.
To reproduce old behavior: Not recommended (was a bug), but algorithm maintains same edge-based seeding if no shapefile specified.
Commit:
6fb03ebf- "Added seep point based flood fill for sea cells"Date: 2025-11-03
Files changed: 6 files (+275, -123)