class RouteGridGenerator(GridGenerator): """ Generate a grid a cross the region area geography object and calculate the routes to the given train stop (to_point) for each grid point. Inputs: region - (required) the bounding region for the grid grid - (required) the empty new RouteGrid object to_point - (required) train stop id where all the grid point should search to max_distance - (default 1500) the max search radius around each search point in which to search for a nearby start train stop. num_routes - (default 2) will perform a route calculation for the closest num_routes to a given grid point. """ def __init__(self, to_point, *args, **kwargs): self.to_point = to_point tn = load_transitnetwork() self.t = RoutePlanner(tn, max_distance=kwargs.get('max_distance', 1500), num_routes=kwargs.get('num_routes', 2)) super(RouteGridGenerator, self).__init__(*args, **kwargs) @property def grid_point_class(self): return RouteGridPoint def work(self, new_point): from_point = new_point.point p = self.t.fastest_route_from_point(from_point, self.to_point) new_point.routes += p
def __init__(self, to_point, *args, **kwargs): self.to_point = to_point tn = load_transitnetwork() self.t = RoutePlanner(tn, max_distance=kwargs.get('max_distance', 1500), num_routes=kwargs.get('num_routes', 2)) super(RouteGridGenerator, self).__init__(*args, **kwargs)