示例#1
0
文件: main.py 项目: jbochi/to-a-pe
 def get(self, stop_id):
     stop_id = unicode(unquote(stop_id))
     stop = Stop.get_by_key_name(stop_id)
     if stop:
         trips = Trip.all().filter('stops =', stop_id).fetch(1000)
         prefetch_refprop(trips, Trip.route)
         template_values = {'stop': stop, 'trips': trips}
         path = os.path.join(os.path.dirname(__file__), 'templates/stop_details.html')
         self.response.out.write(template.render(path, template_values))
     else:
         self.error(404)
         return self.response.out.write('Erro - Pagina nao encontrada')
示例#2
0
文件: main.py 项目: jbochi/to-a-pe
    def get(self, trip_id):
        "Returns encoded polyline path from trip_id"

        trip_id = unquote(trip_id)
        trip = Trip.get_by_key_name('trip_' + trip_id)
        stops = Stop.get_by_key_name(trip.stops)
        stops = filter(lambda s: s is not None, stops)
        stops = filter(lambda s: s.location is not None, stops)
        def serializable_stop(stop):
            return (stop.id,
                    stop.location.lat,
                    stop.location.lon,
                    stop.name)

        stop_locations = [serializable_stop(stop) for stop in stops]

        if trip:
            data = {'points': trip.shape_encoded_polyline,
                    'levels': trip.shape_encoded_levels,
                    'color': trip.route.color,
                    'stops': stop_locations}
            self.response.out.write(simplejson.dumps(data))