Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max_walk_distance argument #14

Closed
rafapereirabr opened this issue Aug 15, 2020 · 7 comments
Closed

Add max_walk_distance argument #14

rafapereirabr opened this issue Aug 15, 2020 · 7 comments
Assignees
Labels

Comments

@rafapereirabr
Copy link
Member

Add a max_walk_distance argument to functions detailed_itineraries and travel_time_matrix

@mvpsaraiva
Copy link
Collaborator

mvpsaraiva commented Aug 17, 2020

I've added functions to set walk and bike speed to the R5R core class.

r5_core$setWalkSpeed(double speed) and r5_core$setBikeSpeed(double speed)

Those speeds are in metres per second. Now, we need to add R wrapper functions around those, probably using km/h as units.

Edit: I've added this comment here because our R wrapper functions will have to convert walking speeds and distance into walking times to pass to the Java api.

@dhersz
Copy link
Member

dhersz commented Aug 17, 2020

Is there a routing-config json in r5 similar to otp? If I recall correctly you can set these speeds in the file. Correct me if I'm wrong.

If that's the case, I think a function to create such a file could be handy and could save us time.

@rafapereirabr
Copy link
Member Author

related to #29

@rafapereirabr rafapereirabr self-assigned this Aug 19, 2020
@rafapereirabr
Copy link
Member Author

I've implmented the paremeter max_walk_dist in the travel_time_matrix function. This implementation is based on a new support function set_max_walk_distance, which works as follows:

#' Set max walking distance
#'
#' @param max_walk_dist numeric, Maximum walking distance (in Km) for the whole
#'                      trip. Passed from routing functions.
#' @param walk_speed numeric, Average walk speed in Km/h. Defaults to 3.6 Km/h.
#'                    Passed from routing functions.
#' @export
#' @family support functions
#'
set_max_walk_distance <- function(max_walk_dist, walk_speed, max_trip_duration){

    if (is.null(max_walk_dist)) {
      max_street_time = as.integer(max_trip_duration)
      return(max_street_time)

    } else if (!is.numeric(max_walk_dist)) {
      stop("max_walk_dist must be numeric")

    } else {
      max_street_time = as.integer(3600 * max_walk_dist / walk_speed)
      return(max_street_time)
    }
  }

@rafapereirabr
Copy link
Member Author

@mvpsaraiva , could you please add a max_trip_duration paremeter to the detailed_itineraries function ? We would need this to implement max_walk_dist .

@mvpsaraiva
Copy link
Collaborator

Done! But... max_trip_duration in detailed_itinerary only affects trips with public transport segments. Walking, driving and cycling trips are only affected by the max_street_time parameter. We can check the user's inputs in the R side, since it doesn't make sense max_street_time to be higher than max_trip_duration.

@rafapereirabr
Copy link
Member Author

Parameter max_walk_distance now added to detailed_itinerary.

As it stands, the user only passes values to the parameters max_trip_duration and max_walk_distance . The value of max_street_time will be calculated from that. If no max_walk_distance is passed, then max_street_time will be equal to max_trip_duration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants