lib/gtfs/realtime.rb in gtfs-realtime-0.1.0 vs lib/gtfs/realtime.rb in gtfs-realtime-0.2.0

- old
+ new

@@ -2,16 +2,17 @@ require "gtfs" require "sequel" require "sqlite3" # we must load our Sequel DB schema first -require "gtfs/realtime/db_schema" +require "gtfs/realtime/database" require "gtfs/gtfs_gem_patch" require "gtfs/realtime/configuration" require "gtfs/realtime/route" require "gtfs/realtime/service_alert" +require "gtfs/realtime/shape" require "gtfs/realtime/stop" require "gtfs/realtime/stop_time" require "gtfs/realtime/stop_time_update" require "gtfs/realtime/trip" require "gtfs/realtime/trip_update" @@ -51,10 +52,22 @@ url: route.url } end ) + GTFS::Realtime::Shape.dataset.delete + GTFS::Realtime::Shape.multi_insert( + static_data.shapes.collect do |shape| + { + id: shape.id.strip, + sequence: shape.pt_sequence, + latitude: shape.pt_lat.to_f, + longitude: shape.pt_lon.to_f + } + end + ) + GTFS::Realtime::Stop.dataset.delete GTFS::Realtime::Stop.multi_insert( static_data.stops.collect do |stop| { id: stop.id.strip, @@ -88,11 +101,9 @@ service_id: trip.service_id.strip, shape_id: trip.shape_id.strip } end ) - - # TODO: load shapes end end def refresh_realtime_feed! trip_updates = get_entities(@configuration.trip_updates_feed)