Skip to content

Commit

Permalink
Merge pull request #9 from elipousson/master
Browse files Browse the repository at this point in the history
Merge changes from fork into development branch for review
  • Loading branch information
florisvdh authored Nov 16, 2022
2 parents 66ea0fe + 08b31fe commit 9f23f02
Show file tree
Hide file tree
Showing 34 changed files with 1,598 additions and 235 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
^rgeopackage\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
^data-raw$
^vignettes/articles$
35 changes: 20 additions & 15 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@ Package: rgeopackage
Title: Helper Tools in Creating or Handling GeoPackage Files
Version: 0.0.0.900
Authors@R: c(
person(given = "Floris",
family = "Vanderhaeghe",
role = c("aut", "cre"),
email = "[email protected]",
person("Floris", "Vanderhaeghe", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6378-6229")),
person("Research Institute for Nature and Forest",
email = "[email protected]",
role = "cph"))
Description: The aim of this R package is to provide helper tools in
creating or handling GeoPackage files, in order to complement
other R spatial packages or GDAL. The package has no dependencies
on other spatial packages and is not tied to any particular package
by design.
person("Research Institute for Nature and Forest", , , "[email protected]", role = "cph"),
person("Eli", "Pousson", , "[email protected]", role = c("aut", "ctb"),
comment = c(ORCID = "0000-0001-8280-1706"))
)
Description: The aim of this R package is to provide helper tools in
creating or handling GeoPackage files, in order to complement other R
spatial packages or GDAL. The package has no dependencies on other
spatial packages and is not tied to any particular package by design.
License: GPL (>= 3)
Depends:
R (>= 3.1.0)
Imports:
cli,
glue,
rlang,
RSQLite,
utils
Suggests:
dplyr,
openssl,
RSQLite,
rmarkdown,
sf,
stars
stars,
testthat (>= 3.0.0)
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.2.1
Config/testthat/edition: 3
31 changes: 31 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Generated by roxygen2: do not edit by hand

export(amend_timestamp)
export(append_gpkg_table)
export(connect_gpkg)
export(create_gpkg_table)
export(preset_timestamp)
export(read_gpkg_contents)
export(read_gpkg_extension)
export(read_gpkg_metadata)
export(read_gpkg_related_tables)
export(read_gpkg_schema)
export(read_gpkg_table)
export(unset_timestamp)
export(update_gpkg_contents)
export(update_gpkg_table)
export(write_gpkg_table)
importFrom(RSQLite,dbAppendTable)
importFrom(RSQLite,dbConnect)
importFrom(RSQLite,dbCreateTable)
importFrom(RSQLite,dbDisconnect)
importFrom(RSQLite,dbExecute)
importFrom(RSQLite,dbExistsTable)
importFrom(RSQLite,dbGetQuery)
importFrom(RSQLite,dbReadTable)
importFrom(RSQLite,dbWriteTable)
importFrom(cli,cli_abort)
importFrom(cli,cli_inform)
importFrom(cli,cli_warn)
importFrom(glue,glue)
importFrom(glue,glue_sql)
importFrom(rlang,`%||%`)
importFrom(rlang,caller_arg)
importFrom(rlang,caller_env)
importFrom(rlang,is_named)
importFrom(rlang,set_names)
38 changes: 38 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' Registered GeoPackage Extensions
#'
#' Reference table of registered GeoPackage extensions from
#' <http://www.geopackage.org/guidance/getting-started.html#registered-extensions>.
#' Note that the information in the reference column is an incomplete
#' representation of the requirements for extension implementation. This data is
#' provided to support a (yet to be developed) functions that allow the addition
#' of extensions to exported GeoPackage files.
#'
#' @format A data frame with 9 rows and 4 variables:
#' \describe{
#' \item{`pos`}{Position/order}
#' \item{`extension`}{Extension title}
#' \item{`url`}{Detail URL}
#' \item{`reference`}{List column with reference tables for
#' gpkg_extensions and other extension-specific tables.}
#' }
"gpkg_extensions"

#' Community GeoPackage Extensions
#'
#' Reference table of community GeoPackage extensions from
#' <http://www.geopackage.org/extensions.html>. Note that the information in the
#' reference column is an incomplete representation of the requirements for
#' extension implementation. This data is provided to support a (yet to be
#' developed) functions that allow the addition of extensions to exported
#' GeoPackage files.
#'
#' @format A data frame with 15 rows and 5 variables:
#' \describe{
#' \item{`pos`}{Position/order}
#' \item{`extension`}{Extension title}
#' \item{`description`}{Extension description}
#' \item{`url`}{Detail URL}
#' \item{`reference`}{List column with reference tables for
#' gpkg_extensions and other extension-specific tables.}
#' }
"community_gpkg_extensions"
72 changes: 72 additions & 0 deletions R/gpkg_contents.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#' Read and update GeoPackage contents table
#'
#' @inheritParams read_gpkg_table
#' @export
read_gpkg_contents <- function(dsn,
quiet = FALSE) {
read_gpkg_table(
dsn = dsn,
table_name = "gpkg_contents",
quiet = quiet
)
}

#' @name update_gpkg_contents
#' @rdname read_gpkg_contents
#' @param identifier Identifier for GeoPackage file.
#' @param description Description for GeoPackage file.
#' @inheritParams amend_timestamp
#' @param title Title for GeoPackage file.
#' @export
#' @importFrom RSQLite dbDisconnect
update_gpkg_contents <- function(dsn,
identifier = NULL,
description = NULL,
timestamp = Sys.time(),
title = identifier,
quiet = FALSE) {
con <- connect_gpkg(dsn)
table_name <- "gpkg_contents"
check_table_exists(con, table_name)

if (!is.null(identifier)) {
update_gpkg_table(
con,
table_name = table_name,
statement = glue_sql("SET identifier = {identifier}", .con = con),
quiet = quiet
)
}

if (!is.null(title)) {
update_gpkg_table(
con,
table_name = table_name,
statement = glue_sql("SET title = {title}", .con = con),
quiet = quiet
)
}

if (!is.null(description)) {
update_gpkg_table(
con,
table_name = table_name,
statement = glue_sql("SET description = {description}", .con = con),
quiet = quiet
)
}

if (!is.null(timestamp)) {
timestamp <- fmt_timestamp(timestamp)

update_gpkg_table(
con,
table_name = table_name,
statement = glue_sql("SET last_change = {timestamp}", .con = con),
quiet = quiet
)
}

RSQLite::dbDisconnect(con)
invisible(NULL)
}
Loading

0 comments on commit 9f23f02

Please sign in to comment.