822 }) |
822 }) |
823 schedule[-1]['stops'].append({ |
823 schedule[-1]['stops'].append({ |
824 'time': formatted_time, |
824 'time': formatted_time, |
825 'id': halt.stop.reference, |
825 'id': halt.stop.reference, |
826 'code': halt.stop.code, |
826 'code': halt.stop.code, |
|
827 'ref': halt.stop.code or halt.stop.reference, |
827 'name': tr(halt.stop.name, 'bus-stops'), |
828 'name': tr(halt.stop.name, 'bus-stops'), |
828 'typename': halt.stop.typename, |
829 'typename': halt.stop.typename, |
|
830 'arrival_time': time_representation(datetime.combine(today(), time()) + halt.arrival_time), |
|
831 'departure_time': time_representation(datetime.combine(today(), time()) + halt.departure_time), |
|
832 'location': str(halt.stop.location), |
829 }) |
833 }) |
830 sign = trip.concise_schedule() |
834 sign = trip.concise_schedule() |
831 try: |
835 try: |
832 sign = [sign[0], sign[-1]] |
836 sign = [sign[0], sign[-1]] |
833 except IndexError: |
837 except IndexError: |
834 sign = [trip.schedule[0].stop.name, trip.schedule[-1].stop.name] |
838 sign = [trip.schedule[0].stop.name, trip.schedule[-1].stop.name] |
835 return render_template('trip.html', |
839 return render_template('trip.html', |
836 schedule = schedule, |
840 schedule = schedule, |
837 trip_reference = trip_reference, |
841 trip_reference = trip_reference, |
838 route = trip.route.reference, |
842 route = trip.route.reference, |
839 description = ' - '.join(tr(place, 'region_name') for place in sign), |
843 #description = ' - '.join(tr(place, 'region_name') for place in sign), |
|
844 description = greatly_simplify_name(sign[-1]), |
840 night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), |
845 night = is_night_time(datetime.combine(today(), time()) + trip.schedule[-1].arrival_time), |
841 tr = tr, |
846 tr = tr, |
842 length = trip.length / 1000, |
847 length = trip.length / 1000, |
843 service = trip.route.service, |
848 service = trip.route.service, |
|
849 shape = ','.join(str.format('[{}, {}]', point[0], point[1]) for point in shapes[trip.shape]), |
|
850 stops = list( |
|
851 dict( |
|
852 ref = halt.stop.reference, |
|
853 name = halt.stop.name, |
|
854 position = str.format('[{}]', str(halt.stop.location)), |
|
855 ) for halt in trip.schedule |
|
856 ), |
844 ) |
857 ) |
845 |
858 |
846 @app.route('/route/<names>') |
859 @app.route('/route/<names>') |
847 def route_page(names): |
860 def route_page(names): |
848 from buses import routes |
861 from buses import routes |