use of org.opentripplanner.common.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, "TRANSIT,WALK", false);
handleRequest(fromLocation, toLocation, intermediateLocations, "TRANSIT,WALK", true);
}
use of org.opentripplanner.common.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.lat - location.lat) > DELTA || Math.abs(leg.to.lon - location.lng) > DELTA);
}
}
use of org.opentripplanner.common.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class TestIntermediatePlaces method testOneIntermediatePlace.
@Test
@Ignore
public void testOneIntermediatePlace() {
GenericLocation fromLocation = new GenericLocation(39.93080, -82.98522);
GenericLocation toLocation = new GenericLocation(39.96383, -82.96291);
GenericLocation[] intermediateLocations = { new GenericLocation(39.92099, -82.95570) };
handleRequest(fromLocation, toLocation, intermediateLocations, "WALK", false);
handleRequest(fromLocation, toLocation, intermediateLocations, "WALK", true);
}
use of org.opentripplanner.common.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, "TRANSIT,WALK", false);
handleRequest(fromLocation, toLocation, intermediateLocations, "TRANSIT,WALK", true);
}
use of org.opentripplanner.common.model.GenericLocation in project OpenTripPlanner by opentripplanner.
the class GtfsTest method plan.
public Leg[] plan(long dateTime, String fromVertex, String toVertex, String onTripId, boolean wheelchairAccessible, boolean preferLeastTransfers, TraverseMode preferredMode, String excludedRoute, String excludedStop, int legCount) {
final TraverseMode mode = preferredMode != null ? preferredMode : TraverseMode.TRANSIT;
RoutingRequest routingRequest = new RoutingRequest();
routingRequest.setNumItineraries(1);
routingRequest.setArriveBy(dateTime < 0);
routingRequest.dateTime = Math.abs(dateTime);
if (fromVertex != null && !fromVertex.isEmpty()) {
routingRequest.from = (new GenericLocation(null, feedId.getId() + ":" + fromVertex));
}
if (toVertex != null && !toVertex.isEmpty()) {
routingRequest.to = new GenericLocation(null, feedId.getId() + ":" + toVertex);
}
if (onTripId != null && !onTripId.isEmpty()) {
routingRequest.startingTransitTripId = (new AgencyAndId(feedId.getId(), onTripId));
}
routingRequest.setRoutingContext(graph);
routingRequest.setWheelchairAccessible(wheelchairAccessible);
routingRequest.transferPenalty = (preferLeastTransfers ? 300 : 0);
routingRequest.setModes(new TraverseModeSet(TraverseMode.WALK, mode));
// TODO route matcher still using underscores because it's quite nonstandard and should be eliminated from the 1.0 release rather than reworked
if (excludedRoute != null && !excludedRoute.isEmpty()) {
routingRequest.setBannedRoutes(feedId.getId() + "__" + excludedRoute);
}
if (excludedStop != null && !excludedStop.isEmpty()) {
routingRequest.setBannedStopsHard(feedId.getId() + ":" + excludedStop);
}
routingRequest.setOtherThanPreferredRoutesPenalty(0);
// The walk board cost is set low because it interferes with test 2c1.
// As long as boarding has a very low cost, waiting should not be "better" than riding
// since this makes interlining _worse_ than alighting and re-boarding the same line.
// TODO rethink whether it makes sense to weight waiting to board _less_ than 1.
routingRequest.setWaitReluctance(1);
routingRequest.setWalkBoardCost(30);
List<GraphPath> paths = new GraphPathFinder(router).getPaths(routingRequest);
TripPlan tripPlan = GraphPathToTripPlanConverter.generatePlan(paths, routingRequest);
// Stored in instance field for use in individual tests
itinerary = tripPlan.itinerary.get(0);
assertEquals(legCount, itinerary.legs.size());
return itinerary.legs.toArray(new Leg[legCount]);
}
Aggregations