diff -r 438d77bca50e -r 36efdea68d03 buses.py --- a/buses.py Sun Apr 15 13:51:39 2018 +0300 +++ b/buses.py Thu Apr 19 14:44:54 2018 +0300 @@ -51,6 +51,7 @@ self.id = entry['route_id'] self.reference = entry['route_short_name'] self.trips = set() + self.service = None def __repr__(self): return 'routes[%r]' % self.reference @@ -68,6 +69,7 @@ self.cluster = None self.pairs = set() # samannimiset lähellä olevat pysäkit self.involved_trips = set() + self.services = set() def __repr__(self): return 'bus_stops[%r]' % self.reference def schedule(self, *, max_amount = 50, arrivals = False): @@ -127,6 +129,16 @@ # Lajittele lopputulos saapumisajan mukaan. result.sort(key = lambda schedule_entry: schedule_entry['time']) return result + @property + def typename(self): + if self.services == {'train'}: + return 'train-station' + elif self.services == {'tram'}: + return 'tram-stop' + elif self.services == {'ferry'}: + return 'ferry-terminal' + else: + return 'bus-stop' class BusHalt: def __init__(self, arrival_time, departure_time, stop, trip, traveled_distance): @@ -203,7 +215,7 @@ route = route, service = services[row['service_id']], length = shape_distances.get(row.get('shape_id'), 1) * float(profile['metrics']['shape-modifier']), - block_id = row['block_id'], + block_id = row.get('block_id') or row['service_id'], ) route.trips.add(trip) if trip.name in all_trips: @@ -492,6 +504,13 @@ trips_by_vehicle_info = {} for trip in all_trips.values(): trips_by_vehicle_info[(trip.block_id, trip.schedule[0].arrival_time)] = trip + if 'services' in profile and profile['services'].get('default-service'): + for route in routes.values(): + if not route.service: + route.service = profile['services']['default-service'] + for trip in route.trips: + for halt in trip.schedule: + halt.stop.services.add(route.service) if __name__ == '__main__': profile.read('profiles/föli.ini')