Search in sources :

Example 11 with FeedScopedId

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;
}
Also used : Trip(org.opentripplanner.model.Trip) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) ArrayList(java.util.ArrayList) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 12 with FeedScopedId

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));
}
Also used : RoutingService(org.opentripplanner.routing.RoutingService) FeedScopedId(org.opentripplanner.model.FeedScopedId) AlertMapper(org.opentripplanner.api.mapping.AlertMapper) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 13 with FeedScopedId

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;
}
Also used : Agency(org.opentripplanner.model.Agency) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 14 with FeedScopedId

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));
}
Also used : FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 15 with FeedScopedId

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;
}
Also used : BannedStopSet(org.opentripplanner.routing.api.request.BannedStopSet) HashMap(java.util.HashMap) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Aggregations

FeedScopedId (org.opentripplanner.model.FeedScopedId)117 Trip (org.opentripplanner.model.Trip)32 Test (org.junit.Test)29 Stop (org.opentripplanner.model.Stop)25 TripPattern (org.opentripplanner.model.TripPattern)25 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)21 ArrayList (java.util.ArrayList)20 Route (org.opentripplanner.model.Route)15 HashSet (java.util.HashSet)11 List (java.util.List)11 Agency (org.opentripplanner.model.Agency)11 Collection (java.util.Collection)9 Map (java.util.Map)9 Collectors (java.util.stream.Collectors)9 ZonedDateTime (java.time.ZonedDateTime)8 TransitEntity (org.opentripplanner.model.TransitEntity)8 RoutingService (org.opentripplanner.routing.RoutingService)8 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)8 Notice (org.opentripplanner.model.Notice)7 Station (org.opentripplanner.model.Station)7