Skip to content

Commit

Permalink
UT navigation follow divergences now
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Aug 21, 2024
1 parent d8ec44c commit f547697
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
24 changes: 16 additions & 8 deletions R/navigation_network.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ required_atts_navigate <- function(mode, distance) {
DM = c(id, levelpath, dn_levelpath,
topo_sort, dn_topo_sort),
UT = c(id, levelpath,
topo_sort, dn_topo_sort),
topo_sort, dn_topo_sort, dn_minor_topo_sort),
DD = c(id, levelpath, dn_levelpath,
topo_sort, dn_topo_sort, dn_minor_topo_sort))

Expand Down Expand Up @@ -43,10 +43,10 @@ get_start_row <- function(x, id) {
#' @details if only `mode` is supplied, require network attributes are displayed.
#'
#' NOTE: for "Upstream with tributaries" navigation, if a tributary emanates from
#' a diversion and is the minor path downstream of that diversion, it is not
#' followed. This can have a very large impact when a diversion between two
#' large river systems. For non-dendritic upstream with tributaries
#' network navigation, use \link{navigate_network_dfs}.
#' a diversion and is the minor path downstream of that diversion, it will be
#' included. This can have a very large impact when a diversion between two
#' large river systems. To strictly follow the dendritic network, set the
#' "dn_minor_topo_sort" attribute to all 0 in x.
#'
#' @returns vector of identifiers found along navigation
#' @name navigate_hydro_network
Expand Down Expand Up @@ -138,10 +138,18 @@ get_UT <- function(x, id, distance) {

x <- filter(x, .data$id %in% all)

filter(x, .data$pathlength_km <= stop_pathlength_km)$id
} else {
all
all <- filter(x, .data$pathlength_km <= stop_pathlength_km)$id
}

incoming_div <- filter(x, !id %in% all &
dn_minor_topo_sort %in% x$topo_sort[x$id %in% all])

extra <- lapply(incoming_div$id, \(i) get_UT(x, i, distance))

all <- c(all, unique(unlist(extra)))

return(all)

}

private_get_UT <- function(x, id) {
Expand Down
8 changes: 4 additions & 4 deletions man/navigate_hydro_network.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f547697

Please sign in to comment.