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, 9311)
  x <- make_planar_pair(towns, towns2)

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


  x <- make_planar_pair(towns2, towns)

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

test_that('make planar x != y, both planar works', {
  data(towns)
  towns <- sf::st_transform(towns, 3857)
  towns2 <- sf::st_transform(towns, 9311)
  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 Sept. 1, 2025, 5:10 p.m.