Search in sources :

Example 96 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class OtpTransitServiceBuilder method removeTripsWithNoneExistingServiceIds.

/**
 * Remove all trips witch reference none existing service ids
 */
private void removeTripsWithNoneExistingServiceIds() {
    Set<FeedScopedId> serviceIds = findAllServiceIds();
    int orgSize = tripsById.size();
    tripsById.removeIf(t -> !serviceIds.contains(t.getServiceId()));
    logRemove("Trip", orgSize, tripsById.size(), "Trip service id does not exist.");
}
Also used : FeedScopedId(org.opentripplanner.model.FeedScopedId) ShapePoint(org.opentripplanner.model.ShapePoint)

Example 97 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class IndexAPI method getAlertsForStop.

/**
 * Return all alerts for a stop
 */
@GET
@Path("/stops/{stopId}/alerts")
public Collection<ApiAlert> getAlertsForStop(@PathParam("stopId") String stopId) {
    RoutingService routingService = createRoutingService();
    // TODO: Add locale
    AlertMapper alertMapper = new AlertMapper(null);
    FeedScopedId id = createId("stopId", stopId);
    return alertMapper.mapToApi(routingService.getTransitAlertService().getStopAlerts(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 98 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class IndexAPI method getAlertsForPattern.

/**
 * Return all alerts for a pattern
 */
@GET
@Path("/patterns/{patternId}/alerts")
public Collection<ApiAlert> getAlertsForPattern(@PathParam("patternId") String patternId) {
    RoutingService routingService = createRoutingService();
    // TODO: Add locale
    AlertMapper alertMapper = new AlertMapper(null);
    FeedScopedId id = createId("patternId", patternId);
    return alertMapper.mapToApi(routingService.getTransitAlertService().getTripPatternAlerts(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 99 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class CalendarServiceDataFactoryImpl method createData.

private CalendarServiceData createData() {
    CalendarServiceData data = new CalendarServiceData();
    setTimeZonesForAgencies(data);
    int index = 0;
    for (FeedScopedId serviceId : serviceIds) {
        index++;
        LOG.debug("serviceId=" + serviceId + " (" + index + "/" + serviceIds.size() + ")");
        TimeZone serviceIdTimeZone = data.getTimeZoneForAgencyId(data.getAgencyIds().stream().filter(agency -> agency.getFeedId().equals(serviceId.getFeedId())).findAny().orElse(null));
        if (serviceIdTimeZone == null) {
            serviceIdTimeZone = TimeZone.getDefault();
        }
        Set<ServiceDate> activeDates = getServiceDatesForServiceId(serviceId, serviceIdTimeZone);
        List<ServiceDate> serviceDates = new ArrayList<>(activeDates);
        Collections.sort(serviceDates);
        data.putServiceDatesForServiceId(serviceId, serviceDates);
    }
    return data;
}
Also used : CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) FeedScopedId(org.opentripplanner.model.FeedScopedId) Logger(org.slf4j.Logger) Date(java.util.Date) TimeZone(java.util.TimeZone) Collection(java.util.Collection) ServiceCalendar(org.opentripplanner.model.calendar.ServiceCalendar) LoggerFactory(org.slf4j.LoggerFactory) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Set(java.util.Set) Agency(org.opentripplanner.model.Agency) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) CalendarServiceData(org.opentripplanner.model.calendar.CalendarServiceData) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) Calendar(java.util.Calendar) Map(java.util.Map) ServiceCalendarDate(org.opentripplanner.model.calendar.ServiceCalendarDate) Collections(java.util.Collections) TimeZone(java.util.TimeZone) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) ArrayList(java.util.ArrayList) FeedScopedId(org.opentripplanner.model.FeedScopedId)

Example 100 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class StopToParentStationLinker method link.

void link() {
    for (Map.Entry<StationElement, FeedScopedId> entry : stationElementsToStations.entrySet()) {
        StationElement stationElement = entry.getKey();
        FeedScopedId stationId = entry.getValue();
        Station otpStation = otpStations.get(stationId);
        if (otpStation == null) {
            issueStore.add(new ParentStationNotFound(stationElement, stationId.getId()));
        } else {
            stationElement.setParentStation(otpStation);
            if (stationElement instanceof Stop) {
                otpStation.addChildStop((Stop) stationElement);
            }
        }
    }
    for (Map.Entry<BoardingArea, FeedScopedId> entry : boardingAreasToStops.entrySet()) {
        BoardingArea boardingArea = entry.getKey();
        FeedScopedId stopId = entry.getValue();
        StationElement otpStop = otpStationElements.get(stopId);
        if (!(otpStop instanceof Stop)) {
            issueStore.add(new ParentStationNotFound(boardingArea, stopId.getId()));
        } else {
            boardingArea.setParentStop((Stop) otpStop);
            ((Stop) otpStop).addBoardingArea(boardingArea);
            boardingArea.setParentStation(otpStop.getParentStation());
        }
    }
}
Also used : Station(org.opentripplanner.model.Station) Stop(org.opentripplanner.model.Stop) StationElement(org.opentripplanner.model.StationElement) FeedScopedId(org.opentripplanner.model.FeedScopedId) Map(java.util.Map) HashMap(java.util.HashMap) ParentStationNotFound(org.opentripplanner.graph_builder.issues.ParentStationNotFound) BoardingArea(org.opentripplanner.model.BoardingArea)

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