Search in sources :

Example 86 with ServiceDate

use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.

the class CalendarServiceImpl method isLocalizedServiceIdActiveOnDate.

@Override
public boolean isLocalizedServiceIdActiveOnDate(LocalizedServiceId localizedServiceId, Date serviceDate) {
    // TODO : Make this more efficient?
    CalendarServiceData data = getData();
    List<Date> dates = data.getDatesForLocalizedServiceId(localizedServiceId);
    return Collections.binarySearch(dates, serviceDate) >= 0;
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date)

Example 87 with ServiceDate

use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.

the class AnomalyCheckFutureTripCounts method constructDate.

private Date constructDate(ServiceDate date) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, date.getYear());
    calendar.set(Calendar.MONTH, date.getMonth() - 1);
    calendar.set(Calendar.DATE, date.getDay());
    Date date1 = calendar.getTime();
    date1 = removeTime(date1);
    return date1;
}
Also used : ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate)

Example 88 with ServiceDate

use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.

the class CountAndTest method constructDate.

private Date constructDate(ServiceDate date) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, date.getYear());
    calendar.set(Calendar.MONTH, date.getMonth() - 1);
    calendar.set(Calendar.DATE, date.getDay());
    Date date1 = calendar.getTime();
    date1 = removeTime(date1);
    return date1;
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate)

Example 89 with ServiceDate

use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.

the class CountAndTestBus method constructDate.

private Date constructDate(ServiceDate date) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, date.getYear());
    calendar.set(Calendar.MONTH, date.getMonth() - 1);
    calendar.set(Calendar.DATE, date.getDay());
    Date date1 = calendar.getTime();
    date1 = removeTime(date1);
    return date1;
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate)

Example 90 with ServiceDate

use of org.onebusaway.gtfs.model.calendar.ServiceDate in project onebusaway-gtfs-modules by OneBusAway.

the class CountAndTestBus method tripIsThisWeek.

private boolean tripIsThisWeek(Set<ServiceDate> serviceDates) {
    Date today = removeTime(new Date());
    Date inOneWeek = removeTime(addDays(new Date(), 7));
    for (ServiceDate calDate : serviceDates) {
        Date date = removeTime(calDate.getAsDate());
        if (date.after(today) && date.before(inOneWeek)) {
            return true;
        }
    }
    return false;
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate)

Aggregations

ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)134 Test (org.junit.Test)49 Date (java.util.Date)46 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)45 ArrayList (java.util.ArrayList)23 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)23 Calendar (java.util.Calendar)22 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)22 HashSet (java.util.HashSet)17 ServiceIdActivation (org.onebusaway.transit_data_federation.services.transit_graph.ServiceIdActivation)14 CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)13 CalendarService (org.onebusaway.gtfs.services.calendar.CalendarService)13 Set (java.util.Set)11 Trip (org.onebusaway.gtfs.model.Trip)11 TimeZone (java.util.TimeZone)10 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)10 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)9 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)9 Agency (org.onebusaway.gtfs.model.Agency)8 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)7