Search in sources :

Example 1 with TurnRestriction

use of org.opentripplanner.common.TurnRestriction in project OpenTripPlanner by opentripplanner.

the class PlainStreetEdgeTest method testTurnRestriction.

@Test
public void testTurnRestriction() {
    StreetEdge e0 = edge(v0, v1, 50.0, StreetTraversalPermission.ALL);
    StreetEdge e1 = edge(v1, v2, 18.4, StreetTraversalPermission.ALL);
    State state = new State(v2, 0, proto.clone());
    state.getOptions().setArriveBy(true);
    _graph.addTurnRestriction(e1, new TurnRestriction(e1, e0, null, TraverseModeSet.allModes()));
    assertNotNull(e0.traverse(e1.traverse(state)));
}
Also used : State(org.opentripplanner.routing.core.State) TurnRestriction(org.opentripplanner.common.TurnRestriction) Test(org.junit.Test)

Example 2 with TurnRestriction

use of org.opentripplanner.common.TurnRestriction in project OpenTripPlanner by opentripplanner.

the class TurnRestrictionTest method DisallowTurn.

private void DisallowTurn(StreetEdge from, StreetEdge to) {
    TurnRestrictionType rType = TurnRestrictionType.NO_TURN;
    TraverseModeSet restrictedModes = new TraverseModeSet(TraverseMode.CAR);
    TurnRestriction restrict = new TurnRestriction(from, to, rType, restrictedModes);
    _graph.addTurnRestriction(from, restrict);
}
Also used : TurnRestrictionType(org.opentripplanner.common.TurnRestrictionType) TurnRestriction(org.opentripplanner.common.TurnRestriction) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet)

Example 3 with TurnRestriction

use of org.opentripplanner.common.TurnRestriction in project OpenTripPlanner by opentripplanner.

the class TurnCostTest method DisallowTurn.

private void DisallowTurn(StreetEdge from, StreetEdge to) {
    TurnRestrictionType rType = TurnRestrictionType.NO_TURN;
    TraverseModeSet restrictedModes = new TraverseModeSet(TraverseMode.CAR);
    TurnRestriction restrict = new TurnRestriction(from, to, rType, restrictedModes);
    _graph.addTurnRestriction(from, restrict);
}
Also used : TurnRestrictionType(org.opentripplanner.common.TurnRestrictionType) TurnRestriction(org.opentripplanner.common.TurnRestriction) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet)

Example 4 with TurnRestriction

use of org.opentripplanner.common.TurnRestriction in project OpenTripPlanner by opentripplanner.

the class Graph method removeEdge.

/**
 * Removes an edge from the graph. This method is not thread-safe.
 * @param e The edge to be removed
 */
public void removeEdge(Edge e) {
    if (e != null) {
        synchronized (alertPatches) {
            // This synchronization is somewhat silly because this
            // method isn't thread-safe anyway, but it is consistent
            alertPatches.remove(e);
        }
        turnRestrictions.remove(e);
        streetNotesService.removeStaticNotes(e);
        edgeById.remove(e.getId());
        if (e instanceof EdgeWithCleanup)
            ((EdgeWithCleanup) e).detach();
        if (e.fromv != null) {
            e.fromv.removeOutgoing(e);
            for (Edge otherEdge : e.fromv.getIncoming()) {
                for (TurnRestriction turnRestriction : getTurnRestrictions(otherEdge)) {
                    if (turnRestriction.to == e) {
                        removeTurnRestriction(otherEdge, turnRestriction);
                    }
                }
            }
            e.fromv = null;
        }
        if (e.tov != null) {
            e.tov.removeIncoming(e);
            e.tov = null;
        }
    }
}
Also used : EdgeWithCleanup(org.opentripplanner.routing.edgetype.EdgeWithCleanup) TurnRestriction(org.opentripplanner.common.TurnRestriction) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge)

Aggregations

TurnRestriction (org.opentripplanner.common.TurnRestriction)4 TurnRestrictionType (org.opentripplanner.common.TurnRestrictionType)2 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)2 Test (org.junit.Test)1 State (org.opentripplanner.routing.core.State)1 EdgeWithCleanup (org.opentripplanner.routing.edgetype.EdgeWithCleanup)1 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)1