Exemplo n.º 1
0
    def get(self, user_id):
        log.info("Home.get")

        if not len(user_id):
            return self.text("/user_id")
        user = self.db.get("SELECT * FROM users WHERE id=%s", user_id)
        if user is None:
            return self.text("User not found")

        if not self.get_argument("partial", None):
            return self.render("page.html", user=user)

        log.info("--> generating partial")

        almanac = Almanac.build(self.db, user_id)  # should be pulled from a cache

        if not almanac.current_point.moving:
            total_weight = sum(
                [weight for place, weight in almanac.current_point.place.connections.items()]
            )  # this goes in almanac somewhere
            weights = []
            for place, weight in almanac.current_point.place.connections.items():
                weights.append("%s (%f)" % (place.id, (weight / total_weight)))

        place = almanac.current_point.place if almanac.current_point.place is not None else None

        return self.render("content.html", place=place, weights=weights, user=user)
Exemplo n.º 2
0
# center = -73.959486, 40.685193  # brooklyn
# center = -72.723889, 43.173611  # vermont       # no points!
# center = -71.009755, 41.569593  # new bedford
# center = -93.219539, 44.933524  # minneapolis
# center = -77.059081, 38.948266  # dc
# center = -104.890219, 39.698841 # denver
# center = -83.961412, 35.935478  # knoxville
# center = -73.490419, 41.908486  # berkshires
# center = -74.035318, 41.498944  # hudson valley
# center = 127.032687, 37.635063  # seoul
# center = -71.221729, 42.306461  # boston
# center = -68.700278, 45.658056  # millinocket
# center = -118.334105, 34.045948 # LA

# almanac = Almanac.build(data, time.mktime(util.parse_date('2011-05-25').timetuple()), time.mktime(util.parse_date('2012-05-27').timetuple()), center)
almanac = Almanac.build(data, time.mktime(util.parse_date('2011-08-01').timetuple()), time.mktime(util.parse_date('2012-05-27').timetuple()), center)
# almanac = Almanac.build(data, time.mktime(util.parse_date('2012-01-01').timetuple()), time.mktime(util.parse_date('2012-05-27').timetuple()), center)

print
print "POINTS"
print np.array(almanac.points)
print     

print "PATHS"
for path in almanac.paths:
    print path        
print    

print "PLACES"        
for place in almanac.places:
    print place