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);
}
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;
}
}
}
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);
}
}
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);
}
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);
}
Aggregations