Skip to content

Commit

Permalink
#25 fix triangulation with 0 points
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Apr 10, 2024
1 parent 0022b48 commit a0f55dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Fix: bug with `set_parallel_strategy(nested(ncores = 4, ncores2 = 4))`
- Fix: attribute `datatime` is `datetime` in VPC files.
- Fix: #25 triangulation with 0 point crashed. 0 point is possible with a filter.

# lasR 0.4.3

Expand Down
Binary file added inst/extdata/las14_pdrf6.laz
Binary file not shown.
6 changes: 6 additions & 0 deletions src/LASRstages/triangulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ bool LASRtriangulate::process(LAS*& las)
}
}

if (coords.size() < 3)
{
last_error = "impossible to construct a Delaunay triangulation with " + std::to_string(coords.size()) + " points";
return false;
}

this->las = las;
d = new delaunator::Delaunator(coords);

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test-triangulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ test_that("triangulate works with intensity",

expect_equal(range(u$rasterize[], na.rm = T), c(165.72, 2368.14), tolerance = 0.01)
})


test_that("triangulate fails with 0 points (#25)",
{
f <- system.file("extdata", "las14_pdrf6.laz", package="lasR")
pipeline <- reader_las() + dtm()
expect_error(suppressWarnings(exec(pipeline, on = f)), "impossible to construct a Delaunay triangulation with 0 points")
})

0 comments on commit a0f55dc

Please sign in to comment.