diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index bd4bde3..3ff510e 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: @@ -10,9 +10,10 @@ name: test-coverage jobs: test-coverage: - runs-on: macos-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} steps: - uses: actions/checkout@v4 @@ -28,10 +29,12 @@ jobs: - name: Test coverage run: | + token <- Sys.getenv("CODECOV_TOKEN", "") covr::codecov( quiet = FALSE, clean = FALSE, - install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package") + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"), + token = if (token != "") token ) shell: Rscript {0} @@ -39,7 +42,7 @@ jobs: if: always() run: | ## -------------------------------------------------------------------- - find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true shell: bash - name: Upload test results diff --git a/CITATION.cff b/CITATION.cff index 924cd98..10bdee1 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -8,7 +8,7 @@ message: 'To cite package "CatastRoNav" in publications use:' type: software license: CC-BY-4.0 title: 'CatastRoNav: Interface to the ''INSPIRE'' services of ''Catastro de Navarra''' -version: 0.0.2.9000 +version: 0.1.0 doi: 10.5281/zenodo.6366407 abstract: Access public spatial data available under the 'INSPIRE' directive. Tools for downloading references, buildings and addresses of properties on Navarre (Spain). @@ -26,7 +26,7 @@ preferred-citation: email: diego.hernangomezherrero@gmail.com orcid: https://orcid.org/0000-0001-8457-4658 year: '2024' - version: 0.0.2.9000 + version: 0.1.0 doi: 10.5281/zenodo.6366407 url: https://ropenspain.github.io/CatastRoNav/ abstract: Access public spatial data available under the INSPIRE directive. Tools diff --git a/DESCRIPTION b/DESCRIPTION index 62dce76..b23e266 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: CatastRoNav Title: Interface to the 'INSPIRE' services of 'Catastro de Navarra' -Version: 0.0.2.9000 +Version: 0.1.0 Authors@R: person("Diego", "Hernangómez", , "diego.hernangomezherrero@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8457-4658")) diff --git a/NAMESPACE b/NAMESPACE index 8d45e5c..825d0fe 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(catrnav_atom_get_parcels) export(catrnav_atom_get_parcels_db_all) export(catrnav_clear_cache) +export(catrnav_detect_cache_dir) export(catrnav_set_cache_dir) export(catrnav_wfs_get_address_bbox) export(catrnav_wfs_get_buildings_bbox) diff --git a/NEWS.md b/NEWS.md index e941dfa..46ca677 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# CatastRoNav (development version) +# CatastRoNav 0.1.0 - Improve condition handling. - Add a `count` parameter that allows to set the maximum number of features to @@ -7,7 +7,8 @@ - Support for ATOM on cadastral parcels added, see `catrnav_atom_get_parcels()`. Other ATOM capabilities to be added when the Cadastre of Navarra make them available. - - New caching system, see `catrnav_set_cache_dir()`. + - New caching system, see `catrnav_set_cache_dir()` and + `catrnav_detect_cache_dir()`. - New dependency: **rappdirs** . # CatastRoNav 0.0.2 diff --git a/R/cache_set.R b/R/cache_set.R index fac0229..08688da 100644 --- a/R/cache_set.R +++ b/R/cache_set.R @@ -3,17 +3,21 @@ #' @family cache utilities #' @seealso [rappdirs::user_config_dir()] #' -#' @return An (invisible) character with the path to your `cache_dir`. +#' @rdname catrnav_set_cache_dir +#' +#' @return +#' [catrnav_set_cache_dir()] is called for its side effects, and returns an +#' (invisible) character with the path to your `cache_dir`. +#' #' @description -#' This function will store your `cache_dir` path on your local machine and -#' would load it for future sessions. Type `Sys.getenv("CATASTRONAV_CACHE_DIR")` -#' to find your cached path. +#' [catrnav_set_cache_dir()] will store your `cache_dir` path on your local +#' machine and would load it for future sessions. #' #' Alternatively, you can store the `cache_dir` manually with the following #' options: #' * Run `Sys.setenv(CATASTRONAV_CACHE_DIR = "cache_dir")`. You would need to #' run this command on each session (Similar to `install = FALSE`). -#' * Write this line on your `.Renviron` file: +#' * Write this line on your .Renviron file: #' `CATASTRONAV_CACHE_DIR = "value_for_cache_dir"` (same behavior than #' `install = TRUE`). This would store your `cache_dir` permanently. #' @@ -44,7 +48,6 @@ #' catrnav_set_cache_dir(verbose = TRUE) #' } #' -#' Sys.getenv("CATASTRONAV_CACHE_DIR") #' @export catrnav_set_cache_dir <- function(cache_dir, overwrite = FALSE, @@ -128,6 +131,35 @@ catrnav_set_cache_dir <- function(cache_dir, } +#' @rdname catrnav_set_cache_dir +#' @name catrnav_detect_cache_dir +#' +#' @export +#' +#' @description +#' [catrnav_detect_cache_dir()] detects and returns the path to your current +#' `cache_dir`. +#' +#' @param ... Ignored +#' @return +#' [catrnav_detect_cache_dir()] returns the path to the `cache_dir` used in this +#' session +#' +#' @examples +#' +#' catrnav_detect_cache_dir() +#' +catrnav_detect_cache_dir <- function(...) { + # nocov start + # This is just a wrapper + + list(...) + cache <- catrnav_hlp_detect_cache_dir() + + cache + # nocov end +} + #' Detect cache dir for CatastRoNav #' #' @noRd diff --git a/README.md b/README.md index f8bac12..a14e081 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ A BibTeX entry for LaTeX users is: title = {{CatastRoNav}: Interface to the {API} {Catastro} de {Navarra}}, author = {Diego Hernangómez}, year = {2024}, - version = {0.0.2.9000}, + version = {0.1.0}, doi = {10.5281/zenodo.6366407}, url = {https://ropenspain.github.io/CatastRoNav/}, abstract = {Access public spatial data available under the INSPIRE directive. Tools for downloading references, buildings and addresses of properties on Navarre (Spain).}, diff --git a/codemeta.json b/codemeta.json index de628b4..523758d 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,7 +8,7 @@ "codeRepository": "https://github.com/rOpenSpain/CatastRoNav", "issueTracker": "https://github.com/rOpenSpain/CatastRoNav/issues", "license": "https://spdx.org/licenses/CC-BY-4.0", - "version": "0.0.2.9000", + "version": "0.1.0", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -190,7 +190,7 @@ }, "SystemRequirements": null }, - "fileSize": "962.98KB", + "fileSize": "961.034KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/inst/WORDLIST b/inst/WORDLIST index be3b9e3..38092a6 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -12,13 +12,13 @@ Navarra ORCID Olite Pamplona +Renviron Royé SITNA SRS WFS cadastral cadastre -catrnav codecov config de diff --git a/inst/schemaorg.json b/inst/schemaorg.json index bcbde54..f8e5518 100644 --- a/inst/schemaorg.json +++ b/inst/schemaorg.json @@ -20,7 +20,7 @@ "url": "https://r-project.org" }, "runtimePlatform": "R version 4.4.0 (2024-04-24 ucrt)", - "version": "0.0.2.9000" + "version": "0.1.0" }, { "id": "https://doi.org/10.5281/zenodo.6366407", diff --git a/man/catrnav_set_cache_dir.Rd b/man/catrnav_set_cache_dir.Rd index 81fc840..f49f508 100644 --- a/man/catrnav_set_cache_dir.Rd +++ b/man/catrnav_set_cache_dir.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/cache_set.R \name{catrnav_set_cache_dir} \alias{catrnav_set_cache_dir} +\alias{catrnav_detect_cache_dir} \title{Set your \pkg{CatastRoNav} cache dir} \usage{ catrnav_set_cache_dir( @@ -10,6 +11,8 @@ catrnav_set_cache_dir( install = FALSE, verbose = TRUE ) + +catrnav_detect_cache_dir(...) } \arguments{ \item{cache_dir}{A path to a cache directory. On missing value the function @@ -24,24 +27,32 @@ this parameter is set to \code{FALSE} automatically.} \item{verbose}{Logical, displays information. Useful for debugging, default is \code{FALSE}.} + +\item{...}{Ignored} } \value{ -An (invisible) character with the path to your \code{cache_dir}. +\code{\link[=catrnav_set_cache_dir]{catrnav_set_cache_dir()}} is called for its side effects, and returns an +(invisible) character with the path to your \code{cache_dir}. + +\code{\link[=catrnav_detect_cache_dir]{catrnav_detect_cache_dir()}} returns the path to the \code{cache_dir} used in this +session } \description{ -This function will store your \code{cache_dir} path on your local machine and -would load it for future sessions. Type \code{Sys.getenv("CATASTRONAV_CACHE_DIR")} -to find your cached path. +\code{\link[=catrnav_set_cache_dir]{catrnav_set_cache_dir()}} will store your \code{cache_dir} path on your local +machine and would load it for future sessions. Alternatively, you can store the \code{cache_dir} manually with the following options: \itemize{ \item Run \code{Sys.setenv(CATASTRONAV_CACHE_DIR = "cache_dir")}. You would need to run this command on each session (Similar to \code{install = FALSE}). -\item Write this line on your \code{.Renviron} file: +\item Write this line on your .Renviron file: \code{CATASTRONAV_CACHE_DIR = "value_for_cache_dir"} (same behavior than \code{install = TRUE}). This would store your \code{cache_dir} permanently. } + +\code{\link[=catrnav_detect_cache_dir]{catrnav_detect_cache_dir()}} detects and returns the path to your current +\code{cache_dir}. } \section{About caching}{ Sometimes cached files may be corrupt. On that case, try re-downloading @@ -59,7 +70,9 @@ corresponding file by any other method and save it on your catrnav_set_cache_dir(verbose = TRUE) } -Sys.getenv("CATASTRONAV_CACHE_DIR") + +catrnav_detect_cache_dir() + } \seealso{ \code{\link[rappdirs:user_data_dir]{rappdirs::user_config_dir()}} diff --git a/vignettes/CatastRoNav.Rmd b/vignettes/CatastRoNav.Rmd index b398955..8bd7153 100644 --- a/vignettes/CatastRoNav.Rmd +++ b/vignettes/CatastRoNav.Rmd @@ -1,7 +1,7 @@ --- title: "Get started" output: rmarkdown::html_vignette -date: "2024-05-28" +date: "2024-06-07" vignette: > %\VignetteIndexEntry{Get started} %\VignetteEngine{knitr::rmarkdown} @@ -107,45 +107,32 @@ we created before: # Cut buildings dataviz <- st_intersection(pamp_bu, pamp_buff) -#> Error in UseMethod("st_intersection"): no applicable method for 'st_intersection' applied to an object of class "NULL" -``` - -``` r ggplot(dataviz) + geom_sf() -#> Error in eval(expr, envir, enclos): object 'dataviz' not found ``` +
+Minimal map +

Minimal map

+
+ Let's extract now the construction year, available in the column `beginning`: ``` r # Extract 4 initial positions year <- substr(dataviz$beginning, 1, 4) -#> Error in eval(expr, envir, enclos): object 'dataviz' not found -``` - -``` r # Replace all that doesn't look as a number with 0000 year[!(year %in% 0:2500)] <- "0000" -#> Error: object 'year' not found -``` - -``` r # To numeric year <- as.integer(year) -#> Error in eval(expr, envir, enclos): object 'year' not found -``` - -``` r # New column dataviz <- dataviz %>% mutate(year = year) -#> Error in eval(expr, envir, enclos): object 'dataviz' not found ``` Last step is to create groups based on the year and create the data @@ -155,25 +142,11 @@ different classes: ``` r dataviz <- dataviz %>% - mutate(year_cat = ggplot2::cut_width(year, - width = 10 - )) -#> Error in eval(expr, envir, enclos): object 'dataviz' not found -``` - -``` r - + mutate(year_cat = ggplot2::cut_width(year, width = 10, dig.lab = 12)) # Adjust the color palette -dataviz_pal <- hcl.colors( - length(levels(dataviz$year_cat)), - "Spectral" -) -#> Error in eval(expr, envir, enclos): object 'dataviz' not found -``` - -``` r +dataviz_pal <- hcl.colors(length(levels(dataviz$year_cat)), "Spectral") ggplot(dataviz) + geom_sf(aes(fill = year_cat), color = NA) + @@ -199,9 +172,13 @@ ggplot(dataviz) + ), plot.margin = margin(r = 40, l = 40) ) -#> Error in eval(expr, envir, enclos): object 'dataviz' not found ``` +
+Pamplona: Urban Growth +

Pamplona: Urban Growth

+
+ ## References - Royé D (2019). "Visualize urban growth." diff --git a/vignettes/CatastRoNav.Rmd.orig b/vignettes/CatastRoNav.Rmd.orig index b069ec2..8a79a53 100644 --- a/vignettes/CatastRoNav.Rmd.orig +++ b/vignettes/CatastRoNav.Rmd.orig @@ -22,7 +22,6 @@ knitr::opts_chunk$set( ) knitr::knit_hooks$set(crop = knitr::hook_pdfcrop) - ``` @@ -57,7 +56,6 @@ On this example we would retrieve the cadastral parcels of [Olite](https://en.wikipedia.org/wiki/Olite): ```{r olite, fig.cap="Example: Olite"} - library(CatastRoNav) # For getting coords library(sf) @@ -91,7 +89,6 @@ In first place, we extract the coordinates of the city center of Pamplona using **mapSpain**: ```{r} - # Use mapSpain for getting the coords pamp <- esp_get_capimun(munic = "^Pamplona") @@ -100,22 +97,18 @@ pamp <- esp_get_capimun(munic = "^Pamplona") pamp_buff <- pamp %>% st_transform(25830) %>% st_buffer(1250) - ``` Next step consists on extracting the buildings using the WFS service: ```{r } - pamp_bu <- catrnav_wfs_get_buildings_bbox(pamp_buff, count = 10000) - ``` Next step for creating the visualization is to crop the buildings to the buffer we created before: ```{r minimal, fig.cap="Minimal map", dpi=150} - # Cut buildings dataviz <- st_intersection(pamp_bu, pamp_buff) @@ -127,7 +120,6 @@ ggplot(dataviz) + Let's extract now the construction year, available in the column `beginning`: ```{r} - # Extract 4 initial positions year <- substr(dataviz$beginning, 1, 4) @@ -147,19 +139,12 @@ visualization. We use here the function `ggplot2::cut_width()` to create different classes: ```{r dataviz, fig.cap="Pamplona: Urban Growth", crop=TRUE} - dataviz <- dataviz %>% - mutate(year_cat = ggplot2::cut_width(year, - width = 10 - )) - + mutate(year_cat = ggplot2::cut_width(year, width = 10, dig.lab = 12)) # Adjust the color palette -dataviz_pal <- hcl.colors( - length(levels(dataviz$year_cat)), - "Spectral" -) +dataviz_pal <- hcl.colors(length(levels(dataviz$year_cat)), "Spectral") ggplot(dataviz) + geom_sf(aes(fill = year_cat), color = NA) + diff --git a/vignettes/dataviz-1.png b/vignettes/dataviz-1.png index c7df3d1..cb1efd3 100644 Binary files a/vignettes/dataviz-1.png and b/vignettes/dataviz-1.png differ diff --git a/vignettes/minimal-1.png b/vignettes/minimal-1.png index ca4b612..9a59d42 100644 Binary files a/vignettes/minimal-1.png and b/vignettes/minimal-1.png differ