forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoutingService.java
184 lines (156 loc) · 5.87 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package org.opentripplanner.routing;
import java.time.ZoneId;
import java.util.Collection;
import java.util.List;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.graph_builder.module.osm.WayPropertySetSource.DrivingDirection;
import org.opentripplanner.routing.algorithm.RoutingWorker;
import org.opentripplanner.routing.api.request.RoutingRequest;
import org.opentripplanner.routing.api.response.RoutingResponse;
import org.opentripplanner.routing.core.intersection_model.IntersectionTraversalCostModel;
import org.opentripplanner.routing.edgetype.StreetEdge;
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graph.Vertex;
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.impl.StreetVertexIndex;
import org.opentripplanner.routing.services.RealtimeVehiclePositionService;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalStationService;
import org.opentripplanner.standalone.api.OtpServerContext;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.service.TransitService;
import org.opentripplanner.util.WorldEnvelope;
/**
* Entry point for requests towards the routing API.
*/
public class RoutingService {
private final OtpServerContext serverContext;
private final Graph graph;
private final ZoneId timeZone;
private final GraphFinder graphFinder;
public RoutingService(OtpServerContext serverContext) {
this.serverContext = serverContext;
this.graph = serverContext.graph();
this.timeZone = serverContext.transitService().getTimeZone();
this.graphFinder = GraphFinder.getInstance(graph);
}
public RoutingResponse route(RoutingRequest request) {
RoutingWorker worker = new RoutingWorker(serverContext, request, timeZone);
return worker.route();
}
/** {@link Graph#getVertex(String)} */
public Vertex getVertex(String label) {
return this.graph.getVertex(label);
}
/** {@link Graph#getVertices()} */
public Collection<Vertex> getVertices() {
return this.graph.getVertices();
}
/** {@link Graph#getVerticesOfType(Class)} */
public <T extends Vertex> List<T> getVerticesOfType(Class<T> cls) {
return this.graph.getVerticesOfType(cls);
}
/** {@link Graph#getEdges()} */
public Collection<Edge> getEdges() {
return this.graph.getEdges();
}
/** {@link Graph#getEdgesOfType(Class)} */
public <T extends Edge> List<T> getEdgesOfType(Class<T> cls) {
return this.graph.getEdgesOfType(cls);
}
/** {@link Graph#getStreetEdges()} */
public Collection<StreetEdge> getStreetEdges() {
return this.graph.getStreetEdges();
}
/** {@link Graph#containsVertex(Vertex)} */
public boolean containsVertex(Vertex v) {
return this.graph.containsVertex(v);
}
/** {@link Graph#getExtent()} */
public Envelope getExtent() {
return this.graph.getExtent();
}
/** {@link Graph#countVertices()} */
public int countVertices() {
return this.graph.countVertices();
}
/** {@link Graph#countEdges()} */
public int countEdges() {
return this.graph.countEdges();
}
/** {@link Graph#getStreetIndex()} */
public StreetVertexIndex getStreetIndex() {
return this.graph.getStreetIndex();
}
/** {@link Graph#getConvexHull()} */
public Geometry getConvexHull() {
return this.graph.getConvexHull();
}
/** {@link Graph#getEnvelope()} */
public WorldEnvelope getEnvelope() {
return this.graph.getEnvelope();
}
/** {@link Graph#getDistanceBetweenElevationSamples()} */
public double getDistanceBetweenElevationSamples() {
return this.graph.getDistanceBetweenElevationSamples();
}
public RealtimeVehiclePositionService getVehiclePositionService() {
return this.graph.getVehiclePositionService();
}
/** {@link Graph#getVehicleRentalStationService()} */
public VehicleRentalStationService getVehicleRentalStationService() {
return this.graph.getVehicleRentalStationService();
}
/** {@link Graph#getVehicleParkingService()} */
public VehicleParkingService getVehicleParkingService() {
return this.graph.getVehicleParkingService();
}
/** {@link Graph#getDrivingDirection()} */
public DrivingDirection getDrivingDirection() {
return this.graph.getDrivingDirection();
}
/** {@link Graph#getIntersectionTraversalModel()} */
public IntersectionTraversalCostModel getIntersectionTraversalModel() {
return this.graph.getIntersectionTraversalModel();
}
/** {@link GraphFinder#findClosestStops(double, double, double)} */
public List<NearbyStop> findClosestStops(double lat, double lon, double radiusMeters) {
return this.graphFinder.findClosestStops(lat, lon, 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
);
}
}