use of org.opentripplanner.routing.edgetype.ElevatorHopEdge in project OpenTripPlanner by opentripplanner.
the class AddTransitModelEntitiesToGraph method createElevatorEdgesAndAddThemToGraph.
/**
* Create elevator edges from pathways. As pathway based elevators are not vertices, but edges
* in the pathway model, we have to model each possible movement as an onboard-offboard pair,
* instead of having only one set of vertices per level and edges between them.
*/
private void createElevatorEdgesAndAddThemToGraph(Graph graph, Pathway pathway, Vertex fromVertex, Vertex toVertex) {
StationElement fromStation = fromVertex.getStationElement();
String fromVertexLevelName = fromStation == null ? fromVertex.getName() : fromStation.getLevelName();
Double fromVertexLevelIndex = fromStation == null ? null : fromStation.getLevelIndex();
StationElement toStation = toVertex.getStationElement();
String toVertexLevelName = toStation == null ? toVertex.getName() : toStation.getLevelName();
Double toVertexLevelIndex = toStation == null ? null : toStation.getLevelIndex();
double levels = 1;
if (fromVertexLevelIndex != null && toVertexLevelIndex != null && !fromVertexLevelIndex.equals(toVertexLevelIndex)) {
levels = Math.abs(fromVertexLevelIndex - toVertexLevelIndex);
}
ElevatorOffboardVertex fromOffboardVertex = new ElevatorOffboardVertex(graph, fromVertex.getLabel() + "_" + pathway.getId() + "_offboard", fromVertex.getX(), fromVertex.getY(), fromVertexLevelName);
ElevatorOffboardVertex toOffboardVertex = new ElevatorOffboardVertex(graph, toVertex.getLabel() + "_" + pathway.getId() + "_offboard", toVertex.getX(), toVertex.getY(), toVertexLevelName);
new PathwayEdge(fromVertex, fromOffboardVertex, fromVertex.getName());
new PathwayEdge(toOffboardVertex, toVertex, toVertex.getName());
ElevatorOnboardVertex fromOnboardVertex = new ElevatorOnboardVertex(graph, fromVertex.getLabel() + "_" + pathway.getId() + "_onboard", fromVertex.getX(), fromVertex.getY(), fromVertexLevelName);
ElevatorOnboardVertex toOnboardVertex = new ElevatorOnboardVertex(graph, toVertex.getLabel() + "_" + pathway.getId() + "_onboard", toVertex.getX(), toVertex.getY(), toVertexLevelName);
new ElevatorBoardEdge(fromOffboardVertex, fromOnboardVertex);
new ElevatorAlightEdge(toOnboardVertex, toOffboardVertex, toVertexLevelName);
StreetTraversalPermission permission = StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE;
new ElevatorHopEdge(fromOnboardVertex, toOnboardVertex, permission, levels, pathway.getTraversalTime());
if (pathway.isBidirectional()) {
new PathwayEdge(fromOffboardVertex, fromVertex, fromVertex.getName());
new PathwayEdge(toVertex, toOffboardVertex, toVertex.getName());
new ElevatorBoardEdge(toOffboardVertex, toOnboardVertex);
new ElevatorAlightEdge(fromOnboardVertex, fromOffboardVertex, fromVertexLevelName);
new ElevatorHopEdge(toOnboardVertex, fromOnboardVertex, permission, levels, pathway.getTraversalTime());
}
}
Aggregations