Skip to content

Commit

Permalink
tests and examples for DOI-USGS#291
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan S Read committed Oct 25, 2016
1 parent 83de188 commit f74517b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/06-simplegeom-obj.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ setMethod("initialize", signature = "simplegeom",
#' @examples
#' simplegeom(c(-88.6, 45.2))
#' \dontrun{
#' simplegeom(Srl, proj4string = CRS("+proj=longlat +datum=WGS84"))
#' 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")
#' 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 @@ -109,7 +115,7 @@ setAs("data.frame", "simplegeom", function(from) {
return(simplegeom)
})

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

stopifnot(grepl('datum=WGS84', proj4string(from)))
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-geoknife_setters.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ 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()
Expand Down

0 comments on commit f74517b

Please sign in to comment.