Skip to content

Commit

Permalink
🚚 Rename function to create polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
NONONOexe committed Sep 1, 2024
1 parent 4a96869 commit c6f72c8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ S3method(split_linestring,sfc_LINESTRING)
S3method(summary,road_network)
S3method(summary,segmented_network)
export(assign_event_to_link)
export(bbox_to_polygon)
export(create_bbox)
export(create_graph)
export(create_graph_links)
export(create_graph_nodes)
export(create_linestring)
export(create_midpoint_graph)
export(create_points)
export(create_polygon)
export(create_road_network)
export(create_segmented_network)
export(decompose_linestring)
Expand Down
6 changes: 3 additions & 3 deletions R/bbox-to-polygon.R → R/create-polygon.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#' Convert a bounding box to a polygon
#' Create polygon from bounding box
#'
#' This function convert a bounding box to a polygon.
#' This function creates a rectangle polygon from a bounding box.
#'
#' @param bbox A numeric matrix with two columns and two rows.
#' `bbox` represents the minimum and maximum coordinates.
#' @return A rectangle polygon with the same size as `bbox`.
#' @export
bbox_to_polygon <- function(bbox) {
create_polygon <- function(bbox) {
tl <- bbox[,1]
br <- bbox[,2]
tr <- c(tl[1], br[2])
Expand Down
2 changes: 1 addition & 1 deletion R/osm-roads.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ osm_roads <- function(bbox, crop = TRUE) {
# Crop to the specified bounding box
if (crop) {
lines <- st_set_agr(lines, "constant")
area <- bbox_to_polygon(bbox)
area <- create_polygon(bbox)
lines <- st_crop(lines, area)
}

Expand Down
12 changes: 6 additions & 6 deletions man/bbox_to_polygon.Rd → man/create_polygon.Rd

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

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
test_that("`bbox_to_polygon` converts bounding box to correct polygon", {
test_that("`create_polygon` creates correct polygon from bounding box", {
# Define a bounding box as a matrix
bbox <- matrix(
c(136.90090, 35.16377, 136.91590, 35.17377),
nrow = 2, dimnames = list(c("x", "y"), c("min", "max"))
)

# Convert the bounding box to a polygon
polygon <- bbox_to_polygon(bbox)
polygon <- create_polygon(bbox)

# Extract the coordinates of the polygon
actual_coords <- unname(polygon[[1]])
Expand Down

0 comments on commit c6f72c8

Please sign in to comment.