Skip to content

Commit

Permalink
the other changes for GDAL 2.5.0; #988
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Mar 14, 2019
1 parent 182c660 commit 9c3b040
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions R/crs.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ is.na.crs = function(x) {
#' @examples
#' st_crs("+init=epsg:3857")$epsg
#' st_crs("+init=epsg:3857")$proj4string
#' st_crs("+init=epsg:3857 +units=km")$b # numeric
#' st_crs("+init=epsg:3857 +units=km")$units # character
#' st_crs("+init=epsg:3857 +units=m")$b # numeric
#' st_crs("+init=epsg:3857 +units=m")$units # character
#' @export
`$.crs` = function(x, name) {
if (is.numeric(name) || name %in% names(x))
Expand Down
6 changes: 5 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -3510,10 +3510,14 @@ rm -f gdal_test errors.txt gdal_test.cpp
GDAL_GE_250="no"
GDAL_MAJ_VER=`echo $GDAL_VERSION | cut -d "." -f1`
GDAL_MOD_VER=`echo $GDAL_VERSION | cut -d "." -f2`
if test "${GDAL_MAJ_VER}" = 2 ; then # will fail on >= 3.x
if test "${GDAL_MAJ_VER}" = 2 ; then
if test "${GDAL_MOD_VER}" -ge 5 ; then
GDAL_GE_250="yes"
fi
else
if test "${GDAL_MAJ_VER}" -ge 3 ; then
GDAL_GE_250="yes"
fi
fi
GDAL_DATA_TEST_FILE="${GDAL_DATADIR}/pcs.csv"
Expand Down
4 changes: 2 additions & 2 deletions man/st_crs.Rd

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

15 changes: 11 additions & 4 deletions tests/testthat/test_crs.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test_that("st_crs works", {
expect_silent(st_crs(nc2) <- 3857)
#expect_warning(st_crs(nc2) <- 0, "Failed to lookup UOM CODE") -> changes in gdal 2.2:
#expect_warning(st_crs(nc2) <- 0)
expect_warning(st_crs(nc2) <- 1000, "not found in EPSG")
#expect_warning(st_crs(nc2) <- 1000, "not found in EPSG") -> changes in gdal 2.5.0
expect_silent(st_crs(nc1) <- st_crs(nc1))

expect_error(st_crs("+proj=ll"), "invalid crs")
Expand Down Expand Up @@ -46,14 +46,21 @@ test_that("st_proj_info works for datum files", {
test_that("$.crs works", {
expect_true(is.numeric(st_crs("+init=epsg:3857")$epsg))
expect_true(is.character(st_crs("+init=epsg:3857")$proj4string))
expect_true(is.numeric(st_crs("+init=epsg:3857 +units=m")$b))
expect_true(is.character(st_crs("+init=epsg:3857 +units=m")$units))
})

test_that("$.crs works 2", {
skip_if_not(sf_extSoftVersion()[["GDAL"]] < "2.5.0")
expect_true(is.numeric(st_crs("+init=epsg:3857 +units=km")$b))
expect_true(is.character(st_crs("+init=epsg:3857 +units=km")$units))
})

test_that("CRS comparison uses ellipsoid and datum (#180)", {
expect_equal(
st_crs("+proj=tmerc +lat_0=0 +lon_0=0 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"),
st_crs("+proj=tmerc +lat_0=0 +lon_0=0 +k=0.9999 +x_0=304800 +y_0=0 +datum=NAD83 +units=m +no_defs"))
skip_if_not(sf_extSoftVersion()[["GDAL"]] < "2.5.0")
expect_equal(
st_crs("+proj=tmerc +lat_0=0 +lon_0=0 +k=0.9999 +x_0=304800 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"),
st_crs("+proj=tmerc +lat_0=0 +lon_0=0 +k=0.9999 +x_0=304800 +y_0=0 +datum=NAD83 +units=m +no_defs"))
})

test_that("Can create dummy crs", {
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test_gdal.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ test_that("st_wrap_dateline works", {

test_that('gdal_subdatasets works', {
skip_if_not(sf_extSoftVersion()[["GDAL"]] >= "2.1.0")
skip_if_not(sf_extSoftVersion()[["GDAL"]] < "2.5.0") # FIXME:
fname = system.file("nc/cropped.nc", package = "sf")
sd2 = gdal_subdatasets(fname)[[2]]
})
Expand Down

0 comments on commit 9c3b040

Please sign in to comment.