Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Sep 12, 2023
1 parent f723650 commit 989f0bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
6 changes: 3 additions & 3 deletions R/read_stream_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if (nchar(dsn) < 1L) {
stop("`dsn` must describe a valid data source name for GDAL (input wasan empty string).", call. = FALSE)
}
dsn_exists <- file.exists(dsn) ## good to see this finally stuck in sf
dsn_exists <- file.exists(dsn)

if (length(dsn) == 1 && dsn_exists) {
dsn = enc2utf8(normalizePath(dsn))
Expand All @@ -25,8 +25,8 @@
info = gdal_dsn_read_vector_stream(stream, dsn, layer, sql, as.character(options), quiet,
drivers, wkt_filter, dsn_exists, dsn_isdb = FALSE, fid_column_name, 80L)

browser()
if (return_stream) return(stream)

# if (return_stream) return(stream)
##// layer has been freed as this point
# geometry_column <- unlist(lapply(
# stream$get_schema()$children, function(s) identical(s$metadata[["ARROW:extension:name"]], "ogc.wkb")
Expand Down
17 changes: 4 additions & 13 deletions inst/include/gdalarrowstream/gdalvectorstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline Rcpp::List ogr_layer_setup(Rcpp::CharacterVector datasource, Rcpp::Charac
bool quiet,
//Rcpp::CharacterVector drivers,
Rcpp::CharacterVector wkt_filter,
bool dsn_exists,

bool dsn_isdb,
int width) {
// adapted from the OGR tutorial @ www.gdal.org
Expand All @@ -108,17 +108,8 @@ inline Rcpp::List ogr_layer_setup(Rcpp::CharacterVector datasource, Rcpp::Charac
// drivers.size() ? drivers_v.data() : NULL, open_options.data(), NULL );
NULL, NULL, NULL );
if( poDS == NULL ) {
// could not open dsn
if( dsn_isdb ) {
Rcpp::stop("Cannot open %s; Check connection parameters.", datasource);
}
if( dsn_exists ) {
Rcpp::stop("Cannot open %s; %s %s",
datasource,
"The source could be corrupt or not supported.",
"See `st_drivers()` for a list of supported formats.");
}
Rcpp::stop("Cannot open %s; The file doesn't seem to exist.", datasource);

Rcpp::stop("Cannot open %s; ", datasource);
}

// Will close the dataset if some early return/exception prevents GDALClose() from being
Expand Down Expand Up @@ -261,7 +252,7 @@ inline Rcpp::List read_gdal_stream(
quiet,
//drivers,
wkt_filter,
dsn_exists, dsn_isdb, width);
dsn_isdb, width);
OGRDataSource* poDS = (OGRDataSource*)(R_ExternalPtrAddr(prep[0]));
OGRLayer* poLayer = (OGRLayer*)R_ExternalPtrAddr(prep[1]);
auto stream_out = reinterpret_cast<struct ArrowArrayStream*>(
Expand Down

0 comments on commit 989f0bc

Please sign in to comment.