Package org.opentripplanner.routing.location

Examples of org.opentripplanner.routing.location.StreetLocation


            LOG.debug("cannot set RoutingContext: setting mode=WALK");
            sptRequestA.setMode(TraverseMode.WALK); // fall back to walk mode
            sptRequestA.setRoutingContext(graphService.getGraph());
        }
        ShortestPathTree sptA = sptService.getShortestPathTree(sptRequestA);
        StreetLocation origin = (StreetLocation) sptRequestA.rctx.fromVertex;
        sptRequestA.cleanup(); // remove inserted points

        // create a LineString for display
        Coordinate pathToStreetCoords[] = new Coordinate[2];
        pathToStreetCoords[0] = dropPoint;
        pathToStreetCoords[1] = origin.getCoordinate();
        LineString pathToStreet = gf.createLineString(pathToStreetCoords);

        // get distance between origin and drop point for time correction
        double distanceToRoad = this.distanceLibrary.distance(origin.getY(), origin.getX(),
                dropPoint.y, dropPoint.x);
        long offRoadTimeCorrection = (long) (distanceToRoad / this.offRoadWalkspeed);

        //
        // --- filter the states ---
View Full Code Here


    public boolean isWheelchairAccessible(Vertex v) {
        if (v instanceof TransitStop) {
            TransitStop ts = (TransitStop) v;
            return ts.hasWheelchairEntrance();
        } else if (v instanceof StreetLocation) {
            StreetLocation sl = (StreetLocation) v;
            return sl.isWheelchairAccessible();
        }
        return true;
    }
View Full Code Here

                        calculatedName = uniqueNames.get(0);
                    } else {
                        calculatedName = resources.getString("unnamedStreet");
                    }
                }
                StreetLocation closest = new StreetLocation(graph, "corner " + Math.random(), coord,
                        calculatedName);
                FreeEdge e = new FreeEdge(closest, intersection);
                closest.getExtra().add(e);
                e = new FreeEdge(intersection, closest);
                closest.getExtra().add(e);
                return closest;
            }
        }

        // if no intersection vertices were found, then find the closest transit stop
        // (we can return stops here because this method is not used when street-transit linking)
        double closestStopDistance = Double.POSITIVE_INFINITY;
        Vertex closestStop = null;
        // elsewhere options=null means no restrictions, find anything.
        // here we skip examining stops, as they are really only relevant when transit is being used
        if (options != null && options.modes.isTransit()) {
            for (TransitStop v : getNearbyTransitStops(coord, 1000)) {
                if (!v.isStreetLinkable()) continue;

                double d = distanceLibrary.distance(v.getCoordinate(), coord);
                if (d < closestStopDistance) {
                    closestStopDistance = d;
                    closestStop = v;
                }
            }
        }
        LOG.debug(" best stop: {} distance: {}", closestStop, closestStopDistance);

        // then find closest walkable street
        StreetLocation closestStreet = null;
        CandidateEdgeBundle bundle = getClosestEdges(location, options, extraEdges, null, false);
        CandidateEdge candidate = bundle.best;
        double closestStreetDistance = Double.POSITIVE_INFINITY;
        if (candidate != null) {
            StreetEdge bestStreet = candidate.edge;
            Coordinate nearestPoint = candidate.nearestPointOnEdge;
            closestStreetDistance = distanceLibrary.distance(coord, nearestPoint);
            LOG.debug("best street: {} dist: {}", bestStreet.toString(), closestStreetDistance);
            if (calculatedName == null || "".equals(calculatedName)) {
                calculatedName = bestStreet.getName();
            }
            String closestName = String.format("%s_%s", bestStreet.getName(), location.toString());
            closestStreet = StreetLocation.createStreetLocation(graph, closestName, calculatedName,
                    bundle.toEdgeList(), nearestPoint, coord);
        }

        // decide whether to return street, or street + stop
        if (closestStreet == null) {
            // no street found, return closest stop or null
            LOG.debug("returning only transit stop (no street found)");
            return closestStop; // which will be null if none was found
        } else {
            // street found
            if (closestStop != null) {
                // both street and stop found
                double relativeStopDistance = closestStopDistance / closestStreetDistance;
                if (relativeStopDistance < 1.5) {
                    LOG.debug("linking transit stop to street (distances are comparable)");
                    closestStreet.addExtraEdgeTo(closestStop);
                }
            }
            LOG.debug("returning split street");
            return closestStreet;
        }
View Full Code Here

        // Vertices for legs 7 and 8
        BikeRentalStationVertex v56 = new BikeRentalStationVertex(
                graph, enterDropoffStation);
        BikeRentalStationVertex v58 = new BikeRentalStationVertex(
                graph, exitDropoffStation);
        StreetLocation v60 = new StreetLocation(
                graph, "Vertex 60", new Coordinate(0, 90), "Vertex 60");

        // Vertex initialization that can't be done using the constructor
        v0.setExitName("Ausfahrt");
        v2.freeFlowing = (true);
View Full Code Here

    public void testForwardExtraEdges() {

        RoutingRequest options = new RoutingRequest();
        options.walkSpeed = 1.0;

        StreetLocation fromLocation = new StreetLocation(_graph, "near_shilshole_22nd",
                new Coordinate(-122.385050, 47.666620), "near_shilshole_22nd");
        fromLocation.getExtra().add(
                new SimpleConcreteEdge(fromLocation, _graph.getVertex("shilshole_22nd")));

        StreetLocation toLocation = new StreetLocation(_graph, "near_56th_20th", new Coordinate(
                -122.382347, 47.669518), "near_56th_20th");
        toLocation.getExtra()
                .add(new SimpleConcreteEdge(_graph.getVertex("56th_20th"), toLocation));

        options.setRoutingContext(_graph, fromLocation, toLocation);
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.walkSpeed = 1.0;
        options.setArriveBy(true);

        StreetLocation fromLocation = new StreetLocation(_graph, "near_shilshole_22nd",
                new Coordinate(-122.385050, 47.666620), "near_shilshole_22nd");
        fromLocation.getExtra().add(
                new SimpleConcreteEdge(fromLocation, _graph.getVertex("shilshole_22nd")));

        StreetLocation toLocation = new StreetLocation(_graph, "near_56th_20th", new Coordinate(
                -122.382347, 47.669518), "near_56th_20th");
        toLocation.getExtra()
                .add(new SimpleConcreteEdge(_graph.getVertex("56th_20th"), toLocation));

        options.setRoutingContext(_graph, fromLocation, toLocation);
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);
View Full Code Here

        HashSet<Edge> turns = new HashSet<Edge>();
        turns.add(left);
        turns.add(leftBack);

        StreetLocation start = StreetLocation.createStreetLocation(graph, "start", "start",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));

        HashSet<Edge> endTurns = new HashSet<Edge>();
        endTurns.add(right);
        endTurns.add(rightBack);

        StreetLocation end = StreetLocation.createStreetLocation(graph, "end", "end",
                filter(endTurns, StreetEdge.class),
                new LinearLocation(0, 0.8).getCoordinate(right.getGeometry()));

        assertTrue(start.getX() < end.getX());
        assertTrue(start.getY() < end.getY());

        List<Edge> extra = end.getExtra();

        assertEquals(4, extra.size());

        long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 11, 1, 12, 34, 25);
        options.dateTime = startTime;
View Full Code Here

        HashSet<Edge> turns = new HashSet<Edge>();
        turns.add(left);
        turns.add(leftBack);
       
        StreetLocation start = StreetLocation.createStreetLocation(graph, "start", "start",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));

        StreetLocation end = StreetLocation.createStreetLocation(graph, "end", "end",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.8).getCoordinate(left.getGeometry()));

        assertEquals(start.getX(), end.getX());
        assertTrue(start.getY() < end.getY());

        List<Edge> extra = end.getExtra();

        assertEquals(4, extra.size());

        long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 11, 1, 12, 34, 25);
        options.dateTime = startTime;
View Full Code Here

        // Sits only on the leftmost edge, not on its reverse.
        HashSet<Edge> turns = new HashSet<Edge>();
        turns.add(left);

        StreetLocation start = StreetLocation.createStreetLocation(graph, "start", "start",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.8).getCoordinate(left.getGeometry()));
       
        StreetLocation end = StreetLocation.createStreetLocation(graph, "end", "end",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));

        assertEquals(start.getX(), end.getX());
        assertTrue(start.getY() > end.getY());

        List<Edge> extra = end.getExtra();
        assertEquals(2, extra.size());

        long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 11, 1, 12, 34, 25);
        options.dateTime = startTime;
        options.setRoutingContext(graph, start, end);
View Full Code Here

        alerts.add(alert);

        graph.streetNotesService.addStaticNote(left, alert, StreetNotesService.ALWAYS_MATCHER);
        graph.streetNotesService.addStaticNote(leftBack, alert, StreetNotesService.ALWAYS_MATCHER);

        StreetLocation start = StreetLocation.createStreetLocation(graph, "start", "start",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));

        // The alert should be preserved
        // traverse the FreeEdge from the StreetLocation to the new IntersectionVertex
        RoutingRequest req = new RoutingRequest();
        req.setMaxWalkDistance(Double.MAX_VALUE);
        State traversedOne = new State((Vertex) start, req);
        State currentState;
        for (Edge e : start.getOutgoing()) {
            currentState = e.traverse(traversedOne);
            if (currentState != null) {
                traversedOne = currentState;
                break;
            }
        }

        assertEquals(alerts, graph.streetNotesService.getNotes(traversedOne));
        assertNotSame(left, traversedOne.getBackEdge().getFromVertex());
        assertNotSame(leftBack, traversedOne.getBackEdge().getFromVertex());

        // now, make sure wheelchair alerts are preserved
        Alert wheelchairAlert = Alert.createSimpleAlerts("This is the wheelchair alert");
        Set<Alert> wheelchairAlerts = new HashSet<>();
        wheelchairAlerts.add(wheelchairAlert);

        graph.streetNotesService.removeStaticNotes(left);
        graph.streetNotesService.removeStaticNotes(leftBack);
        graph.streetNotesService.addStaticNote(left, wheelchairAlert,
                StreetNotesService.WHEELCHAIR_MATCHER);
        graph.streetNotesService.addStaticNote(leftBack, wheelchairAlert,
                StreetNotesService.WHEELCHAIR_MATCHER);

        req.setWheelchairAccessible(true);

        start = StreetLocation.createStreetLocation(graph, "start", "start",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));

        traversedOne = new State((Vertex) start, req);
        for (Edge e : start.getOutgoing()) {
            currentState = e.traverse(traversedOne);
            if (currentState != null) {
                traversedOne = currentState;
                break;
            }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.location.StreetLocation

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.