R/read_stream_internal.R

# gdal_ptrs <-  function(dsource, layer) {
#     layer <-  if (missing(layer)) {
#     character()
#   } else {
#     enc2utf8(layer)
#   }
#   #gdal_ptrs_cpp(dsource, layer)
# }
# 
# gdal_vector_data <-  function(dsource, layer, ..., sql = NA, options = NULL, quiet = FALSE, 
#                         fid_column_name = character(0),
#                         if_drivers = character(0), 
#                          extent = NA, 
#                          optional = FALSE, return_stream = FALSE) {
#   
#   ## vapourize this 
#   layer <-  if (missing(layer)) {
#     character()
#   } else {
#     enc2utf8(layer)
#   }
#   if (nchar(dsource) < 1L) {
#     stop("`dsour` must describe a valid source description for GDAL (input was an empty string).", call. = FALSE)
#   }
#   dsn_exists <-  file.exists(dsource)  
# 
#   if (length(dsource) == 1 && dsn_exists) {
#     dsource <- enc2utf8(normalizePath(dsource))
#   }
#   
# 
#     stream <- nanoarrow::nanoarrow_allocate_array_stream()
# 
#     # 
#     # info <- gdal_dsn_read_vector_stream(stream, 
#     #                                     dsource, layer, sql, as.character(options), quiet,
#     #                             if_drivers, extent, dsn_exists,  fid_column_name, 80L)
#     # 
#     # 
#     
#     # geometry_column <- unlist(lapply(
#     #   stream$get_schema()$children, function(s) identical(s$metadata[["ARROW:extension:name"]], "ogc.wkb")
#     # ))
#     crs <- info[[1L]]
#     if (info[[2L]] == -1) {
#       num_features = NULL
#     }
#     
# #    df = suppressWarnings(nanoarrow::convert_array_stream(x$stream, x$num_features))
#     #list(stream  = stream, crs = crs, num_features = num_features)
#     d <-  nanoarrow::convert_array_stream(stream, num_features)
#     #d$wkb_geometry <- wk::wkb(d$wkb_geometry, crs = crs)
#     d
# }
# 
# 
# 
hypertidy/vapour documentation built on March 2, 2024, 7:59 p.m.