revrt.RouteFinder#
- class RouteFinder(zarr_fp, cost_function, route_definitions, cache_size=250000000, log_level=None)#
Bases:
objectFind least-cost paths for one or more starting points in parallel.
- Parameters:
zarr_fp (path-like) – Path to zarr file containing cost layers.
cost_function (
str) – JSON string representation of the cost function. The following keys are allowed in the cost function: “cost_layers”, “friction_layers”, and “ignore_invalid_costs”. See the documentation of the cost function for details on each of these inputs.route_definitions (
listoftuple) – List of tuples containing path definitions. Each path definition tuple should be of the form (int, list, list). The int input is a route ID (non-negative) that you can use to link results to input route definitions. The first list contains the starting points and the second list contains the ending points. Each point is represented as a two-tuple of non-negative integers representing the indices in the array for the pixel indicating where routing should begin/end. A unique path will be returned for each of the starting points in each of the path definition tuples (assuming a valid path exists).cache_size (
int, default250_000_000) – Cache size to use for computation, in bytes. By default, 250,000,000 (250MB).log_level (
int, optional) – Logging level for Rust tracing emitted to stderr. Roughly follows the Python logging module levels, where 0 = TRACE, 10 = DEBUG, 20 = INFO, 30 = WARN, and 40 = ERROR. If None is given, no logging is set up. By default, None.
- Yields:
tuple– A tuple representing the route finding result for a single path definition. The first element is the route definition ID (as given in the input) and the second element is a list of path routing results. Each result is a tuple where the first element is a list of points that the route goes through and the second element is the final route cost. The result list will contain multiple tuples if the path definition had multiple starting points. An empty list will be returned if no paths were found from any of the starting points to any of the ending points. This generator will yield one tuple per path definition. Order is not guaranteed, so use the route ID input to match results to inputs.
Methods