aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stop_areas_to_way_costs_converter.rb
blob: c6a00d31b88c925537d27df87fdd0d392131f439 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class StopAreasToWayCostsConverter
  def initialize(stop_areas)
    @stop_areas = stop_areas
  end

  def convert
    @stop_areas.each_cons(2).map do |stop_area_pair|
      WayCost.new(
        departure: Geokit::LatLng.new(
          stop_area_pair[0].latitude,
          stop_area_pair[0].longitude
        ),
        arrival: Geokit::LatLng.new(
          stop_area_pair[1].latitude,
          stop_area_pair[1].longitude
        ),
        id: "#{stop_area_pair[0].id}-#{stop_area_pair[1].id}"
      )
    end
  end
end