Skip to content

Commit

Permalink
issues caught by roxygen2 7.3.0; int/size_t warning
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Jan 12, 2024
1 parent 9c48f4b commit b3396ca
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ LinkingTo:
VignetteBuilder:
knitr
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 2
SystemRequirements: GDAL (>= 2.0.1), GEOS (>= 3.4.0),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ S3method(is.na,bbox)
S3method(is.na,crs)
S3method(is.na,m_range)
S3method(is.na,z_range)
S3method(is_geometry_column,PqConnection)
S3method(is_geometry_column,default)
S3method(merge,sf)
S3method(plot,sf)
S3method(plot,sfc_CIRCULARSTRING)
Expand Down
2 changes: 2 additions & 0 deletions R/db.R
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,12 @@ setMethod("dbDataType", c("DBIObject", "sf"), function(dbObj, obj) {
#' @param classes classes inherited
is_geometry_column <- function(con, x, classes = "") UseMethod("is_geometry_column")

#' @export
is_geometry_column.PqConnection <- function(con, x, classes = c("pq_geometry")) {
vapply(x, inherits, logical(1), classes)
}

#' @export
is_geometry_column.default <- function(con, x, classes = c("character")) {
# try all character columns (in conjunction with try_postgis_as_sfc)
vapply(x, function(x) inherits(x, classes) && !all(is.na(x)),
Expand Down
2 changes: 1 addition & 1 deletion R/init.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @importFrom utils head object.size str tail packageVersion compareVersion globalVariables
#' @importFrom stats aggregate dist na.omit rbinom runif setNames
#' @importFrom tools file_ext file_path_sans_ext
#' @importFrom methods as new slot slotNames "slot<-"
#' @importFrom methods as new slot slotNames slot<-
#' @importFrom grid convertHeight convertUnit convertWidth current.viewport linesGrob nullGrob pathGrob pointsGrob polylineGrob unit viewport
#' @import graphics
#' @importFrom grDevices dev.size rgb cm
Expand Down
1 change: 0 additions & 1 deletion man/sf-package.Rd

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

30 changes: 25 additions & 5 deletions src/mdim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ List CPL_read_mdim(CharacterVector file, CharacterVector array_names, CharacterV
dimensions.attr("names") = dim_names;
if (! proxy) { // read the arrays:
auto data_type(arr->GetDataType());
size_t sz = data_type.GetSize();
if (data_type.GetClass() == GEDTC_NUMERIC) {
NumericVector vec(nValues);
if (debug)
Expand Down Expand Up @@ -342,29 +343,30 @@ List CPL_read_mdim(CharacterVector file, CharacterVector array_names, CharacterV
vec_lst[i] = vec;
} else if (data_type.GetClass() == GEDTC_COMPOUND) {
const auto &components = data_type.GetComponents();
size_t sz = data_type.GetSize();
std::vector<GByte> buf(sz * nValues);
bool ok = arr->Read(offst.data(),
anCount.data(),
stp.data(), /* step: defaults to 1,1,1 */
nullptr, /* stride: default to row-major convention */
data_type,
&buf[0]);
if (!ok)
stop("Cannot read array into Compound buffer");
DataFrame tbl;
GByte *v = buf.data();
for (const auto &co: components) {
auto t(co->GetType());
if (t.GetClass() == GEDTC_NUMERIC) {
if (t.GetSize() != sizeof(double))
if (t.GetNumericDataType() != GDT_Float64)
stop("only Float64 data supported in numeric compounds");
NumericVector vec(nValues);
for (int j = 0; j < nValues; j++)
for (size_t j = 0; j < nValues; j++)
memcpy(&(vec[j]), v + j * sz + co->GetOffset(), sizeof(double));
tbl.push_back(vec, co->GetName());
} else if (t.GetClass() == GEDTC_STRING) {
CharacterVector vec(nValues);
const char *str;
for (int j = 0; j < nValues; j++) {
for (size_t j = 0; j < nValues; j++) {
memcpy(&str, v + j * sz + co->GetOffset(), sizeof(const char *));
vec[j] = str; // deep copy
}
Expand All @@ -374,7 +376,25 @@ List CPL_read_mdim(CharacterVector file, CharacterVector array_names, CharacterV
}
vec_lst[i] = tbl;
} else { // GEDTC_STRING:
stop("reading string data not implemented");
std::vector<GByte> buf(sz * nValues);
bool ok = arr->Read(offst.data(),
anCount.data(),
stp.data(), /* step: defaults to 1,1,1 */
nullptr, /* stride: default to row-major convention */
data_type,
&buf[0]);
if (!ok)
stop("Cannot read array into string buffer");
GByte *v = buf.data();
CharacterVector vec(nValues);
const char *str;
for (size_t j = 0; j < nValues; j++) {
memcpy(&str, v + j * sz, sizeof(const char *));
vec[j] = str; // deep copy
}
vec.attr("dim") = dims;
vec.attr("units") = arr->GetUnit();
vec_lst[i] = vec;
}
}
}
Expand Down

0 comments on commit b3396ca

Please sign in to comment.