Skip to content

Commit

Permalink
add support for wmts to get_layers_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-carteron committed Nov 16, 2023
1 parent 47a0f0b commit 5f74458
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 72 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ importFrom(utils,menu)
importFrom(xml2,as_list)
importFrom(xml2,xml_attr)
importFrom(xml2,xml_find_all)
importFrom(xml2,xml_name)
importFrom(xml2,xml_text)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# happign 0.2.1
* Fix `get_wms_raster()` because of [#21](https://github.com/paul-carteron/happign/issues/21)

# happign 0.2.0
* `get_wms_raster` is made faster by using gdalwarp from `sf::gdal_utils`.
There is no longer need to download several tiles.
Expand Down
2 changes: 1 addition & 1 deletion R/get_apicarto_gpu.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' "secteur-cc", "prescription-surf", "prescription-lin", "prescription-pct",
#' "info-surf", "info-lin", "info-pct". See detail for more info.
#' @param categorie public utility easement according to the
#' [national nomenclature](http://www.geoinformations.developpement-durable.gouv.fr/nomenclature-nationale-des-sup-r1082.html)
#' [national nomenclature](https://www.geoinformations.developpement-durable.gouv.fr/nomenclature-nationale-des-sup-r1082.html)
#' @param dTolerance numeric; Complex shape cannot be handle by API; using `dTolerance` allow to simplify them. See `?sf::st_simplify`
#'
#' @details
Expand Down
26 changes: 14 additions & 12 deletions R/get_layers_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' information about these two Webservice formats.
#'
#' @importFrom httr2 req_perform req_url_path req_url_query request resp_body_xml
#' @importFrom xml2 xml_find_all
#' @importFrom xml2 xml_find_all xml_name xml_text
#'
#' @seealso
#' [get_apikeys()]
Expand Down Expand Up @@ -39,7 +39,7 @@
get_layers_metadata <- function(apikey,
data_type) {

match.arg(data_type, c("wms", "wfs"))
match.arg(data_type, c("wms", "wfs", "wmts"))

# check input ----
# check parameter : apikey
Expand All @@ -55,17 +55,21 @@ get_layers_metadata <- function(apikey,

version <- switch(data_type,
"wms" = "1.3.0",
"wfs" = "2.0.0")
"wfs" = "2.0.0",
"wmts" = "1.0.0")

path <- switch(data_type,
"wms" = "r",
"wfs" = NULL)
"wfs" = NULL,
"wmts" = NULL)

xpath <- switch(data_type,
"wfs" = "//d1:FeatureType",
# /*[position() <= 3] select first three node of each selected node
"wfs" = "//d1:FeatureType/*[position() <= 3]",
# first element is always "Cache IGN" so I remove it with position()>1
# parenthesis are needed for creating a node set but I don't get it
"wms" = "(//d1:Layer)[position()>1]")
# parenthesis are needed for creating a node set but
"wms" = "(//d1:Layer)[position() > 1]/*[position() <= 3]",
"wmts" = "//d1:Layer/*[position() <= 2 or self::ows:Identifier]")

req <- request("https://wxs.ign.fr/") |>
req_url_path(apikey,"geoportail", path) |>
Expand All @@ -84,11 +88,9 @@ get_layers_metadata <- function(apikey,
return(NULL)
}

clean_metadata <- suppressWarnings(
as.data.frame(do.call(rbind, as_list(req)))[, 1:3])
clean_metadata <-
as.data.frame(apply(clean_metadata, c(1, 2), unlist))
metadata <- as.data.frame(matrix(xml_text(req), ncol = 3, byrow = T)) |>
setNames(xml_name(req)[1:3])

return(clean_metadata)
return(metadata)
}

86 changes: 34 additions & 52 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Warning :
I test with happign 1.0.0 but i finally decided to stay at 0.2.0. There's
no difference in code between both version.

## Test environments

* Windows Server 2022, R-devel, 64 bit
Expand All @@ -15,73 +11,59 @@ There were no ERRORs or WARNINGs for each environnement

### Windows Server 2022, R-devel, 64 bit

There are 2 NOTES which can be ignored :
- lastMiKTeXException : see https://github.com/r-hub/rhub/issues/503
- NULL : see https://github.com/r-hub/rhub/issues/560

── happign 1.0.0: NOTE
── happign 0.2.1: NOTE

Build ID: happign_1.0.0.tar.gz-3f5a67511a43498bbc0b99be7af2f6df
Build ID: happign_0.2.1.tar.gz-d913df9579c1400dba591299ccc039e8
Platform: Windows Server 2022, R-devel, 64 bit
Submitted: 48m 59.5s ago
Build time: 7m 21.6s
Submitted: 1h 12m 9s ago
Build time: 8m 57s

❯ checking CRAN incoming feasibility ... [43s] NOTE
Maintainer: 'Paul Carteron <carteronpaul@gmail.com>'

Found the following (possibly) invalid URLs:
URL: http://www.geoinformations.developpement-durable.gouv.fr/nomenclature-nationale-des-sup-r1082.html (moved to https://www.geoinformations.developpement-durable.gouv.fr/nomenclature-nationale-des-sup-r1082.html)
From: man/get_apicarto_gpu.Rd
Status: 200
Message: OK

❯ checking for non-standard things in the check directory ... NOTE
Found the following files/directories:
''NULL''

❯ checking for detritus in the temp directory ... NOTE
Found the following files/directories:
'lastMiKTeXException'

0 errors ✔ | 0 warnings ✔ | 2 notes ✖

### Windows Server 2022, R-release, 32/64 bit

There is 1 NOTE but i cannot do much because data contain accent

── happign 1.0.0: NOTE
── happign 0.2.1: IN-PROGRESS

Build ID: happign_1.0.0.tar.gz-3ecf3a4b4d2547fd9803fc834070abe9
Platform: Windows Server 2022, R-release, 32/64 bit
Submitted: 7 minutes 52.1 seconds ago
Build time: 7 minutes 49.2 seconds

NOTES:

* checking data for non-ASCII characters ... NOTE
Note: found 7592 marked UTF-8 strings

### Ubuntu Linux 20.04.1 LTS, R-release, GCC
Build ID: happign_0.2.1.tar.gz-297c789019a748c3a20531c4a5676423
Platform: Ubuntu Linux 20.04.1 LTS, R-release, GCC
Submitted: 1h 12m 9.1s ago

There is 1 NOTE that can be ignored :
- tidy : https://github.com/r-hub/rhub/issues/548

── happign 1.0.0: NOTE
── happign 0.2.1: NOTE

Build ID: happign_1.0.0.tar.gz-85edc5b55e4b484cbd4c71c8a0f68332
Platform: Ubuntu Linux 20.04.1 LTS, R-release, GCC
Submitted: 48m 59.6s ago
Build time: 43m 54.3s
Build ID: happign_0.2.1.tar.gz-abc42f0e197d416a90bd15908ed4e383
Platform: Fedora Linux, R-devel, clang, gfortran
Submitted: 1h 12m 9.2s ago
Build time: 1h 6m 32.6s

❯ checking CRAN incoming feasibility ... [11s/67s] NOTE
Maintainer: ‘Paul Carteron <carteronpaul@gmail.com>

Found the following (possibly) invalid URLs:
URL: http://www.geoinformations.developpement-durable.gouv.fr/nomenclature-nationale-des-sup-r1082.html (moved to https://www.geoinformations.developpement-durable.gouv.fr/nomenclature-nationale-des-sup-r1082.html)
From: man/get_apicarto_gpu.Rd
Status: 200
Message: OK

❯ checking HTML version of manual ... NOTE
Skipping checking HTML validation: no command 'tidy' found

0 errors ✔ | 0 warnings ✔ | 1 note ✖

### Fedora Linux, R-devel, clang, gfortran

There is 1 NOTE that can be ignored :
- tidy : https://github.com/r-hub/rhub/issues/548

── happign 1.0.0: NOTE
### Windows Server 2022, R-release, 32/64 bit

Build ID: happign_1.0.0.tar.gz-4edc205be092475bb1d3180ac532e29a
Platform: Fedora Linux, R-devel, clang, gfortran
Submitted: 48m 59.6s ago
Build time: 37m 21.6s
### Ubuntu Linux 20.04.1 LTS, R-release, GCC

❯ checking HTML version of manual ... NOTE
Skipping checking HTML validation: no command 'tidy' found
### Fedora Linux, R-devel, clang, gfortran

0 errors ✔ | 0 warnings ✔ | 1 note ✖
2 changes: 1 addition & 1 deletion man/get_apicarto_gpu.Rd

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

Loading

0 comments on commit 5f74458

Please sign in to comment.