Search in sources :

Example 16 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class TestHopFactory method testDwell.

public void testDwell() throws Exception {
    Vertex stop_a = graph.getVertex(feedId + ":A_depart");
    Vertex stop_c = graph.getVertex(feedId + ":C_arrive");
    RoutingRequest options = new RoutingRequest();
    options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 8, 0, 0);
    options.setRoutingContext(graph, stop_a, stop_c);
    ShortestPathTree spt = aStar.getShortestPathTree(options);
    GraphPath path = spt.getPath(stop_c, false);
    assertNotNull(path);
    assertEquals(6, path.states.size());
    long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 8, 30, 0);
    assertEquals(endTime, path.getEndTime());
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) GraphPath(org.opentripplanner.routing.spt.GraphPath) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest)

Example 17 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class RoutingRequestTest method testRequest.

@Test
public void testRequest() {
    RoutingRequest request = new RoutingRequest();
    request.addMode(CAR);
    assertTrue(request.streetSubRequestModes.getCar());
    request.removeMode(CAR);
    assertFalse(request.streetSubRequestModes.getCar());
    request.setStreetSubRequestModes(new TraverseModeSet(TraverseMode.BICYCLE, TraverseMode.WALK));
    assertFalse(request.streetSubRequestModes.getCar());
    assertTrue(request.streetSubRequestModes.getBicycle());
    assertTrue(request.streetSubRequestModes.getWalk());
}
Also used : RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Test(org.junit.Test)

Example 18 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class RoutingRequestTest method testIntermediatePlaces.

@Test
public void testIntermediatePlaces() {
    RoutingRequest req = new RoutingRequest();
    assertFalse(req.hasIntermediatePlaces());
    req.clearIntermediatePlaces();
    assertFalse(req.hasIntermediatePlaces());
    req.addIntermediatePlace(randomLocation());
    assertTrue(req.hasIntermediatePlaces());
    req.clearIntermediatePlaces();
    assertFalse(req.hasIntermediatePlaces());
    req.addIntermediatePlace(randomLocation());
    req.addIntermediatePlace(randomLocation());
    assertTrue(req.hasIntermediatePlaces());
}
Also used : RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Test(org.junit.Test)

Example 19 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class StateEditorTest method testIncrementTimeInSeconds.

@Test
public final void testIncrementTimeInSeconds() {
    RoutingRequest routingRequest = new RoutingRequest();
    StateEditor stateEditor = new StateEditor(routingRequest, null);
    stateEditor.setTimeSeconds(0);
    stateEditor.incrementTimeInSeconds(999999999);
    assertEquals(999999999, stateEditor.child.getTimeSeconds());
}
Also used : RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Test(org.junit.Test)

Example 20 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class StateEditorTest method testSetNonTransitOptionsFromState.

/**
 * Test update of non transit options.
 */
@Test
public final void testSetNonTransitOptionsFromState() {
    RoutingRequest request = new RoutingRequest();
    request.setMode(TraverseMode.CAR);
    request.parkAndRide = true;
    Graph graph = new Graph();
    graph.index = new GraphIndex(graph);
    graph.streetIndex = new StreetVertexIndex(graph);
    request.rctx = new RoutingContext(request, graph);
    State state = new State(request);
    state.stateData.carParked = true;
    state.stateData.bikeParked = true;
    state.stateData.usingRentedBike = false;
    state.stateData.nonTransitMode = TraverseMode.WALK;
    StateEditor se = new StateEditor(request, null);
    se.setNonTransitOptionsFromState(state);
    State updatedState = se.makeState();
    assertEquals(TraverseMode.WALK, updatedState.getNonTransitMode());
    assertEquals(true, updatedState.isCarParked());
    assertEquals(true, updatedState.isBikeParked());
    assertEquals(false, updatedState.isBikeRenting());
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) GraphIndex(org.opentripplanner.routing.graph.GraphIndex) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) StreetVertexIndex(org.opentripplanner.routing.impl.StreetVertexIndex) Test(org.junit.Test)

Aggregations

RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)102 GraphPath (org.opentripplanner.routing.spt.GraphPath)50 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)42 Test (org.junit.Test)37 State (org.opentripplanner.routing.core.State)33 Vertex (org.opentripplanner.routing.graph.Vertex)31 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)18 Edge (org.opentripplanner.routing.graph.Edge)17 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)17 AStar (org.opentripplanner.routing.algorithm.astar.AStar)16 Graph (org.opentripplanner.routing.graph.Graph)15 StateEditor (org.opentripplanner.routing.core.StateEditor)13 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)13 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)11 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)10 HashSet (java.util.HashSet)9 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)9 TraverseMode (org.opentripplanner.routing.core.TraverseMode)7 ArrayList (java.util.ArrayList)6 Coordinate (org.locationtech.jts.geom.Coordinate)6