Unverified Commit 177af7d1 authored by Laura A DeCicco's avatar Laura A DeCicco Committed by GitHub
Browse files

Merge pull request #549 from dblodgett-usgs/master

CI upgrades
parents 58b0ae25 50483382
Pipeline #29434 failed with stage
......@@ -43,4 +43,4 @@ README.Rmd
vignettes/tutorial.Rmd
vignettes/phosData.rds
vignettes/waterservices.png
.gitlab-ci.yml
......@@ -21,8 +21,8 @@ jobs:
- {os: macOS-latest, r: 'devel'}
- {os: macOS-latest, r: '4.0'}
- {os: windows-latest, r: '4.0'}
- {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- {os: ubuntu-18.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
......@@ -61,6 +61,10 @@ jobs:
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: mac dependencies
if: runner.os == 'macOS'
run: brew install pkg-config gdal proj geos udunits
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
......
variables:
_R_CHECK_CRAN_INCOMING_: "false"
_R_CHECK_FORCE_SUGGESTS_: "true"
_R_CHECK_DONTTEST_EXAMPLES_: "false"
NOT_CRAN: "true"
before_script:
- apt-get update
- apt-get install -y --no-install-recommends qpdf pandoc pandoc-citeproc
- export PATH="/usr/local/lib/R/site-library/littler/examples/:${PATH}"
- echo "options(Ncpus = $(nproc --all))" >> /usr/local/lib/R/etc/Rprofile.site
- install2.r devtools
- r -e 'devtools::install_dev_deps()'
test:
stage: test
tags:
- chs-shared
image: code.chs.usgs.gov:5001/wma/hydrogeoenv:rocker-geospatial
script:
- r -e 'devtools::check(check_dir = ".")'
- r -e 'capture.output(print(covr::coverage_to_list(covr::package_coverage(type = "all")), width = 20), file = "covr.txt", split = TRUE)'
artifacts:
paths:
- "*.Rcheck"
- "covr.txt"
......@@ -39,10 +39,10 @@ get_nldi_sources <- function() {
}
#' @title Query NLDI
#' @description Queries the NLDI for a given URL. If local sf install is
#' available the function returns a sf data.frame.
#' If the object requested is a POINT object, the XY coordinates are added
#' as columns. Otherwise the columns returned are "sourceName" and
#' @description Queries the NLDI for a given URL. If local sf install is
#' available the function returns a sf data.frame.
#' If the object requested is a POINT object, the XY coordinates are added
#' as columns. Otherwise the columns returned are "sourceName" and
#' "identifier" for features, and "nhdplus_comid".
#' @param url the URL to retrieve
#' @param type the type of data being returned (nav or feature)
......@@ -57,7 +57,7 @@ get_nldi_sources <- function() {
#' base = "https://labs.waterdata.usgs.gov/api/nldi/linked-data/"
#' get_nldi(paste0(base, "comid/101"), type = "feature", use_sf = FALSE)
#' get_nldi(paste0(base, "comid/101"), type = "feature", use_sf = TRUE)
#' get_nldi(paste0(base, "nwissite/USGS-11120000"), type = "feature", use_sf = TRUE)
#' get_nldi(url = paste0(base, "nwissite/USGS-11120000"), type = "feature", use_sf = TRUE)
#' get_nldi(paste0(base, "nwissite/USGS-11120000"), type = "feature", use_sf = TRUE)
#' }
......@@ -149,7 +149,7 @@ clean_nwis_ids = function(tmp) {
# If data.frame, and of type NWIS, then strip "USGS-" from identifiers
if (is.data.frame(tmp)) {
if ("sourceName" %in% names(tmp) &&
if ("sourceName" %in% names(tmp) &&
tmp$sourceName[1] == "NWIS Sites") {
tmp$identifier = gsub("USGS-", "", tmp$identifier)
......@@ -168,40 +168,54 @@ clean_nwis_ids = function(tmp) {
#' @noRd
#' @examples
#' \dontrun{
#' valid_ask(get_nldi_sources(), "nwis")
#' valid_ask(all = get_nldi_sources(), "nwis")
#' }
valid_ask = function(all, type){
# those where the requested pattern is included in a nldi_source ...
# means we will catch nwis - not just nwissite ...
# means we will catch both wqp and WQP ...
cond <- grepl(paste0(tolower(type), collapse = "|"), tolower(all$source))
cond2 <- grepl(paste0(tolower(all$source), collapse = "|"), tolower(type))
### WOW! This is hacky and will hopefully be unneeded latter on....
all = rbind(all, c("flowlines", "NHDPlus", NA))
cond <- grepl(paste0(tolower(type), collapse = "|"), tolower(c(all$source)))
cond2 <- grepl(paste0(tolower(all$source), collapse = "|"), tolower(c(all$source)))
list(good = all[cond,], bad = type[!cond2])
}
#' @title Retrieve features from the \href{https://labs.waterdata.usgs.gov/api/nldi/swagger-ui/index.html?configUrl=/api/nldi/v3/api-docs/swagger-config}{NLDI}
#' @description Provides a formal query to the
#' @title R Client for the Network Linked Data Index
#' @description Provides a formal client to the USGS
#' \href{https://labs.waterdata.usgs.gov/about-nldi/index.html}{Network Linked Data Index}.
#' The function is useful for topology and location based feature discovery.
#' A user must supply a starting feature, and can add optional navigation direction(s),
#' and features to identify on the navigated network.
#' Valid starting options can be given by one of the following arguments: comid, nwis, huc12,
#' wqp, location, and start.
#' @param comid an NHDPlusV2 COMID
#' @param nwis a USGS NWIS siteID
#' @param wqp a water quality point ID
#' @param huc12 a HUC12 ID
#' @param location Coordinate pair in WGS84 GCS provided as a numeric vector ordered lng/lat
#' @param origin a named list specifying a feature type and ID (e.g. list("comid" = 101))
#' @param nav where to navigate from the starting point ("UM", "UT", DM", "DD")
#' @param find what resources to find along the navigation path(s) (see get_nldi_sources()$source). Can also include 'basin', which will return the upstream basin of the starting feature
#' @param distance_km how far to look along the navigation path in kilometers (default = 100)
#' @param no_sf if available, should `sf` be used for parsing, defaults to `TRUE` if `sf` is locally installed
#' @return a list of data.frames
#' @details The function is useful for topology and location based
#' feature discovery. A user must specify an origin feature, optional navigation
#' direction(s) along the network, as well as features to identify along the
#' navigated paths. Valid starting options can be given by one of the following
#' arguments: comid, nwis, huc12, wqp, location, and start.
#' @param comid numeric or character. An NHDPlusV2 COMID
#' @param nwis numeric or character. A USGS NWIS siteID
#' @param wqp numeric or character. A water quality point ID
#' @param huc12 numeric or character. A WBD HUC12 unit ID
#' @param location numeric vector. Coordinate pair in WGS84
#' SRS ordered lng/lat (X,Y)
#' @param origin named list. Specifying a feature type and ID
#' (e.g. list("comid" = 101))
#' @param nav character vector. where to navigate from the starting point.
#' Options include along the upper mainsteam (UM), upstream tributary (UT),
#' downstream mainstem (DM) and downstream divergences (DD). You may select
#' one or more of the abbreviations ("UM", "UT", DM", "DD").
#' @param find character vector. Define what resources to find along the
#' navigation path(s) (see get_nldi_sources()$source). Can also include 'basin'
#' or 'flowline', which will return the upstream basin of the starting feature
#' or flowlines along the navigation respectively. The default is "flowlines". If you provide any other resource, AND want flowlines, then flowlines must be explicitly requested.
#' @param distance_km numeric. Define how far to look along the navigation path in
#' kilometers (default = 100)
#' @param no_sf if available, should `sf` be used for parsing,
#' defaults to `TRUE` if `sf` is locally installed
#' @return a list of data.frames if sf is not installed, a list of sf objects if it is
#' @export
#' @keywords nldi
#' @examples
......@@ -226,52 +240,45 @@ valid_ask = function(all, type){
#' ## GENERAL ORIGIN: WaDE
#' findNLDI(origin = list("wade" = 'CA_45206'))
#'
#' # Navigation
#' # Navigation (flowlines will be returned if find is unspecified)
#' # UPPER MAINSTEM of USGS-11120000
#' str(findNLDI(nwis = '11120000', nav = "UM"), max.level = 1)
#' findNLDI(nwis = '11120000', nav = "UM")
#'
#' # MULTI-REQUEST
#' # UPPER MAINSTEM and TRIBUTARY of USGS-11120000
#' str(findNLDI(nwis = '11120000', nav = c("UT", "UM")), max.level = 1)
#' findNLDI(nwis = '11120000', nav = c("UT", "UM"))
#'
#' # Discover Features
#' # Discover Features(flowlines will not be returned unless included in find)
#'
#' ## Find feature(s) on the upper tributary of USGS-11120000
#' str(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp")), max.level = 1)
#' findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp"))
#'
#' ## Find upstream basin boundary of USGS-11120000
#' str(findNLDI(nwis = '11120000', find = "basin"), max.level = 1)
#' ## Find upstream basin boundary and of USGS-11120000
#' findNLDI(nwis = '11120000', find = "basin")
#'
#' # Control Distance
#'
#' ## Limit search to 100 km
#' str(findNLDI(comid = 101, nav = "DM", find = c("nwis", "wqp"), distance_km = 100), max.level = 1)
#'
#' ## Convert returned list of data.frames to list of spatial features
#' \donttest{
#' nldi = findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp"))
#' str(nldi, max.level = 1)
#' }
#' ## Limit search to 50 km
#' findNLDI(comid = 101, nav = "DM", find = c("nwis", "wqp", "flowlines"), distance_km = 50)
findNLDI <- function(comid = NULL,
nwis = NULL,
wqp = NULL,
huc12 = NULL,
location = NULL,
origin = NULL,
nav = NULL,
find = NULL,
distance_km = 100,
no_sf = FALSE) {
nwis = NULL,
wqp = NULL,
huc12 = NULL,
location = NULL,
origin = NULL,
nav = NULL,
find = c("flowlines"),
distance_km = 100,
no_sf = FALSE) {
# Should sf be used? Both no_sf and pkg.env must agree
use_sf = all(pkg.env$local_sf, !no_sf)
# Should the basin be identified?
getBasin = ("basin" %in% find)
# From the collection of all possible origins, pick 1 and remove NULLS
# From the collection of possible origins, pick 1 and remove NULLS
starter <- tc(c(
list(
comid = comid,
......@@ -289,10 +296,10 @@ findNLDI <- function(comid = NULL,
}
# Ensure nav types are valid
bad_nav = !nav %in% c("UM", "UT", "DD", "DM")
bad_nav <- !nav %in% c("UM", "UT", "DD", "DM")
if (any(bad_nav)) {
stop(nav[bad_nav], " not a valid navigation. Use one of: UM, UT, DD, DM")
stop(nav[bad_nav], " not a valid navigation. Chose from: UM, UT, DD, DM")
}
# name of starter
......@@ -300,42 +307,44 @@ findNLDI <- function(comid = NULL,
# If location, ensure lng is first argument (hack for USA features)
if (start_type == 'location') {
if (location[1] > 0) {
stop("Please provide location in the form c(lng,lat)")
if(any(grepl("sfc$|sf$", class(location))) & use_sf ) {
if(sf::st_geometry_type(location) != "POINT"){
stop("Only POINT objects can be passed to location")
}
location = sf::st_coordinates(location)
} else {
if (location[1] > 0) { stop("Provide location in the form c(lng,lat)") }
}
# Must convert location to COMID for tracing and discovery ...
tmp_url = paste0(
tmp_url <- paste0(
pkg.env$nldi_base,
"comid/position?coords=POINT%28",
location[1] ,
"%20",
location[2] ,
"%29"
location[1] , "%20", location[2] , "%29"
)
tmp_return = get_nldi(tmp_url, "feature", use_sf = use_sf)
tmp_return <- get_nldi(tmp_url, "feature", use_sf = use_sf)
# Override starter with location based COMID
starter = list("comid" = tmp_return$identifier)
starter <- list("comid" = tmp_return$identifier)
}
# Reset (if needed)
start_type = names(starter)
start_type <- names(starter)
if(is.null(pkg.env$current_nldi)) {
pkg.env$current_nldi <- get_nldi_sources()
}
# Defining the origin URL.
# Align request with formal name from offerings
# If NWIS, add "USGS-" prefix
# Align request with formal name from sources
# If NWIS, add "USGS-" prefix
start_url = paste0(
valid_ask(pkg.env$current_nldi, type = start_type)$good$feature,
"/",
ifelse(start_type == "nwis", paste0("USGS-", starter), starter),
"/"
valid_ask(pkg.env$current_nldi, type = start_type)$good$feature, "/",
ifelse(start_type == "nwis", paste0("USGS-", starter), starter), "/"
)
# Makes sure that all requested features to `find` are valid and name-aligned
......@@ -344,67 +353,49 @@ findNLDI <- function(comid = NULL,
}
# Set empty lists to store origin, navigation, features, and basin requests ...
start <- navigate <- features <- basin <- list()
# Set origin url
start[["start"]] <- start_url
navigate <- features <- list()
# Build navigation URLs
for (i in seq_along(nav)) {
navigate[[nav[i]]] = paste0(start_url, "navigation/", nav[i])
}
# Build basin URL
if (getBasin) {
basin[["basin"]] = paste0(start_url, "basin")
}
# Build find URLs
if (length(find) > 0) {
features = lapply(navigate, paste0, paste0("/", find))
features = lapply(navigate, paste0, paste0("/", find), paste0("?distance=", distance_km))
}
# Add distance constraints to features
features = lapply(features, paste0, paste0("?distance=", distance_km))
# Add distance constraints to navigations flowpaths
navigate = lapply(navigate, paste0, paste0("/flowlines?distance=", distance_km))
names <- unlist(lapply(nav, paste0, paste0("_", find)))
# combine, unlist, relist
ll = as.list(unlist(c(start, basin, navigate, features)))
search <- data.frame(
url = unlist(c(start_url,
if (getBasin) { paste0(start_url, "basin") },
features)),
# define the type of each URL (feature, basin, or nav)
# This is needed as the attribute names for each varies
types = c("feature",
if (getBasin) { 'basin' },
rep("nav", length(nav)),
rep("feature", length(find) * length(nav)))
type = c("feature",
if(getBasin) { 'basin' },
ifelse(rep(find, length(nav)) == "flowlines", "nav", "feature")),
name = c("origin",
if (getBasin) { 'basin' },
names[!names %in% c("UM_", "UT_", "DD_", "DM_")])
)
# Send NLDI queries ...
shp = lapply(seq_along(ll), function(x) {
get_nldi(ll[[x]], type = types[x], use_sf = use_sf)
shp <- lapply(1:nrow(search), function(x) {
get_nldi(search$url[x], type = search$type[x], use_sf = use_sf)
})
# Remove basin from find list ...
find = find[find != 'basin']
# if no features (aside from basin) were requested then names are NULL
# else, the names are the combination of the navigation direction
# and the feature discovered ...
feats = if (is.null(find) | length(find) == 0) {
NULL
} else {
unlist(lapply(nav, paste0, paste0("_", find)))
}
# Set the names of the parsed URL list
names(shp) = c("origin",
if (getBasin){'basin'},
nav,
feats)
names(shp) <- search$name
# Clean up NWIS ids, trim NULLs, and return ...
tc(lapply(shp, clean_nwis_ids))
shp = tc(lapply(shp, clean_nwis_ids))
if(length(shp) == 1){
shp = shp[[1]]
}
return(shp)
}
......@@ -2,7 +2,7 @@
% Please edit documentation in R/findNLDI.R
\name{findNLDI}
\alias{findNLDI}
\title{Retrieve features from the \href{https://labs.waterdata.usgs.gov/api/nldi/swagger-ui/index.html?configUrl=/api/nldi/v3/api-docs/swagger-config}{NLDI}}
\title{R Client for the Network Linked Data Index}
\usage{
findNLDI(
comid = NULL,
......@@ -12,43 +12,55 @@ findNLDI(
location = NULL,
origin = NULL,
nav = NULL,
find = NULL,
find = c("flowlines"),
distance_km = 100,
no_sf = FALSE
)
}
\arguments{
\item{comid}{an NHDPlusV2 COMID}
\item{comid}{numeric or character. An NHDPlusV2 COMID}
\item{nwis}{a USGS NWIS siteID}
\item{nwis}{numeric or character. A USGS NWIS siteID}
\item{wqp}{a water quality point ID}
\item{wqp}{numeric or character. A water quality point ID}
\item{huc12}{a HUC12 ID}
\item{huc12}{numeric or character. A WBD HUC12 unit ID}
\item{location}{Coordinate pair in WGS84 GCS provided as a numeric vector ordered lng/lat}
\item{location}{numeric vector. Coordinate pair in WGS84
SRS ordered lng/lat (X,Y)}
\item{origin}{a named list specifying a feature type and ID (e.g. list("comid" = 101))}
\item{origin}{named list. Specifying a feature type and ID
(e.g. list("comid" = 101))}
\item{nav}{where to navigate from the starting point ("UM", "UT", DM", "DD")}
\item{nav}{character vector. where to navigate from the starting point.
Options include along the upper mainsteam (UM), upstream tributary (UT),
downstream mainstem (DM) and downstream divergences (DD). You may select
one or more of the abbreviations ("UM", "UT", DM", "DD").}
\item{find}{what resources to find along the navigation path(s) (see get_nldi_sources()$source). Can also include 'basin', which will return the upstream basin of the starting feature}
\item{find}{character vector. Define what resources to find along the
navigation path(s) (see get_nldi_sources()$source). Can also include 'basin'
or 'flowline', which will return the upstream basin of the starting feature
or flowlines along the navigation respectively. The default is "flowlines". If you provide any other resource, AND want flowlines, then flowlines must be explicitly requested.}
\item{distance_km}{how far to look along the navigation path in kilometers (default = 100)}
\item{distance_km}{numeric. Define how far to look along the navigation path in
kilometers (default = 100)}
\item{no_sf}{if available, should `sf` be used for parsing, defaults to `TRUE` if `sf` is locally installed}
\item{no_sf}{if available, should `sf` be used for parsing,
defaults to `TRUE` if `sf` is locally installed}
}
\value{
a list of data.frames
a list of data.frames if sf is not installed, a list of sf objects if it is
}
\description{
Provides a formal query to the
Provides a formal client to the USGS
\href{https://labs.waterdata.usgs.gov/about-nldi/index.html}{Network Linked Data Index}.
The function is useful for topology and location based feature discovery.
A user must supply a starting feature, and can add optional navigation direction(s),
and features to identify on the navigated network.
Valid starting options can be given by one of the following arguments: comid, nwis, huc12,
wqp, location, and start.
}
\details{
The function is useful for topology and location based
feature discovery. A user must specify an origin feature, optional navigation
direction(s) along the network, as well as features to identify along the
navigated paths. Valid starting options can be given by one of the following
arguments: comid, nwis, huc12, wqp, location, and start.
}
\examples{
......@@ -72,31 +84,24 @@ Valid starting options can be given by one of the following arguments: comid, nw
## GENERAL ORIGIN: WaDE
findNLDI(origin = list("wade" = 'CA_45206'))
# Navigation
# Navigation (flowlines will be returned if find is unspecified)
# UPPER MAINSTEM of USGS-11120000
str(findNLDI(nwis = '11120000', nav = "UM"), max.level = 1)
findNLDI(nwis = '11120000', nav = "UM")
# MULTI-REQUEST
# UPPER MAINSTEM and TRIBUTARY of USGS-11120000
str(findNLDI(nwis = '11120000', nav = c("UT", "UM")), max.level = 1)
findNLDI(nwis = '11120000', nav = c("UT", "UM"))
# Discover Features
# Discover Features(flowlines will not be returned unless included in find)
## Find feature(s) on the upper tributary of USGS-11120000
str(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp")), max.level = 1)
findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp"))
## Find upstream basin boundary of USGS-11120000
str(findNLDI(nwis = '11120000', find = "basin"), max.level = 1)
## Find upstream basin boundary and of USGS-11120000
findNLDI(nwis = '11120000', find = "basin")
# Control Distance
## Limit search to 100 km
str(findNLDI(comid = 101, nav = "DM", find = c("nwis", "wqp"), distance_km = 100), max.level = 1)
## Convert returned list of data.frames to list of spatial features
\donttest{
nldi = findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp"))
str(nldi, max.level = 1)
}
## Limit search to 50 km
findNLDI(comid = 101, nav = "DM", find = c("nwis", "wqp", "flowlines"), distance_km = 50)
}
\keyword{nldi}
......@@ -2,35 +2,34 @@ context("NLDI...")
test_that("NLDI offerings...", {
skip_on_cran()
expect_true(nrow(get_nldi_sources()) > 1)
})
test_that("NLDI starting sources...", {
skip_on_cran()
# LINESTRING GEOMETERY
expect_equal(sum(names(findNLDI(comid = 101)[[1]]) %in%
expect_equal(sum(names(findNLDI(comid = 101)) %in%
c('sourceName', 'identifier', "comid", "geometry")), 4)
# POINT GEOMETERY
expect_equal(sum(names(findNLDI(nwis = '11120000')[[1]]) ==
c('sourceName', 'identifier', "comid",
expect_equal(sum(names(findNLDI(nwis = '11120000')) ==
c('sourceName', 'identifier', "comid",
"X", "Y", "geometry")), 6)
# COMID
expect_equal(findNLDI(comid = 101)[[1]]$sourceName, "NHDPlus comid")
expect_equal(findNLDI(comid = 101)$sourceName, "NHDPlus comid")
# NWIS
expect_equal(findNLDI(nwis = '11120000')[[1]]$sourceName, "NWIS Sites")
expect_equal(findNLDI(nwis = '11120000')$sourceName, "NWIS Sites")
# WQP
expect_equal(findNLDI(wqp = 'USGS-04024315')[[1]]$sourceName, "Water Quality Portal")
expect_equal(findNLDI(wqp = 'USGS-04024315')$sourceName, "Water Quality Portal")
# LOCATION
expect_equal(findNLDI(location = c(-115,40))[[1]]$sourceName, "NHDPlus comid")
expect_equal(findNLDI(location = c(-115,40))$sourceName, "NHDPlus comid")
# ERROR: LOCATION COORDINATES FLIPPED
expect_error(findNLDI(location = c(40, -115)))
# GENERAL START: STABLE
expect_equal(findNLDI(origin = list("comid" = 101))[[1]]$sourceName, "NHDPlus comid")
expect_equal(findNLDI(origin = list("comid" = 101))$sourceName, "NHDPlus comid")
# GENERAL START: NON-STABLE
expect_equal(findNLDI(origin = list("wade" = 'CA_45206'))[[1]]$sourceName, "Water Data Exchange 2.0 Sites")
expect_equal(findNLDI(origin = list("wade" = 'CA_45206'))$sourceName, "Water Data Exchange 2.0 Sites")
# ERROR: TWO STARTS
expect_error(findNLDI(nwis = 1000, comid = 101))
# NON EXISTING SITE
......@@ -38,9 +37,9 @@ test_that("NLDI starting sources...", {
})
test_that("NLDI navigation sources...", {
skip_on_cran()
# UPPER TRIBUTARY
expect_equal(length(findNLDI(nwis = '11120000', nav = "UT")), 2)
# UPPER MAIN
......@@ -57,43 +56,61 @@ test_that("NLDI navigation sources...", {
})
test_that("NLDI find sources...", {
skip_on_cran()
expect_equal(length(findNLDI(nwis = '11120000', nav = "UT", find = "wade")),3)
expect_equal(length(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp"))), 4)
expect_equal(length(findNLDI(nwis = '11120000', nav = c("UT", "UM"), find = c("nwis", "wqp"))), 7)
expect_equal(length(findNLDI(nwis = '11120000', nav = "UT", find = "wade")),2)
expect_equal(length(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis", "wqp"))), 3)
expect_equal(length(findNLDI(nwis = '11120000', nav = c("UT", "UM"), find = c("nwis", "wqp", "flowlines"))), 7)
})
test_that("sf not installed...", {
skip_on_cran()
expect_true(!"geometry" %in% findNLDI(nwis = '11120000', no_sf = TRUE)[[1]])
expect_equal(class(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis"), no_sf = TRUE)[[2]]), "character")
expect_true(c("X") %in% names(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis"), no_sf = TRUE)[[3]]))
expect_equal(class(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis"), no_sf = TRUE)[[2]]), "data.frame")
expect_true(c("X") %in% names(findNLDI(nwis = '11120000', nav = "UT", find = c("nwis"), no_sf = TRUE)[[2]]))
})
test_that("Distance...", {