Search in sources :

Example 71 with Vertex

use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.

the class OverlayGraph method addEdge.

public void addEdge(Edge e) {
    Vertex fromv = e.getFromVertex();
    Vertex tov = e.getToVertex();
    addOutgoing(fromv, e);
    addIncoming(tov, e);
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex)

Example 72 with Vertex

use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.

the class GraphGeographicFilter method findHull.

public void findHull() {
    LOG.info("finding hull of graph...");
    LOG.debug("using only stops? {}", useOnlyStops);
    if (bufferMeters < prototypeRoutingRequest.maxWalkDistance)
        LOG.warn("geographic filter buffer is smaller than max walk distance, this will probably yield incorrect results.");
    Graph graph = graphService.getRouter(prototypeRoutingRequest.routerId).graph;
    List<Geometry> geometries = new ArrayList<Geometry>();
    for (Vertex v : graph.getVertices()) {
        if (useOnlyStops && !(v instanceof TransitStop))
            continue;
        Point pt = gf.createPoint(v.getCoordinate());
        Geometry geom = crudeProjectedBuffer(pt, bufferMeters);
        geometries.add(geom);
    }
    Geometry multiGeom = gf.buildGeometry(geometries);
    LOG.info("unioning hull...");
    hull = multiGeom.union();
    LOG.trace("hull is {}", hull.toText());
// may lead to false rejections
// DouglasPeuckerSimplifier simplifier = new DouglasPeuckerSimplifier();
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) Vertex(org.opentripplanner.routing.graph.Vertex) Graph(org.opentripplanner.routing.graph.Graph) TransitStop(org.opentripplanner.routing.vertextype.TransitStop) ArrayList(java.util.ArrayList) Point(com.vividsolutions.jts.geom.Point)

Example 73 with Vertex

use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.

the class GraphVisualizer method checkGraph.

protected void checkGraph() {
    HashSet<Vertex> seenVertices = new HashSet<Vertex>();
    Collection<Vertex> allVertices = getGraph().getVertices();
    Vertex v = allVertices.iterator().next();
    System.out.println("initial vertex: " + v);
    Queue<Vertex> toExplore = new LinkedList<Vertex>();
    toExplore.add(v);
    seenVertices.add(v);
    while (!toExplore.isEmpty()) {
        Vertex src = toExplore.poll();
        for (Edge e : src.getOutgoing()) {
            Vertex tov = e.getToVertex();
            if (!seenVertices.contains(tov)) {
                seenVertices.add(tov);
                toExplore.add(tov);
            }
        }
    }
    System.out.println("After investigation, visited " + seenVertices.size() + " of " + allVertices.size());
    /* now, let's find an unvisited vertex */
    for (Vertex u : allVertices) {
        if (!seenVertices.contains(u)) {
            System.out.println("unvisited vertex" + u);
            break;
        }
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 74 with Vertex

use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.

the class GraphVisualizer method verticesSelected.

public void verticesSelected(final List<Vertex> selected) {
    // sort vertices by name
    Collections.sort(selected, new Comparator<Vertex>() {

        @Override
        public int compare(Vertex arg0, Vertex arg1) {
            return arg0.getLabel().compareTo(arg1.getLabel());
        }
    });
    ListModel<DisplayVertex> data = new VertexList(selected);
    nearbyVertices.setModel(data);
    // pick out an intersection vertex and find the path
    // if the spt is already available
    Vertex target = null;
    for (Vertex vv : selected) {
        if (vv instanceof IntersectionVertex) {
            target = vv;
            break;
        }
    }
    if (target != null && spt != null) {
        List<GraphPath> paths = spt.getPaths(target, true);
        showPathsInPanel(paths);
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) GraphPath(org.opentripplanner.routing.spt.GraphPath)

Example 75 with Vertex

use of org.opentripplanner.routing.graph.Vertex in project OpenTripPlanner by opentripplanner.

the class ShowGraph method buildSpatialIndex.

/*
     * Iterate through all vertices and their (outgoing) edges. If they are of 'interesting' types, 
     * add them to the corresponding spatial index.
     */
public synchronized void buildSpatialIndex() {
    vertexIndex = new STRtree();
    edgeIndex = new STRtree();
    Envelope env;
    // int xminx, xmax, ymin, ymax;
    for (Vertex v : graph.getVertices()) {
        Coordinate c = v.getCoordinate();
        env = new Envelope(c);
        vertexIndex.insert(env, v);
        for (Edge e : v.getOutgoing()) {
            if (e.getGeometry() == null)
                continue;
            if (e instanceof PatternEdge || e instanceof StreetTransitLink || e instanceof StreetEdge || e instanceof PathwayEdge || e instanceof SimpleTransfer) {
                env = e.getGeometry().getEnvelopeInternal();
                edgeIndex.insert(env, e);
            }
        }
    }
    vertexIndex.build();
    edgeIndex.build();
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) Coordinate(com.vividsolutions.jts.geom.Coordinate) STRtree(com.vividsolutions.jts.index.strtree.STRtree) StreetTransitLink(org.opentripplanner.routing.edgetype.StreetTransitLink) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) SimpleTransfer(org.opentripplanner.routing.edgetype.SimpleTransfer) Envelope(com.vividsolutions.jts.geom.Envelope) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) PatternEdge(org.opentripplanner.routing.edgetype.PatternEdge) Edge(org.opentripplanner.routing.graph.Edge) PatternEdge(org.opentripplanner.routing.edgetype.PatternEdge)

Aggregations

Vertex (org.opentripplanner.routing.graph.Vertex)143 Edge (org.opentripplanner.routing.graph.Edge)63 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)45 GraphPath (org.opentripplanner.routing.spt.GraphPath)39 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)35 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)34 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)32 Graph (org.opentripplanner.routing.graph.Graph)29 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)28 Coordinate (com.vividsolutions.jts.geom.Coordinate)24 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)24 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)20 State (org.opentripplanner.routing.core.State)20 Stop (org.onebusaway.gtfs.model.Stop)18 LineString (com.vividsolutions.jts.geom.LineString)16 ArrayList (java.util.ArrayList)16 HashSet (java.util.HashSet)13 Test (org.junit.Test)13 Trip (org.onebusaway.gtfs.model.Trip)12 Envelope (com.vividsolutions.jts.geom.Envelope)11