Skip to content

Commit

Permalink
updating for start on DOI-USGS#291
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan S Read committed Oct 28, 2016
1 parent f239d45 commit 52b6bea
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 15 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: geoknife
Type: Package
Title: Web-Processing of Large Gridded Datasets
Version: 1.4.0
Date: 2016-10-26
Version: 1.4.1
Date: 2016-10-28
Authors@R: c( person("Jordan", "Read", role = c("aut","cre"),
email = "jread@usgs.gov"),
person("Jordan", "Walker", role = c("aut"),
Expand All @@ -29,7 +29,7 @@ Copyright: This software is in the public domain because it contains materials
that originally came from the United States Geological Survey, an agency of
the United States Department of Interior. For more information, see the
official USGS copyright policy at
http://www.usgs.gov/visual-id/credit_usgs.html#copyright
https://www2.usgs.gov/visual-id/credit_usgs.html#copyright
Depends:
R (>= 3.0)
Imports:
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ importFrom(sp,Polygon)
importFrom(sp,Polygons)
importFrom(sp,SpatialPolygons)
importFrom(sp,coordinates)
importFrom(sp,proj4string)
importFrom(utils,lsf.str)
importFrom(utils,packageName)
importFrom(utils,packageVersion)
Expand Down
20 changes: 17 additions & 3 deletions R/06-simplegeom-obj.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ setMethod("initialize", signature = "simplegeom",
.Object@DRAW_SCHEMA = 'http://cida-test.er.usgs.gov/mda.lakes/draw.xsd'
.Object@sp <- SpatialPolygons(...)
return(.Object)
})
})


#' Create simplegeom object
Expand All @@ -46,7 +46,12 @@ setMethod("initialize", signature = "simplegeom",
#' simplegeom(c(-88.6, 45.2))
#' \dontrun{
#' library(sp)
#' simplegeom(Srl, proj4string = CRS("+proj=longlat +datum=WGS84"))
#' Sr1 <- Polygon(cbind(c(-89.0001,-89,-88.9999,-89,-89.0001),c(46,46.0001,46,45.9999,46)))
#' Sr2 <- Polygon(cbind(c(-88.6,-88.5999,-88.5999,-88.6,-88.6),c(45.2,45.2,45.1999,45.1999,45.2)))
#' Srs1 <- Polygons(list(Sr1), "s1")
#' Srs2 <- Polygons(list(Sr2), "s2")
#' SP <- SpatialPolygons(list(Srs1,Srs2), proj4string = CRS("+proj=longlat +datum=WGS84"))
#' result(geoknife(simplegeom(SP), 'prism', wait=TRUE))
#' }
#' simplegeom(data.frame('point1'=c(-89, 46), 'point2'=c(-88.6, 45.2)))
#' @author Jordan S Read
Expand Down Expand Up @@ -79,7 +84,7 @@ setMethod("simplegeom", signature("ANY"), function(.Object, ...) {
})

setAs("numeric","simplegeom",function(from) {

## create new simplegeom object based on a lon lat pair
if (length(from) == 2){
ring <- data.frame('bufferedPoint' = from)
Expand Down Expand Up @@ -109,3 +114,12 @@ setAs("data.frame", "simplegeom", function(from) {
simplegeom <- new("simplegeom", Srl, proj4string = CRS("+proj=longlat +datum=WGS84"))
return(simplegeom)
})

#'@importFrom sp Polygons Polygon CRS proj4string
setAs("SpatialPolygons", "simplegeom", function(from) {

stopifnot(grepl('datum=WGS84', proj4string(from)))

simplegeom <- new("simplegeom", from@polygons, proj4string = CRS("+proj=longlat +datum=WGS84"))
return(simplegeom)
})
7 changes: 6 additions & 1 deletion man/simplegeom-methods.Rd

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

27 changes: 19 additions & 8 deletions tests/testthat/test-geoknife_setters.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ test_that("webprocess can set algorithms", {
wp <- webprocess()
algs <- query(wp, 'algorithms')
expect_error(algorithm(wp)<-'bad.char')
expect_error(algorithm(wp)<-NULL)
expect_error(algorithm(wp)<-list('junk'='will break process'))
algorithm(wp) <- algs[1]
# test that it properly sets
expect_equal(algorithm(wp), algs[1])

expect_error(algorithm(wp)<-NULL)
expect_error(algorithm(wp)<-list('junk'='will break process'))
algorithm(wp) <- algs[1]
# test that it properly sets
expect_equal(algorithm(wp), algs[1])
})

context("Test setting of webgeom simple sets")
Expand All @@ -34,10 +34,21 @@ test_that("geoknife sets stencil correctly", {
cancel(job)
})

library(sp)
Sr1 <- Polygon(cbind(c(-89.0001,-89,-88.9999,-89,-89.0001),c(46,46.0001,46,45.9999,46)))
Sr2 <- Polygon(cbind(c(-88.6,-88.5999,-88.5999,-88.6,-88.6),c(45.2,45.2,45.1999,45.1999,45.2)))
Srs1 <- Polygons(list(Sr1), "s1")
Srs2 <- Polygons(list(Sr2), "s2")
test_that("geoknife converts SpatialPolygons to simplegeoms correctly", {

SP <- SpatialPolygons(list(Srs1,Srs2), proj4string = CRS("+proj=longlat +datum=WGS84"))
expect_is(simplegeom(SP), 'simplegeom')
expect_error(simplegeom(SpatialPolygons(list(Srs1,Srs2))))
})

context("geoknife w/ knife modified in line")
test_that("geoknife sets knife correctly", {
testthat::skip_on_cran()
job <- geoknife('HUC8::09020306', 'prism', wait=TRUE)
expect_true(geoknife:::canStart())
})

0 comments on commit 52b6bea

Please sign in to comment.