@@ -51,7 +51,7 @@ set_utf8 = function(x) {
5151# ' of LineString and MultiLineString, or of Polygon and MultiPolygon, convert
5252# ' all to the Multi variety; defaults to \code{TRUE}
5353# ' @param stringsAsFactors logical; logical: should character vectors be
54- # ' converted to factors? Default for \code{read_sf} or R version >= 4.1.0 is
54+ # ' converted to factors? Default for \code{read_sf} or R version >= 4.1.0 is
5555# ' \code{FALSE}, for \code{st_read} and R version < 4.1.0 equal to
5656# ' \code{default.stringsAsFactors()}
5757# ' @param int64_as_string logical; if TRUE, Int64 attributes are returned as
@@ -146,7 +146,7 @@ st_read.default = function(dsn, layer, ...) {
146146}
147147
148148process_cpl_read_ogr = function (x , quiet = FALSE , ... , check_ring_dir = FALSE ,
149- stringsAsFactors = ifelse(as_tibble , FALSE , sf_stringsAsFactors()),
149+ stringsAsFactors = ifelse(as_tibble , FALSE , sf_stringsAsFactors()),
150150 geometry_column = 1 , as_tibble = FALSE , optional = FALSE ) {
151151
152152 which.geom = which(vapply(x , function (f ) inherits(f , " sfc" ), TRUE ))
@@ -156,7 +156,7 @@ process_cpl_read_ogr = function(x, quiet = FALSE, ..., check_ring_dir = FALSE,
156156
157157 # in case no geometry is present:
158158 if (length(which.geom ) == 0 ) {
159- if (! quiet )
159+ if (! quiet )
160160 warning(" no simple feature geometries present: returning a data.frame or tbl_df" , call. = FALSE )
161161 x = if (! as_tibble ) {
162162 if (any(sapply(x , is.list )))
@@ -204,6 +204,10 @@ process_cpl_read_ogr = function(x, quiet = FALSE, ..., check_ring_dir = FALSE,
204204 x
205205}
206206
207+ process_cpl_read_ogr_stream = function (x , ... ) {
208+ x
209+ }
210+
207211# ' @name st_read
208212# ' @param fid_column_name character; name of column to write feature IDs to; defaults to not doing this
209213# ' @param drivers character; limited set of driver short names to be tried (default: try all)
@@ -214,10 +218,11 @@ process_cpl_read_ogr = function(x, quiet = FALSE, ..., check_ring_dir = FALSE,
214218# ' to the current working directory (see \link{getwd}). "Shapefiles" consist of several files with the same basename
215219# ' that reside in the same directory, only one of them having extension \code{.shp}.
216220# ' @export
217- st_read.character = function (dsn , layer , ... , query = NA , options = NULL , quiet = FALSE , geometry_column = 1L ,
221+ st_read.character = function (dsn , layer , ... , query = NA , options = NULL , quiet = FALSE , geometry_column = 1L ,
218222 type = 0 , promote_to_multi = TRUE , stringsAsFactors = sf_stringsAsFactors(),
219223 int64_as_string = FALSE , check_ring_dir = FALSE , fid_column_name = character (0 ),
220- drivers = character (0 ), wkt_filter = character (0 ), optional = FALSE ) {
224+ drivers = character (0 ), wkt_filter = character (0 ), optional = FALSE ,
225+ use_stream = FALSE ) {
221226
222227 layer = if (missing(layer ))
223228 character (0 )
@@ -233,11 +238,24 @@ st_read.character = function(dsn, layer, ..., query = NA, options = NULL, quiet
233238 if (length(promote_to_multi ) > 1 )
234239 stop(" `promote_to_multi' should have length one, and applies to all geometry columns" )
235240
236- x = CPL_read_ogr(dsn , layer , query , as.character(options ), quiet , type , fid_column_name ,
237- drivers , wkt_filter , promote_to_multi , int64_as_string , dsn_exists , dsn_isdb , getOption(" width" ))
238- process_cpl_read_ogr(x , quiet , check_ring_dir = check_ring_dir ,
239- stringsAsFactors = stringsAsFactors , geometry_column = geometry_column ,
240- optional = optional , ... )
241+
242+
243+ if (use_stream ) {
244+ stream = nanoarrow :: nanoarrow_allocate_array_stream()
245+ CPL_read_gdal_stream(stream , dsn , layer , query , as.character(options ), quiet ,
246+ drivers , wkt_filter , dsn_exists , dsn_isdb , getOption(" width" ))
247+ process_cpl_read_ogr_stream(stream , quiet , check_ring_dir = check_ring_dir ,
248+ stringsAsFactors = stringsAsFactors , geometry_column = geometry_column ,
249+ optional = optional , ... )
250+ } else {
251+ x = CPL_read_ogr(dsn , layer , query , as.character(options ), quiet , type , fid_column_name ,
252+ drivers , wkt_filter , promote_to_multi , int64_as_string , dsn_exists , dsn_isdb , getOption(" width" ))
253+
254+ process_cpl_read_ogr(x , quiet , check_ring_dir = check_ring_dir ,
255+ stringsAsFactors = stringsAsFactors , geometry_column = geometry_column ,
256+ optional = optional , ... )
257+ }
258+
241259}
242260
243261# ' @name st_read
@@ -606,7 +624,7 @@ print.sf_layers = function(x, ...) {
606624# ' @param options character; driver dependent dataset open options, multiple options supported.
607625# ' @param do_count logical; if TRUE, count the features by reading them, even if their count is not reported by the driver
608626# ' @name st_layers
609- # ' @return list object of class \code{sf_layers} with elements
627+ # ' @return list object of class \code{sf_layers} with elements
610628# ' \describe{
611629# ' \item{name}{name of the layer}
612630# ' \item{geomtype}{list with for each layer the geometry types}
@@ -751,7 +769,7 @@ check_append_delete <- function(append, delete) {
751769
752770# ' @name st_write
753771# ' @export
754- # ' @details st_delete deletes layer(s) in a data source, or a data source if layers are
772+ # ' @details st_delete deletes layer(s) in a data source, or a data source if layers are
755773# ' omitted; it returns TRUE on success, FALSE on failure, invisibly.
756774st_delete = function (dsn , layer = character (0 ), driver = guess_driver_can_write(dsn ), quiet = FALSE ) {
757775 invisible (CPL_delete_ogr(dsn , layer , driver , quiet ) == 0 )
0 commit comments