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

Configuration of various constraints and costs #187

Open
stupidpupil opened this issue Jul 27, 2021 · 7 comments
Open

Configuration of various constraints and costs #187

stupidpupil opened this issue Jul 27, 2021 · 7 comments
Assignees

Comments

@stupidpupil
Copy link
Contributor

stupidpupil commented Jul 27, 2021

I feel I should say up front: I'm immensely thankful for this package and all the work on r5r (and indeed r5). I really hope that opening this issue doesn't come across as ungrateful.

Some context

I'm based in Wales, one of the four countries of the United Kingdom (UK).

The UK has some unusual features, including:

  • driving on the left (with implications for driving and cycling turn costs),
  • supporting walking and cycling on a broad set of road types (as tagged in OSM, e.g highway=trunk)

as well as the usual variation between countries, like:

  • driving speed limits/plausible driving speeds,
  • expected 'slack' for transfers to allow for arrival delays

For context, I link to a couple of OpenTripPlanner-related bits of code or configuration: UKWayPropertySetSource.java and my own route-config.json.

Expectations

It should be possible to configure the graph building process and trip planner requests to take account of the local features and variation described above, and this should be explained in the r5r documentation.

r5r might also supply some defaults for different sets of countries if r5 does not do so.

Current situation

It is not clearly documented how to configure r5r to take account of any of the above.

Discussion

I believe that some of this is probably configurable by pre-processing OSM data or supplying a build-config.json (when running setup_r5). This is a based on a quick skim of bits of the r5 source, for example SpeedConfig.java and TNBuilderConfig.java.

I'll dig into this a bit more and try to draft some documentation if I make sense of it, unless someone tells me I'm looking in the wrong place.

@rafapereirabr
Copy link
Member

Hi @stupidpupil , thank you for the kind message. I understand the points you raise, they look quite important for many contexts including the UK, Japan, South Africa, India etc. From what I understand the innerworkings of R5 and r5r, though, it sounds to me this would need to be addressed upstream in R5.

@mvpsaraiva , what do you think?

@stupidpupil
Copy link
Contributor Author

stupidpupil commented Jul 27, 2021

I do think you're right that left-hand drive regions aren't currently fully supported by R5 (per conveyal/r5#644 ) for driving and cycling. (I also suspect that transfer slack times are hard-coded in R5 at the moment.)

It does look like driving speeds can be amended by build-config.json in the data_path folder, e.g.

{
  "speeds":{ 
    // https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/853603/notes-and-definitions.pdf#page=6
    "units":"km/h",
    "values":{
      "motorway": 78,
      "motorway_link": 78,
      "trunk": 44,
      "trunk_link": 44,
      "primary": 44,
      "primary_link": 44,
      "secondary": 42,
      "secondary_link": 42,
      "tertiary": 37,
      "tertiary_link": 37,
      "living_street": 14,
      "pedestrian": 5,
      "residential": 19,
      "unclassified": 37,
      "service": 16,
      "track": 14,
      "road": 37
    },
    "defaultSpeed": 37
  }
}

@mvpsaraiva
Copy link
Collaborator

Hi @stupidpupil and @rafapereirabr.

I was looking into this, and it looks like we just need to save a build-config.json file containing the configurations on the same folder as the .pbf and GTFS before building the network.dat. The json file needs to contain the fields specified in
the TNBuilderConfig.java class.

I do think you're right that left-hand drive regions aren't currently fully supported by R5 (per conveyal/r5#644 ) for driving and cycling. (I also suspect that transfer slack times are hard-coded in R5 at the moment.)

Indeed, not all configurations you need are available via build-config.json. The only way to change those hardcoded options is upstream in R5.

We never tested using the build-config.json. I'll try to create a few files with different driving speeds and check if its working properly. If it's working, then we just need to write the documentation and maybe provide a template build-config.json that users can easily edit.

@mvpsaraiva
Copy link
Collaborator

I have made some tests and indeed R5 looks for a build-config.json file in the same folder where the osm.pbf and gtfs are stored and uses the settings on that file to build the network.dat. I did not test all the parameters, but I've changed some of the driving speeds and it worked.

For now, you can call r5r_core$defaultBuildConfig() from the R script to get a string with the default configurations in json format. Then you just need to save that string into a build-config.json on your data folder and edit the relevant parameters.

@rafapereirabr and @dhersz: I think we have two options now, moving forward:

  • create an R wrapper function such as get_build_config_json() around r5r_core$defaultBuildConfig(), with the proper documentation;
  • leave it as is, and document somewhere that advanced users can call r5r_core$defaultBuildConfig() directly.

@rafapereirabr
Copy link
Member

I like the idea of creating a wrapper function around r5r_core$defaultBuildConfig() that allows users to customize road speed. So the user would call the function like in the code below and the function would save a build-config.json with the speeds set by the user.

set_road_speed(motorway = 70,
               motorway_link = 60,
               trunk = 50)

This would not entirely address @stupidpupil's issue but it could certainly be helpful.

@rafapereirabr rafapereirabr self-assigned this May 2, 2022
@rafapereirabr
Copy link
Member

rafapereirabr commented May 2, 2022

I've created a set_road_speed() function which can be used to save a custom build-config.json in the data_path before building the network. This is a beta version, and you can check the function here. I haven't documented it yet, but it's pretty straightforward.

Let me know what you think.

@dhersz dhersz added the v1.0 Features to be included in r5r 1.0 label May 4, 2022
@rafapereirabr rafapereirabr removed the v1.0 Features to be included in r5r 1.0 label May 4, 2022
@rafapereirabr
Copy link
Member

rafapereirabr commented May 4, 2022

We've decided to address this issue in a future version. v.1.1 so we can have a better understanding of how the json file affects r5r_core().

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

No branches or pull requests

4 participants