Skip to content

Commit

Permalink
bump patch version and skip geojson_write tests on travis for now
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jun 10, 2015
1 parent 68177e2 commit edf82a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -5,7 +5,7 @@ Description: Convert data to 'geoJSON' or 'topoJSON' from various R classes,
classes. 'geojsonio' does not aim to replace packages like 'sp', 'rgdal', 'rgeos',
but rather aims to be a high level client to simplify conversions of data
from and to 'geoJSON' and 'topoJSON'.
Version: 0.1.0.9300
Version: 0.1.1.9000
License: MIT + file LICENSE
Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"),
email = "myrmecocystus@gmail.com"),
Expand Down
15 changes: 12 additions & 3 deletions tests/testthat/test-geojson_write.R
@@ -1,32 +1,41 @@
context("geojson_write")

test_that("precision argument works with polygons", {
skip_on_travis()
skip_on_cran()

poly <- list(c(-114.345703125,39.436192999314095),
c(-114.345703125,43.45291889355468))
a <- suppressMessages(geojson_write(poly, geometry = "polygon"))
expect_is(a, "geojson")
a_txt <- gsub("\\s+", " ", paste0(readLines("myfile.geojson"), collapse = ""))
expect_equal(a_txt, "{\"type\": \"FeatureCollection\", \"features\": [{ \"type\": \"Feature\", \"id\": 0, \"properties\": { \"dummy\": 0.000000 }, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -114.345703125, 39.436192999314095 ], [ -114.345703125, 43.452918893554681 ], [ -114.345703125, 39.436192999314095 ] ] ] } }]}")

b <- suppressMessages(geojson_write(poly, geometry = "polygon", precision = 2))
expect_is(b, "geojson")
b_txt <- gsub("\\s+", " ", paste0(readLines("myfile.geojson"), collapse = ""))
expect_equal(b_txt, "{\"type\": \"FeatureCollection\", \"features\": [{ \"type\": \"Feature\", \"id\": 0, \"properties\": { \"dummy\": 0.000000 }, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -114.35, 39.44 ], [ -114.35, 43.45 ], [ -114.35, 39.44 ] ] ] } }]}")
})

test_that("precision argument works with points", {
skip_on_travis()
skip_on_cran()

c <- suppressMessages(geojson_write(us_cities[1:2,], lat = 'lat', lon = 'long', precision = 2))
expect_is(c, "geojson")
c_txt <- gsub("\\s+", " ", paste0(readLines("myfile.geojson"), collapse = ""))
expect_equal(c_txt, "{\"type\": \"FeatureCollection\", \"features\": [{ \"type\": \"Feature\", \"id\": 1, \"properties\": { \"name\": \"Abilene TX\", \"country.etc\": \"TX\", \"pop\": 113888, \"lat\": 32.450000, \"long\": -99.740000, \"capital\": 0 }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -99.74, 32.45 ] } },{ \"type\": \"Feature\", \"id\": 2, \"properties\": { \"name\": \"Akron OH\", \"country.etc\": \"OH\", \"pop\": 206634, \"lat\": 41.080000, \"long\": -81.520000, \"capital\": 0 }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -81.52, 41.08 ] } }]}")

d <- suppressMessages(geojson_write(us_cities[1:2,], lat = 'lat', lon = 'long', precision = 1))
expect_is(d, "geojson")
d_txt <- gsub("\\s+", " ", paste0(readLines("myfile.geojson"), collapse = ""))
expect_equal(d_txt, "{\"type\": \"FeatureCollection\", \"features\": [{ \"type\": \"Feature\", \"id\": 1, \"properties\": { \"name\": \"Abilene TX\", \"country.etc\": \"TX\", \"pop\": 113888, \"lat\": 32.450000, \"long\": -99.740000, \"capital\": 0 }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -99.7, 32.5 ] } },{ \"type\": \"Feature\", \"id\": 2, \"properties\": { \"name\": \"Akron OH\", \"country.etc\": \"OH\", \"pop\": 206634, \"lat\": 41.080000, \"long\": -81.520000, \"capital\": 0 }, \"geometry\": { \"type\": \"Point\", \"coordinates\": [ -81.5, 41.1 ] } }]}")
})

test_that("precision argument works with sp objects", {
skip_on_travis()
skip_on_cran()

library('sp')
poly1 <- Polygons(list(Polygon(cbind(c(-100.111,-90.111,-85.111,-100.111),
c(40.111,50.111,45.111,40.111)))), "1")
Expand All @@ -37,7 +46,7 @@ test_that("precision argument works with sp objects", {
expect_is(e, "geojson")
e_txt <- gsub("\\s+", " ", paste0(readLines("myfile.geojson"), collapse = ""))
expect_equal(e_txt, "{\"type\": \"FeatureCollection\", \"features\": [{ \"type\": \"Feature\", \"id\": 1, \"properties\": { \"dummy\": 0.000000 }, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -100.111, 40.111 ], [ -90.111, 50.111 ], [ -85.111, 45.111 ], [ -100.111, 40.111 ] ] ] } },{ \"type\": \"Feature\", \"id\": 2, \"properties\": { \"dummy\": 0.000000 }, \"geometry\": { \"type\": \"Polygon\", \"coordinates\": [ [ [ -90.111, 30.111 ], [ -80.111, 40.111 ], [ -75.111, 35.111 ], [ -90.111, 30.111 ] ] ] } }]}")

f <- suppressMessages(geojson_write(sp_poly, precision = 2))
expect_is(f, "geojson")
f_txt <- gsub("\\s+", " ", paste0(readLines("myfile.geojson"), collapse = ""))
Expand Down

0 comments on commit edf82a2

Please sign in to comment.