diff -r b8467d51f1b8 -r b736478416d4 service.py --- a/service.py Wed Sep 12 08:27:27 2018 +0300 +++ b/service.py Thu Sep 13 21:32:30 2018 +0300 @@ -790,8 +790,8 @@ @app.route('/trip/') def trip(trip_reference): from flask import request - from buses import all_trips - from busroute import simplify_name + from buses import all_trips, shapes + from busroute import simplify_name,greatly_simplify_name try: trip = all_trips[trip_reference] except KeyError: @@ -824,8 +824,12 @@ 'time': formatted_time, 'id': halt.stop.reference, 'code': halt.stop.code, + 'ref': halt.stop.code or halt.stop.reference, 'name': tr(halt.stop.name, 'bus-stops'), 'typename': halt.stop.typename, + 'arrival_time': time_representation(datetime.combine(today(), time()) + halt.arrival_time), + 'departure_time': time_representation(datetime.combine(today(), time()) + halt.departure_time), + 'location': str(halt.stop.location), }) sign = trip.concise_schedule() try: @@ -836,11 +840,20 @@ schedule = schedule, trip_reference = trip_reference, route = trip.route.reference, - description = ' - '.join(tr(place, 'region_name') for place in sign), + #description = ' - '.join(tr(place, 'region_name') for place in sign), + description = greatly_simplify_name(sign[-1]), night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), tr = tr, length = trip.length / 1000, service = trip.route.service, + shape = ','.join(str.format('[{}, {}]', point[0], point[1]) for point in shapes[trip.shape]), + stops = list( + dict( + ref = halt.stop.reference, + name = halt.stop.name, + position = str.format('[{}]', str(halt.stop.location)), + ) for halt in trip.schedule + ), ) @app.route('/route/')