Search in sources :

Example 1 with PathwayEdge

use of org.opentripplanner.routing.edgetype.PathwayEdge in project OpenTripPlanner by opentripplanner.

the class DirectTransferGenerator method buildGraph.

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
    /* Initialize graph index which is needed by the nearby stop finder. */
    if (graph.index == null) {
        graph.index = new GraphIndex(graph);
    }
    /* The linker will use streets if they are available, or straight-line distance otherwise. */
    NearbyStopFinder nearbyStopFinder = new NearbyStopFinder(graph, radiusMeters);
    if (nearbyStopFinder.useStreets) {
        LOG.info("Creating direct transfer edges between stops using the street network from OSM...");
    } else {
        LOG.info("Creating direct transfer edges between stops using straight line distance (not streets)...");
    }
    int nTransfersTotal = 0;
    int nLinkableStops = 0;
    for (TransitStop ts0 : Iterables.filter(graph.getVertices(), TransitStop.class)) {
        /* Skip stops that are entrances to stations or whose entrances are coded separately */
        if (!ts0.isStreetLinkable())
            continue;
        if (++nLinkableStops % 1000 == 0) {
            LOG.info("Linked {} stops", nLinkableStops);
        }
        LOG.debug("Linking stop '{}' {}", ts0.getStop(), ts0);
        /* Determine the set of stops that are already reachable via other pathways or transfers */
        Set<TransitStop> pathwayDestinations = new HashSet<TransitStop>();
        for (Edge e : ts0.getOutgoing()) {
            if (e instanceof PathwayEdge || e instanceof SimpleTransfer) {
                if (e.getToVertex() instanceof TransitStop) {
                    TransitStop to = (TransitStop) e.getToVertex();
                    pathwayDestinations.add(to);
                }
            }
        }
        /* Make transfers to each nearby stop that is the closest stop on some trip pattern. */
        int n = 0;
        for (NearbyStopFinder.StopAtDistance sd : nearbyStopFinder.findNearbyStopsConsideringPatterns(ts0)) {
            /* Skip the origin stop, loop transfers are not needed. */
            if (sd.tstop == ts0 || pathwayDestinations.contains(sd.tstop))
                continue;
            new SimpleTransfer(ts0, sd.tstop, sd.dist, sd.geom, sd.edges);
            n += 1;
        }
        LOG.debug("Linked stop {} to {} nearby stops on other patterns.", ts0.getStop(), n);
        if (n == 0) {
            LOG.debug(graph.addBuilderAnnotation(new StopNotLinkedForTransfers(ts0)));
        }
        nTransfersTotal += n;
    }
    LOG.info("Done connecting stops to one another. Created a total of {} transfers from {} stops.", nTransfersTotal, nLinkableStops);
    graph.hasDirectTransfers = true;
}
Also used : StopNotLinkedForTransfers(org.opentripplanner.graph_builder.annotation.StopNotLinkedForTransfers) TransitStop(org.opentripplanner.routing.vertextype.TransitStop) GraphIndex(org.opentripplanner.routing.graph.GraphIndex) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) SimpleTransfer(org.opentripplanner.routing.edgetype.SimpleTransfer) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) Edge(org.opentripplanner.routing.graph.Edge) HashSet(java.util.HashSet)

Example 2 with PathwayEdge

use of org.opentripplanner.routing.edgetype.PathwayEdge in project OpenTripPlanner by opentripplanner.

the class GTFSPatternHopFactory method loadPathways.

private void loadPathways(Graph graph) {
    for (Pathway pathway : _dao.getAllPathways()) {
        Vertex fromVertex = context.stationStopNodes.get(pathway.getFromStop());
        Vertex toVertex = context.stationStopNodes.get(pathway.getToStop());
        if (pathway.isWheelchairTraversalTimeSet()) {
            new PathwayEdge(fromVertex, toVertex, pathway.getTraversalTime(), pathway.getWheelchairTraversalTime());
        } else {
            new PathwayEdge(fromVertex, toVertex, pathway.getTraversalTime());
        }
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) Pathway(org.onebusaway.gtfs.model.Pathway) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge)

Example 3 with PathwayEdge

use of org.opentripplanner.routing.edgetype.PathwayEdge 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 4 with PathwayEdge

use of org.opentripplanner.routing.edgetype.PathwayEdge in project OpenTripPlanner by opentripplanner.

the class UnconnectedStop method fulfillDemands.

/**
 * @retrun return true if the stop is not connected to any street
 */
@Override
public boolean fulfillDemands(TransitStop ts, Graph graph) {
    List<Edge> outgoingStreets = ts.getOutgoingStreetEdges();
    boolean hasStreetLink = false;
    for (Edge e : ts.getIncoming()) {
        if (e instanceof StreetTransitLink || e instanceof PathwayEdge) {
            hasStreetLink = true;
            break;
        }
    }
    if (!hasStreetLink) {
        // TODO: see what if there is incoming and not outgoing
        for (Edge e : ts.getOutgoing()) {
            if (e instanceof StreetTransitLink) {
                hasStreetLink = true;
                break;
            }
        }
    }
    return !(hasStreetLink || (outgoingStreets.size() > 0));
}
Also used : StreetTransitLink(org.opentripplanner.routing.edgetype.StreetTransitLink) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 5 with PathwayEdge

use of org.opentripplanner.routing.edgetype.PathwayEdge in project OpenTripPlanner by opentripplanner.

the class ShowGraph method findVisibleElements.

@SuppressWarnings("unchecked")
private synchronized void findVisibleElements() {
    visibleVertices = (List<Vertex>) vertexIndex.query(modelBounds);
    visibleStreetEdges.clear();
    visibleLinkEdges.clear();
    visibleTransitEdges.clear();
    for (Edge de : (Iterable<Edge>) edgeIndex.query(modelBounds)) {
        if (de instanceof PatternEdge) {
            visibleTransitEdges.add(de);
        } else if (de instanceof PathwayEdge || de instanceof StreetTransitLink || de instanceof SimpleTransfer) {
            visibleLinkEdges.add(de);
        } else if (de instanceof StreetEdge) {
            visibleStreetEdges.add(de);
        }
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) PathwayEdge(org.opentripplanner.routing.edgetype.PathwayEdge) StreetTransitLink(org.opentripplanner.routing.edgetype.StreetTransitLink) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) SimpleTransfer(org.opentripplanner.routing.edgetype.SimpleTransfer) 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

PathwayEdge (org.opentripplanner.routing.edgetype.PathwayEdge)5 Edge (org.opentripplanner.routing.graph.Edge)4 SimpleTransfer (org.opentripplanner.routing.edgetype.SimpleTransfer)3 StreetTransitLink (org.opentripplanner.routing.edgetype.StreetTransitLink)3 Vertex (org.opentripplanner.routing.graph.Vertex)3 PatternEdge (org.opentripplanner.routing.edgetype.PatternEdge)2 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)2 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 STRtree (com.vividsolutions.jts.index.strtree.STRtree)1 HashSet (java.util.HashSet)1 Pathway (org.onebusaway.gtfs.model.Pathway)1 StopNotLinkedForTransfers (org.opentripplanner.graph_builder.annotation.StopNotLinkedForTransfers)1 GraphIndex (org.opentripplanner.routing.graph.GraphIndex)1 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)1