Skip to content

Commit

Permalink
relax requirement for new attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Aug 22, 2024
1 parent d23dfe7 commit 7f3bfb4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 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, dn_minor_topo_sort),
topo_sort, dn_topo_sort),
DD = c(id, levelpath, dn_levelpath,
topo_sort, dn_topo_sort, dn_minor_topo_sort))

Expand Down Expand Up @@ -116,6 +116,15 @@ navigate_hydro_network.hy <- function(x, start, mode, distance = NULL) {
"DD" = get_DD
)

if(mode == "UT") {
if(dn_minor_topo_sort %in% names(x)) {
required_atts <- c(required_atts, dn_minor_topo_sort)
} else {
# TODO: for a future release, remove this and add dn_minor_topo_sort to required at top of this file
warning(dn_minor_topo_sort, " will be a required attribute for UT navigation in a future release.")
}
}

fun(select(st_drop_geometry(x), all_of(required_atts)),
start, distance)

Expand All @@ -141,12 +150,14 @@ get_UT <- function(x, id, distance) {
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])
if(dn_minor_topo_sort %in% names(x)) {
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))
extra <- lapply(incoming_div$id, \(i) get_UT(x, i, distance))

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

return(all)

Expand Down

0 comments on commit 7f3bfb4

Please sign in to comment.