Skip to content

Commit

Permalink
Merge pull request #41 from pepijn-devries/work-in-progress
Browse files Browse the repository at this point in the history
Fix in WMTS
  • Loading branch information
pepijn-devries authored Mar 25, 2024
2 parents 1dd808b + 5165864 commit a3593ac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: CopernicusMarine
Type: Package
Title: Search Download and Handle Data from Copernicus Marine Service Information
Version: 0.2.3
Date: 2024-01-25
Version: 0.2.3.001
Date: 2024-03-26
Authors@R: c(person("Pepijn", "de Vries", role = c("aut", "cre", "dtc"),
email = "pepijn.devries@outlook.com",
comment = c(ORCID = "0000-0002-7961-6646")))
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
CopernicusMarine v0.2.3.001 (Release date: 2024-02-26)
-------------

* Fix in `addCmsWMTSTiles`

CopernicusMarine v0.2.3 (Release date: 2024-01-25)
-------------

Expand Down
13 changes: 10 additions & 3 deletions R/cms_wmts.r
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ cms_wmts_details <- function(product, layer, variable) {
"WMTS:https://wmts.marine.copernicus.eu/teroWmts/%s?request=GetCapabilities" |>
sprintf(product),
quiet = TRUE)
desc <- copwmtsinfo |> stringr::str_match_all("SUBDATASET_(\\d)_DESC=(.*?)\n")
desc <- copwmtsinfo |> stringr::str_match_all("SUBDATASET_(\\d+)_DESC=(.*?)\n")
if (length(desc) == 0) return(dplyr::tibble(desc = character(0), url = character(0)))
desc <- desc[[1]][,3]
url <- copwmtsinfo |> stringr::str_match_all("SUBDATASET_(\\d)_NAME=(.*?)\n")
url <- copwmtsinfo |> stringr::str_match_all("SUBDATASET_(\\d+)_NAME=(.*?)\n")
url <- url[[1]][,3]
result <- dplyr::bind_cols(desc = desc, url = url)

Expand All @@ -73,7 +73,14 @@ addCmsWMTSTiles <- function(

detail <- cms_wmts_details(product, layer, variable)
detail <- detail$url |> strsplit(",") |> unlist()
detail <- detail[startsWith(detail, "layer=")]
detail <- detail[startsWith(detail, "layer=")] |> unique()
if (length(detail) == 0) rlang::abort(
c(x = "Could not find a WMTS URL",
i = "Check your parameter settings"))
if (length(detail) > 1) rlang::abort(
c(x = "Found ambiguous WMTS URLs",
i = "Check your parameter settings"))

leaflet::addTiles(
map = map,
urlTemplate =
Expand Down
1 change: 1 addition & 0 deletions man/CopernicusMarine-package.Rd

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

0 comments on commit a3593ac

Please sign in to comment.