inst/tests/test_sfs_polygon.R

test_that("signed area / direction", {
    poly_cw  = cbind(x=c(0,0,1,1,0), y=c(0,1,1,0,0))
    poly_ccw = cbind(x=c(0,1,1,0,0), y=c(0,0,1,1,0))
    poly_bad = cbind(x=c(0,1,1,0), y=c(0,0,1,1)) 

    expect_equal(ring_signed_area(poly_cw), -1)
    expect_equal(ring_signed_area(poly_ccw), 1)
    expect_error(ring_signed_area(poly_bad))

    expect_true(is_cw(poly_cw))
    expect_false(is_cw(poly_ccw))
    expect_error(is_cw(poly_bad))
})
rundel/sfs documentation built on May 28, 2019, 10:41 a.m.