Skip to content

Commit

Permalink
Style and update NEWS for 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemahoney218 committed Jan 18, 2021
1 parent cd064ff commit ebae2b0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 22 deletions.
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# terrainr 0.2.1
* Improvements and bug fixes:
* The `transportation` endpoint has moved servers, and is now handled by the
same function that handles DEMs and orthoimages
* Internal changes:
* The main branch of `terrainr` is now `main`
* Tests run on a schedule on Monday/Wednesday/Friday mornings, to alert to
endpoint changes
* Restyled code

# terrainr 0.2.0
* Breaking changes:
* `merge_rasters` loses the argument `merge_raster`. For the "georeference
Expand Down
1 change: 0 additions & 1 deletion R/classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ terrainr_coordinate_pair <- function(coords, coord_units = c(
lat <- coords[[1]]
lng <- coords[[2]]
} else {

names(coords) <- tolower(names(coords))

if (all(names(coords) %in% c(latitude_names, longitude_names))) {
Expand Down
16 changes: 9 additions & 7 deletions R/get_bbox.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
#' @md
# nolint start
get_bbox <- function(data = NULL, lat = NULL, lng = NULL, na.rm = NULL) {
# lintr complains about na.rm but I want to mimic base R
# nolint end
# lintr complains about na.rm but I want to mimic base R
# nolint end
UseMethod("get_bbox")
}

#' @rdname get_bbox
#' @export
# nolint start
get_bbox.sf <- function(data, lat, lng, na.rm) {
# nolint end
# nolint end
coords <- as.data.frame(sf::st_coordinates(data))
terrainr::get_coord_bbox(lat = coords$Y, lng = coords$X, na.rm = na.rm)
}
Expand All @@ -55,16 +55,18 @@ get_bbox.sf <- function(data, lat, lng, na.rm) {
get_bbox.RasterLayer <- function(data, lat, lng, na.rm) {
# nolint end
coords <- raster::extent(data)
terrainr::get_coord_bbox(lat = c(coords@ymin, coords@ymax),
lng = c(coords@xmin, coords@xmax),
na.rm = na.rm)
terrainr::get_coord_bbox(
lat = c(coords@ymin, coords@ymax),
lng = c(coords@xmin, coords@xmax),
na.rm = na.rm
)
}

#' @rdname get_bbox
#' @export
# nolint start
get_coord_bbox <- function(data = NULL, lat, lng, na.rm = NULL) {
# nolint end
# nolint end
if (!is.null(data)) {
lat <- tryCatch(lat, error = function(e) rlang::ensym(lat))
lng <- tryCatch(lng, error = function(e) rlang::ensym(lng))
Expand Down
3 changes: 2 additions & 1 deletion R/hit_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ hit_national_map_api <- function(bbox,
res <- httr::GET(url, query = c(bbox_arg, query_arg))
body <- tryCatch(httr::content(res, type = "application/json"),
error = function(e) {
tryCatch({
tryCatch(
{
res <- httr::GET(url, query = c(bbox_arg, query_arg))
httr::content(res, type = "application/json")
},
Expand Down
2 changes: 1 addition & 1 deletion R/merge_rasters.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ merge_rasters <- function(input_rasters,
total_extent,
output_image,
overwrite = overwrite
)
)
)
invisible(
utils::capture.output(
gdalUtils::mosaic_rasters(
Expand Down
17 changes: 9 additions & 8 deletions tests/testthat/test-4-merge_rasters.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ test_that("merge_raster files are identical no matter the filename", {
# assign the output tile filenames...
tmptif <- vector("list")
temp_tiles <- get_tiles(first_tile,
services = c("elevation", "ortho"),
georeference = FALSE)
services = c("elevation", "ortho"),
georeference = FALSE
)
tmptif[[1]] <- temp_tiles[[1]]
tmptif[[2]] <- get_tiles(second_tile)[[1]]

Expand All @@ -57,16 +58,16 @@ test_that("merge_raster files are identical no matter the filename", {
)

merge_orth <- tempfile(fileext = ".tiff")
merge_rasters(temp_tiles[[1]],
tempfile(fileext = ".tif"),
temp_tiles[[2]],
merge_orth)
merge_rasters(
temp_tiles[[1]],
tempfile(fileext = ".tif"),
temp_tiles[[2]],
merge_orth
)

stored_raster <- raster::raster("testdata/merge_rasters_test.tif")
test_raster <- raster::raster(merge_orth)

expect_equal(stored_raster@crs, test_raster@crs)
expect_equal(stored_raster@extent, test_raster@extent)

})

1 change: 0 additions & 1 deletion tests/testthat/test-get_bbox.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ test_that("raster s3 method definitions work", {
get_bbox(raster::raster("testdata/3DEP.tif")),
tolerance = 0.00001
)

})
5 changes: 3 additions & 2 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test_that("distance conversions make sense", {
1000
)
expect_equal(terrainr::convert_distance(100, "feet"),
terrainr::convert_distance(1200, "inches"),
tolerance = 0.001)
terrainr::convert_distance(1200, "inches"),
tolerance = 0.001
)
})
1 change: 0 additions & 1 deletion tests/testthat/test-vector_to_overlay.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ test_that("vector_to_overlay generates the same tiles", {
png::readPNG("testdata/vto_poly.png")
)
})

0 comments on commit ebae2b0

Please sign in to comment.