Search in sources :

Example 11 with GenericLocation

use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method testTransitWithoutIntermediatePlaces.

@Test
public void testTransitWithoutIntermediatePlaces() {
    GenericLocation fromLocation = new GenericLocation(39.9308, -83.0118);
    GenericLocation toLocation = new GenericLocation(39.9998, -83.0198);
    GenericLocation[] intermediateLocations = {};
    handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.TRANSIT, TraverseMode.WALK), false);
    handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.TRANSIT, TraverseMode.WALK), true);
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Test(org.junit.Test)

Example 12 with GenericLocation

use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method handleRequest.

private void handleRequest(GenericLocation from, GenericLocation to, GenericLocation[] via, TraverseModeSet 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> paths = graphPathFinder.graphPathFinderEntryPoint(request);
    assertNotNull(paths);
    assertFalse(paths.isEmpty());
    List<Itinerary> itineraries = GraphPathToItineraryMapper.mapItineraries(paths, request);
    TripPlan plan = TripPlanMapper.mapTripPlan(request, itineraries);
    assertLocationIsVeryCloseToPlace(from, plan.from);
    assertLocationIsVeryCloseToPlace(to, plan.to);
    assertTrue(1 <= plan.itineraries.size());
    for (Itinerary itinerary : plan.itineraries) {
        validateIntermediatePlacesVisited(itinerary, via);
        assertTrue(via.length < itinerary.legs.size());
        validateLegsTemporally(request, itinerary);
        validateLegsSpatially(plan, itinerary);
        if (modes.contains(TraverseMode.TRANSIT)) {
            assert itinerary.transitTimeSeconds > 0;
        }
    }
}
Also used : GraphPath(org.opentripplanner.routing.spt.GraphPath) Itinerary(org.opentripplanner.model.plan.Itinerary) TripPlan(org.opentripplanner.model.plan.TripPlan) GenericLocation(org.opentripplanner.model.GenericLocation) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest)

Example 13 with GenericLocation

use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method validateIntermediatePlacesVisited.

// Check that every via location is visited in the right order
private void validateIntermediatePlacesVisited(Itinerary itinerary, GenericLocation[] via) {
    int legIndex = 0;
    for (GenericLocation location : via) {
        Leg leg;
        do {
            assertTrue("Intermediate location was not an endpoint of any leg", legIndex < itinerary.legs.size());
            leg = itinerary.legs.get(legIndex);
            legIndex++;
        } while (Math.abs(leg.to.coordinate.latitude() - location.lat) > DELTA || Math.abs(leg.to.coordinate.longitude() - location.lng) > DELTA);
    }
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) Leg(org.opentripplanner.model.plan.Leg)

Example 14 with GenericLocation

use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method testWithoutIntermediatePlaces.

@Test
public void testWithoutIntermediatePlaces() {
    GenericLocation fromLocation = new GenericLocation(39.93080, -82.98522);
    GenericLocation toLocation = new GenericLocation(39.96383, -82.96291);
    GenericLocation[] intermediateLocations = {};
    handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.WALK), false);
    handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.WALK), true);
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Test(org.junit.Test)

Example 15 with GenericLocation

use of org.opentripplanner.model.GenericLocation in project OpenTripPlanner by opentripplanner.

the class TestIntermediatePlaces method testTransitOneIntermediatePlace.

@Test
public void testTransitOneIntermediatePlace() {
    GenericLocation fromLocation = new GenericLocation(39.9108, -83.0118);
    GenericLocation toLocation = new GenericLocation(39.9698, -83.0198);
    GenericLocation[] intermediateLocations = { new GenericLocation(39.9948, -83.0148) };
    handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.TRANSIT, TraverseMode.WALK), false);
    handleRequest(fromLocation, toLocation, intermediateLocations, new TraverseModeSet(TraverseMode.TRANSIT, TraverseMode.WALK), true);
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) Test(org.junit.Test)

Aggregations

GenericLocation (org.opentripplanner.model.GenericLocation)19 Test (org.junit.Test)14 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)8 RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)4 FeedScopedId (org.opentripplanner.model.FeedScopedId)3 Ignore (org.junit.Ignore)2 Coordinate (org.locationtech.jts.geom.Coordinate)2 GraphPath (org.opentripplanner.routing.spt.GraphPath)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Itinerary (org.opentripplanner.model.plan.Itinerary)1 Leg (org.opentripplanner.model.plan.Leg)1 TripPlan (org.opentripplanner.model.plan.TripPlan)1 AStar (org.opentripplanner.routing.algorithm.astar.AStar)1 TrivialRemainingWeightHeuristic (org.opentripplanner.routing.algorithm.astar.strategies.TrivialRemainingWeightHeuristic)1 State (org.opentripplanner.routing.core.State)1 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)1 Edge (org.opentripplanner.routing.graph.Edge)1 Vertex (org.opentripplanner.routing.graph.Vertex)1