Search in sources :

Example 51 with Stop

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);
}
Also used : Stop(org.onebusaway.gtfs.model.Stop) StopTime(org.onebusaway.gtfs.model.StopTime)

Example 52 with Stop

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());
}
Also used : Stop(org.onebusaway.gtfs.model.Stop) StopTime(org.onebusaway.gtfs.model.StopTime) Test(org.junit.Test)

Example 53 with Stop

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());
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) Test(org.junit.Test)

Example 54 with Stop

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);
    }
}
Also used : GtfsMutableRelationalDao(org.onebusaway.gtfs.services.GtfsMutableRelationalDao) GtfsReader(org.onebusaway.gtfs.serialization.GtfsReader) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) HibernateGtfsFactory(org.onebusaway.gtfs.services.HibernateGtfsFactory) File(java.io.File) CalendarService(org.onebusaway.gtfs.services.calendar.CalendarService)

Example 55 with Stop

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));
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Stop (org.onebusaway.gtfs.model.Stop)160 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)75 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)49 Trip (org.onebusaway.gtfs.model.Trip)40 Test (org.junit.Test)39 ArrayList (java.util.ArrayList)33 StopTime (org.onebusaway.gtfs.model.StopTime)33 Route (org.onebusaway.gtfs.model.Route)28 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)23 Agency (org.onebusaway.gtfs.model.Agency)19 Vertex (org.opentripplanner.routing.graph.Vertex)18 HashMap (java.util.HashMap)14 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)13 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)11 LineString (com.vividsolutions.jts.geom.LineString)10 List (java.util.List)10 GET (javax.ws.rs.GET)10 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)10 GraphPath (org.opentripplanner.routing.spt.GraphPath)10 Coordinate (com.vividsolutions.jts.geom.Coordinate)9