diff --git a/R/gpkg-srs.R b/R/gpkg-srs.R index 37c80be..c06cf36 100644 --- a/R/gpkg-srs.R +++ b/R/gpkg-srs.R @@ -26,7 +26,7 @@ gpkg_list_srs <- function(x, column_name = "srs_id") { } #' @param default _logical_ or _character_. If `TRUE`, or one or more of `"cartesian"`, `"geographic"`, or `"crs84"`, then these default Spatial Reference Systems are added. -#' @return `gpkg_list_srs()`: _vector_ of values from specified `column_name` +#' @return `gpkg_create_spatial_ref_sys()`: _integer_. Result of running sequential `gpkg_execute()` statements. This method is run for the side-effect of creating the table if needed, and adding any "default" records. #' @export #' @rdname gpkg-srs gpkg_create_spatial_ref_sys <- function(x, default = TRUE, query_string = FALSE) { @@ -114,7 +114,7 @@ gpkg_create_spatial_ref_sys <- function(x, default = TRUE, query_string = FALSE) #' @param organization _character_. Organization, for example `"EPSG"` #' @param organization_coordsys_id _integer_. Organization Coordinate System ID, for example `4326L` #' @param definition _character_. WKT2019 Coordinate Reference System description string -#' @param description _character. Description +#' @param description _character_. Description #' @param query_string _logical_. Return SQL queries without executing? Default: `FALSE` #' #' @return `gpkg_add_spatial_ref_sys()`: _integer_ result of executing SQL statement diff --git a/R/gpkg-validate.R b/R/gpkg-validate.R index f9dca7f..afb8e70 100644 --- a/R/gpkg-validate.R +++ b/R/gpkg-validate.R @@ -2,10 +2,15 @@ #' #' Checks for presence of required tables, valid values and other constraints. #' -#' @param x Path to GeoPackages -#' @param diagnostics Return a list containing diagnostics (missing table names, invalid values, other errors) -#' -#' @return `TRUE` if valid. `FALSE` if one or more problems are found. For full diagnostics run with `diagnostics = TRUE` to return a list containing results for each input GeoPackage. +#' @param x A _geopackage_ object, or _character_ path to GeoPackage +#' @param diagnostics Return a list containing individual diagnostic test results (see Details) +#' @details +#' Several tests are run on the input GeoPackage, including: +#' - `required_tables`: _logical_. `TRUE` if `gpkg_contents` and `gpkg_spatial_ref_sys` tables exist +#' - `has_contents`: _logical_. `TRUE` if the number of rows in `gpkg_contents` table is greater than `0` and all tables listed in `gpkg_contents` are in the database +#' - `has_spatial_tables`: _logical_. `TRUE` if the number of tables in `gpkg_contents` with `data_type` `"features"` or `"2d-gridded-coverage"` is greater than `0` +#' +#' @return _logical_. `TRUE` if valid. `FALSE` if one or more problems are found. For full diagnostics run with `diagnostics = TRUE` to return a list containing results for each test run on the input GeoPackage. #' @export gpkg_validate <- function(x, diagnostics = FALSE) { x <- .gpkg_connection_from_x(x) @@ -13,10 +18,8 @@ gpkg_validate <- function(x, diagnostics = FALSE) { cg <- gpkg_contents(x) res <- list( required_tables = all(c("gpkg_contents","gpkg_spatial_ref_sys") %in% lt), - has_contents = (nrow(cg) > 0), - has_spatial_tables = all(cg$table_name %in% lt) && - sum(cg$data_type %in% - c("features", "2d-gridded-coverage")) > 0 + has_contents = (nrow(cg) > 0) && all(cg$table_name %in% lt), + has_spatial_tables = sum(cg$data_type %in% c("features", "2d-gridded-coverage")) > 0 ) if (is.null(diagnostics) || length(diagnostics) == 0 || diff --git a/man/gpkg-srs.Rd b/man/gpkg-srs.Rd index f7b1b81..a7c048e 100644 --- a/man/gpkg-srs.Rd +++ b/man/gpkg-srs.Rd @@ -46,14 +46,14 @@ gpkg_delete_spatial_ref_sys(x, srs_id = NULL) \item{definition}{\emph{character}. WKT2019 Coordinate Reference System description string} -\item{description}{_character. Description} +\item{description}{\emph{character}. Description} } \value{ \code{gpkg_spatial_ref_sys()}: \emph{data.frame} \code{gpkg_list_srs()}: \emph{vector} of values from specified \code{column_name} -\code{gpkg_list_srs()}: \emph{vector} of values from specified \code{column_name} +\code{gpkg_create_spatial_ref_sys()}: \emph{integer}. Result of running sequential \code{gpkg_execute()} statements. This method is run for the side-effect of creating the table if needed, and adding any "default" records. \code{gpkg_add_spatial_ref_sys()}: \emph{integer} result of executing SQL statement diff --git a/man/gpkg_validate.Rd b/man/gpkg_validate.Rd index 540070d..d0189c7 100644 --- a/man/gpkg_validate.Rd +++ b/man/gpkg_validate.Rd @@ -7,13 +7,21 @@ gpkg_validate(x, diagnostics = FALSE) } \arguments{ -\item{x}{Path to GeoPackages} +\item{x}{A \emph{geopackage} object, or \emph{character} path to GeoPackage} -\item{diagnostics}{Return a list containing diagnostics (missing table names, invalid values, other errors)} +\item{diagnostics}{Return a list containing individual diagnostic test results (see Details)} } \value{ -\code{TRUE} if valid. \code{FALSE} if one or more problems are found. For full diagnostics run with \code{diagnostics = TRUE} to return a list containing results for each input GeoPackage. +\emph{logical}. \code{TRUE} if valid. \code{FALSE} if one or more problems are found. For full diagnostics run with \code{diagnostics = TRUE} to return a list containing results for each test run on the input GeoPackage. } \description{ Checks for presence of required tables, valid values and other constraints. } +\details{ +Several tests are run on the input GeoPackage, including: +\itemize{ +\item \code{required_tables}: \emph{logical}. \code{TRUE} if \code{gpkg_contents} and \code{gpkg_spatial_ref_sys} tables exist +\item \code{has_contents}: \emph{logical}. \code{TRUE} if the number of rows in \code{gpkg_contents} table is greater than \code{0} and all tables listed in \code{gpkg_contents} are in the database +\item \code{has_spatial_tables}: \emph{logical}. \code{TRUE} if the number of tables in \code{gpkg_contents} with \code{data_type} \code{"features"} or \code{"2d-gridded-coverage"} is greater than \code{0} +} +}