Search in sources :

Example 1 with ElevatorHopEdge

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());
    }
}
Also used : ElevatorHopEdge(org.opentripplanner.routing.edgetype.ElevatorHopEdge) StationElement(org.opentripplanner.model.StationElement) ElevatorOnboardVertex(org.opentripplanner.routing.vertextype.ElevatorOnboardVertex) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) ElevatorBoardEdge(org.opentripplanner.routing.edgetype.ElevatorBoardEdge) ElevatorOffboardVertex(org.opentripplanner.routing.vertextype.ElevatorOffboardVertex) ElevatorAlightEdge(org.opentripplanner.routing.edgetype.ElevatorAlightEdge)

Aggregations

StationElement (org.opentripplanner.model.StationElement)1 ElevatorAlightEdge (org.opentripplanner.routing.edgetype.ElevatorAlightEdge)1 ElevatorBoardEdge (org.opentripplanner.routing.edgetype.ElevatorBoardEdge)1 ElevatorHopEdge (org.opentripplanner.routing.edgetype.ElevatorHopEdge)1 PathwayEdge (org.opentripplanner.routing.edgetype.PathwayEdge)1 StreetTraversalPermission (org.opentripplanner.routing.edgetype.StreetTraversalPermission)1 ElevatorOffboardVertex (org.opentripplanner.routing.vertextype.ElevatorOffboardVertex)1 ElevatorOnboardVertex (org.opentripplanner.routing.vertextype.ElevatorOnboardVertex)1