Commit 464327a3 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Catching a wierd condition where a URL doesn't return the content-type

parent bdbeb444
...@@ -41,7 +41,12 @@ getWebServiceData <- function(obs_url, ...){ ...@@ -41,7 +41,12 @@ getWebServiceData <- function(obs_url, ...){
return(invisible(NULL)) return(invisible(NULL))
} else { } else {
headerInfo <- httr::headers(returnedList) headerInfo <- httr::headers(returnedList)
if(!"content-type" %in% names(headerInfo)){
message("Unknown content, returning NULL")
return(invisible(NULL))
}
if(headerInfo$`content-type` %in% c("text/tab-separated-values;charset=UTF-8")){ if(headerInfo$`content-type` %in% c("text/tab-separated-values;charset=UTF-8")){
returnedDoc <- httr::content(returnedList, type="text",encoding = "UTF-8") returnedDoc <- httr::content(returnedList, type="text",encoding = "UTF-8")
} else if (headerInfo$`content-type` %in% } else if (headerInfo$`content-type` %in%
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#' "observedProperty=urn:ogc:def:property:OGC:GroundWaterLevel", #' "observedProperty=urn:ogc:def:property:OGC:GroundWaterLevel",
#' "responseFormat=text/xml", #' "responseFormat=text/xml",
#' "featureOfInterest=VW_GWDP_GEOSERVER.USGS.403836085374401",sep="&") #' "featureOfInterest=VW_GWDP_GEOSERVER.USGS.403836085374401",sep="&")
#' if(!httr::http_error(obs_url)){ #'
#' data_returned <- importNGWMN(obs_url) #' data_returned <- importNGWMN(obs_url)
#' } #'
#' } #' }
#' #'
importNGWMN <- function(input, asDateTime=FALSE, tz="UTC"){ importNGWMN <- function(input, asDateTime=FALSE, tz="UTC"){
......
...@@ -32,9 +32,9 @@ obs_url <- paste("https://cida.usgs.gov/ngwmn_cache/sos?request=GetObservation", ...@@ -32,9 +32,9 @@ obs_url <- paste("https://cida.usgs.gov/ngwmn_cache/sos?request=GetObservation",
"observedProperty=urn:ogc:def:property:OGC:GroundWaterLevel", "observedProperty=urn:ogc:def:property:OGC:GroundWaterLevel",
"responseFormat=text/xml", "responseFormat=text/xml",
"featureOfInterest=VW_GWDP_GEOSERVER.USGS.403836085374401",sep="&") "featureOfInterest=VW_GWDP_GEOSERVER.USGS.403836085374401",sep="&")
if(!httr::http_error(obs_url)){
data_returned <- importNGWMN(obs_url) data_returned <- importNGWMN(obs_url)
}
} }
} }
...@@ -27,6 +27,11 @@ parameterData data frame with the following information: ...@@ -27,6 +27,11 @@ parameterData data frame with the following information:
Imports data from NWIS about meaured parameter based on user-supplied parameter code or codes. Imports data from NWIS about meaured parameter based on user-supplied parameter code or codes.
This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes} This function gets the data from here: \url{https://nwis.waterdata.usgs.gov/nwis/pmcodes}
} }
\examples{
paramINFO <- readNWISpCode(c('01075','00060','00931'))
paramINFO <- readNWISpCode(c('01075','00060','00931', NA))
}
\seealso{ \seealso{
\code{\link{importRDB1}} \code{\link{importRDB1}}
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment