Skip to content

Commit

Permalink
Merge pull request #55 from munterfinger/develop
Browse files Browse the repository at this point in the history
Release v0.4.1 on CRAN.
  • Loading branch information
munterfi authored Aug 19, 2020
2 parents c24e299 + 49e4f4b commit 922ca0a
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 78 deletions.
29 changes: 15 additions & 14 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: hereR
Type: Package
Title: 'sf'-Based Interface to the 'HERE' REST APIs
Version: 0.4.0
Version: 0.4.1
Authors@R: c(
person("Merlin", "Unterfinger", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-2020-2366")),
person("Daniel", "Possenriede", role = "ctb", comment = c(ORCID = "0000-0002-6738-9845", "Geocode return options")))
Expand All @@ -19,23 +19,24 @@ Description: Interface to the 'HERE' REST APIs <https://developer.here.com/devel
Locations, routes and isolines are returned as 'sf' objects.
Depends: R (>= 3.3.0)
Imports:
curl (>= 4.2),
data.table (>= 1.12.6),
flexpolyline (>= 0.1.0),
jsonlite (>= 1.6),
curl (>= 4.3),
data.table (>= 1.13.0),
flexpolyline (>= 0.1.1),
jsonlite (>= 1.7.0),
sf (>= 0.9-0),
stringr (>= 1.4.0)
Suggests:
covr (>= 3.3.2),
ggplot2 (>= 3.2.1),
knitr (>= 1.25),
leafpop (>= 0.0.1),
lwgeom (>= 0.2-3),
mapview (>= 2.7.8),
rmarkdown (>= 1.16),
testthat (>= 2.2.1)
covr (>= 3.5.0),
ggplot2 (>= 3.3.2),
htmlwidgets (>= 1.5.1),
knitr (>= 1.29),
leafpop (>= 0.0.5),
lwgeom (>= 0.2-5),
mapview (>= 2.9.0),
rmarkdown (>= 2.3),
testthat (>= 2.3.2)
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
VignetteBuilder: knitr
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# version 0.4.1

* Change example and API mock data for `intermodal_route()` from Berlin to Switzerland, as the service is now also available there.
* Force {mapview} to use 'classical' leaflet/htmlwidgets rendering (which embeds data directly in the html) and not the file format 'flatgeobuf' in vignette building (see [#54](https://github.com/munterfinger/hereR/issues/54)).
* Temporarily deactivate all maps in the vignettes to solve the issues on CRAN (closes [#54](https://github.com/munterfinger/hereR/issues/54)). With the next release of {mapview} >= v2.9.1 on CRAN the maps will be reactivated.

# version 0.4.0

* Changed CI from Travis to GitHub actions.
Expand Down
14 changes: 2 additions & 12 deletions R/intermodal_route.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@
#' # Provide an API Key for a HERE project
#' set_key("<YOUR API KEY>")
#'
#' # Change POIs to Berlin, as service is not available in Switzerland
#' library(sf)
#' poi <- data.frame(
#' name = c("HERE Berlin", "Treptow", "Potsdam", "Tiergarten"),
#' lng = c(13.384944, 13.461215, 13.058351, 13.336490),
#' lat = c(52.531056, 52.493908, 52.403587, 52.514557)
#') %>%
#' st_as_sf(coords = c("lng", "lat")) %>%
#' st_set_crs(4326)
#'
#' # Intermodal routing
#' routes <- intermodal_route(
#' origin = poi[1:2, ],
#' destination = poi[3:4, ],
#' origin = poi[1:3, ],
#' destination = poi[4:6, ],
#' url_only = TRUE
#' )
intermodal_route <- function(origin, destination, datetime = Sys.time(),
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Codecov test coverage](https://codecov.io/gh/munterfinger/hereR/branch/master/graph/badge.svg)](https://codecov.io/gh/munterfinger/hereR?branch=master)
<!-- badges: end -->

The `hereR` package provides an interface to the **HERE REST APIs** for R:
The **hereR** package provides an interface to the **HERE REST APIs** for R:
(1) geocode and autocomplete addresses or reverse geocode POIs using the **Geocoder API**;
(2) route directions, travel distance or time matrices and isolines using the **Routing API**;
(3) request real-time traffic flow and incident information from the **Traffic API**;
Expand All @@ -18,7 +18,8 @@ Locations, routes and isolines are returned as `sf` objects.

## Installation

Install the released version from [CRAN](https://CRAN.R-project.org/package=hereR/) with:
You can install the released version of **hereR** from
[CRAN](https://CRAN.R-project.org/package=hereR/) with:

``` r
install.packages("hereR")
Expand All @@ -27,7 +28,7 @@ install.packages("hereR")
Install the development version from [GitHub](https://github.com/munterfinger/hereR/) with:

``` r
devtools::install_github("munterfinger/hereR")
remotes::install_github("munterfinger/hereR")
```

## Usage
Expand Down
13 changes: 2 additions & 11 deletions data-raw/Internal.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
## Create internal `mock` and `example` dataset
library(sf)

## POIs for intermodal routes (service not available in Switzerland)
poi_berlin <- data.frame(
name = c("HERE Berlin", "Treptow", "Potsdam", "Tiergarten"),
lng = c(13.384944, 13.461215, 13.058351, 13.336490),
lat = c(52.531056, 52.493908, 52.403587, 52.514557)
) %>%
st_as_sf(coords = c("lng", "lat")) %>%
st_set_crs(4326)

## URLs
url_geocode <-
geocode(addresses = poi$city, url_only = TRUE)
Expand All @@ -24,7 +15,7 @@ url_route <-
url_route_matrix <-
route_matrix(origin = poi, url_only = TRUE)
url_intermodal_route <-
intermodal_route(origin = poi_berlin[1:2, ], destination = poi_berlin[3:4, ], url_only = TRUE)
intermodal_route(origin = poi[1:3, ], destination = poi[4:6, ], url_only = TRUE)
url_isoline <-
isoline(poi = poi, url_only = TRUE)
url_weather_observation <-
Expand Down Expand Up @@ -72,7 +63,7 @@ example <- list(
reverse_geocode_landmarks = reverse_geocode(poi = poi, results = 3, landmarks = TRUE),
route = route(origin = poi[1:2, ], destination = poi[3:4, ]),
route_matrix = route_matrix(origin = poi),
intermodal_route = intermodal_route(origin = poi_berlin[1:2, ], destination = poi_berlin[3:4, ]),
intermodal_route = intermodal_route(origin = poi[1:3, ], destination = poi[4:6, ]),
isoline = isoline(poi = poi),
weather_observation = weather(poi = poi, product = "observation"),
weather_forecast_hourly = weather(poi = poi, product = "forecast_hourly"),
Expand Down
14 changes: 2 additions & 12 deletions man/intermodal_route.Rd

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

5 changes: 3 additions & 2 deletions vignettes/geocoder.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ knitr::opts_chunk$set(
library(hereR)
library(data.table)
library(mapview)
mapviewOptions(fgb = FALSE)
addresses <- poi$city
geocoded <- hereR:::example$geocode
suggestions <- hereR:::example$autocomplete
Expand Down Expand Up @@ -53,7 +54,7 @@ geocoded_sfdf <- st_as_sf(data.frame(locs, df[locs$id, ]))
```

Print the geocoded addresses on an interactive leaflet map:
```{r map_geocoded, eval=TRUE, out.width='100%'}
```{r map_geocoded, eval=FALSE, out.width='100%'}
mapview(geocoded,
label = geocoded$address,
col.regions = "yellow",
Expand Down Expand Up @@ -95,7 +96,7 @@ rev_landmarks <- reverse_geocode(poi = poi, results = 3, landmarks = TRUE)

The function returns an `sf` object, containing the suggested addresses or landmark names of the reverse geocoded POIs. The coordinates are different from the initially provided POIs since they represent the locations of the suggested addresses or landmarks.

```{r map_reverse_geocode, eval=TRUE, echo=TRUE, out.width='100%'}
```{r map_reverse_geocode, eval=FALSE, echo=TRUE, out.width='100%'}
m <-
mapview(poi, alpha.region = 0, col.region = "transparent",
label = poi$city, cex = 30, layer.name = "POIs",
Expand Down
20 changes: 4 additions & 16 deletions vignettes/intermodal.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ knitr::opts_chunk$set(
library(hereR)
library(mapview)
mapviewOptions(
fgb = FALSE,
vector.palette = colorRampPalette(
c("#000004FF", "#420A68FF", "#932667FF", "#DD513AFF", "#FCA50AFF", "#FCFFA4FF")
)
)
intermodal_routes <- hereR:::example$intermodal_route
origin <- poi[1:2, ]
destination <- poi[3:4, ]
```

Routing intermodal directions between locations based on the 'HERE Intermodal Routing' API.
Expand All @@ -31,19 +29,10 @@ Routing intermodal directions between locations based on the 'HERE Intermodal Ro
In order to calculate route geometries (`LINESTRING`) between pairs of points using the 'HERE Intermodal Routing API' the function `intermodal_route()` is used. The function takes origin and destination locations as `sf` objects containing geometries of type `POINT` as input. Routes can be limited to a maximum number of allowed transfers (includes mode changes and public transit transfers), by specifying the `transfer` parameter.

```{r int_directions, eval=FALSE}
## POIs for intermodal routes in Berlin (service is not yet available in Switzerland)
poi_berlin <- data.frame(
name = c("HERE Berlin", "Treptow", "Potsdam", "Tiergarten"),
lng = c(13.384944, 13.461215, 13.058351, 13.336490),
lat = c(52.531056, 52.493908, 52.403587, 52.514557)
) %>%
st_as_sf(coords = c("lng", "lat")) %>%
st_set_crs(4326)
# Request routes
intermodal_routes <- route(
origin = poi_berlin[1:2, ],
destination = poi_berlin[3:4, ]
origin = poi[1:3, ],
destination = poi[4:6, ]
)
```

Expand All @@ -54,10 +43,9 @@ knitr::kable(head(as.data.frame(intermodal_routes)[, colnames(intermodal_routes)
```

Print the intermodal routes on an interactive leaflet map:
```{r map_int_routes, eval=TRUE, out.width='100%'}
```{r map_int_routes, eval=FALSE, out.width='100%'}
mapview(intermodal_routes,
zcol = "mode",
lwd = intermodal_routes$duration/max(intermodal_routes$duration)*5,
layer.name = "Intermodal route",
map.types = c("Esri.WorldTopoMap"),
homebutton = FALSE
Expand Down
5 changes: 3 additions & 2 deletions vignettes/routing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ knitr::opts_chunk$set(
library(hereR)
library(mapview)
mapviewOptions(
fgb = FALSE,
vector.palette = colorRampPalette(
c("#000004FF", "#420A68FF", "#932667FF", "#DD513AFF", "#FCA50AFF", "#FCFFA4FF")
)
Expand Down Expand Up @@ -45,7 +46,7 @@ knitr::kable(head(as.data.frame(routes)[, colnames(routes) != "geometry"]), form
```

Construct a route label and print the routes on an interactive leaflet map:
```{r map_routes, eval=TRUE, out.width='100%'}
```{r map_routes, eval=FALSE, out.width='100%'}
routes$label <- paste(origin$city[routes$id],
destination$city[routes$id],
sep = " - ")
Expand Down Expand Up @@ -94,7 +95,7 @@ iso <- isoline(
```

Convert range from seconds to minutes and print the aggregated isolines on an interactive leaflet map:
```{r map_isoline, eval=TRUE, out.width='100%'}
```{r map_isoline, eval=FALSE, out.width='100%'}
iso$minutes <- iso$range/60
mapview(iso,
zcol = "minutes",
Expand Down
5 changes: 3 additions & 2 deletions vignettes/traffic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ knitr::opts_chunk$set(
library(hereR)
library(mapview)
mapviewOptions(
fgb = FALSE,
vector.palette = colorRampPalette(
c("#FFD700", "#CA0020")
)
Expand All @@ -37,7 +38,7 @@ flows <- flow(
```

Print the (ordered) 'jam factor' of the traffic flow on an interactive leaflet map:
```{r map_flow, eval=TRUE, out.width='100%'}
```{r map_flow, eval=FALSE, out.width='100%'}
flows <- flows[order(flows$JF), ]
mapview(flows,
zcol = "JF",
Expand All @@ -59,7 +60,7 @@ incidents <- incident(
```

Print the traffic incidents on an interactive leaflet map:
```{r map_incidents, eval=TRUE, out.width='100%'}
```{r map_incidents, eval=FALSE, out.width='100%'}
mapview(incidents,
zcol = "type",
layer.name = "Incident type",
Expand Down
5 changes: 3 additions & 2 deletions vignettes/transit.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ library(hereR)
library(mapview)
library(sf)
mapviewOptions(
fgb = FALSE,
vector.palette = colorRampPalette(
c("#000004FF", "#420A68FF", "#932667FF", "#DD513AFF", "#FCA50AFF", "#FCFFA4FF")
)
Expand Down Expand Up @@ -52,7 +53,7 @@ knitr::kable(head(as.data.frame(connection_section)[, colnames(connection_sectio
```

Print the public transport sections on an interactive leaflet map:
```{r pt_connection_section_map, eval=TRUE, out.width='100%'}
```{r pt_connection_section_map, eval=FALSE, out.width='100%'}
mapview(connection_section,
zcol = "mode",
layer.name = "Transport mode",
Expand Down Expand Up @@ -89,7 +90,7 @@ stations <- station(
```

Print the POIs, the radius and stations on an interactive leaflet map:
```{r stations_map, eval=TRUE, out.width='100%'}
```{r stations_map, eval=FALSE, out.width='100%'}
buffer <-
poi %>%
st_transform(2056) %>%
Expand Down
5 changes: 3 additions & 2 deletions vignettes/weather.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ library(hereR)
library(mapview)
library(ggplot2)
mapviewOptions(
fgb = FALSE,
vector.palette = colorRampPalette(
c("#0571B0", "#92C5DE", "#F7F7F7","#F4A582", "#CA0020")
)
Expand Down Expand Up @@ -50,7 +51,7 @@ knitr::kable(as.data.frame(observation)[, cols], format = "html")
```

Print the weather observation information on an interactive leaflet map:
```{r map_obs, eval=TRUE, out.width='100%'}
```{r map_obs, eval=FALSE, out.width='100%'}
m <-
mapview(observation,
zcol = "temperature",
Expand Down Expand Up @@ -101,7 +102,7 @@ g <- lapply(1:nrow(forecast), function(x) {
```

2. Then add list of graphs to the leaflet map using the the `popup` parameter:
```{r map_forecast, eval=TRUE, out.width='100%'}
```{r map_forecast, eval=FALSE, out.width='100%'}
m <-
mapview(forecast,
color = "black",
Expand Down

0 comments on commit 922ca0a

Please sign in to comment.