Search in sources :

Example 1 with NoFutureDates

use of org.opentripplanner.graph_builder.issues.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, DataImportIssueStore issueStore) {
    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 (FeedScopedId sid : data.getServiceIds()) {
        agencies.add(sid.getFeedId());
        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.getFeedId());
            }
            // 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)) {
            issueStore.add(new NoFutureDates(agency));
        }
    }
}
Also used : ServiceDate(org.opentripplanner.model.calendar.ServiceDate) NoFutureDates(org.opentripplanner.graph_builder.issues.NoFutureDates) FeedScopedId(org.opentripplanner.model.FeedScopedId) Date(java.util.Date) ServiceDate(org.opentripplanner.model.calendar.ServiceDate) HashSet(java.util.HashSet)

Aggregations

Date (java.util.Date)1 HashSet (java.util.HashSet)1 NoFutureDates (org.opentripplanner.graph_builder.issues.NoFutureDates)1 FeedScopedId (org.opentripplanner.model.FeedScopedId)1 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)1