Search in sources :

Example 11 with GenericLocation

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

the class TestIntermediatePlaces method testThreeBusStopPlaces.

@Test
public void testThreeBusStopPlaces() {
    GenericLocation fromLocation = new GenericLocation(39.9058, -83.1341);
    GenericLocation toLocation = new GenericLocation(39.9058, -82.8841);
    GenericLocation[] intermediateLocations = { new GenericLocation(39.9058, -82.9841) };
    handleRequest(fromLocation, toLocation, intermediateLocations, "TRANSIT", false);
    handleRequest(fromLocation, toLocation, intermediateLocations, "TRANSIT", true);
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Test(org.junit.Test)

Example 12 with GenericLocation

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

the class TestHalfEdges method testStreetLocationFinder.

@Test
public void testStreetLocationFinder() {
    StreetVertexIndexServiceImpl finder = new StreetVertexIndexServiceImpl(graph);
    // test that the local stop finder finds stops
    GenericLocation loc = new GenericLocation(40.01, -74.005000001);
    assertTrue(finder.getNearbyTransitStops(loc.getCoordinate(), 100).size() > 0);
    // test that the closest vertex finder returns the closest vertex
    TemporaryStreetLocation some = (TemporaryStreetLocation) finder.getVertexForLocation(new GenericLocation(40.00, -74.00), null, true);
    assertNotNull(some);
    some.dispose();
    // test that the closest vertex finder correctly splits streets
    TemporaryStreetLocation start = (TemporaryStreetLocation) finder.getVertexForLocation(new GenericLocation(40.004, -74.01), null, false);
    assertNotNull(start);
    assertTrue("wheelchair accessibility is correctly set (splitting)", start.isWheelchairAccessible());
    Collection<Edge> edges = start.getOutgoing();
    start.dispose();
    assertEquals(2, edges.size());
    RoutingRequest biking = new RoutingRequest(new TraverseModeSet(TraverseMode.BICYCLE));
    TemporaryStreetLocation end = (TemporaryStreetLocation) finder.getVertexForLocation(new GenericLocation(40.008, -74.0), biking, true);
    assertNotNull(end);
    edges = end.getIncoming();
    end.dispose();
    assertEquals(2, edges.size());
    // test that it is possible to travel between two splits on the same street
    RoutingRequest walking = new RoutingRequest(TraverseMode.WALK);
    start = (TemporaryStreetLocation) finder.getVertexForLocation(new GenericLocation(40.004, -74.0), walking, false);
    exception.expect(TrivialPathException.class);
    end = (TemporaryStreetLocation) finder.getVertexForLocation(new GenericLocation(40.008, -74.0), walking, true);
/*assertNotNull(end);
        // The visibility for temp edges for start and end is set in the setRoutingContext call
        walking.setRoutingContext(graph, start, end);
        ShortestPathTree spt = aStar.getShortestPathTree(walking);
        GraphPath path = spt.getPath(end, false);
        for (State s : path.states) {
            assertFalse(s.getBackEdge() == top);
        }
        walking.cleanup();*/
}
Also used : TemporaryStreetLocation(org.opentripplanner.routing.location.TemporaryStreetLocation) GenericLocation(org.opentripplanner.common.model.GenericLocation) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) TraverseModeSet(org.opentripplanner.routing.core.TraverseModeSet) TemporaryFreeEdge(org.opentripplanner.routing.edgetype.TemporaryFreeEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Edge(org.opentripplanner.routing.graph.Edge) StreetVertexIndexServiceImpl(org.opentripplanner.routing.impl.StreetVertexIndexServiceImpl) Test(org.junit.Test)

Example 13 with GenericLocation

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

the class SimpleStreetSplitterTest method testFindEndVertexForParkAndRide.

/**
 * Tests that traverse mode WALK is used when getting closest end vertex for park and ride.
 */
@Test
public void testFindEndVertexForParkAndRide() {
    GenericLocation genericLocation = new GenericLocation(10, 23);
    RoutingRequest routingRequest = new RoutingRequest();
    routingRequest.setMode(TraverseMode.CAR);
    routingRequest.parkAndRide = true;
    spySimpleStreetSplitter.getClosestVertex(genericLocation, routingRequest, true);
    verify(spySimpleStreetSplitter).link(any(Vertex.class), eq(TraverseMode.WALK), eq(routingRequest));
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) GenericLocation(org.opentripplanner.common.model.GenericLocation) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) Test(org.junit.Test)

Example 14 with GenericLocation

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

the class BatchProcessor method buildRequest.

private RoutingRequest buildRequest(Individual i) {
    RoutingRequest req = prototypeRoutingRequest.clone();
    req.setDateTime(date, time, timeZone);
    if (searchCutoffSeconds > 0) {
        req.worstTime = req.dateTime + (req.arriveBy ? -searchCutoffSeconds : searchCutoffSeconds);
    }
    GenericLocation latLon = new GenericLocation(i.lat, i.lon);
    req.batch = true;
    if (req.arriveBy)
        req.to = latLon;
    else
        req.from = latLon;
    try {
        req.setRoutingContext(graphService.getRouter(req.routerId).graph);
        return req;
    } catch (VertexNotFoundException vnfe) {
        LOG.debug("no vertex could be created near the origin point");
        return null;
    }
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) VertexNotFoundException(org.opentripplanner.routing.error.VertexNotFoundException)

Example 15 with GenericLocation

use of org.opentripplanner.common.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, "WALK", false);
    handleRequest(fromLocation, toLocation, intermediateLocations, "WALK", true);
}
Also used : GenericLocation(org.opentripplanner.common.model.GenericLocation) Test(org.junit.Test)

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