def build(cls, data, start, end, center=None): log.info("Loading OpenPaths data...") if center is not None: points = [Point(i, float(d['lon']), float(d['lat']), d['t']) for i, d in enumerate(data) if d['t'] >= start and d['t'] <= end and science.geo_distance((float(d['lon']), float(d['lat'])), center) <= RADIUS] else: points = [Point(i, float(d['lon']), float(d['lat']), d['t']) for i, d in enumerate(data) if d['t'] >= start and d['t'] <= end] points.sort(key=lambda p: p.t) log.info("Generating graph...") start_clock = time.clock() paths = Path.find_paths(points) places = Place.find_places(paths, CLUSTER_RADIUS) cities = City.find_cities(places, CITY_RADIUS) almanac = Almanac(points, paths, places, cities) # almanac.label() print("(%ss)" % (time.clock() - start_clock)) return almanac