Skip to content

Commit

Permalink
Add tests and NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed May 21, 2024
1 parent 544e659 commit cbf952f
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 65 deletions.
15 changes: 15 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ references:
email: [email protected]
year: '2024'
version: '>= 2.0.0'
- type: software
title: jsonlite
abstract: 'jsonlite: A Simple and Robust JSON Parser and Generator for R'
notes: Imports
url: https://jeroen.r-universe.dev/jsonlite
repository: https://CRAN.R-project.org/package=jsonlite
authors:
- family-names: Ooms
given-names: Jeroen
email: [email protected]
orcid: https://orcid.org/0000-0002-4035-0289
year: '2024'
identifiers:
- type: url
value: https://arxiv.org/abs/1403.2805
- type: software
title: rappdirs
abstract: 'rappdirs: Application Directories: Determine Where to Save Data, Caches,
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Depends:
R (>= 3.6.0)
Imports:
countrycode (>= 1.2.0),
jsonlite,
geojsonsf (>= 2.0.0),
jsonlite,
rappdirs (>= 0.3.0),
sf (>= 0.9.0),
utils
Expand Down
40 changes: 22 additions & 18 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

- New functions:
- `gisco_get_education()`.
- Add access to [GISCO Address
API](https://gisco-services.ec.europa.eu/addressapi/docs/screen/home)
through new functions. See `?gisco_addressapi` to know more.
- New dependency: **jsonlite** added to 'Imports'.
- Update `gisco_db` with the most up-to-date released data.
- Default year of some functions updated to the latest available data:
- `gisco_get_lau()` and `gisco_get_urban_audit()` default year now is
Expand Down Expand Up @@ -30,7 +34,7 @@

# giscoR 0.3.5

- Review examples to avoid CRAN errors and notes.
- Review examples to avoid **CRAN** errors and notes.
- New helper function: `gisco_detect_cache_dir()`.
- Now the functions fail gracefully with an informative message, instead of an
error, and return `NULL`.
Expand All @@ -45,12 +49,12 @@

# giscoR 0.3.2

- Fix HTML5 issue as requested by CRAN.
- Fix HTML5 issue as requested by **CRAN**.

# giscoR 0.3.1

- Add `Copyright` on DESCRIPTION.
- Add `lwgeom` on `Suggests`.
- Add `Copyright` on `DESCRIPTION`.
- Add **lwgeom** on 'Suggests'.
- `gisco_get_airports()` and `gisco_get_ports()`:
- Only year available is 2013.
- Now information is downloaded instead of using internal data.
Expand All @@ -67,22 +71,22 @@
`gisco_clear_cache()`.
- Fix an error when `cache = FALSE`. Now files are loaded instead throwing an
error.
- New tests with `testthat`.
- New tests with **testthat**.
- Update on docs. New examples
- Refactor documents and codes for the previous `gisco_get` doc.
- Add `eurostat` package to `Suggests`.
- `lwgeom` dependency removed.
- Add **eurostat** package to ' Suggests'.
- **lwgeom** dependency removed.
- Update internal grid object.
- `tmap` package replaced by `ggplot2` on vignettes and examples.
- **tmap** package replaced by **ggplot2** on vignettes and examples.

# giscoR 0.2.4

- New `eu` field on `giscoR::gisco_countrycode`.
- Fix typos on documentation
- Include vignette on the package
- Move docs to `roxygen2`
- `lwgeom` moved to Import field.
- `cartography` package replaced by `tmap` on vignettes.
- Fix typos on documentation.
- Include vignette on the package.
- Move docs to **roxygen2**.
- **lwgeom** moved to 'Imports' field.
- **cartography** package replaced by **tmap** on vignettes.

# giscoR 0.2.3

Expand All @@ -95,14 +99,14 @@

# giscoR 0.2.1

- Remove CRAN notes.
- Remove **CRAN** notes.
- Improve docs.
- Fix CRAN checks.
- Fix **CRAN** checks.

# giscoR 0.2.0

- Remove `colorspace` as dependency.
- Bump R minimal version to 3.6.0.
- Remove **colorspace** as dependency.
- Bump **R** minimal version to `3.6.0`.
- Change order on parameters for `gisco_get()` functions.
- Rewriting of internal functions and utils.
- Add `verbose` parameter to functions.
Expand All @@ -120,7 +124,7 @@
# giscoR 0.1.1

- Added `giscoR::tgs00026` dataset.
- Remove `eurostat` dependency.
- Remove **eurostat** dependency.

# giscoR 0.1.0

Expand Down
53 changes: 20 additions & 33 deletions R/gisco_get_healthcare.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,45 +42,32 @@ gisco_get_healthcare <- function(cache = TRUE, update_cache = FALSE,
epsg <- "4326"
ext <- "gpkg"

if (!is.null(country)) {
country_get <- gsc_helper_countrynames(country, "eurostat")
} else {
country_get <- "EU"
}


api_entry <- paste0(
"https://gisco-services.ec.europa.eu/pub/healthcare",
"/gpkg/", country_get, ".gpkg"
"/gpkg/EU.gpkg"
)

n_cnt <- seq_len(length(api_entry))

ress <- lapply(n_cnt, function(x) {
api <- api_entry[x]
filename <- basename(api)
filename <- basename(api_entry)


if (cache) {
# Guess source to load
namefileload <- gsc_api_cache(
api, filename, cache_dir, update_cache,
verbose
)
} else {
namefileload <- api
}

if (is.null(namefileload)) {
return(NULL)
}

data_sf <- gsc_api_load(namefileload, epsg, ext, cache, verbose)
if (cache) {
# Guess source to load
namefileload <- gsc_api_cache(
api_entry, filename, cache_dir, update_cache,
verbose
)
} else {
namefileload <- api_entry
}

data_sf
})
if (is.null(namefileload)) {
return(NULL)
}

data_sf_all <- do.call("rbind", ress)
data_sf <- gsc_api_load(namefileload, epsg, ext, cache, verbose)

return(data_sf_all)
if (!is.null(country) && "cc" %in% names(data_sf)) {
country <- gsc_helper_countrynames(country, "eurostat")
data_sf <- data_sf[data_sf$cc %in% country, ]
}
return(data_sf)
}
1 change: 0 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ results](https://badges.cranchecks.info/worst/giscoR.svg)](https://cran.r-projec
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.4317946-blue)](https://doi.org/10.5281/zenodo.4317946)
[![Project Status:
Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![status](https://tinyverse.netlify.app/status/giscoR)](https://CRAN.R-project.org/package=giscoR)

<!-- badges: end -->

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ results](https://badges.cranchecks.info/worst/giscoR.svg)](https://cran.r-projec
[![DOI](https://img.shields.io/badge/DOI-10.5281/zenodo.4317946-blue)](https://doi.org/10.5281/zenodo.4317946)
[![Project Status:
Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![status](https://tinyverse.netlify.app/status/giscoR)](https://CRAN.R-project.org/package=giscoR)

<!-- badges: end -->

Expand Down Expand Up @@ -187,7 +186,6 @@ We now download the data from Eurostat:
library(eurostat)
popdens <- get_eurostat("demo_r_d3dens") %>%
filter(TIME_PERIOD == "2021-01-01")
#> indexed 0B in 0s, 0B/sindexed 1.00TB in 0s, 415.28TB/s
```

By last, we merge and manipulate the data for creating the final plot:
Expand Down
18 changes: 15 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@
"sameAs": "https://CRAN.R-project.org/package=geojsonsf"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "jsonlite",
"name": "jsonlite",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=jsonlite"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "rappdirs",
"name": "rappdirs",
Expand All @@ -205,7 +217,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=rappdirs"
},
"5": {
"6": {
"@type": "SoftwareApplication",
"identifier": "sf",
"name": "sf",
Expand All @@ -218,7 +230,7 @@
},
"sameAs": "https://CRAN.R-project.org/package=sf"
},
"6": {
"7": {
"@type": "SoftwareApplication",
"identifier": "utils",
"name": "utils"
Expand All @@ -228,7 +240,7 @@
"applicationCategory": "cartography",
"isPartOf": "http://ropengov.org/",
"keywords": ["ropengov", "r", "spatial", "api-wrapper", "rstats", "r-package", "eurostat", "gisco", "thematic-maps", "eurostat-data", "cran", "ggplot2", "gis"],
"fileSize": "1224.516KB",
"fileSize": "1250.44KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
4 changes: 4 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ ggspatial
gisco
giscoR’
httr
jsonlite
kms
les
licence
limites
lwgeom
mapsf
rOG
rcartocolor
roxygen
testthat
tidyterra
tmap
4 changes: 2 additions & 2 deletions man/chunks/addressapi.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Brief description of the API endpoints (source [GISCO Address API \>
Endpoints](https://gisco-services.ec.europa.eu/addressapi/docs/screen/endpoints):

| **Endpoint** | **Description** |
|--------------------|------------------------------------------------------------|
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `/countries` | Returns all country codes that are compatible with the address API. Check the coverage map for available countries and see [here for a list of official country codes](https://publications.europa.eu/code/en/en-5000500.htm). |
| `/provinces` | Returns all provinces within the specified country. Can also be used to get the province of a specified city. |
| `/cities` | Returns all cities within a specified province or country. |
Expand All @@ -17,7 +17,7 @@ Endpoints](https://gisco-services.ec.europa.eu/addressapi/docs/screen/endpoints)
The resulting object may present the following variables:

| **Property name** | **Description** |
|------------------------------------------|--------------------------------------|
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `LD` | Refers to "Locator Designator" and represents the house number part of the address |
| `TF` | Refers to "Thoroughfare" and represents the street or road part of the address |
| `L0` | Refers to Level 0 of the API administrative levels. Values are country codes consisting of 2 characters. |
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-gisco_addressapi.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ test_that("gisco_addressapi_search online", {
test_that("gisco_addressapi_reverse online", {
skip_on_cran()
skip_if_gisco_offline()
expect_silent(n <- gisco_addressapi_bbox(
expect_silent(n <- gisco_addressapi_reverse(
x = 14.90691902084116,
y = 49.63074884786084
))
Expand Down
Binary file modified vignettes/africa-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/country-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/giscoR-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions vignettes/giscoR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ eu_bord <- borders %>%
# Eurostat data - Disposable income
pps <- get_eurostat("tgs00026") %>%
filter(TIME_PERIOD == "2021-01-01")
#> indexed 0B in 0s, 0B/sindexed 1.00TB in 0s, 4.79PB/s
```

``` r

nuts2_sf <- nuts2 %>%
left_join(pps, by = "geo") %>%
Expand Down

0 comments on commit cbf952f

Please sign in to comment.