diff --git a/NAMESPACE b/NAMESPACE index 56ca275..41f4f2d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,7 +10,6 @@ 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) @@ -18,6 +17,7 @@ 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) diff --git a/R/bbox-to-polygon.R b/R/create-polygon.R similarity index 74% rename from R/bbox-to-polygon.R rename to R/create-polygon.R index 32bd204..6fe14c9 100644 --- a/R/bbox-to-polygon.R +++ b/R/create-polygon.R @@ -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]) diff --git a/R/osm-roads.R b/R/osm-roads.R index 392fe1d..c13af7e 100644 --- a/R/osm-roads.R +++ b/R/osm-roads.R @@ -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) } diff --git a/man/bbox_to_polygon.Rd b/man/create_polygon.Rd similarity index 55% rename from man/bbox_to_polygon.Rd rename to man/create_polygon.Rd index 7a1557f..9ce3811 100644 --- a/man/bbox_to_polygon.Rd +++ b/man/create_polygon.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bbox-to-polygon.R -\name{bbox_to_polygon} -\alias{bbox_to_polygon} -\title{Convert a bounding box to a polygon} +% Please edit documentation in R/create-polygon.R +\name{create_polygon} +\alias{create_polygon} +\title{Create polygon from bounding box} \usage{ -bbox_to_polygon(bbox) +create_polygon(bbox) } \arguments{ \item{bbox}{A numeric matrix with two columns and two rows. @@ -14,5 +14,5 @@ bbox_to_polygon(bbox) A rectangle polygon with the same size as \code{bbox}. } \description{ -This function convert a bounding box to a polygon. +This function creates a rectangle polygon from a bounding box. } diff --git a/tests/testthat/test-bbox-to-polygon.R b/tests/testthat/test-create-polygon.R similarity index 86% rename from tests/testthat/test-bbox-to-polygon.R rename to tests/testthat/test-create-polygon.R index 20fc897..592d83e 100644 --- a/tests/testthat/test-bbox-to-polygon.R +++ b/tests/testthat/test-create-polygon.R @@ -1,4 +1,4 @@ -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), @@ -6,7 +6,7 @@ test_that("`bbox_to_polygon` converts bounding box to correct polygon", { ) # 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]])