Skip to content

Bug: No option in route() to exclude toll cost query #165

@cpaez1990

Description

@cpaez1990

Describe the bug
The route() function by default returns both route and toll costs, even if the "vignettes" option is specified "TRUE" or "FALSE". The issue is HERE charges a completely separate query for the toll costs. If, for example, you are running 10,000 routing queries to get driving distance and/or time and you do not care about toll costs, the package/function is still requesting and returning toll costs. So, instead of paying for only 10,000 Time-aware routing queries, you end of paying the 10,000 Time-aware routing queries in addition to 10,000 toll costs queries. Please see response from HERE staff:

The vignettes option does not control if the toll cost calculation is used or not. It is the return parameter that defines if toll is calculated or not.
Please see example:

With toll:
https://router.hereapi.com/v8/routes?apiKey=UHJbl8jpA0y7_cdaa_eoxiOoPdDXM10U18e8wDe4ZUM&origin=25.7697124504299,-80.214703178901&destination=25.7752549324994,-80.3217694619194&departureTime=2024-08-12T12:40:12-04:00&transportMode=car&alternatives=0&return=polyline,elevation,travelSummary,tolls&tolls[summaries]=total&tolls[vignettes]=all&currency=USD

No Toll:
https://router.hereapi.com/v8/routes?apiKey=UHJbl8jpA0y7_cdaa_eoxiOoPdDXM10U18e8wDe4ZUM&origin=25.7697124504299,-80.214703178901&destination=25.7752549324994,-80.3217694619194&departureTime=2024-08-12T12:40:12-04:00&transportMode=car&alternatives=0&return=polyline,elevation,travelSummary&currency=USD

Traffic
If you specify departureTime=any, the route calculation will not take traffic flow and other time-dependent effects into account. Long-term closures (that is, current closures that last for more than a day) will still be considered.
https://www.here.com/docs/bundle/routing-api-developer-guide-v8/page/tutorials/departure-time.html

How these parameters are controlled in the "hereR" inteface I cannot support on, for that you would need to contact the maintainer of that software.

Reproducible example
Include R code to reproduce the bug. Use the reprex package.

rm(list = ls())
gc()

# Load/Install Packages
packages <-
  c(
    "data.table",
    "dplyr",
    "foreach",
    "doParallel",
    "hereR",
    "sf"
  )
new_packages <- packages[!(packages %in% installed.packages()[, "Package"])]
if (length(new_packages) > 0)
  install.packages(new_packages)
invisible(lapply(packages, require, character.only = TRUE))
rm(packages, new_packages)


set_key("INSERT KEY") 

origin_lat <- 25.769712450429886
origin_lon <- -80.21470317890105
dest_lat <- 25.77525493249939
dest_lon <- -80.32176946191942

create_sf_point <- function(lat, lon) {
  st_as_sf(data.frame(lon = lon, lat = lat), coords = c("lon", "lat"), crs = 4326)
}

origin <- create_sf_point(origin_lat, origin_lon)
destination <- create_sf_point(dest_lat, dest_lon)

route1 <- route(
  origin = origin,
  destination = destination,
  transport_mode = "car",
  vignettes = FALSE
)
route2 <- route(
  origin = origin,
  destination = destination,
  vignettes = FALSE
)
route3 <- route(
  origin = origin,
  destination = destination
)
route4 <- route(
  origin = origin,
  destination = destination,
  vignettes = TRUE
)
route(origin = origin,destination = destination,url_only = TRUE)

Expected behavior
The route() function should have a specific option to control if the toll cost calculation is used or not; based on customer support from HERE and example queries provided to them, the vignettes option does not control toll cost calculation (see response from HERE above). Otherwise, for commercial use this could result in additional costs from the toll cost queries.

Optionally: R session info
Include session info: devtools::session_info().

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions