Skip to content

Commit

Permalink
feat: add get_providers() to export the provider list with URLS, subd…
Browse files Browse the repository at this point in the history
…omains, name and attribution
  • Loading branch information
rCarto committed Jan 15, 2024
1 parent 76e5cbf commit d216b6e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(create_provider)
export(get_credit)
export(get_providers)
export(get_tiles)
export(plot_tiles)
importFrom(grDevices,dev.size)
Expand All @@ -15,7 +16,6 @@ importFrom(sf,st_crs)
importFrom(sf,st_geometry)
importFrom(sf,st_is)
importFrom(sf,st_transform)
importFrom(terra,'RGB<-')
importFrom(terra,as.polygons)
importFrom(terra,ext)
importFrom(terra,gdal)
Expand Down
11 changes: 11 additions & 0 deletions R/get_providers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#' @title Providers
#' @description
#' List of builtin providers with their name, URL, subdomains and
#' attribution text.
#' @return A list of is returned.
#' @export
#' @examples
#' get_providers()
get_providers <- function(){
return(.global_maptiles$providers)
}
8 changes: 2 additions & 6 deletions inst/tinytest/test_maptiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ osm <- list(src = "OpenStreetMap",
sub = NA,
cit = "© OpenStreetMap contributors",
ext = "png")
stadia <- list(src = "Stadia.Stamen.Toner",
q = "https://tiles.stadiamaps.com/tiles/stamen_toner/{z}/{x}/{y}.png?api_key={apikey}",
sub = NA,
cit = "© Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap contributors",
ext = "png")
expect_identical(maptiles:::get_param("OpenStreetMap"), osm)
expect_warning(maptiles:::get_param("Stamen.Toner"))
expect_error(maptiles:::get_param("Esri.Delorme"))
Expand Down Expand Up @@ -185,7 +180,8 @@ osmouaich <- create_provider(
expect_equal(get_credit(osmouaich), "ouaich ouaich yo")
expect_null(get_credit("Wuwu"))


# get_providers ----
expect_equal(get_providers(), maptiles:::.global_maptiles$providers)

if (home){
# download_tiles() ----
Expand Down
18 changes: 18 additions & 0 deletions man/get_providers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d216b6e

Please sign in to comment.