forked from entur/OpenTripPlanner-LegacyHSLFork
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRoutingService.java
110 lines (97 loc) · 3.82 KB
/
RoutingService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package org.opentripplanner.routing;
import java.time.ZoneId;
import java.util.List;
import org.locationtech.jts.geom.Coordinate;
import org.opentripplanner.routing.algorithm.RoutingWorker;
import org.opentripplanner.routing.algorithm.via.ViaRoutingWorker;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.api.request.RouteViaRequest;
import org.opentripplanner.routing.api.response.RoutingResponse;
import org.opentripplanner.routing.api.response.ViaRoutingResponse;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graphfinder.GraphFinder;
import org.opentripplanner.routing.graphfinder.NearbyStop;
import org.opentripplanner.routing.graphfinder.PlaceAtDistance;
import org.opentripplanner.routing.graphfinder.PlaceType;
import org.opentripplanner.routing.services.RealtimeVehiclePositionService;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalService;
import org.opentripplanner.standalone.api.OtpServerRequestContext;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.service.TransitService;
// TODO VIA: 2022-08-29 javadocs
/**
* Entry point for requests towards the routing API.
*/
public class RoutingService implements org.opentripplanner.routing.api.request.RoutingService {
private final OtpServerRequestContext serverContext;
private final Graph graph;
private final ZoneId timeZone;
private final GraphFinder graphFinder;
public RoutingService(OtpServerRequestContext serverContext) {
this.serverContext = serverContext;
this.graph = serverContext.graph();
this.timeZone = serverContext.transitService().getTimeZone();
this.graphFinder = serverContext.graphFinder();
}
@Override
public RoutingResponse route(RouteRequest request) {
RoutingWorker worker = new RoutingWorker(serverContext, request, timeZone);
return worker.route();
}
@Override
public ViaRoutingResponse route(RouteViaRequest request) {
var viaRoutingWorker = new ViaRoutingWorker(
request,
req ->
new RoutingWorker(serverContext, req, serverContext.transitService().getTimeZone()).route()
);
return viaRoutingWorker.route();
}
public RealtimeVehiclePositionService getVehiclePositionService() {
return this.graph.getVehiclePositionService();
}
/** {@link Graph#getVehicleRentalService()} */
public VehicleRentalService getVehicleRentalService() {
return this.graph.getVehicleRentalService();
}
/** {@link Graph#getVehicleParkingService()} */
public VehicleParkingService getVehicleParkingService() {
return this.graph.getVehicleParkingService();
}
/** {@link GraphFinder#findClosestStops(Coordinate, double)} */
public List<NearbyStop> findClosestStops(Coordinate coordinate, double radiusMeters) {
return this.graphFinder.findClosestStops(coordinate, radiusMeters);
}
/**
* {@link GraphFinder#findClosestPlaces(double, double, double, int, List, List, List, List, List, TransitService)}
*/
public List<PlaceAtDistance> findClosestPlaces(
double lat,
double lon,
double radiusMeters,
int maxResults,
List<TransitMode> filterByModes,
List<PlaceType> filterByPlaceTypes,
List<FeedScopedId> filterByStops,
List<FeedScopedId> filterByRoutes,
List<String> filterByBikeRentalStations,
List<String> filterByBikeParks,
List<String> filterByCarParks,
TransitService transitService
) {
return this.graphFinder.findClosestPlaces(
lat,
lon,
radiusMeters,
maxResults,
filterByModes,
filterByPlaceTypes,
filterByStops,
filterByRoutes,
filterByBikeRentalStations,
transitService
);
}
}