Search in sources :

Example 1 with NoFutureDates

use of org.opentripplanner.graph_builder.annotation.NoFutureDates in project OpenTripPlanner by opentripplanner.

the class Graph method updateTransitFeedValidity.

// Infer the time period covered by the transit feed
public void updateTransitFeedValidity(CalendarServiceData data) {
    long now = new Date().getTime() / 1000;
    final long SEC_IN_DAY = 24 * 60 * 60;
    HashSet<String> agenciesWithFutureDates = new HashSet<String>();
    HashSet<String> agencies = new HashSet<String>();
    for (AgencyAndId sid : data.getServiceIds()) {
        agencies.add(sid.getAgencyId());
        for (ServiceDate sd : data.getServiceDatesForServiceId(sid)) {
            // Adjust for timezone, assuming there is only one per graph.
            long t = sd.getAsDate(getTimeZone()).getTime() / 1000;
            if (t > now) {
                agenciesWithFutureDates.add(sid.getAgencyId());
            }
            // assume feed is unreliable after midnight on last service day
            long u = t + SEC_IN_DAY;
            if (t < this.transitServiceStarts)
                this.transitServiceStarts = t;
            if (u > this.transitServiceEnds)
                this.transitServiceEnds = u;
        }
    }
    for (String agency : agencies) {
        if (!agenciesWithFutureDates.contains(agency)) {
            LOG.warn(this.addBuilderAnnotation(new NoFutureDates(agency)));
        }
    }
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) NoFutureDates(org.opentripplanner.graph_builder.annotation.NoFutureDates) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate)

Aggregations

AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)1 NoFutureDates (org.opentripplanner.graph_builder.annotation.NoFutureDates)1