aboutsummaryrefslogtreecommitdiffstats
path: root/lib/way_cost.rb
AgeCommit message (Collapse)Author
2018-03-14Add `StopAreasToWayCostsConverter`Teddy Wing
A new class that converts a list of `StopArea`s to `WayCost`s. This will be called from `Chouette::Route` to get `WayCost`s from its stops, which will then be JSON serialised and stored in `Route#costs`. Update `WayCost`: * Remove comment about calculating the ID automatically. It actually needs to be the same as the `JourneyPattern#cost` ID (`key`), which is a string with the IDs of the departure and arrival stops. * Make `#==` check that `id`s are the same, which necessitates making `id` a reader. Refs #6095
2018-03-14TomTom::Batch: Extract code to `#extract_costs_to_way_costs!`Teddy Wing
Extract some code from `#batch` to allow us to test the part that takes distance and time values from the response JSON and put fill them into `WayCost`s. In order for the test to work, had to add an `#==` method to `WayCost` and make `distance` and `time` accessors. The JSON file fixture is a copy of a response from the TomTom `/batch` API. The file is pretty big. I'm not sure if maybe I should condense it for the sake of test performance. Refs #6095
2018-03-14TomTom#batch: Populate WayCosts with distance & time from APITeddy Wing
Look through the API response from `/batch` and extract the distance & time values given to us by TomTom. These are inserted in the `WayCost`s given to use in the argument to `#batch`. At the end, we get a list of `WayCost`s that are completely filled with distance & time values. We need to split up this code a bit to make it more testable, but already this seems to function correctly. Refs #6095
2018-03-14Add `TomTom` class to communicate with their APITeddy Wing
Provides an interface to communicate with the TomTom API. Currently includes a method `#batch` to make a batch routing request (https://developer.tomtom.com/online-routing/online-routing-documentation/batch-routing). Left a bunch of development-related code in just to preserve my in-progress stages. Originally I was told to use the matrix routing API, but that turned out to not match what we wanted. Namely, matrix routing would produce a table with every point routed with every other point. We instead want routes of each segment in a line, in order (or, just the diagonal of the matrix). Using the batch API allows us to get the routes we need without doing unnecessary work. Update the `WayCost` class to provide `departure` and `arrival` methods as readers, and make `id` an optional parameter for now. (We still need to figure out how we're dealing with ID.) Refs #6095
2018-03-14WayCost.new: Make `distance` and `time` arguments optionalTeddy Wing
We don't have these values until after the TomTom API calculation, but we need to create `WayCost` objects before then. Give these values defaults so we don't have to set them. Refs #6095
2018-03-14Create `WayCost`Teddy Wing
A data class to hold the distance and time cost required to go between departure and arrival points. Refs #6095