tests/testthat/test-planar.R

test_that('make planar x only works', {
  data(towns)
  x <- make_planar_pair(towns)

  expect_equal(sf::st_crs(x$x)[[1]], 'EPSG:3857')
})

test_that('make planar x == y, no planar works', {
  data(towns)
  x <- make_planar_pair(towns, towns)

  expect_equal(sf::st_crs(x$x)[[1]], 'EPSG:3857')
  expect_equal(sf::st_crs(x$y)[[1]], 'EPSG:3857')
})

test_that('make planar x != y, one planar works', {
  data(towns)
  towns2 <- sf::st_transform(towns, 2163)
  x <- make_planar_pair(towns, towns2)

  expect_equal(sf::st_crs(x$x)[[1]], 'EPSG:2163')
  expect_equal(sf::st_crs(x$y)[[1]], 'EPSG:2163')


  x <- make_planar_pair(towns2, towns)

  expect_equal(sf::st_crs(x$x)[[1]], 'EPSG:2163')
  expect_equal(sf::st_crs(x$y)[[1]], 'EPSG:2163')
})

test_that('make planar x != y, both planar works', {
  data(towns)
  towns <- sf::st_transform(towns, 3857)
  towns2 <- sf::st_transform(towns, 2163)
  x <- make_planar_pair(towns, towns2)

  expect_equal(sf::st_crs(x$x)[[1]], 'EPSG:3857')
  expect_equal(sf::st_crs(x$y)[[1]], 'EPSG:3857')
})

Try the geomander package in your browser

Any scripts or data that you put into this service are public.

geomander documentation built on April 16, 2023, 5:18 p.m.