Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing wrapper function #1535

Draft
wants to merge 10 commits into
base: feature/routing-refactor
Choose a base branch
from

Conversation

emlys
Copy link
Member

@emlys emlys commented Feb 28, 2024

Description

Add a function route that encapsulates the common structure of routed functions in invest.

All our routed functions use a stack or queue to track which pixels can be processed next. There is some logic specific to the routing algorithm that identifies "seed" pixels (pixels that routing can begin from). Seed pixels are pushed to the stack.
There is a second chunk of logic that is applied to each pixel on the stack. This is the core of the routing algorithm. It calculates results and pushes neighboring pixels to the stack when possible. The route wrapper separates these chunks of logic into a seed_fn and a route_fn.

The seed_fn must accept x and y parameters. Other arbitrary parameters are also allowed. It returns a boolean (True if the pixel at (x, y) meets the criteria for a seed pixel, False otherwise).

The route_fn must accept x and y parameters. Other arbitrary parameters are also allowed. It performs calculations and sets values in the target rasters for the pixel (x, y). It returns a list of pixels that can now be pushed to the stack (represented as flat indexes).

Checklist

  • Updated HISTORY.rst and link to any relevant issue (if these changes are user-facing)
  • Updated the user's guide (if needed)
  • Tested the Workbench UI (if relevant)

@emlys emlys changed the title rough draft of routing wrapper fn and use it in ndr Routing wrapper function Mar 1, 2024
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.

None yet

1 participant