diff --git a/R/OGRSQLConnection.R b/R/OGRSQLConnection.R index c70d047..09652fd 100644 --- a/R/OGRSQLConnection.R +++ b/R/OGRSQLConnection.R @@ -8,7 +8,8 @@ setClass( "OGRSQLConnection", contains = "DBIConnection", - slots = list(DSN = "character", readonly = "logical") + slots = list(DSN = "character", + readonly = "logical") ) #' @rdname OGRSQLConnection-class diff --git a/R/sf_ogr.R b/R/sf_ogr.R index a86c7d7..2ec3686 100644 --- a/R/sf_ogr.R +++ b/R/sf_ogr.R @@ -21,9 +21,8 @@ OGRSQL <- function(){ new("OGRSQLDriver") } setMethod("dbConnect", "OGRSQLDriver", function(drv, DSN = "", readonly = TRUE, ...) { - ## FIXME: could be a new MEM dataset if (nchar(DSN) < 1) stop("DSN must be a valid data source name (file, connection string, url, ...)") - new("OGRSQLDriver", DSN = DSN, readonly = readonly, ...) + new("OGRSQLConnection", DSN = DSN, readonly = readonly, ...) }) #' @rdname OGRSQLConnection-class @@ -34,7 +33,6 @@ setMethod("dbDisconnect", "OGRSQLConnection", function(conn, ...) { conn }) - #' Delayed read for vector resources #' #' A lazy data frame for GDAL vector data sources. as_ogr is DBI compatible and designed to work with dplyr. @@ -54,20 +52,20 @@ setMethod("dbDisconnect", "OGRSQLConnection", function(conn, ...) { #' @return a 'tbl_OGRSQLConnection' #' @export -as_ogr <- function(x, layer, query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") { +as_ogr <- function(x, layer,..., query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") { UseMethod("as_ogr") } #' @name as_ogr #' @export -as_ogr.character <- function(x, layer, query, ignore_lyrs) { +as_ogr.character <- function(x, layer, ..., query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") { db <- dbConnect(OGRSQL(), x) - as_ogr(db, layer, query = query, ignore_lyrs = ignore_lyrs) + as_ogr(db, layer, ..., query = query, ignore_lyrs = ignore_lyrs) } #' @name as_ogr #' @export -as_ogr.OGRSQLConnection <- function(x, layer, query, ignore_lyrs) { +as_ogr.OGRSQLConnection <- function(x, layer, ..., query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") { if (!is.na(query)) { if (!missing(layer)) message("'layer' argument ignored, using 'query'") diff --git a/man/OGRSQLConnection-class.Rd b/man/OGRSQLConnection-class.Rd index c2d3450..83308a7 100644 --- a/man/OGRSQLConnection-class.Rd +++ b/man/OGRSQLConnection-class.Rd @@ -4,7 +4,7 @@ \name{OGRSQLConnection-class} \alias{OGRSQLConnection-class} \alias{show,OGRSQLConnection-method} -\alias{dbSendQuery,OGRSQLConnection,ANY-method} +\alias{dbSendQuery,OGRSQLConnection-method} \alias{dbReadTable,OGRSQLConnection,character-method} \alias{dbListTables,OGRSQLConnection-method} \alias{dbExistsTable,OGRSQLConnection,ANY-method} @@ -13,7 +13,7 @@ \usage{ \S4method{show}{OGRSQLConnection}(object) -\S4method{dbSendQuery}{OGRSQLConnection,ANY}(conn, statement, ...) +\S4method{dbSendQuery}{OGRSQLConnection}(conn, statement, ...) \S4method{dbReadTable}{OGRSQLConnection,character}(conn, name, ...) diff --git a/man/as_ogr.Rd b/man/as_ogr.Rd index c169fe7..70f0a03 100644 --- a/man/as_ogr.Rd +++ b/man/as_ogr.Rd @@ -6,11 +6,11 @@ \alias{as_ogr.OGRSQLConnection} \title{Delayed read for vector resources} \usage{ -as_ogr(x, layer, query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") +as_ogr(x, layer, ..., query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") -\method{as_ogr}{character}(x, layer, query, ignore_lyrs) +\method{as_ogr}{character}(x, layer, ..., query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") -\method{as_ogr}{OGRSQLConnection}(x, layer, query, ignore_lyrs) +\method{as_ogr}{OGRSQLConnection}(x, layer, ..., query = NA, ignore_lyrs = "gpkg_|rtree_|sqlite_") } \arguments{ \item{x}{the data source (file path, url, or database connection)} @@ -24,6 +24,8 @@ are no layers in \code{dsn}. If \code{dsn} is a database connection, then \code{\link[DBI]{Id}}). It is also possible to omit \code{layer} and rather use the \code{query} argument.} +\item{...}{parameter(s) passed on to \link[sf]{st_as_sf}} + \item{query}{SQL query to pass in directly} \item{ignore_lyrs}{pattern for layers to be ignored description} diff --git a/man/hfsubsetR-package.Rd b/man/hfsubsetR-package.Rd index 59421aa..401d566 100644 --- a/man/hfsubsetR-package.Rd +++ b/man/hfsubsetR-package.Rd @@ -4,9 +4,9 @@ \name{hfsubsetR-package} \alias{hfsubsetR} \alias{hfsubsetR-package} -\title{hfsubsetR: Build Hydrofabric subsets in R} +\title{hfsubsetR: Hydrofabric Subsetter} \description{ -Extract hydrofabric subsets in R. +Subset Hydrofabric Data in R } \seealso{ Useful links: