Examples of StreetVertex


Examples of org.opentripplanner.routing.edgetype.StreetVertex

      Map<String, Object> tags = new HashMap<String, Object>();

      tags.put("class", vertex.getClass().getName());

      if (vertex instanceof StreetVertex) {
        StreetVertex sv = (StreetVertex) vertex;
        StreetTraversalPermission perms = sv.getPermission();
        if (perms != null)
          tags.put("access", perms.toString().toLowerCase());
      } else if (vertex instanceof AbstractStopVertex) {
        AbstractStopVertex stopVertex = (AbstractStopVertex) vertex;
        StopEntry stop = stopVertex.getStop();
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

        double uDist = dLib.fastDistance(head.getCoordinate(), u.getCoordinate());
        double vDist = dLib.fastDistance(head.getCoordinate(), v.getCoordinate());

        // Order the vertices along the partial edge by distance from the head of the edge.
        // TODO(flamholz): this logic is insufficient for curvy streets/roundabouts.
        StreetVertex first = u;
        StreetVertex second = v;
        if (vDist < uDist) {
            first = v;
            second = u;
        }

        Geometry parentGeom = e.getGeometry();
        LineString myGeom = GeometryUtils.getInteriorSegment(parentGeom, first.getCoordinate(),
                second.getCoordinate());

        double lengthRatio = myGeom.getLength() / parentGeom.getLength();
        double length = e.getDistance() * lengthRatio;

        String name = first.getLabel() + " to " + second.getLabel();
        return new PartialStreetEdge(e, first, second, myGeom, name, length);
    }
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

        // If the from and to vertices are generated and lie on some of the same edges, we need to wire them
        // up along those edges so that we don't get odd circuitous routes for really short trips.
        // TODO(flamholz): seems like this might be the wrong place for this code? Can't find a better one.
        //
        if (fromVertex instanceof StreetLocation && toVertex instanceof StreetLocation) {
            StreetVertex fromStreetVertex = (StreetVertex) fromVertex;
            StreetVertex toStreetVertex = (StreetVertex) toVertex;
            Set<StreetEdge> overlap = overlappingPlainStreetEdges(fromStreetVertex,
                    toStreetVertex);

            for (StreetEdge pse : overlap) {
                PartialStreetEdge ppse = makePartialEdgeAlong(pse, fromStreetVertex, toStreetVertex);
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

            List<Edge> extraEdges) {
        LOG.debug("Looking for/making a vertex near {}", location);

        // first, check for intersections very close by
        Coordinate coord = location.getCoordinate();
        StreetVertex intersection = getIntersectionAt(coord);
        String calculatedName = location.name;
        if (intersection != null) {
            // We have an intersection vertex. Check that this vertex has edges we can traverse.
            boolean canEscape = false;
            if (options == null) {
                canEscape = true; // Some tests do not supply options.
            } else {
                TraversalRequirements reqs = new TraversalRequirements(options);
                for (StreetEdge e : Iterables.filter ( options.arriveBy ?
                        intersection.getIncoming() : intersection.getOutgoing(),
                        StreetEdge.class)) {
                    if (reqs.canBeTraversed(e)) {
                        canEscape = true;
                        break;
                    }
                }
            }      
            if (canEscape) {
                // Coordinate is at an intersection or street endpoint, and has traversible edges.
                if (!location.hasName()) {
                    LOG.debug("found intersection {}. not splitting.", intersection);
                    // generate names for corners when no name was given
                    Set<String> uniqueNameSet = new HashSet<String>();
                    for (Edge e : intersection.getOutgoing()) {
                        if (e instanceof StreetEdge) {
                            uniqueNameSet.add(e.getName());
                        }
                    }
                    List<String> uniqueNames = new ArrayList<String>(uniqueNameSet);
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

                coordinate.y);
        double dLat = SphericalDistanceLibrary.metersToDegrees(MAX_CORNER_DISTANCE_METERS);
        Envelope envelope = new Envelope(coordinate);
        envelope.expandBy(dLon, dLat);
        List<Vertex> nearby = getVerticesForEnvelope(envelope);
        StreetVertex nearest = null;
        double bestDistanceMeter = Double.POSITIVE_INFINITY;
        for (Vertex v : nearby) {
            if (v instanceof StreetVertex) {
                double distanceMeter = distanceLibrary.fastDistance(coordinate, v.getCoordinate());
                if (distanceMeter < MAX_CORNER_DISTANCE_METERS) {
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

        // nearestPointOnEdge);
    }

    /** Calculates the endwiseVertex if appropriate. */
    private StreetVertex calcEndwiseVertex() {
        StreetVertex retV = null;
        if (nearestSegmentIndex == 0 && Math.abs(nearestSegmentFraction) < 0.000001) {
            retV = (StreetVertex) edge.getFromVertex();
        } else if (nearestSegmentIndex == numEdgeCoords - 2
                && Math.abs(nearestSegmentFraction - 1.0) < 0.000001) {
            retV = (StreetVertex) edge.getToVertex();
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

        return v;
    }

    private void edges(String... vLabels) {
        for (int i = 0; i < vLabels.length - 1; i++) {
            StreetVertex vA = (StreetVertex) _graph.getVertex(vLabels[i]);
            StreetVertex vB = (StreetVertex) _graph.getVertex(vLabels[i + 1]);

            new SimpleEdge(vA, vB);
            new SimpleEdge(vB, vA);
        }
    }
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

        assertEquals(0, edges.size());
    }

    public void testGetStreetEdgesSeveral() {
        Graph g = new Graph();
        StreetVertex a = new IntersectionVertex(g, "A", 5, 5);
        StreetVertex b = new IntersectionVertex(g, "B", 6, 6);
        StreetVertex c = new IntersectionVertex(g, "C", 3, 2);

        Set<Edge> allStreetEdges = new HashSet<Edge>(4);
        allStreetEdges.add(edge(a, b, 1.0));
        allStreetEdges.add(edge(b, c, 1.0));
        allStreetEdges.add(edge(c, b, 1.0));
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

        assertEquals(allStreetEdges, edges);
    }

    public void testGetEdgesAndVerticesById() {
        Graph g = new Graph();
        StreetVertex a = new IntersectionVertex(g, "A", 5, 5);
        StreetVertex b = new IntersectionVertex(g, "B", 6, 6);
        StreetVertex c = new IntersectionVertex(g, "C", 3, 2);

        Set<Edge> allEdges = new HashSet<Edge>(4);
        allEdges.add(edge(a, b, 1.0));
        allEdges.add(edge(b, c, 1.0));
        allEdges.add(edge(c, b, 1.0));
View Full Code Here

Examples of org.opentripplanner.routing.vertextype.StreetVertex

            List<StreetVertex> list = Arrays.asList(edges.endwiseVertex);
            linker.splitVertices.put(v, list);
            return list;
        } else {
            /* is the stop right at an intersection? */
            StreetVertex atIntersection = linker.index.getIntersectionAt(coordinate);
            if (atIntersection != null) {
                // if so, the stop can be linked directly to all vertices at the intersection
                if (edges.getScore() > distanceLibrary.distance(atIntersection.getCoordinate(), coordinate))
                    return Arrays.asList(atIntersection);
            }
            return getSplitterVertices(vertexLabel, edges.toEdgeList(), coordinate);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.