misc/persolijn

osm-routing/src/main/java/osm/routing/RoutingStrategy.java in master
Repositories | Summary | Log | Files

RoutingStrategy.java (1662B) download


 1package osm.routing;
 2
 3import java.util.Collection;
 4import java.util.Map;
 5import java.util.stream.Collectors;
 6
 7import osm.routing.RoutingGraph.Route;
 8
 9/**
10 * Represents a routing strategy for finding the optimal route between two
11 * points on a graph.
12 *
13 * @param <N> The type of nodes in the graph.
14 * @param <E> The type of edges connecting the nodes.
15 */
16@FunctionalInterface
17public interface RoutingStrategy<N extends RoutingNode<N>, E extends RoutingEdge<N>> {
18
19    /**
20     * Finds the optimal route between the start node and a collection of target
21     * nodes using the default offset value of 0.
22     *
23     * @param router  The routing graph.
24     * @param targets The target nodes and their distances.
25     * @param start   The starting node.
26     * @return A Route object representing the optimal route from the start to a
27     *         target node.
28     */
29    default Route<N> route(RoutingGraph<N, E> router, Collection<N> targets, N start, long offset) {
30        Map<N, Long> targetMap = targets.stream().collect(Collectors.toMap(k -> k, v -> 0L));
31        return route(router, targetMap, start, offset);
32    }
33
34    /**
35     * Finds the optimal route between the start node and a collection of target
36     * nodes with a specified offset value.
37     *
38     * @param router  The routing graph.
39     * @param targets The target nodes and their distances.
40     * @param start   The starting node.
41     * @param offset  The offset value.
42     * @return A Route object representing the optimal route from the start to a
43     *         target node.
44     */
45    Route<N> route(RoutingGraph<N, E> router, Map<N, Long> targets, N start, long offset);
46}