Search in sources :

Example 11 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)

Example 12 with Stop

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

the class DeferredValueConverterTest method testDouble.

@Test
public void testDouble() {
    Object value = convert(new Stop(), "lat", "47.1");
    assertEquals(new Double(47.1), value);
}
Also used : Stop(org.onebusaway.gtfs.model.Stop) Test(org.junit.Test)

Example 13 with Stop

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

the class DeferredValueConverterTest method testAgencAndId_ExistingAgencyId.

@Test
public void testAgencAndId_ExistingAgencyId() {
    Stop stop = new Stop();
    stop.setId(new AgencyAndId("2", "456"));
    Object value = convert(stop, "id", "123");
    assertEquals(new AgencyAndId("2", "123"), value);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) Test(org.junit.Test)

Example 14 with Stop

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

the class DeferredValueSetterTest method testInteger.

@Test
public void testInteger() {
    DeferredValueSetter setter = createSetter(1);
    Stop stop = new Stop();
    setter.setValue(BeanWrapperFactory.wrap(stop), "locationType");
    assertEquals(1, stop.getLocationType());
}
Also used : Stop(org.onebusaway.gtfs.model.Stop) Test(org.junit.Test)

Example 15 with Stop

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

the class GtfsRelationalDaoImplTest method testBart.

@Test
public void testBart() throws IOException {
    GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
    GtfsTestData.readGtfs(dao, GtfsTestData.getBartGtfs(), "BART");
    List<String> tripAgencyIds = dao.getTripAgencyIdsReferencingServiceId(new AgencyAndId("BART", "WKDY"));
    assertEquals(1, tripAgencyIds.size());
    assertEquals("BART", tripAgencyIds.get(0));
    Agency agency = dao.getAgencyForId("BART");
    List<Route> routes = dao.getRoutesForAgency(agency);
    assertEquals(10, routes.size());
    agency = dao.getAgencyForId("AirBART");
    routes = dao.getRoutesForAgency(agency);
    assertEquals(1, routes.size());
    Route route = dao.getRouteForId(new AgencyAndId("BART", "01"));
    List<Trip> trips = dao.getTripsForRoute(route);
    assertEquals(225, trips.size());
    Trip trip = dao.getTripForId(new AgencyAndId("BART", "15PB1"));
    List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
    assertEquals(12, stopTimes.size());
    // Ensure the stopTimes are in stop sequence order
    for (int i = 0; i < stopTimes.size() - 1; i++) assertTrue(stopTimes.get(i).getStopSequence() < stopTimes.get(i + 1).getStopSequence());
    Stop stop = dao.getStopForId(new AgencyAndId("BART", "DBRK"));
    stopTimes = dao.getStopTimesForStop(stop);
    assertEquals(584, stopTimes.size());
    List<ShapePoint> shapePoints = dao.getShapePointsForShapeId(new AgencyAndId("BART", "airbart-dn.csv"));
    assertEquals(50, shapePoints.size());
    for (int i = 0; i < shapePoints.size() - 1; i++) assertTrue(shapePoints.get(i).getSequence() < shapePoints.get(i + 1).getSequence());
    trip = dao.getTripForId(new AgencyAndId("AirBART", "M-FSAT1DN"));
    List<Frequency> frequencies = dao.getFrequenciesForTrip(trip);
    assertEquals(1, frequencies.size());
    Frequency frequency = frequencies.get(0);
    assertEquals(5 * 60 * 60, frequency.getStartTime());
    assertEquals(6 * 60 * 60, frequency.getEndTime());
    assertEquals(trip, frequency.getTrip());
    assertEquals(1200, frequency.getHeadwaySecs());
    ServiceCalendar calendar = dao.getCalendarForServiceId(new AgencyAndId("BART", "WKDY"));
    assertEquals(new ServiceDate(2007, 1, 1), calendar.getStartDate());
    List<ServiceCalendarDate> calendarDates = dao.getCalendarDatesForServiceId(new AgencyAndId("BART", "WKDY"));
    assertEquals(7, calendarDates.size());
}
Also used : ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate) Trip(org.onebusaway.gtfs.model.Trip) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Frequency(org.onebusaway.gtfs.model.Frequency) Route(org.onebusaway.gtfs.model.Route) StopTime(org.onebusaway.gtfs.model.StopTime) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Aggregations

Stop (org.onebusaway.gtfs.model.Stop)40 Test (org.junit.Test)29 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)24 StopTime (org.onebusaway.gtfs.model.StopTime)11 Trip (org.onebusaway.gtfs.model.Trip)11 Agency (org.onebusaway.gtfs.model.Agency)8 ShapePoint (org.onebusaway.gtfs.model.ShapePoint)7 Route (org.onebusaway.gtfs.model.Route)6 ServiceCalendar (org.onebusaway.gtfs.model.ServiceCalendar)6 FareAttribute (org.onebusaway.gtfs.model.FareAttribute)5 ServiceCalendarDate (org.onebusaway.gtfs.model.ServiceCalendarDate)5 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)5 GtfsRelationalDao (org.onebusaway.gtfs.services.GtfsRelationalDao)5 FareRule (org.onebusaway.gtfs.model.FareRule)4 GtfsMutableRelationalDao (org.onebusaway.gtfs.services.GtfsMutableRelationalDao)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 CsvEntityContextImpl (org.onebusaway.csv_entities.CsvEntityContextImpl)3 Frequency (org.onebusaway.gtfs.model.Frequency)3 Transfer (org.onebusaway.gtfs.model.Transfer)3