Skip to content

Commit

Permalink
bugfix PointDB R-package connection write scanAngleRank as signed int…
Browse files Browse the repository at this point in the history
…eger; R-package as.LAS change parameter proj4string to crs for lidR compatiblity
  • Loading branch information
swoellauer committed Oct 11, 2024
1 parent 0227165 commit 6560a69
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 35 deletions.
54 changes: 27 additions & 27 deletions r-package/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
Package: RSDB
Type: Package
Title: R to RSDB Server Connection Package
Version: 1.3.9
Author: woellauer
Maintainer: woellauer <email@email>
Description: RSDB (Remote Sensing Database) manages (hyperspectral) rasters and (LiDAR) point-clouds as well as vector data and auxiliary ROIs (regions of interest as named polygons) and POIs (points of interest as named points). Contained data can be queried, processed and analysed.
This R package connects to an RSDB server running at local or remote computer.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Imports:
R6,
httr,
jsonlite,
openssl,
raster,
sf,
stars
Suggests:
rgl,
lidR,
rlas,
data.table,
hsdar,
mapview
Package: RSDB
Type: Package
Title: R to RSDB Server Connection Package
Version: 1.3.10
Author: woellauer
Maintainer: woellauer <email@email>
Description: RSDB (Remote Sensing Database) manages (hyperspectral) rasters and (LiDAR) point-clouds as well as vector data and auxiliary ROIs (regions of interest as named polygons) and POIs (points of interest as named points). Contained data can be queried, processed and analysed.
This R package connects to an RSDB server running at local or remote computer.
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.2
Imports:
R6,
httr,
jsonlite,
openssl,
raster,
sf,
stars
Suggests:
rgl,
lidR,
rlas,
data.table,
hsdar,
mapview
10 changes: 5 additions & 5 deletions r-package/R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Creates an \link{extent} that covers the square over the circle at point x,y with radius r.
#'
#' Extents are used to query data from \link{RasterDB} , from \link{PointCloud} and from \link{PointDB}.
#' Extents are used to query data from \link{RasterDB} , from \link{PointCloud} and from \link{PointDB}.
#'
#' @param x first coordinate
#' @param y second coordinate
Expand All @@ -19,7 +19,7 @@ extent_radius <- function(x, y, r) {
#'
#' Creates an \link{extent} that covers the square with center point x,y and with diameter (edge length) d.
#'
#' Extents are used to query data from \link{RasterDB} , from \link{PointCloud} and from \link{PointDB}.
#' Extents are used to query data from \link{RasterDB} , from \link{PointCloud} and from \link{PointDB}.
#'
#' @param x first coordinate
#' @param y second coordinate
Expand Down Expand Up @@ -215,12 +215,12 @@ as.speclib <- function(rasterStack, na=NULL) {
#'
#' Convert data.frame of points (received from PointDB or PointCloud) to \link[lidR]{LAS} in lidR package.
#'
#' optional parameter proj4string: crs of points. e.g. proj4string <- CRS(pointdb$info$proj4)
#' Optional parameter crs: crs of points. e.g. crs <- sf::st_crs(paste0('EPSG:', pointdb$info$epsg))
#'
#' @seealso \link[lidR]{LAS}
#' @author woellauer
#' @export
as.LAS <- function(df, proj4string = sp::CRS()) {
as.LAS <- function(df, crs = sf::NA_crs_) {
stopifnot(is.data.frame(df))
cn <- colnames(df)
stopifnot("x" %in% cn && "y" %in% cn)
Expand All @@ -234,7 +234,7 @@ as.LAS <- function(df, proj4string = sp::CRS()) {

header <- rlas::header_create(dt)

result <- lidR::LAS(data=dt, header=header, proj4string=proj4string, check=TRUE)
result <- lidR::LAS(data=dt, header=header, crs=crs, check=TRUE)
return(result)
}

Expand Down
1 change: 1 addition & 0 deletions r-package/man/RSDB-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions r-package/man/as.LAS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/util/rdat/RdatDataFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@ public void write(DataOutput out, Iterable<T> coll) throws IOException {
}

}

public static class Int8Column<T> extends Column<T> {
@FunctionalInterface
public static interface ToByteFunction<T> {
byte applyAsByte(T value);
}

private final ToByteFunction<T> mapper;

public Int8Column(String name, ToByteFunction<T> mapper) {
super(name);
this.mapper = mapper;
}

@Override
public void write(DataOutput out, Iterable<T> coll) throws IOException {
Rdat.writeSizedString(out, name);
out.writeByte(Rdat.TYPE_INT8);
out.writeByte(Rdat.TYPE_INT8_SIZE);
for (T e:coll) {
byte v = mapper.applyAsByte(e);
out.writeByte(v);
}
}

}

public static class DoubleColumn<T> extends Column<T> {

Expand Down
3 changes: 2 additions & 1 deletion src/util/rdat/RdatDataFrame_points.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import util.rdat.RdatDataFrame.DoubleColumn;
import util.rdat.RdatDataFrame.UInt16Column;
import util.rdat.RdatDataFrame.UInt8Column;
import util.rdat.RdatDataFrame.Int8Column;

public class RdatDataFrame_points {

Expand All @@ -27,7 +28,7 @@ public class RdatDataFrame_points {
add(new UInt16Column<GeoPoint>("intensity", GeoPoint::getIntensity));
add(new UInt8Column<GeoPoint>("returnNumber", GeoPoint::getReturnNumber));
add(new UInt8Column<GeoPoint>("returns", GeoPoint::getReturns));
add(new UInt8Column<GeoPoint>("scanAngleRank", GeoPoint::getScanAngleRank));
add(new Int8Column<GeoPoint>("scanAngleRank", GeoPoint::getScanAngleRank));
add(new UInt8Column<GeoPoint>("classification", GeoPoint::getClassification));
add(new UInt8Column<GeoPoint>("classificationFlags", GeoPoint::getClassificationFlags));
}};
Expand Down

0 comments on commit 6560a69

Please sign in to comment.