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);
}
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;
}
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);
}
}
Aggregations