Search in sources :

Example 1 with TransitStopStreetVertex

use of org.opentripplanner.routing.vertextype.TransitStopStreetVertex in project OpenTripPlanner by opentripplanner.

the class TransitToTaggedStopsModule method connectVertexToStop.

private boolean connectVertexToStop(TransitStop ts, boolean wheelchairAccessible) {
    String stopCode = ts.getStopCode();
    if (stopCode == null) {
        return false;
    }
    Envelope envelope = new Envelope(ts.getCoordinate());
    double xscale = Math.cos(ts.getCoordinate().y * Math.PI / 180);
    envelope.expandBy(searchRadiusLat / xscale, searchRadiusLat);
    Collection<Vertex> vertices = index.getVerticesForEnvelope(envelope);
    // in their ref= tag that matches the GTFS stop code of this TransitStop.
    for (Vertex v : vertices) {
        if (!(v instanceof TransitStopStreetVertex)) {
            continue;
        }
        TransitStopStreetVertex tsv = (TransitStopStreetVertex) v;
        // Only use stop codes for linking TODO: find better method to connect stops without stop code
        if (tsv.stopCode != null && tsv.stopCode.equals(stopCode)) {
            new StreetTransitLink(ts, tsv, wheelchairAccessible);
            new StreetTransitLink(tsv, ts, wheelchairAccessible);
            LOG.debug("Connected " + ts.toString() + " to " + tsv.getLabel());
            return true;
        }
    }
    return false;
}
Also used : TransitStopStreetVertex(org.opentripplanner.routing.vertextype.TransitStopStreetVertex) TransitStopStreetVertex(org.opentripplanner.routing.vertextype.TransitStopStreetVertex) Vertex(org.opentripplanner.routing.graph.Vertex) StreetTransitLink(org.opentripplanner.routing.edgetype.StreetTransitLink) Envelope(com.vividsolutions.jts.geom.Envelope)

Aggregations

Envelope (com.vividsolutions.jts.geom.Envelope)1 StreetTransitLink (org.opentripplanner.routing.edgetype.StreetTransitLink)1 Vertex (org.opentripplanner.routing.graph.Vertex)1 TransitStopStreetVertex (org.opentripplanner.routing.vertextype.TransitStopStreetVertex)1