Search in sources :

Example 16 with GenericLocation

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);
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Test(org.junit.Test)

Example 17 with GenericLocation

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);
    }
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Leg(org.opentripplanner.api.model.Leg)

Example 18 with GenericLocation

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);
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with GenericLocation

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);
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Test(org.junit.Test)

Example 20 with GenericLocation

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]);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) GraphPath(org.opentripplanner.routing.spt.GraphPath) TripPlan(org.opentripplanner.api.model.TripPlan) GenericLocation(org.opentripplanner.common.model.GenericLocation) TraverseMode(org.opentripplanner.routing.core.TraverseMode) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) GraphPathFinder(org.opentripplanner.routing.impl.GraphPathFinder)

Aggregations

GenericLocation (org.opentripplanner.common.model.GenericLocation)28 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)20 Test (org.junit.Test)14 AStar (org.opentripplanner.routing.algorithm.AStar)9 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)7 DominanceFunction (org.opentripplanner.routing.spt.DominanceFunction)7 Graph (org.opentripplanner.routing.graph.Graph)5 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)5 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)4 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)4 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 TIntIntMap (gnu.trove.map.TIntIntMap)3 ArrayList (java.util.ArrayList)3 Agency (org.onebusaway.gtfs.model.Agency)3 Route (org.onebusaway.gtfs.model.Route)3 Stop (org.onebusaway.gtfs.model.Stop)3 StopTime (org.onebusaway.gtfs.model.StopTime)3 Trip (org.onebusaway.gtfs.model.Trip)3 StopPattern (org.opentripplanner.model.StopPattern)3