diff --git a/DESCRIPTION b/DESCRIPTION index 81604a5..c88297f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: fresh Title: Freshwater Referenced Spatial Hydrology -Version: 0.27.1 +Version: 0.27.2 Authors@R: c( person("Allan", "Irvine", , "al@newgraphenvironment.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3495-2128")), diff --git a/NEWS.md b/NEWS.md index 8191977..9738dd1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# fresh 0.27.2 + +Fix `frs_order_child()` SQL referencing nonexistent column `s.stream_order_max`. `fresh.streams` has `stream_order` and `stream_order_parent` from FWA but no `stream_order_max` — the 0.27.0 SQL failed at execution against any real database (only the SQL-shape unit tests passed, and they asserted the broken predicate). Drop the broken predicate; default both `child_order_min` and `child_order_max` to `1L` when neither is set, which matches bcfishpass's hardcoded `stream_order = 1` predicate exactly. Caller-passed bounds still apply unchanged. + +Adds a regression test that scans the emitted SQL across every parameter combination for `stream_order_max` and fails if it reappears. + # fresh 0.27.1 Patch follow-up to 0.27.0. `.frs_load_rules` validator now accepts the `channel_width_min_bypass` predicate that link emits to drive `frs_order_child()` post-classify (link#96 wiring). Validates that the field is a named mapping with `stream_order` and `stream_order_parent_min` integer scalars. Without this patch, link's emitted rules.yaml fails fast at `frs_params()` with `unknown predicates: channel_width_min_bypass` before any classification runs. diff --git a/R/frs_order_child.R b/R/frs_order_child.R index ed061c6..b724a77 100644 --- a/R/frs_order_child.R +++ b/R/frs_order_child.R @@ -27,19 +27,21 @@ #' #' @section Direct-child semantics: #' -#' A "direct child" of a large river is a segment whose order matches -#' the highest order on its blue_line_key — i.e., it flows directly -#' into the parent river, not as a sub-tributary inside a multi-order -#' network: +#' A "direct child" of a large river is a segment whose stream_order +#' matches the caller's child-order filter (`child_order_min` / +#' `child_order_max`) AND whose `stream_order_parent` (the order of +#' the river it flows into) is `>= parent_order_min`: #' #' ``` -#' s.stream_order = s.stream_order_max -- (on the same blue_line_key) #' s.stream_order_parent >= parent_order_min +#' [AND s.stream_order >= child_order_min] +#' [AND s.stream_order <= child_order_max] #' ``` #' -#' The `stream_order = stream_order_max` test implicitly captures -#' "stop at order change" — once the segment's order would exceed -#' `stream_order_max`, you're no longer on the direct-child reach. +#' Default child filter is `stream_order = 1` (matches bcfishpass's +#' hard-coded predicate exactly). Pass `child_order_min` / `child_order_max` +#' to widen — e.g. `child_order_min = 1, child_order_max = 2` for +#' order-1 and order-2 tributaries. #' #' @section Distance grain: #' @@ -60,10 +62,9 @@ #' AND .species_code = '' #' AND .accessible = TRUE #' AND .