-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vectorized version of osm_get_metadata_gpx and updated tests after se…
…rver's API change
- Loading branch information
Showing
14 changed files
with
119 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Vectorized version of osm_get_metadata_gpx() | ||
|
||
#' Download GPS Track Metadata | ||
#' | ||
#' Use this to access the metadata about GPX files. Available without authentication if the file is marked public. | ||
#' Otherwise only usable by the owner account and requires authentication. | ||
#' | ||
#' @param gpx_id A vector of track ids represented by a numeric or a character value. | ||
#' @param format Format of the output. Can be `R` (default) or `xml`. | ||
#' | ||
#' @return | ||
#' If `format = "R"`, returns a data frame with one trace per row. If `format = "xml"`, returns a | ||
#' [xml2::xml_document-class] with the following format: | ||
#' ```xml | ||
#' <?xml version="1.0" encoding="UTF-8"?> | ||
#' <osm version="0.6" generator="OpenStreetMap server"> | ||
#' <gpx_file id="836619" name="track.gpx" lat="52.0194" lon="8.51807" uid="1234" user="Hartmut Holzgraefe" visibility="public" pending="false" timestamp="2010-10-09T09:24:19Z"> | ||
#' <description>PHP upload test</description> | ||
#' <tag>test</tag> | ||
#' <tag>php</tag> | ||
#' </gpx_file> | ||
#' <gpx_file> | ||
#' ... | ||
#' </gpx_file> | ||
#' </osm> | ||
#' ``` | ||
#' @family get GPS' functions | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' trk_meta <- osm_get_gpx_metadata(gpx_id = 3498170) | ||
#' trk_meta | ||
#' } | ||
osm_get_gpx_metadata <- function(gpx_id, format = c("R", "xml")) { | ||
format <- match.arg(format) | ||
|
||
if (length(gpx_id) == 1) { | ||
out <- osm_get_metadata_gpx(gpx_id = gpx_id, format = format) | ||
} else { | ||
outL <- lapply(gpx_id, function(id) { | ||
osm_get_metadata_gpx(gpx_id = id, format = format) | ||
}) | ||
|
||
if (format == "R") { | ||
out <- do.call(rbind, outL) | ||
} else if (format == "xml") { | ||
out <- xml2::xml_new_root(outL[[1]]) | ||
for (i in seq_len(length(outL) - 1)) { | ||
xml2::xml_add_child(out, xml2::xml_child(outL[[i + 1]])) | ||
} | ||
} | ||
} | ||
|
||
return(out) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
tests/testthat/mock_get_metadata_gpx/osm.org/api/0.6/gpx/3458743/details.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> | ||
<gpx_file id="3458743" name="not_saved" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-10-12T11:08:58Z" lat="41.71107572503388" lon="2.236165450885892"> | ||
<description>Puiggiró</description> | ||
<tag>explorant</tag> | ||
<tag>Cingles de Bertí</tag> | ||
</gpx_file> | ||
</osm> |
2 changes: 1 addition & 1 deletion
2
tests/testthat/mock_get_metadata_gpx/osm.org/api/0.6/gpx/3790367/details.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 19 additions & 16 deletions
35
tests/testthat/mock_list_gpxs/osm.org/api/0.6/user/gpx_files.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/"> | ||
<gpx_file id="3431956" name="StJuli_DeRibelles_HostalDeLaMuga_Talaix__Sadernes.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-09-28T09:23:52Z" lat="42.333541251719" lon="2.5914327520877123"> | ||
<gpx_file id="3431956" name="StJuli_DeRibelles_HostalDeLaMuga_Talaix__Sadernes.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-09-28T09:23:52Z" lat="42.333541251719" lon="2.5914327520877123"> | ||
<description>StJuliàDeRibelles_HostalDeLaMuga_Talaixà_Sadernes</description> | ||
</gpx_file> | ||
<gpx_file id="3472797" name="not_saved" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-10-25T12:06:03Z" lat="42.313132993876934" lon="2.5896873883903027"> | ||
<gpx_file id="3472797" name="not_saved" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-10-25T12:06:03Z" lat="42.313132993876934" lon="2.5896873883903027"> | ||
<description>St. Aniol - Passant del Gamarús - cova dels Trabucaires - Passant d'en Llebre</description> | ||
</gpx_file> | ||
<gpx_file id="3494162" name="not_saved" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-11-07T18:18:15Z" lat="41.49835919961333" lon="2.1166683454066515"> | ||
<gpx_file id="3494162" name="not_saved" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-11-07T18:18:15Z" lat="41.49835919961333" lon="2.1166683454066515"> | ||
<description>camins de Cerdanyola</description> | ||
<tag>trailrun</tag> | ||
</gpx_file> | ||
<gpx_file id="3498170" name="bruc.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-11-11T09:58:39Z" lat="41.58796912059188" lon="1.7747229896485806"> | ||
<gpx_file id="3498170" name="bruc.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2020-11-11T09:58:39Z" lat="41.58796912059188" lon="1.7747229896485806"> | ||
<description>Corriols per les rodalies del Bruc</description> | ||
</gpx_file> | ||
<gpx_file id="3789949" name="Roca_de_la_Pena_corrent.gpx" user="jmaspons" visibility="public" pending="false" timestamp="2021-08-19T21:47:50Z" lat="42.18059817329049" lon="1.4281276892870665"> | ||
<gpx_file id="3789949" name="Roca_de_la_Pena_corrent.gpx" uid="11725140" user="jmaspons" visibility="public" pending="false" timestamp="2021-08-19T21:47:50Z" lat="42.18059817329049" lon="1.4281276892870665"> | ||
<description>Roca de la Pena circular</description> | ||
</gpx_file> | ||
<gpx_file id="3789948" name="Roca_de_la_Pena_des_de_Llobera.gpx" user="jmaspons" visibility="public" pending="false" timestamp="2021-08-19T21:47:07Z" lat="42.18116671778262" lon="1.4277103543281555"> | ||
<gpx_file id="3789948" name="Roca_de_la_Pena_des_de_Llobera.gpx" uid="11725140" user="jmaspons" visibility="public" pending="false" timestamp="2021-08-19T21:47:07Z" lat="42.18116671778262" lon="1.4277103543281555"> | ||
<description>Roca de la Pena des de Llobera</description> | ||
</gpx_file> | ||
<gpx_file id="3790367" name="Airoto_Marimanha.gpx" user="jmaspons" visibility="public" pending="false" timestamp="2021-08-20T10:30:15Z" lat="42.69660229794681" lon="1.0419843904674053"> | ||
<gpx_file id="3790367" name="Airoto_Marimanha.gpx" uid="11725140" user="jmaspons" visibility="public" pending="false" timestamp="2021-08-20T10:30:15Z" lat="42.69660229794681" lon="1.0419843904674053"> | ||
<description>Airoto Marimanha Oriental</description> | ||
<tag>camp</tag> | ||
<tag>a</tag> | ||
<tag>través</tag> | ||
</gpx_file> | ||
<gpx_file id="3901854" name="Castell_Canig__refugi_d_Arag_.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2021-11-02T18:22:25Z" lat="42.53348727710545" lon="2.395844478160143"> | ||
<gpx_file id="3901854" name="Castell_Canig__refugi_d_Arag_.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2021-11-02T18:22:25Z" lat="42.53348727710545" lon="2.395844478160143"> | ||
<description>Castell - Canigó - refugi d'Aragó</description> | ||
</gpx_file> | ||
<gpx_file id="4073819" name="Bisaroques.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-01-24T07:51:46Z" lat="42.188827358186245" lon="2.5100998766720295"> | ||
<gpx_file id="4062097" name="cingles.gpx" uid="11725140" user="jmaspons" visibility="trackable" pending="false" timestamp="2022-01-19T15:45:51Z" lat="41.70677346177399" lon="2.2133453004062176"> | ||
<description>Turó de les 11 hores</description> | ||
</gpx_file> | ||
<gpx_file id="4073819" name="Bisaroques.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-01-24T07:51:46Z" lat="42.188827358186245" lon="2.5100998766720295"> | ||
<description>Volta circular amb corriols per traçar</description> | ||
</gpx_file> | ||
<gpx_file id="4118006" name="Perles_Figols.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-02-13T19:21:43Z" lat="42.17918783426285" lon="1.3936991896480322"> | ||
<gpx_file id="4118006" name="Perles_Figols.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-02-13T19:21:43Z" lat="42.17918783426285" lon="1.3936991896480322"> | ||
<description>Camins pendents d'agegir entre Perles i Fígols pel Collet de la Canal d'en Joan</description> | ||
</gpx_file> | ||
<gpx_file id="4431250" name="activity_8969751253.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-06-07T10:19:52Z" lat="42.23573558963835" lon="1.6616315860301256"> | ||
<gpx_file id="4431250" name="activity_8969751253.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-06-07T10:19:52Z" lat="42.23573558963835" lon="1.6616315860301256"> | ||
<description>Gósol - Vulturó per Josa del Cadí</description> | ||
</gpx_file> | ||
<gpx_file id="4431415" name="activity_8969751704.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-06-07T10:49:34Z" lat="42.28576574474573" lon="1.6366010438650846"> | ||
<gpx_file id="4431415" name="activity_8969751704.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-06-07T10:49:34Z" lat="42.28576574474573" lon="1.6366010438650846"> | ||
<description>Vulturó i fins més avall del refugi de St. Jordi</description> | ||
</gpx_file> | ||
<gpx_file id="4432183" name="activity_8969752023.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-06-07T16:34:34Z" lat="42.27627390995622" lon="1.818500580266118"> | ||
<gpx_file id="4432183" name="activity_8969752023.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2022-06-07T16:34:34Z" lat="42.27627390995622" lon="1.818500580266118"> | ||
<description>Tornada a Gòsol</description> | ||
</gpx_file> | ||
<gpx_file id="7797939" name="activity_11093847135.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2023-06-04T09:17:06Z" lat="31.136192930862308" lon="-7.927299840375781"> | ||
<gpx_file id="7797939" name="activity_11093847135.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2023-06-04T09:17:06Z" lat="31.136192930862308" lon="-7.927299840375781"> | ||
<description>Imlil - Tamsoult</description> | ||
</gpx_file> | ||
<gpx_file id="7797955" name="activity_11103300874.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2023-06-04T09:21:17Z" lat="31.063376488164067" lon="-7.937062913551927"> | ||
<gpx_file id="7797955" name="activity_11103300874.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2023-06-04T09:21:17Z" lat="31.063376488164067" lon="-7.937062913551927"> | ||
<description>Toubkal - Imlil</description> | ||
</gpx_file> | ||
<gpx_file id="7797946" name="activity_11102996506.gpx" user="jmaspons" visibility="identifiable" pending="false" timestamp="2023-06-04T09:19:07Z" lat="31.097403075546026" lon="-7.967628613114357"> | ||
<gpx_file id="7797946" name="activity_11102996506.gpx" uid="11725140" user="jmaspons" visibility="identifiable" pending="false" timestamp="2023-06-04T09:19:07Z" lat="31.097403075546026" lon="-7.967628613114357"> | ||
<description>Tamsoult - Refuge Toubkal</description> | ||
</gpx_file> | ||
</osm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters