Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Mar 1, 2022
1 parent b001823 commit ebcefe5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Binary file added inst/extdata/las14_prf6.laz
Binary file not shown.
15 changes: 14 additions & 1 deletion inst/tinytest/test-readlas.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,23 @@ stream.las <- rlas:::stream.las
# "read returns good values", {

las <- read.las(lazfile)
header <- read.lasheader(lazfile)

expect_true(is.data.frame(las))
expect_equal(dim(las), c(30, 16))

expect_equal(mean(las$X), 339008.1, tolerance = 0.001)
expect_equal(mean(las$Y), 5248000, tolerance = 0.001)
expect_equal(mean(las$Z), 975.899, tolerance = 0.001)
expect_equal(mean(las$Z), 975.899, tolerance = 0.001)
expect_equal(mean(las$Intensity), 78.6, tolerance = 0.001)
expect_equal(tabulate(las$ReturnNumber, 5), header$`Number of points by return`)
expect_equal(tabulate(las$NumberOfReturns, 5), c(24,6,0,0,0))
expect_equal(unique(las$ScanDirectionFlag), c(1,0))
expect_equal(as.numeric(table(las$ScanDirectionFlag)), c(7, 23))
expect_true(is.integer(las$ScanAngleRank))
expect_equal(unique(las$ScanAngleRank), c(-21,-22))
expect_equal(as.numeric(table(las$ScanAngleRank)), c(20, 10))
expect_equal(unique(las$PointSourceID), 17)

# "filter returns good values", {

Expand Down
27 changes: 27 additions & 0 deletions inst/tinytest/test-readlas14.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
if ( !(identical(Sys.getenv("NOT_CRAN"), "true") || (isTRUE(unname(Sys.info()["user"]) == "jr"))) ) exit_file("Skip on CRAN")

lazfile <- system.file("extdata", "las14_prf6.laz", package = "rlas")
stream.las <- rlas:::stream.las

# "read returns good values", {

las <- read.las(lazfile)
header <- read.lasheader(lazfile)

expect_true(is.data.frame(las))
expect_equal(dim(las), c(135, 18))
expect_equal(mean(las$X), 487823.6, tolerance = 0.001)
expect_equal(mean(las$Y), 5313802, tolerance = 0.001)
expect_equal(mean(las$Z), 689.388, tolerance = 0.001)
expect_equal(mean(las$Intensity), 27601.32, tolerance = 0.001)
expect_equal(tabulate(las$ReturnNumber, 15), header$`Number of points by return`)
expect_equal(tabulate(las$NumberOfReturns, 15), c(50,45,33,6,1,0,0,0,0,0,0,0,0,0,0))
expect_equal(unique(las$ScanDirectionFlag), c(0,1))
expect_equal(as.numeric(table(las$ScanDirectionFlag)), c(65, 70))
expect_true(is.null(las$ScanAngleRank))
expect_true(is.double(las$ScanAngle))
expect_equal(mean(las$ScanAngle), -13.50187, tolerance = 0.000001)
expect_equal(unique(las$PointSourceID), 108)



2 changes: 1 addition & 1 deletion src/rlasstreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ void RLASstreamer::write_point()
Overlap.push_back(lasreader->point.get_extended_overlap_flag());

if (a && !extended)
SAR.push_back(lasreader->point.get_scan_angle());
SAR.push_back(lasreader->point.get_scan_angle_rank());
else if (a && extended)
SA.push_back(lasreader->point.get_scan_angle());

Expand Down

0 comments on commit ebcefe5

Please sign in to comment.