use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsHibernateReaderExampleMain method main.
public static void main(String[] args) throws IOException {
if (!(args.length == 1 || args.length == 2)) {
System.err.println("usage: gtfsPath [hibernate-config.xml]");
System.exit(-1);
}
String resource = "classpath:org/onebusaway/gtfs/examples/hibernate-configuration-examples.xml";
if (args.length == 2)
resource = args[1];
HibernateGtfsFactory factory = createHibernateGtfsFactory(resource);
GtfsReader reader = new GtfsReader();
reader.setInputLocation(new File(args[0]));
GtfsMutableRelationalDao dao = factory.getDao();
reader.setEntityStore(dao);
reader.run();
Collection<Stop> stops = dao.getAllStops();
for (Stop stop : stops) System.out.println(stop.getName());
CalendarService calendarService = factory.getCalendarService();
Set<AgencyAndId> serviceIds = calendarService.getServiceIds();
for (AgencyAndId serviceId : serviceIds) {
Set<ServiceDate> dates = calendarService.getServiceDatesForServiceId(serviceId);
ServiceDate from = null;
ServiceDate to = null;
for (ServiceDate date : dates) {
from = min(from, date);
to = max(to, date);
}
System.out.println("serviceId=" + serviceId + " from=" + from + " to=" + to);
}
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class HibernateGtfsRelationalDaoImplCaltrainTest method testGetStopById.
@Test
public void testGetStopById() {
AgencyAndId id = aid("Gilroy Caltrain");
Stop stop = _dao.getStopForId(id);
assertEquals(id, stop.getId());
assertNull(stop.getCode());
assertEquals("7150 Monterey Street, Gilroy", stop.getDesc());
assertEquals(37.003084, stop.getLat(), 0.000001);
assertEquals(-121.567091, stop.getLon(), 0.000001);
assertEquals(0, stop.getLocationType());
assertEquals("Gilroy Caltrain", stop.getName());
assertEquals("6", stop.getZoneId());
assertNull(stop.getUrl());
assertNull(stop.getParentStation());
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class HibernateGtfsRelationalImplBartTest method testCalendarForServiceId.
@Test
public void testCalendarForServiceId() {
ServiceCalendar calendar = _dao.getCalendarForServiceId(new AgencyAndId("BART", "WKDY"));
assertEquals(new ServiceDate(2007, 1, 1), calendar.getStartDate());
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class HibernateGtfsRelationalImplBartTest method testCalendarDateForServiceId.
@Test
public void testCalendarDateForServiceId() {
List<ServiceCalendarDate> calendarDates = _dao.getCalendarDatesForServiceId(new AgencyAndId("BART", "WKDY"));
assertEquals(7, calendarDates.size());
}
use of org.onebusaway.gtfs.model.AgencyAndId in project onebusaway-gtfs-modules by OneBusAway.
the class EntityRetentionGraph method retainTrip.
private void retainTrip(Trip trip, boolean retainUp) {
if (retainUp) {
for (StopTime stopTime : _dao.getStopTimesForTrip(trip)) retainUp(stopTime);
if (_retainBlocks && trip.getBlockId() != null) {
AgencyAndId blockId = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId());
retainUp(new BlockIdKey(blockId));
}
for (Frequency frequency : _dao.getFrequenciesForTrip(trip)) retainUp(frequency);
} else {
retainDown(trip.getRoute());
retainDown(new ServiceIdKey(trip.getServiceId()));
AgencyAndId shapeId = trip.getShapeId();
if (shapeId != null && shapeId.hasValues())
retainDown(new ShapeIdKey(shapeId));
}
}
Aggregations