Search in sources :

Example 1 with LocalizedServiceId

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

the class CalendarServiceImpl method getServiceDates.

private Map<LocalizedServiceId, List<Date>> getServiceDates(ServiceIdIntervals serviceIdIntervals, ServiceIdOp op, Date from, Date to, boolean includeNextDate) {
    CalendarServiceData allData = getData();
    Map<LocalizedServiceId, List<Date>> results = new HashMap<LocalizedServiceId, List<Date>>();
    for (Map.Entry<LocalizedServiceId, ServiceInterval> entry : serviceIdIntervals) {
        LocalizedServiceId serviceId = entry.getKey();
        ServiceInterval interval = entry.getValue();
        List<Date> serviceDates = getServiceDates(allData, serviceId, interval, op, from, to, includeNextDate);
        if (!serviceDates.isEmpty())
            results.put(serviceId, serviceDates);
    }
    return results;
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) HashMap(java.util.HashMap) LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) ServiceInterval(org.onebusaway.gtfs.model.calendar.ServiceInterval) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date)

Example 2 with LocalizedServiceId

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

the class CalendarServiceImplSyntheticTest method testGetServiceDatesWithinRange06.

@Test
public void testGetServiceDatesWithinRange06() {
    Date from = date("2010-02-02 00:30 Pacific Standard Time");
    Date to = date("2010-02-02 00:45 Pacific Standard Time");
    Map<LocalizedServiceId, List<Date>> result = service.getServiceDateArrivalsWithinRange(intervals, from, to);
    assertEquals(1, result.size());
    List<Date> dates = result.get(lsid1);
    assertEquals(1, dates.size());
    assertTrue(dates.contains(d1.getAsDate(tz)));
    result = service.getServiceDateDeparturesWithinRange(intervals, from, to);
    assertEquals(1, result.size());
    dates = result.get(lsid1);
    assertEquals(1, dates.size());
    assertTrue(dates.contains(d1.getAsDate(tz)));
}
Also used : LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) ArrayList(java.util.ArrayList) List(java.util.List) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date) Test(org.junit.Test)

Example 3 with LocalizedServiceId

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

the class CalendarServiceImplSyntheticTest method testGetServiceDatesWithinRange03.

@Test
public void testGetServiceDatesWithinRange03() {
    Date from = date("2010-02-02 03:30 Pacific Standard Time");
    Date to = date("2010-02-02 03:45 Pacific Standard Time");
    Map<LocalizedServiceId, List<Date>> result = service.getServiceDateArrivalsWithinRange(intervals, from, to);
    assertEquals(0, result.size());
}
Also used : LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) ArrayList(java.util.ArrayList) List(java.util.List) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date) Test(org.junit.Test)

Example 4 with LocalizedServiceId

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

the class CalendarServiceImplSyntheticTest method testGetServiceDatesWithinRange07.

@Test
public void testGetServiceDatesWithinRange07() {
    Date from = date("2010-02-02 00:30 Pacific Standard Time");
    Date to = date("2010-02-02 01:45 Pacific Standard Time");
    Map<LocalizedServiceId, List<Date>> result = service.getServiceDateArrivalsWithinRange(intervals, from, to);
    assertEquals(1, result.size());
    List<Date> dates = result.get(lsid1);
    assertEquals(1, dates.size());
    assertTrue(dates.contains(d1.getAsDate(tz)));
    result = service.getServiceDateDeparturesWithinRange(intervals, from, to);
    assertEquals(1, result.size());
    dates = result.get(lsid1);
    assertEquals(1, dates.size());
    assertTrue(dates.contains(d1.getAsDate(tz)));
    result = service.getServiceDatesWithinRange(intervals, from, to);
    assertEquals(1, result.size());
    dates = result.get(lsid1);
    assertEquals(1, dates.size());
    assertTrue(dates.contains(d1.getAsDate(tz)));
}
Also used : LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) ArrayList(java.util.ArrayList) List(java.util.List) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date) Test(org.junit.Test)

Example 5 with LocalizedServiceId

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

the class CalendarServiceImplSyntheticTest method testGetServiceDatesWithinRange05.

@Test
public void testGetServiceDatesWithinRange05() {
    Date from = date("2010-02-02 04:30 Pacific Standard Time");
    Date to = date("2010-02-02 04:45 Pacific Standard Time");
    Map<LocalizedServiceId, List<Date>> result = service.getServiceDateDeparturesWithinRange(intervals, from, to);
    assertEquals(0, result.size());
}
Also used : LocalizedServiceId(org.onebusaway.gtfs.model.calendar.LocalizedServiceId) ArrayList(java.util.ArrayList) List(java.util.List) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)11 LocalizedServiceId (org.onebusaway.gtfs.model.calendar.LocalizedServiceId)11 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)11 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 List (java.util.List)8 CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)4 TimeZone (java.util.TimeZone)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)3 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)2 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Agency (org.onebusaway.gtfs.model.Agency)1 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)1 Trip (org.onebusaway.gtfs.model.Trip)1 ServiceInterval (org.onebusaway.gtfs.model.calendar.ServiceInterval)1