use of org.onebusaway.gtfs.model.Stop in project OpenTripPlanner by opentripplanner.
the class TimetableFilterTest method makeStopTimes.
private List<StopTime> makeStopTimes(Trip trip) {
StopTime[] stopTimes = new StopTime[stops.length];
int cumulativeTime = 7 * 3600;
for (int i = 0; i < stops.length; i++) {
Stop stop = stops[i];
StopTime st = new StopTime();
st.setStop(stop);
st.setArrivalTime(cumulativeTime);
// dwell time is 30 secs
cumulativeTime += 30;
st.setDepartureTime(cumulativeTime);
// hop time is 2 minutes
cumulativeTime += 120;
st.setPickupType(StopPattern.PICKDROP_SCHEDULED);
st.setDropOffType(StopPattern.PICKDROP_SCHEDULED);
st.setTrip(trip);
stopTimes[i] = st;
}
return Arrays.asList(stopTimes);
}
use of org.onebusaway.gtfs.model.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class HibernateGtfsRelationalDaoImplCaltrainTest method testGetStopTimesForStop.
@Test
public void testGetStopTimesForStop() {
Stop stop = _dao.getStopForId(aid("Menlo Park Caltrain"));
List<StopTime> stopTimes = _dao.getStopTimesForStop(stop);
assertEquals(208, stopTimes.size());
}
use of org.onebusaway.gtfs.model.Stop 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.Stop 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.Stop in project onebusaway-gtfs-modules by OneBusAway.
the class GtfsRelationalDaoImpl method getStopsForStation.
@Override
public List<Stop> getStopsForStation(Stop station) {
if (_stopsByStation == null) {
_stopsByStation = new HashMap<Stop, List<Stop>>();
for (Stop stop : getAllStops()) {
if (stop.getLocationType() == 0 && stop.getParentStation() != null) {
Stop parentStation = getStopForId(new AgencyAndId(stop.getId().getAgencyId(), stop.getParentStation()));
List<Stop> subStops = _stopsByStation.get(parentStation);
if (subStops == null) {
subStops = new ArrayList<Stop>(2);
_stopsByStation.put(parentStation, subStops);
}
subStops.add(stop);
}
}
}
return list(_stopsByStation.get(station));
}
Aggregations