Skip to content

Commit

Permalink
Transform angle threshold to radians in main function
Browse files Browse the repository at this point in the history
  • Loading branch information
cforgaci committed Nov 11, 2024
1 parent bdf4731 commit 854319d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/stroke.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ stroke <- function(edges, angle_threshold = 0, attributes = FALSE,

# extract CRS from the edges
crs <- sf::st_crs(edges_sfc)

Check warning on line 46 in R/stroke.R

View workflow job for this annotation

GitHub Actions / lint

file=R/stroke.R,line=46,col=1,[trailing_whitespace_linter] Trailing whitespace is superfluous.
# convert angle threshold to radians
angle_threshold_rad <- angle_threshold / 180 * pi

# split the edges into their constituent points
edge_pts <- sfheaders::sfc_to_df(edges_sfc)
Expand All @@ -57,7 +60,7 @@ stroke <- function(edges, angle_threshold = 0, attributes = FALSE,
links <- get_links(segments)

# calculate interior angles between segment pairs, identify best links
best_links <- best_link(nodes, segments, links, angle_threshold)
best_links <- best_link(nodes, segments, links, angle_threshold_rad)

# verify that the best links identified fulfill input requirements
final_links <- cross_check_links(best_links, flow_mode)
Expand Down Expand Up @@ -136,8 +139,6 @@ best_link <- function(nodes, segments, links, angle_threshold = 0) {
best_links <- array(integer(), dim = dim(segments))
colnames(best_links) <- c("start", "end")

angle_threshold_rad <- angle_threshold / 180 * pi # convert to radians

for (iseg in seq_len(nrow(segments))) {
start_node <- segments[iseg, "start"]
end_node <- segments[iseg, "end"]
Expand Down

0 comments on commit 854319d

Please sign in to comment.