Search in sources :

Example 1 with Itinerary

use of org.opentripplanner.api.model.Itinerary in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method handleRequest.

private void handleRequest(GenericLocation from, GenericLocation to, GenericLocation[] via, String modes, boolean arriveBy) {
    RoutingRequest request = new RoutingRequest(modes);
    request.setDateTime("2016-04-20", "13:00", timeZone);
    request.setArriveBy(arriveBy);
    request.from = from;
    request.to = to;
    for (GenericLocation intermediateLocation : via) {
        request.addIntermediatePlace(intermediateLocation);
    }
    List<GraphPath> pathList = graphPathFinder.graphPathFinderEntryPoint(request);
    assertNotNull(pathList);
    assertFalse(pathList.isEmpty());
    TripPlan plan = GraphPathToTripPlanConverter.generatePlan(pathList, request);
    assertLocationIsVeryCloseToPlace(from, plan.from);
    assertLocationIsVeryCloseToPlace(to, plan.to);
    assertTrue(1 <= plan.itinerary.size());
    for (Itinerary itinerary : plan.itinerary) {
        validateIntermediatePlacesVisited(itinerary, via);
        assertTrue(via.length < itinerary.legs.size());
        validateLegsTemporally(request, itinerary);
        validateLegsSpatially(plan, itinerary);
        if (modes.contains("TRANSIT")) {
            assert itinerary.transitTime > 0;
        }
    }
}
Also used : GraphPath(org.opentripplanner.routing.spt.GraphPath) TripPlan(org.opentripplanner.api.model.TripPlan) Itinerary(org.opentripplanner.api.model.Itinerary) GenericLocation(org.opentripplanner.common.model.GenericLocation) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest)

Example 2 with Itinerary

use of org.opentripplanner.api.model.Itinerary in project OpenTripPlanner by opentripplanner.

the class GraphPathToTripPlanConverterTest method testEndWithLegSwitch.

/**
 * Test that a LEG_SWITCH mode at the end of a graph path does not generate an extra leg.
 * Also test that such a LEG_SWITCH mode does not show up as part of the itinerary.
 */
@Test
public void testEndWithLegSwitch() {
    // Reuse testGenerateItinerary()'s graph path, but shorten it
    GraphPath graphPath = new GraphPath(buildPaths()[0].states.get(3), false);
    Itinerary itinerary = GraphPathToTripPlanConverter.generateItinerary(graphPath, false, false, locale);
    assertEquals(1, itinerary.legs.size());
    assertEquals("WALK", itinerary.legs.get(0).mode);
}
Also used : GraphPath(org.opentripplanner.routing.spt.GraphPath) Itinerary(org.opentripplanner.api.model.Itinerary) Test(org.junit.Test)

Aggregations

Itinerary (org.opentripplanner.api.model.Itinerary)2 GraphPath (org.opentripplanner.routing.spt.GraphPath)2 Test (org.junit.Test)1 TripPlan (org.opentripplanner.api.model.TripPlan)1 GenericLocation (org.opentripplanner.common.model.GenericLocation)1 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)1