Package org.opentripplanner.common.model

Examples of org.opentripplanner.common.model.GenericLocation


        modes.setCar(true);
        reqs.modes = modes;
       
        // Location along the top edge, traveling with the forward edge
        // exactly.
        GenericLocation loc = new GenericLocation(c);
        loc.heading = top.getAzimuth();
       
        CandidateEdgeBundle candidates = finder.getClosestEdges(loc, reqs);
        Collections.sort(candidates, new CandidateEdge.CandidateEdgeScoreComparator());
       
View Full Code Here


    }

    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
        StreetLocation some = (StreetLocation) finder.getVertexForLocation(new GenericLocation(
                40.00, -74.00), null);
        assertNotNull(some);

        // test that the closest vertex finder correctly splits streets
        StreetLocation start = (StreetLocation) finder.getVertexForLocation(new GenericLocation(
                40.004, -74.01), null);
        assertNotNull(start);
        assertTrue("wheelchair accessibility is correctly set (splitting)",
                start.isWheelchairAccessible());

        List<Edge> extras = start.getExtra();
        assertEquals(4, extras.size());

        RoutingRequest biking = new RoutingRequest(new TraverseModeSet(TraverseMode.BICYCLE));
        StreetLocation end = (StreetLocation) finder.getVertexForLocation(new GenericLocation(
                40.008, -74.0), biking);
        assertNotNull(end);

        extras = end.getExtra();
        assertEquals(4, extras.size());

        // test that the closest vertex finder also adds an edge to transit
        // stops (if you are really close to the transit stop relative to the
        // street)
        StreetLocation location = (StreetLocation) finder.getVertexForLocation(new GenericLocation(
                40.00999, -74.004999), new RoutingRequest());
        assertTrue(location.isWheelchairAccessible());
        boolean found = false;
        for (Edge extra : location.getExtra()) {
            if (extra instanceof FreeEdge && ((FreeEdge) extra).getToVertex().equals(station1)) {
                found = true;
            }
        }
        assertTrue(found);

        // test that it is possible to travel between two splits on the same street
        RoutingRequest walking = new RoutingRequest(TraverseMode.WALK);
        start = (StreetLocation) finder.getVertexForLocation(new GenericLocation(40.004, -74.0),
                walking);
        end = (StreetLocation) finder.getVertexForLocation(new GenericLocation(40.008, -74.0),
                walking);
        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);
View Full Code Here

        when(graph.getEdges()).thenReturn(hops);
        when(depart.getCoordinate()).thenReturn(new Coordinate(0, 0));
        when(dwell.getCoordinate()).thenReturn(new Coordinate(0, 0));
        when(arrive.getCoordinate()).thenReturn(new Coordinate(0, 0));
        routingRequest.from = new GenericLocation();
        routingRequest.startingTransitTripId = agencyAndId;
        when(serviceDay.secondsSinceMidnight(anyInt())).thenReturn(9);

        patternHop0.setGeometry(geometry);
        tripPattern.add(tripTimes);
View Full Code Here

        PatternHop patternHop = new PatternHop(depart, arrive, stopDepart, stopArrive, 0);

        when(graph.getEdges()).thenReturn(Collections.<Edge>singletonList(patternHop));
        when(depart.getCoordinate()).thenReturn(new Coordinate(0, 0));
        when(arrive.getCoordinate()).thenReturn(new Coordinate(0, 0));
        routingRequest.from = new GenericLocation();
        routingRequest.startingTransitTripId = agencyAndId;
        when(serviceDay.secondsSinceMidnight(anyInt())).thenReturn(10);
        when(graph.getVertex("Station_0")).thenReturn(station0);
        when(graph.getVertex("Station_1")).thenReturn(station1);
View Full Code Here

        when(graph.getEdges()).thenReturn(hops);
        when(depart.getCoordinate()).thenReturn(new Coordinate(0, 0));
        when(dwell.getCoordinate()).thenReturn(new Coordinate(0, 0));
        when(arrive.getCoordinate()).thenReturn(new Coordinate(0, 0));
        routingRequest.from = new GenericLocation();
        routingRequest.startingTransitTripId = agencyAndId;
        when(graph.getVertex("Station_0")).thenReturn(station0);
        when(graph.getVertex("Station_1")).thenReturn(station1);
        when(graph.getVertex("Station_2")).thenReturn(station2);
View Full Code Here

        carSpeed = 40; // 40 m/s, 144 km/h, above the maximum (finite) driving speed limit worldwide
        setModes(new TraverseModeSet(TraverseMode.WALK, TraverseMode.TRANSIT));
        bikeWalkingOptions = this;

        // So that they are never null.
        from = new GenericLocation();
        to = new GenericLocation();
    }
View Full Code Here

        if (mode == TraverseMode.CAR) {
            //rr.kissAndRide = true; // allow car->walk transition. we are assuming that someone will drop you off.
            rr.parkAndRide = true; // allow car->walk transition only at tagged park and ride facilities.
            rr.modes.setWalk(true); // need to walk after dropping the car off
        }
        rr.from = (new GenericLocation(request.from.lat, request.from.lon));
        // FIXME requires destination to be set, not necesary for analyst
        rr.to = new GenericLocation(request.to.lat, request.to.lon);
        rr.setArriveBy(dest);
        rr.setRoutingContext(graph);
        // Set batch after context, so both origin and dest vertices will be found.
        rr.batch = (true);
        rr.walkSpeed = request.walkSpeed;
View Full Code Here

    /** Look for an option connecting origin to destination without using transit. */
    private void findStreetOption(TraverseMode mode) {
        // Make a normal OTP routing request so we can traverse edges and use GenericAStar
        RoutingRequest rr = new RoutingRequest(mode);
        rr.from = (new GenericLocation(request.from.lat, request.from.lon));
        rr.to = new GenericLocation(request.to.lat, request.to.lon);
        rr.setArriveBy(false);
        rr.setRoutingContext(graph);
        // This is not a batch search, it is a point-to-point search with goal direction.
        // Impose a max time to protect against very slow searches.
        int worstElapsedTime = request.streetTime * 60;
 
View Full Code Here

        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;
View Full Code Here

        routingRequest.setNumItineraries(1);
       
        routingRequest.setArriveBy(dateTime < 0);
        routingRequest.dateTime = Math.abs(dateTime);
        if (fromVertex != null && !fromVertex.isEmpty()) {
            routingRequest.from = (new GenericLocation(null, agencyId + ":" + fromVertex));
        }
        if (toVertex != null && !toVertex.isEmpty()) {
            routingRequest.to = new GenericLocation(null, agencyId + ":" + toVertex);
        }
        if (onTripId != null && !onTripId.isEmpty()) {
            routingRequest.startingTransitTripId = (new AgencyAndId(agencyId, onTripId));
        }
        routingRequest.setRoutingContext(graph);
View Full Code Here

TOP

Related Classes of org.opentripplanner.common.model.GenericLocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.