From ddfc41f75cb52f02511e2acd6429270bc9c0ab19 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 26 Mar 2018 11:49:40 +0200 Subject: TomTom::Matrix#extract_costs_to_way_costs!: Try to include stop IDs 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 --- lib/tom_tom/matrix.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/tom_tom/matrix.rb b/lib/tom_tom/matrix.rb index e0ee566b6..55568ab66 100644 --- a/lib/tom_tom/matrix.rb +++ b/lib/tom_tom/matrix.rb @@ -5,8 +5,8 @@ module TomTom end def matrix(way_costs) - points = points_from_way_costs(way_costs) - points = points_as_params(points) + points_with_ids = points_from_way_costs(way_costs) + points = points_as_params(points_with_ids) response = @connection.post do |req| req.url '/routing/1/matrix/json' @@ -23,7 +23,7 @@ module TomTom extract_costs_to_way_costs!( way_costs, - points, + points_with_ids, JSON.parse(response.body) ) end @@ -81,16 +81,16 @@ module TomTom way_costs << WayCost.new( departure: Geokit::LatLng.new( - departure[:point][:latitude], - departure[:point][:longitude] + departure.coordinates.lat, + departure.coordinates.lng ), arrival: Geokit::LatLng.new( - arrival[:point][:latitude], - arrival[:point][:longitude] + arrival.coordinates.lat, + arrival.coordinates.lng ), distance: distance, - time: column['response']['routeSummary']['travelTimeInSeconds'] - # id: 'TODO: figure out how to add combined stop IDs' + time: column['response']['routeSummary']['travelTimeInSeconds'], + id: "#{departure.id}-#{arrival.id}" ) end end -- cgit v1.2.3