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);
}
}
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()));
}
}
}
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());
}
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);
}
}
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());
}
Aggregations