use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.
the class PlaceFinderTraverseVisitor method handlePatternsAtStop.
private void handlePatternsAtStop(Stop stop, double distance) {
if (includePatternAtStops) {
List<TripPattern> patterns = routingService.getPatternsForStop(stop).stream().filter(pattern -> filterByModes == null || filterByModes.contains(pattern.getMode())).filter(pattern -> filterByRoutes == null || filterByRoutes.contains(pattern.route.getId())).filter(pattern -> pattern.canBoard(pattern.getStopIndex(stop))).collect(toList());
for (TripPattern pattern : patterns) {
String seenKey = pattern.route.getId().toString() + ":" + pattern.getId().toString();
if (!seenPatternAtStops.contains(seenKey)) {
PatternAtStop row = new PatternAtStop(stop, pattern);
PlaceAtDistance place = new PlaceAtDistance(row, distance);
placesFound.add(place);
seenPatternAtStops.add(seenKey);
}
}
}
}
use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.
the class RideMapper method rideForTransitPathLeg.
public static Ride rideForTransitPathLeg(TransitPathLeg leg, TransitLayer transitLayer) {
TransitPathLeg<TripSchedule> transitPathLeg = leg.asTransitLeg();
TripSchedule tripSchedule = transitPathLeg.trip();
Ride ride = new Ride();
TripPattern tripPattern = tripSchedule.getOriginalTripPattern();
ride.firstStop = transitLayer.getStopByIndex(transitPathLeg.fromStop());
ride.lastStop = transitLayer.getStopByIndex(transitPathLeg.toStop());
ride.startZone = ride.firstStop.getFirstZoneAsString();
ride.endZone = ride.lastStop.getFirstZoneAsString();
// In almost all cases (except some loop routes) this should get the right set of zones passed through.
// We don't have the position of the stops within the pattern so can't readily get more accurate than this.
boolean onBoard = false;
for (Stop stop : tripPattern.getStops()) {
if (stop == ride.firstStop) {
onBoard = true;
}
if (onBoard) {
ride.zones.add(stop.getFirstZoneAsString());
if (stop == ride.lastStop)
break;
}
}
ride.agency = tripPattern.route.getAgency().getId();
ride.route = tripPattern.route.getId();
ride.trip = tripSchedule.getOriginalTripTimes().trip.getId();
// TODO verify that times are in seconds after midnight
ride.startTime = transitPathLeg.fromTime();
ride.endTime = transitPathLeg.toTime();
// In the default fare service, we classify rides by mode.
ride.classifier = tripPattern.getMode();
return ride;
}
use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.
the class StreetSearch method route.
/**
* return access times (in seconds) by stop index
*/
void route(Place place, boolean fromOrigin) {
Vertex vertex = null;
if (place.stopId != null) {
vertex = graph.getVertex(place.stopId.getId());
}
if (vertex == null) {
vertex = new TemporaryStreetLocation(place.name, new Coordinate(place.coordinate.longitude(), place.coordinate.latitude()), new NonLocalizedString(place.name), !fromOrigin);
splitter.link(vertex);
}
List<StopAtDistance> stopAtDistanceList = nearbyStopFinder.findNearbyStopsViaStreets(Set.of(vertex), !fromOrigin, true);
if (stopAtDistanceList.isEmpty()) {
throw new RuntimeException("No stops found nearby: " + place);
}
for (StopAtDistance stopAtDistance : stopAtDistanceList) {
if (!(stopAtDistance.stop instanceof Stop))
continue;
int stopIndex = transitLayer.getIndexByStop((Stop) stopAtDistance.stop);
int accessTimeSec = (int) stopAtDistance.edges.stream().map(Edge::getDistanceMeters).collect(Collectors.summarizingDouble(Double::doubleValue)).getSum();
resultTimesSecByStopIndex.put(stopIndex, accessTimeSec);
pathsByStopIndex.put(stopIndex, stopAtDistance);
}
LOG.debug("Found {} {} stops", resultTimesSecByStopIndex.size(), fromOrigin ? "access" : "egress");
}
use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.
the class AlertToLegMapper method getAlertsForStopAndTrip.
private static Collection<TransitAlert> getAlertsForStopAndTrip(Graph graph, FeedScopedId stopId, FeedScopedId tripId, boolean checkParentStop) {
Stop stop = graph.index.getStopForId(stopId);
if (stop == null) {
return new ArrayList<>();
}
Collection<TransitAlert> alertsForStopAndTrip = graph.getTransitAlertService().getStopAndTripAlerts(stopId, tripId);
if (checkParentStop) {
if (alertsForStopAndTrip == null) {
alertsForStopAndTrip = new HashSet<>();
}
if (stop.isPartOfStation()) {
// Also check parent
Collection<TransitAlert> alerts = graph.getTransitAlertService().getStopAndTripAlerts(stop.getParentStation().getId(), tripId);
if (alerts != null) {
alertsForStopAndTrip.addAll(alerts);
}
}
// TODO SIRI: Add support for fetching alerts attached to MultiModal-stops
// if (stop.getMultiModalStation() != null) {
// //Also check multimodal parent
// FeedScopedId multimodalStopId = new FeedScopedId(stopId.getAgencyId(), stop.getMultiModalStation());
// Collection<AlertPatch> multimodalStopAlerts = graph.index.getAlertsForStopAndTrip(multimodalStopId, tripId);
// if (multimodalStopAlerts != null) {
// alertsForStopAndTrip.addAll(multimodalStopAlerts);
// }
// }
}
return alertsForStopAndTrip;
}
use of org.opentripplanner.model.Stop in project OpenTripPlanner by opentripplanner.
the class AlertToLegMapper method getAlertsForStop.
private static Collection<TransitAlert> getAlertsForStop(Graph graph, FeedScopedId stopId, boolean checkParentStop) {
Stop stop = graph.index.getStopForId(stopId);
if (stop == null) {
return new ArrayList<>();
}
Collection<TransitAlert> alertsForStop = graph.getTransitAlertService().getStopAlerts(stopId);
if (checkParentStop) {
if (alertsForStop == null) {
alertsForStop = new HashSet<>();
}
if (stop.isPartOfStation()) {
// Also check parent
Collection<TransitAlert> parentStopAlerts = graph.getTransitAlertService().getStopAlerts(stop.getParentStation().getId());
if (parentStopAlerts != null) {
alertsForStop.addAll(parentStopAlerts);
}
}
// TODO SIRI: Add support for fetching alerts attached to MultiModal-stops
// if (stop.getMultiModalStation() != null) {
// //Also check multimodal parent
// FeedScopedId multimodalStopId = new FeedScopedId(stopId.getAgencyId(), stop.getMultiModalStation());
// Collection<AlertPatch> multimodalStopAlerts = graph.index.getAlertsForStopId(multimodalStopId);
// if (multimodalStopAlerts != null) {
// alertsForStop.addAll(multimodalStopAlerts);
// }
// }
}
return alertsForStop;
}
Aggregations