Skip to content

Commit

Permalink
check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Oct 2, 2024
1 parent c85e3f0 commit 24cf370
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export(sort_network)
export(st_compatibalize)
export(to_flownetwork)
importFrom(RANN,nn2)
importFrom(data.table,.N)
importFrom(data.table,.SD)
importFrom(data.table,as.data.table)
importFrom(data.table,copy)
importFrom(data.table,data.table)
Expand Down
8 changes: 5 additions & 3 deletions R/index_points_to_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ matcher <- function(coords, points, search_radius, max_matches = 1) {
matched
}

utils::globalVariables(c("L1", "N", "nn.dists"))
#' @importFrom data.table .N .SD
matcher_dt <- function(coords, points, search_radius, max_matches = 1) {

max_match_ <- ifelse(nrow(coords) < 1000, nrow(coords), 1000)
Expand All @@ -56,10 +58,10 @@ matcher_dt <- function(coords, points, search_radius, max_matches = 1) {

# First get rid of duplicate nodes on the same line.
matched <- matched[, .SD[nn.dists == min(nn.dists)],
by = .(L1, point_id)]
by = list(L1, point_id)]

# Now limit to max matches per point
matched <- matched[, N := seq_len(.N), by = .(point_id)]
matched <- matched[, N := seq_len(.N), by = list(point_id)]

matched <- matched[N <= max_matches]

Expand Down Expand Up @@ -219,7 +221,7 @@ interp_meas <- function(m, x1, y1, x2, y2) {
#' sf::st_point(c(-76.88081, 39.36354))),
#' crs = 4326)
#'
#' index_points_to_lines(sample_flines, points),
#' index_points_to_lines(sample_flines, points,
#' search_radius = units::set_units(0.2, "degrees"),
#' max_matches = 10)
#'
Expand Down
2 changes: 1 addition & 1 deletion man/index_points_to_lines.Rd

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

0 comments on commit 24cf370

Please sign in to comment.