use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class SiriFuzzyTripMatcher method getTripIdForTripShortNameServiceDateAndMode.
List<FeedScopedId> getTripIdForTripShortNameServiceDateAndMode(String tripShortName, ServiceDate serviceDate, TraverseMode traverseMode) /*, TransmodelTransportSubmode transportSubmode*/
{
Set<Trip> cachedTripsBySiriId = getCachedTripsBySiriId(tripShortName);
if (cachedTripsBySiriId.isEmpty()) {
cachedTripsBySiriId = getCachedTripsByVehicleRef(tripShortName);
}
List<FeedScopedId> matches = new ArrayList<>();
for (Trip trip : cachedTripsBySiriId) {
if (trip.getRoute().getMode().equals(traverseMode)) /*|| trip.getTransportSubmode().equals(transportSubmode)*/
{
Set<ServiceDate> serviceDates = routingService.getCalendarService().getServiceDatesForServiceId(trip.getServiceId());
if (serviceDates.contains(serviceDate) && trip.getTripShortName() != null && trip.getTripShortName().equals(tripShortName)) {
matches.add(trip.getId());
}
}
}
return matches;
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class IndexAPI method getAlertsForTrip.
/**
* Return all alerts for a trip
*/
@GET
@Path("/trips/{tripId}/alerts")
public Collection<ApiAlert> getAlertsForTrip(@PathParam("tripId") String tripId) {
RoutingService routingService = createRoutingService();
// TODO: Add locale
AlertMapper alertMapper = new AlertMapper(null);
FeedScopedId id = createId("tripId", tripId);
return alertMapper.mapToApi(routingService.getTransitAlertService().getTripAlerts(id));
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class AgencyMapper method doMap.
private Agency doMap(org.onebusaway.gtfs.model.Agency rhs) {
Agency lhs = new Agency(new FeedScopedId(feedId, rhs.getId()), rhs.getName(), rhs.getTimezone());
lhs.setUrl(rhs.getUrl());
lhs.setLang(rhs.getLang());
lhs.setPhone(rhs.getPhone());
lhs.setFareUrl(rhs.getFareUrl());
lhs.setBrandingUrl(rhs.getBrandingUrl());
return lhs;
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class StopToParentStationLinker method addBoardingArea.
void addBoardingArea(BoardingArea boardingArea, String stopId) {
boardingAreas.add(boardingArea);
boardingAreasToStops.put(boardingArea, new FeedScopedId(boardingArea.getId().getFeedId(), stopId));
}
use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.
the class RoutingResource method makeBannedTripMap.
/**
* Take a string in the format agency:id or agency:id:1:2:3:4.
* TODO Improve Javadoc. What does this even mean? Why are there so many colons and numbers?
* Convert to a Map from trip --> set of int.
*/
public HashMap<FeedScopedId, BannedStopSet> makeBannedTripMap(String banned) {
if (banned == null) {
return null;
}
HashMap<FeedScopedId, BannedStopSet> bannedTripMap = new HashMap<FeedScopedId, BannedStopSet>();
String[] tripStrings = banned.split(",");
for (String tripString : tripStrings) {
// TODO this apparently allows banning stops within a trip with integers. Why?
String[] parts = tripString.split(":");
// throw exception?
if (parts.length < 2)
continue;
String agencyIdString = parts[0];
String tripIdString = parts[1];
FeedScopedId tripId = new FeedScopedId(agencyIdString, tripIdString);
BannedStopSet bannedStops;
if (parts.length == 2) {
bannedStops = BannedStopSet.ALL;
} else {
bannedStops = new BannedStopSet();
for (int i = 2; i < parts.length; ++i) {
bannedStops.add(Integer.parseInt(parts[i]));
}
}
bannedTripMap.put(tripId, bannedStops);
}
return bannedTripMap;
}
Aggregations