Skip to content

Commit

Permalink
Prepare lidR for rlas 1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Jun 26, 2024
1 parent 32e2557 commit 15febfc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion R/io_readLAS.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ streamLAS.LAScluster = function(x, ofile, select = "*", filter = "", filter_wkt

streamLAS.character = function(x, ofile, select = "*", filter = "", filter_wkt = "")
{
# Compatibility with rlas that no longer supports WKT string to filter polygons
geom = list()
if (packageVersion("rlas") > "1.7.0")
{
if (is.character(filter_wkt) && filter_wkt[1] != "")
{
geom = sf::st_as_sfc(filter_wkt)
geom = extract_polygons(geom)
}
}

assert_all_are_existing_files(x)

islas <- tools::file_ext(x) %in% c("las", "laz", "ply", "LAS", "LAZ", "PLY")
Expand Down Expand Up @@ -229,7 +240,10 @@ streamLAS.character = function(x, ofile, select = "*", filter = "", filter_wkt =
}
}

data <- rlas:::stream.las(ifiles, ofile, select, filter, filter_wkt)
if (packageVersion("rlas") > "1.7.0")
data <- rlas:::stream.las(ifiles, ofile, select, filter, geom)
else
data <- rlas:::stream.las(ifiles, ofile, select, filter, filter_wkt)

if (is.null(data))
return(invisible())
Expand Down
1 change: 1 addition & 0 deletions R/utils_geometry.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extract_polygons = function(sfc)
# Fix #763. Complex code to avoid using boost
coordinates = lapply(sfc, sf::st_coordinates)
rings = lapply(coordinates, extract_rings)
return(rings)
}

extract_rings = function(coordinates)
Expand Down

0 comments on commit 15febfc

Please sign in to comment.