Search in sources :

Example 51 with Edge

use of org.opentripplanner.routing.graph.Edge 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)

Example 52 with Edge

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

the class ShowGraph method handleNewHighlights.

private void handleNewHighlights() {
    // fill(0, 0, 0, 1);
    // rect(0,0,this.width, this.height);
    desaturate();
    noFill();
    // , 8);
    stroke(256, 0, 0, 128);
    strokeWeight(6);
    while (!newHighlightedEdges.isEmpty()) {
        Edge de = newHighlightedEdges.poll();
        if (de != null) {
            drawEdge(de);
            highlightedEdges.add(de);
        }
    }
    if (VIDEO)
        saveVideoFrame();
}
Also used : StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) PatternEdge(org.opentripplanner.routing.edgetype.PatternEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 53 with Edge

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

the class ShowGraph method drawTransit.

private boolean drawTransit(int startMillis) {
    if (drawTransitEdges) {
        // transparent blue
        stroke(40, 40, 128, 30);
        strokeWeight(4);
        noFill();
        // for (Edge e : visibleTransitEdges) {
        while (drawOffset < visibleTransitEdges.size()) {
            Edge e = visibleTransitEdges.get(drawOffset);
            drawEdge(e);
            drawOffset += 1;
            if (drawOffset % BLOCK_SIZE == 0) {
                if (millis() - startMillis > FRAME_TIME)
                    return false;
            }
        }
    }
    return true;
}
Also used : StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) PatternEdge(org.opentripplanner.routing.edgetype.PatternEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 54 with Edge

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

the class ShowGraph method drawAnotation.

public void drawAnotation(GraphBuilderAnnotation anno) {
    Envelope env = new Envelope();
    Edge e = anno.getReferencedEdge();
    if (e != null) {
        this.enqueueHighlightedEdge(e);
        env.expandToInclude(e.getFromVertex().getCoordinate());
        env.expandToInclude(e.getToVertex().getCoordinate());
    }
    ArrayList<Vertex> vertices = new ArrayList<Vertex>();
    Vertex v = anno.getReferencedVertex();
    if (v != null) {
        env.expandToInclude(v.getCoordinate());
        vertices.add(v);
    }
    if (e == null && v == null)
        return;
    // make it a little bigger, especially needed for STOP_UNLINKED
    env.expandBy(0.02);
    // highlight relevant things
    this.clearHighlights();
    this.setHighlightedVertices(vertices);
    // zoom the graph display
    this.zoomToEnvelope(env);
    // and draw
    this.draw();
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) 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)

Example 55 with Edge

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

the class ShowGraph method drawLinks.

private boolean drawLinks(int startMillis) {
    if (drawLinkEdges) {
        // transparent blue
        stroke(256, 165, 0, 30);
        strokeWeight(3);
        noFill();
        // for (Edge e : visibleTransitEdges) {
        while (drawOffset < visibleLinkEdges.size()) {
            Edge e = visibleLinkEdges.get(drawOffset);
            drawEdge(e);
            drawOffset += 1;
            if (drawOffset % BLOCK_SIZE == 0) {
                if (millis() - startMillis > FRAME_TIME)
                    return false;
            }
        }
    }
    return true;
}
Also used : StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) PatternEdge(org.opentripplanner.routing.edgetype.PatternEdge) Edge(org.opentripplanner.routing.graph.Edge)

Aggregations

Edge (org.opentripplanner.routing.graph.Edge)113 Vertex (org.opentripplanner.routing.graph.Vertex)61 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)53 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)26 HashSet (java.util.HashSet)23 State (org.opentripplanner.routing.core.State)22 Coordinate (com.vividsolutions.jts.geom.Coordinate)19 Graph (org.opentripplanner.routing.graph.Graph)19 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)18 Test (org.junit.Test)17 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)17 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)17 ArrayList (java.util.ArrayList)16 LineString (com.vividsolutions.jts.geom.LineString)15 GraphPath (org.opentripplanner.routing.spt.GraphPath)15 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)12 PathwayEdge (org.opentripplanner.routing.edgetype.PathwayEdge)11 Geometry (com.vividsolutions.jts.geom.Geometry)9 Stop (org.onebusaway.gtfs.model.Stop)9 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)9