Skip to content

Commit b3396ca

Browse files
committed
issues caught by roxygen2 7.3.0; int/size_t warning
1 parent 9c48f4b commit b3396ca

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ LinkingTo:
113113
VignetteBuilder:
114114
knitr
115115
Encoding: UTF-8
116-
RoxygenNote: 7.2.3
116+
RoxygenNote: 7.3.0
117117
Roxygen: list(markdown = TRUE)
118118
Config/testthat/edition: 2
119119
SystemRequirements: GDAL (>= 2.0.1), GEOS (>= 3.4.0),

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ S3method(is.na,bbox)
4242
S3method(is.na,crs)
4343
S3method(is.na,m_range)
4444
S3method(is.na,z_range)
45+
S3method(is_geometry_column,PqConnection)
46+
S3method(is_geometry_column,default)
4547
S3method(merge,sf)
4648
S3method(plot,sf)
4749
S3method(plot,sfc_CIRCULARSTRING)

R/db.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,12 @@ setMethod("dbDataType", c("DBIObject", "sf"), function(dbObj, obj) {
559559
#' @param classes classes inherited
560560
is_geometry_column <- function(con, x, classes = "") UseMethod("is_geometry_column")
561561

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

567+
#' @export
566568
is_geometry_column.default <- function(con, x, classes = c("character")) {
567569
# try all character columns (in conjunction with try_postgis_as_sfc)
568570
vapply(x, function(x) inherits(x, classes) && !all(is.na(x)),

R/init.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' @importFrom utils head object.size str tail packageVersion compareVersion globalVariables
22
#' @importFrom stats aggregate dist na.omit rbinom runif setNames
33
#' @importFrom tools file_ext file_path_sans_ext
4-
#' @importFrom methods as new slot slotNames "slot<-"
4+
#' @importFrom methods as new slot slotNames slot<-
55
#' @importFrom grid convertHeight convertUnit convertWidth current.viewport linesGrob nullGrob pathGrob pointsGrob polylineGrob unit viewport
66
#' @import graphics
77
#' @importFrom grDevices dev.size rgb cm

man/sf-package.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mdim.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ List CPL_read_mdim(CharacterVector file, CharacterVector array_names, CharacterV
307307
dimensions.attr("names") = dim_names;
308308
if (! proxy) { // read the arrays:
309309
auto data_type(arr->GetDataType());
310+
size_t sz = data_type.GetSize();
310311
if (data_type.GetClass() == GEDTC_NUMERIC) {
311312
NumericVector vec(nValues);
312313
if (debug)
@@ -342,29 +343,30 @@ List CPL_read_mdim(CharacterVector file, CharacterVector array_names, CharacterV
342343
vec_lst[i] = vec;
343344
} else if (data_type.GetClass() == GEDTC_COMPOUND) {
344345
const auto &components = data_type.GetComponents();
345-
size_t sz = data_type.GetSize();
346346
std::vector<GByte> buf(sz * nValues);
347347
bool ok = arr->Read(offst.data(),
348348
anCount.data(),
349349
stp.data(), /* step: defaults to 1,1,1 */
350350
nullptr, /* stride: default to row-major convention */
351351
data_type,
352352
&buf[0]);
353+
if (!ok)
354+
stop("Cannot read array into Compound buffer");
353355
DataFrame tbl;
354356
GByte *v = buf.data();
355357
for (const auto &co: components) {
356358
auto t(co->GetType());
357359
if (t.GetClass() == GEDTC_NUMERIC) {
358-
if (t.GetSize() != sizeof(double))
360+
if (t.GetNumericDataType() != GDT_Float64)
359361
stop("only Float64 data supported in numeric compounds");
360362
NumericVector vec(nValues);
361-
for (int j = 0; j < nValues; j++)
363+
for (size_t j = 0; j < nValues; j++)
362364
memcpy(&(vec[j]), v + j * sz + co->GetOffset(), sizeof(double));
363365
tbl.push_back(vec, co->GetName());
364366
} else if (t.GetClass() == GEDTC_STRING) {
365367
CharacterVector vec(nValues);
366368
const char *str;
367-
for (int j = 0; j < nValues; j++) {
369+
for (size_t j = 0; j < nValues; j++) {
368370
memcpy(&str, v + j * sz + co->GetOffset(), sizeof(const char *));
369371
vec[j] = str; // deep copy
370372
}
@@ -374,7 +376,25 @@ List CPL_read_mdim(CharacterVector file, CharacterVector array_names, CharacterV
374376
}
375377
vec_lst[i] = tbl;
376378
} else { // GEDTC_STRING:
377-
stop("reading string data not implemented");
379+
std::vector<GByte> buf(sz * nValues);
380+
bool ok = arr->Read(offst.data(),
381+
anCount.data(),
382+
stp.data(), /* step: defaults to 1,1,1 */
383+
nullptr, /* stride: default to row-major convention */
384+
data_type,
385+
&buf[0]);
386+
if (!ok)
387+
stop("Cannot read array into string buffer");
388+
GByte *v = buf.data();
389+
CharacterVector vec(nValues);
390+
const char *str;
391+
for (size_t j = 0; j < nValues; j++) {
392+
memcpy(&str, v + j * sz, sizeof(const char *));
393+
vec[j] = str; // deep copy
394+
}
395+
vec.attr("dim") = dims;
396+
vec.attr("units") = arr->GetUnit();
397+
vec_lst[i] = vec;
378398
}
379399
}
380400
}

0 commit comments

Comments
 (0)