Coder Social home page Coder Social logo

Add max_walk_distance argument about r5r HOT 7 CLOSED

ipeagit avatar ipeagit commented on August 25, 2024
Add max_walk_distance argument

from r5r.

Comments (7)

mvpsaraiva avatar mvpsaraiva commented on August 25, 2024

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.

from r5r.

dhersz avatar dhersz commented on August 25, 2024

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.

from r5r.

rafapereirabr avatar rafapereirabr commented on August 25, 2024

related to #29

from r5r.

rafapereirabr avatar rafapereirabr commented on August 25, 2024

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)
    }
  }

from r5r.

rafapereirabr avatar rafapereirabr commented on August 25, 2024

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

from r5r.

mvpsaraiva avatar mvpsaraiva commented on August 25, 2024

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.

from r5r.

rafapereirabr avatar rafapereirabr commented on August 25, 2024

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.

from r5r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.