aboutsummaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)Author
2018-05-06Update ci task to enable simple chouette-core build. Refs #6957Alban Peignier
2018-04-27TomTom::Matrix: Disable traffic information6661-make-TomTom-data-more-consistentTeddy Wing
By default the TomTom API uses traffic data to calculate travel time. This means that previously, getting costs for the exact same route twice at different times could produce different results. Johan made a good suggestion to turn off this functionality as it's apparently enabled by default. This should get us correct times regardless of time of day since the distances will be effectively the same. Refs #6661
2018-04-19Refs #6573; Fix task6573-fix-checksums-update-taskZog
Force-load all models beforehand
2018-04-16Add a task to check stop points positionsZog
2018-04-10Refs #6426; Disable "Create opposite route" action instead of hiding itZog
2018-04-10Merge pull request #460 from af83/6360-workbenchimport-displayLuc Donnet
6360 Add checks on calendars during WorkbenchImport
2018-04-10Merge pull request #438 from af83/6368-gtfs-importLuc Donnet
GTFS import (first step)
2018-04-10Keep ci database.yml in ci:docker:clean. Refs #6047Alban Peignier
2018-04-10Merge pull request #450 from ↵Luc Donnet
af83/6404-way-costs--snap-distance-and-time-to-1-when-between-0-a 6404: RouteWayCostUnitConverter: Snap values between 0–1 to 1
2018-04-09Refs #6360; Add checks on calendars during WorkbenchImportZog
2018-04-08Restore project config/database.yml in ci:docker:clean task. Refs #6047Alban Peignier
2018-04-08Update ci task to avoid problem with CHOUETTE_DEPLOY_DISABLED variable is ↵Alban Peignier
used. Refs #6047
2018-04-05RouteWayCostUnitConverter: Snap values between 0–1 to 16404-way-costs--snap-distance-and-time-to-1-when-between-0-aTeddy Wing
We use integer values for distance (kilometres) and time (minutes). If the values aren't very big, like bus stops inside a city for example, the integer conversion will put distance and time at `0`, which isn't correct. To continue to use our chosen measurement units while still displaying something that makes sense to users, snap any values >0 and <=1 to `1`. Refs #6404
2018-04-04Add a small log message for each TomTom invocation. Refs #62226222-route-way-costs--use-TomTom-matrix-API-instead-of-batchAlban Peignier
2018-04-03Add GTFS::Time and use it to compute day offset for VehicleJourneys. Refs #6368Alban Peignier
2018-03-27TomTom::Matrix: Add comment about JSON serialisationTeddy Wing
Make it clearer why we have to use a custom serialiser here. Refs #6222
2018-03-27TomTom::Matrix: Serialize `BigDecimal` as floatTeddy Wing
Rails serialises `BigDecimal`s as JSON strings to prevent loss of precision. The `latitude` and `longitude` columns in `StopArea` are stored as `BigDecimal`s. The trouble is that TomTom's API requires the latitude & longitude values to be JSON floats, not strings. Make a new JSON serialiser that converts the `BigDecimal` coordinates to float to allow the values to be correctly interpreted by the API. Refs #6222
2018-03-27TomTom::Matrix: Remove completed TODOTeddy Wing
Already handled this a few commits ago. Refs #6222
2018-03-27TomTom::Matrix#points_from_way_costs: Use array instead of setTeddy Wing
Using a set ended up not working out. I needed to be able to index into the list in `#extract_costs_to_way_costs!`, and sets aren't indexable. This is because they're supposed to be unordered, though modern Ruby implements `Set` with `Hash` under the hood, which is ordered in Ruby. I like the idea of having a data structure that automatically eliminates duplicates, but it wasn't meant to be, because for the extraction to `WayCost`s, I need an ordered list. Rather than create a new `OrderedSet` type, I just went the simple route and used an Array, eliminating the duplicates manually because I know when duplicates are supposed to occur due to the nature of the data set. Remove the `#eql?` and `#hash` methods from `TomTom::Matrix::Point`. Because we're not longer using `Set`, these methods don't need to be implemented. Refs #6222
2018-03-27TomTom::Matrix#extract_costs_to_way_costs!: Try to include stop IDsTeddy Wing
Change this code to get stop IDs based on the change in be3e1effcdea87909a181c7e9b12cf6867b1839d. It should use these IDs to construct new `WayCost`s with the combination of stop IDs from departure and arrival stops. This doesn't work currently because the method has code that tries to index the `points` collection, but it's a `Set`, and sets don't support indexing and aren't ordered, so this code errors. Need to change the `Set` to something else that will work here. Refs #6222
2018-03-27TomTom::Matrix#points_as_params: Use `TomTom::Matrix::Point`sTeddy Wing
Rewrite this method to accept `TomTom::Matrix::Point`s instead of plain `Geokit::LatLng` coordinates. Do this because this method needs to take the result of `#points_from_way_costs` as input, and that method now returns a `Set` of `Point`s. Refs #6222
2018-03-27TomTom::Matrix#points_from_way_costs: Better names for IDsTeddy Wing
Instead of a generic `ids` array, use clearer variable names for these values. Refs #6222
2018-03-27TomTom::Matrix#points_from_way_costs: Include stop IDs with pointsTeddy Wing
We need to persist stop IDs in order to properly construct `WayCost` objects from the costs returned from the TomTom matrix API. In order to persist stop IDs, my idea here is to group together a point and its corresponding ID into a bucket. When we later `#extract_costs_to_way_costs!`, we'll be able to grab the correct ID for a given coordinate to create a `WayCost` from it. Here, we create a new `TomTom::Matrix::Point` class that encapsulates a coordinate and an ID, and build a `Set` of those. I needed an `#eql?` and `#hash` method on `Point` as described in the `Set` documentation (https://ruby-doc.org/stdlib-1.9.3/libdoc/set/rdoc/Set.html) in order to properly maintain a unique set. Refs #6222
2018-03-27Add `TomTom::Matrix`Teddy Wing
A new component to the `TomTom` module that asks TomTom's Matrix API endpoint (https://developer.tomtom.com/online-routing/online-routing-documentation/matrix-routing) to compute `WayCost`s. The matrix API will give us all costs between each pair of coordinates. This will enable us to provide costs for any combination of points in a journey pattern. Given a list of `WayCost`s, it will send all points from those costs to the matrix API and return a list of all non-zero `WayCost`s between all pairs of coordinates. `points_from_way_costs()` extracts unique coordinates from the `WayCost`s. `points_as_params()` builds a list of points in the format expected by the matrix API. The response from the matrix API is formatted as a two-dimensional array consisting of rows and columns that pair each "origin" point with each "destination" point. We loop through this matrix and construct new `WayCost` objects for each pair of coordinates. At the moment, I haven't figured out how I want to save `WayCost` IDs when creating the new pairs. Leaving that for later. Refs #6222
2018-03-23Add erd diagram for export and mergeLuc Donnet
2018-03-19Fix typo for Import class Refs #6243Luc Donnet
2018-03-19Fix coordinates synchronization for reflex Refs #6245Luc Donnet
2018-03-16Fix reflex sync Refs #6141Luc Donnet
2018-03-16Fix stop_area state for filter and display. Update reflex sync to use ↵Luc Donnet
confirmed_at. Refs #6141
2018-03-15Avoid error when distance or time cost is ignored. Refs #6203Alban Peignier
2018-03-15RouteWayCostUnitConverter: Round kilometres to 2 decimal placesTeddy Wing
The JavaScript validation doesn't pass if we have more than two decimal places (I think because it uses a number field step value of 0.01). Round the values to allow them to pass frontend validation. Refs #6203
2018-03-15Rename `RouteWayCostJSONSerializer` to `RouteWayCostUnitConverter`Teddy Wing
Because we need to pass a Ruby hash to Rabl instead of a JSON string, get rid of our serialiser and instead turn it into a function that just converts the distance & time units. Fix a bug in the test that had the `'1-2'` key as a symbol instead of a string which was caused by a copy-paste from JSON and not being thorough enough in search-and-replace. Refs #6203
2018-03-15Add `RouteWayCostJSONSerializer`Teddy Wing
This serialiser will take `Route#costs` and convert the distance and time fields from meters to kilometres and seconds to minutes respectively. We need this because the frontend uses kilometre and minute units while the TomTom API gives us the others (and we store the data we get from TomTom without treatment). Unfortunately, due to the way that Rabl works, this doesn't quite work just yet. The serializer returns a string, and Rabl just puts this string into the JSON output instead of a real JSON hash. Looks like I'm going to have to convert my serializer into a generic converter. Refs #6203
2018-03-15Merge pull request #379 from ↵Alban Peignier
af83/6095-route--calculate-distance-and-time-cost-between-stops Calculate distance and time cost between Route stops. Refs #6095
2018-03-15Route: Don't run `#calculate_costs!` on callback if TomTom disabledTeddy Wing
We say `TomTom` is disabled when no API key is present. If this is the case, the `after_save` callback that uses it shouldn't be executed. I had to change my `API_KEY` constant to an instance variable to be able to change it for testing. Refs #6095
2018-03-15Delete number attributes for 3-Generic-2 compliance_controlLuc Donnet
2018-03-15Merge pull request #364 from af83/6028-compliance-controls-model-attributesLuc Donnet
Refs #6028 small changes in model attribute for CC
2018-03-14Add `WayCostCollectionJSONSerializer`Teddy Wing
A JSON serialiser for a collection of `WayCost`s. This will be used to store `WayCost`s for a `Chouette::Route` in the `Route#costs` JSON field. Refs #6095
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: Rename `#convert_way_costs_for_batch`Teddy Wing
Rename to `#convert_way_costs` since this method now lives inside the `TomTom::Batch` class, so that part of the name became redundant. Refs #6095
2018-03-14TomTom: Provide `TomTom.batch(...)` methodTeddy Wing
This change enables us to call `TomTom.batch(...)` instead of `TomTom.new.batch(...)` a couple commits ago. This is nice because the initialisation was kind of unnecessary for users of the class. Refs #6095
2018-03-14tom_tom/batch: Use `module ...` syntaxTeddy Wing
Change the `TomTom::Batch` to `module ... class ...` syntax instead. I like this better in this case. Refs #6095
2018-03-14Move `lib/tom_tom.rb` to `lib/tom_tom/batch.rb`Teddy Wing
Separate the functionality a little better by moving the `/batch` endpoint code into a new class. The goal here is also to lay the foundation for being able to call `TomTom.batch()` instead of `TomTom.new.batch()`. 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-14secrets.yml: Add `tomtom_api_key`Teddy Wing
Make the TomTom API key accessible to the application. It gets set in Docker via an environment variable. Still need to work out how we're setting it in development. For now I'm just saving it in `secrets.yml` without committing it. Refs #6095
2018-03-14Revert "TomTom: Add method for `calculateRoute` endpoint"Teddy Wing
This reverts commit f28a4b2c5b348bc12b455aa0cd76a9513103aea7. As stated in that commit, I'm going to use the `/batch` endpoint instead of `/calculateRoute` because I know that's already working.
2018-03-14TomTom: Add method for `calculateRoute` endpointTeddy Wing
A new method to provide access to the `/calculateRoute` endpoint, which calculates costs for a single route through a bunch of waypoints. This doesn't work currently because the API requires that I send `supportingPoints` in the body of the request. Since I'm not too clear on what those are, I'm going to cut off development of this method here and just use `#batch` instead for my purposes. My idea was to use this endpoint instead of `/batch` to allow us to calculate a single route instead of having the API do `/calculateRoute` for each of our point pairs. This seemed like it would be more efficient, and give us our distance and time costs between each waypoint all in one go, but since I'm not clear on how to use this API and whether it will give us the correct data, I'm going to stick with `/batch`. I'll probably be reverting this code. Just committing it now in case it becomes useful in the future. Refs #6095
2018-03-14TomTom#batch: Remove unwanted paramsTeddy Wing
I had copy-pasted these from the example in the docs (https://developer.tomtom.com/online-routing/online-routing-documentation/batch-routing), but I don't think we want some of these. For `maxAlternatives`, it's already 0 by default according to their docs, and the others don't really make sense for us because we want a general routing instead of one based on traffic or time of day. Refs #6095
2018-03-14TomTom: Use travelMode='bus'Teddy Wing
For now, hard-code 'bus' as the travel mode. This feature is currently only going to be used for Ouibus, so we want to be able to request in 'bus' mode, but for now don't have time to think about how to make it more extensible to other travel modes and operators. Refs #6095