Skip to content

Commit

Permalink
address further nhddplusTools dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dblodgett-usgs committed Jan 15, 2024
1 parent a017376 commit 8127ed3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: hydroloom
Title: Utilities to Weave Hydrologic Fabrics
Version: 1.0.1
Version: 1.0.2
Authors@R:
person(given = "David",
family = "Blodgett",
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
hydroloom 1.0.1
hydroloom 1.0.1 and 1.0.2
==========

- Add checks if nhdplusTools is available.
Expand Down
2 changes: 2 additions & 0 deletions R/disambiguate.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' value, duplicates will be returned.
#' @export
#' @examples
#' if(require(nhdplusTools)) {
#' source(system.file("extdata", "sample_flines.R", package = "nhdplusTools"))
#'
#' hydro_location <- sf::st_sf(id = c(1, 2, 3),
Expand Down Expand Up @@ -45,6 +46,7 @@
#' result[result$point_id == 2, ]
#'
#' result[result$point_id == 3, ]
#' }
#'
disambiguate_indexes <- function(indexes, flowpath, hydro_location) {
orig_index_names <- names(indexes)
Expand Down
3 changes: 2 additions & 1 deletion R/get_hydro_location.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @returns sfc_POINT simple feature geometry list of length `nrow(indexes)`
#' @export
#' @examples
#' if(require(nhdplusTools)) {
#' source(system.file("extdata", "sample_flines.R", package = "nhdplusTools"))
#'
#' indexes <- index_points_to_lines(sample_flines,
Expand All @@ -16,7 +17,7 @@
#' crs = 4326)))
#'
#' get_hydro_location(indexes, sample_flines)
#'
#'}
get_hydro_location <- function(indexes, flowpath) {
flowpath <- hy(flowpath)

Expand Down
3 changes: 2 additions & 1 deletion R/index_points_to_lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ interp_meas <- function(m, x1, y1, x2, y2) {
#' @examples
#'
#' \donttest{
#'
#' if(require(nhdplusTools)) {
#' source(system.file("extdata", "sample_flines.R", package = "nhdplusTools"))
#'
#' point <- sf::st_sfc(sf::st_point(c(-76.87479, 39.48233)),
Expand All @@ -178,6 +178,7 @@ interp_meas <- function(m, x1, y1, x2, y2) {
#' max_matches = 10)
#'
#' }
#' }
#'
index_points_to_lines <- function(x, points,
search_radius = NULL,
Expand Down
2 changes: 2 additions & 0 deletions man/disambiguate_indexes.Rd

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

3 changes: 2 additions & 1 deletion man/get_hydro_location.Rd

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

3 changes: 2 additions & 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.

5 changes: 5 additions & 0 deletions tests/testthat/test_index.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if(require(nhdplusTools)) {

sample_flines <- sf::st_cast(sample_flines, "LINESTRING", warn = FALSE)
}

test_that("point indexing to nearest existing node works as expected", {

if(!require(nhdplusTools)) skip("Missing nhdplusTools")
Expand Down Expand Up @@ -108,6 +109,8 @@ test_that("point indexing to nearest existing node works as expected", {

test_that("point indexing works without measures", {

if(!require(nhdplusTools)) skip("Missing nhdplusTools")

flines_in <- sample_flines

flines_in <- sf::st_cast(sf::st_transform(flines_in, 4269),
Expand All @@ -126,6 +129,8 @@ test_that("point indexing works without measures", {

test_that("point indexing to for multiple points works", {

if(!require(nhdplusTools)) skip("Missing nhdplusTools")

flines_in <- sample_flines

flines_in <- sf::st_transform(flines_in, 4269)
Expand Down

0 comments on commit 8127ed3

Please sign in to comment.