Search in sources :

Example 16 with Agency

use of org.onebusaway.gtfs.model.Agency in project OpenTripPlanner by opentripplanner.

the class CalendarServiceDataFactoryImpl method setTimeZonesForAgencies.

private void setTimeZonesForAgencies(CalendarServiceData data) {
    for (Agency agency : _dao.getAllAgencies()) {
        TimeZone timeZone = TimeZone.getTimeZone(agency.getTimezone());
        if (timeZone.getID().equals("GMT") && !agency.getTimezone().toUpperCase().equals("GMT")) {
            throw new UnknownAgencyTimezoneException(agency.getName(), agency.getTimezone());
        }
        data.putTimeZoneForAgencyId(agency.getId(), timeZone);
    }
}
Also used : TimeZone(java.util.TimeZone) Agency(org.onebusaway.gtfs.model.Agency) UnknownAgencyTimezoneException(org.onebusaway.gtfs.impl.calendar.UnknownAgencyTimezoneException)

Example 17 with Agency

use of org.onebusaway.gtfs.model.Agency in project OpenTripPlanner by opentripplanner.

the class RoutingContext method setServiceDays.

/**
 * Cache ServiceDay objects representing which services are running yesterday, today, and tomorrow relative to the search time. This information
 * is very heavily used (at every transit boarding) and Date operations were identified as a performance bottleneck. Must be called after the
 * TraverseOptions already has a CalendarService set.
 */
private void setServiceDays() {
    Calendar c = Calendar.getInstance();
    c.setTime(new Date(opt.getSecondsSinceEpoch() * 1000));
    c.setTimeZone(graph.getTimeZone());
    final ServiceDate serviceDate = new ServiceDate(c);
    this.serviceDays = new ArrayList<ServiceDay>(3);
    if (calendarService == null && graph.getCalendarService() != null && (opt.modes == null || opt.modes.contains(TraverseMode.TRANSIT))) {
        LOG.warn("RoutingContext has no CalendarService. Transit will never be boarded.");
        return;
    }
    for (String feedId : graph.getFeedIds()) {
        for (Agency agency : graph.getAgencies(feedId)) {
            addIfNotExists(this.serviceDays, new ServiceDay(graph, serviceDate.previous(), calendarService, agency.getId()));
            addIfNotExists(this.serviceDays, new ServiceDay(graph, serviceDate, calendarService, agency.getId()));
            addIfNotExists(this.serviceDays, new ServiceDay(graph, serviceDate.next(), calendarService, agency.getId()));
        }
    }
}
Also used : ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Agency(org.onebusaway.gtfs.model.Agency) Calendar(java.util.Calendar) LineString(com.vividsolutions.jts.geom.LineString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) Date(java.util.Date) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate)

Example 18 with Agency

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

the class HibernateGtfsRelationalDaoImplCaltrainTest method testGetAgencyForId.

@Test
public void testGetAgencyForId() {
    Agency agency = _dao.getAgencyForId(_agencyId);
    assertNotNull(agency);
    assertEquals(_agencyId, agency.getId());
    assertEquals("Caltrain", agency.getName());
    assertEquals("http://www.caltrain.com", agency.getUrl());
    assertEquals("America/Los_Angeles", agency.getTimezone());
    assertNull(agency.getLang());
    assertNull(agency.getPhone());
}
Also used : Agency(org.onebusaway.gtfs.model.Agency) Test(org.junit.Test)

Example 19 with Agency

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

the class CalendarServiceDataFactoryImpl method setTimeZonesForAgencies.

private void setTimeZonesForAgencies(CalendarServiceData data) {
    for (Agency agency : _dao.getAllAgencies()) {
        TimeZone timeZone = TimeZone.getTimeZone(agency.getTimezone());
        if (timeZone.getID().equals("GMT") && !agency.getTimezone().toUpperCase().equals("GMT")) {
            throw new UnknownAgencyTimezoneException(agency.getName(), agency.getTimezone());
        }
        data.putTimeZoneForAgencyId(agency.getId(), timeZone);
    }
}
Also used : TimeZone(java.util.TimeZone) Agency(org.onebusaway.gtfs.model.Agency)

Example 20 with Agency

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

the class GtfsMappingTest method testAgency.

@Test
public void testAgency() throws CsvEntityIOException, IOException {
    StringBuilder b = new StringBuilder();
    b.append("agency_id,agency_name,agency_url,agency_timezone,agency_fare_url,agency_lang,agency_phone,agency_email\n");
    b.append("1,Agency,http://agency/,Amercia/Los_Angeles,http://agency/fare_url,en,800-555-BUS1,agency@email.com\n");
    _reader.readEntities(Agency.class, new StringReader(b.toString()));
    Agency agency = _dao.getAgencyForId("1");
    assertEquals("1", agency.getId());
    assertEquals("Agency", agency.getName());
    assertEquals("http://agency/", agency.getUrl());
    assertEquals("Amercia/Los_Angeles", agency.getTimezone());
    assertEquals("http://agency/fare_url", agency.getFareUrl());
    assertEquals("en", agency.getLang());
    assertEquals("800-555-BUS1", agency.getPhone());
    assertEquals("agency@email.com", agency.getEmail());
}
Also used : Agency(org.onebusaway.gtfs.model.Agency) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

Agency (org.onebusaway.gtfs.model.Agency)57 Test (org.junit.Test)28 Route (org.onebusaway.gtfs.model.Route)21 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)20 Trip (org.onebusaway.gtfs.model.Trip)19 Stop (org.onebusaway.gtfs.model.Stop)18 StopTime (org.onebusaway.gtfs.model.StopTime)15 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)10 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)9 ArrayList (java.util.ArrayList)8 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)7 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)7 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)7 TransitGraphImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TransitGraphImpl)6 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)5 CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)5 TripEntryImpl (org.onebusaway.transit_data_federation.impl.transit_graph.TripEntryImpl)5 ShapePoints (org.onebusaway.transit_data_federation.model.ShapePoints)5 StopPattern (org.opentripplanner.model.StopPattern)5 Graph (org.opentripplanner.routing.graph.Graph)5