Search in sources :

Example 26 with TransitStopVertex

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

the class GraphPathToItineraryMapper method addPlaces.

/**
 * Add {@link Place} fields to a {@link Leg}.
 *
 * @param leg The leg to add the places to
 * @param states The states that go with the leg
 */
private static void addPlaces(Leg leg, State[] states, Locale requestedLocale) {
    Vertex firstVertex = states[0].getVertex();
    Vertex lastVertex = states[states.length - 1].getVertex();
    Stop firstStop = firstVertex instanceof TransitStopVertex ? ((TransitStopVertex) firstVertex).getStop() : null;
    Stop lastStop = lastVertex instanceof TransitStopVertex ? ((TransitStopVertex) lastVertex).getStop() : null;
    leg.from = makePlace(firstVertex, firstStop, requestedLocale);
    leg.to = makePlace(lastVertex, lastStop, requestedLocale);
}
Also used : TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) BikeRentalStationVertex(org.opentripplanner.routing.vertextype.BikeRentalStationVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) ExitVertex(org.opentripplanner.routing.vertextype.ExitVertex) Vertex(org.opentripplanner.routing.graph.Vertex) BikeParkVertex(org.opentripplanner.routing.vertextype.BikeParkVertex) Stop(org.opentripplanner.model.Stop) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex)

Example 27 with TransitStopVertex

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

the class DirectGraphFinder method findClosestStops.

/**
 * Return all stops within a certain radius of the given vertex, using straight-line distance independent of streets.
 * If the origin vertex is a StopVertex, the result will include it.
 */
@Override
public List<StopAtDistance> findClosestStops(double lat, double lon, double radiusMeters) {
    List<StopAtDistance> stopsFound = Lists.newArrayList();
    Coordinate coordinate = new Coordinate(lon, lat);
    for (TransitStopVertex it : streetIndex.getNearbyTransitStops(coordinate, radiusMeters)) {
        double distance = SphericalDistanceLibrary.distance(coordinate, it.getCoordinate());
        if (distance < radiusMeters) {
            Coordinate[] coordinates = new Coordinate[] { coordinate, it.getCoordinate() };
            StopAtDistance sd = new StopAtDistance(it, distance, null, geometryFactory.createLineString(coordinates), null);
            stopsFound.add(sd);
        }
    }
    return stopsFound;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex)

Example 28 with TransitStopVertex

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

the class PlaceFinderTraverseVisitor method visitVertex.

@Override
public void visitVertex(State state) {
    Vertex vertex = state.getVertex();
    double distance = state.getWalkDistance();
    if (vertex instanceof TransitStopVertex) {
        Stop stop = ((TransitStopVertex) vertex).getStop();
        handleStop(stop, distance);
        handlePatternsAtStop(stop, distance);
    } else if (vertex instanceof BikeRentalStationVertex) {
        handleBikeRentalStation(((BikeRentalStationVertex) vertex).getStation(), distance);
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) BikeRentalStationVertex(org.opentripplanner.routing.vertextype.BikeRentalStationVertex) BikeRentalStationVertex(org.opentripplanner.routing.vertextype.BikeRentalStationVertex) Stop(org.opentripplanner.model.Stop) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex)

Aggregations

TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)28 Stop (org.opentripplanner.model.Stop)12 Vertex (org.opentripplanner.routing.graph.Vertex)12 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)8 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)8 ArrayList (java.util.ArrayList)7 Coordinate (org.locationtech.jts.geom.Coordinate)7 Envelope (org.locationtech.jts.geom.Envelope)7 Graph (org.opentripplanner.routing.graph.Graph)7 LineString (org.locationtech.jts.geom.LineString)6 DataImportIssueStore (org.opentripplanner.graph_builder.DataImportIssueStore)5 StreetTransitLink (org.opentripplanner.routing.edgetype.StreetTransitLink)5 Iterables (com.google.common.collect.Iterables)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)4 BikeRentalStationVertex (org.opentripplanner.routing.vertextype.BikeRentalStationVertex)4 SplitterVertex (org.opentripplanner.routing.vertextype.SplitterVertex)4 LinearLocation (org.locationtech.jts.linearref.LinearLocation)3 LocationIndexedLine (org.locationtech.jts.linearref.LocationIndexedLine)3