Search in sources :

Example 36 with Stop

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

the class DeferredValueConverterTest method testAgencAndId_DefaultAgencyId.

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

Example 37 with Stop

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

the class GtfsReaderTest method testCaltrain.

@Test
public void testCaltrain() throws IOException, ParseException {
    File resourcePath = GtfsTestData.getCaltrainGtfs();
    String agencyId = "Caltrain";
    GtfsDao entityStore = processFeed(resourcePath, agencyId, false);
    Collection<Agency> agencies = entityStore.getAllAgencies();
    assertEquals(1, agencies.size());
    Agency agency = entityStore.getAgencyForId(agencyId);
    assertNotNull(agency);
    assertEquals("Caltrain", agency.getName());
    assertEquals("http://www.caltrain.com", agency.getUrl());
    assertEquals("America/Los_Angeles", agency.getTimezone());
    assertNull(agency.getPhone());
    assertNull(agency.getLang());
    Collection<Route> routes = entityStore.getAllRoutes();
    assertEquals(3, routes.size());
    AgencyAndId routeBulletId = new AgencyAndId(agencyId, "ct_bullet");
    Route routeBullet = entityStore.getRouteForId(routeBulletId);
    assertEquals(routeBulletId, routeBullet.getId());
    assertEquals(agency, routeBullet.getAgency());
    assertNull(routeBullet.getShortName());
    assertEquals("Bullet", routeBullet.getLongName());
    assertNull(routeBullet.getDesc());
    assertEquals(2, routeBullet.getType());
    assertNull(routeBullet.getUrl());
    assertNull(routeBullet.getColor());
    assertEquals("ff0000", routeBullet.getTextColor());
    Route routeLocal = entityStore.getRouteForId(new AgencyAndId(agencyId, "ct_local"));
    Collection<Stop> stops = entityStore.getAllStops();
    assertEquals(31, stops.size());
    AgencyAndId stopAId = new AgencyAndId(agencyId, "San Francisco Caltrain");
    Stop stopA = entityStore.getStopForId(stopAId);
    assertEquals(stopAId, stopA.getId());
    assertNull(stopA.getCode());
    assertEquals("700 4th Street, San Francisco", stopA.getDesc());
    assertEquals(37.7764393371, stopA.getLat(), 0.000001);
    assertEquals(-122.394322993, stopA.getLon(), 0.000001);
    assertEquals(0, stopA.getLocationType());
    assertEquals("San Francisco Caltrain", stopA.getName());
    assertEquals("1", stopA.getZoneId());
    assertNull(stopA.getUrl());
    AgencyAndId stopBId = new AgencyAndId(agencyId, "Gilroy Caltrain");
    Stop stopB = entityStore.getStopForId(stopBId);
    assertEquals(stopBId, stopB.getId());
    assertNull(stopB.getCode());
    assertEquals("7150 Monterey Street, Gilroy", stopB.getDesc());
    assertEquals(37.003084, stopB.getLat(), 0.000001);
    assertEquals(-121.567091, stopB.getLon(), 0.000001);
    assertEquals(0, stopB.getLocationType());
    assertEquals("Gilroy Caltrain", stopB.getName());
    assertEquals("6", stopB.getZoneId());
    assertNull(stopB.getUrl());
    Collection<Trip> trips = entityStore.getAllTrips();
    assertEquals(260, trips.size());
    AgencyAndId tripAId = new AgencyAndId(agencyId, "10101272009");
    Trip tripA = entityStore.getTripForId(tripAId);
    assertEquals(tripAId, tripA.getId());
    assertNull(tripA.getBlockId());
    assertEquals("0", tripA.getDirectionId());
    assertEquals(routeLocal, tripA.getRoute());
    assertEquals(new AgencyAndId(agencyId, "WD01272009"), tripA.getServiceId());
    assertEquals(new AgencyAndId(agencyId, "cal_sj_sf"), tripA.getShapeId());
    assertEquals("San Jose to San Francisco", tripA.getTripHeadsign());
    Collection<StopTime> stopTimes = entityStore.getAllStopTimes();
    assertEquals(4712, stopTimes.size());
    StopTime stopTimeA = stopTimes.iterator().next();
    assertEquals(entityStore.getTripForId(new AgencyAndId(agencyId, "10101272009")), stopTimeA.getTrip());
    assertEquals(21120, stopTimeA.getArrivalTime());
    assertEquals(21120, stopTimeA.getDepartureTime());
    assertEquals(entityStore.getStopForId(new AgencyAndId(agencyId, "22nd Street Caltrain")), stopTimeA.getStop());
    assertEquals(21, stopTimeA.getStopSequence());
    assertNull(stopTimeA.getStopHeadsign());
    assertEquals(0, stopTimeA.getPickupType());
    assertEquals(0, stopTimeA.getDropOffType());
    assertFalse(stopTimeA.isShapeDistTraveledSet());
    Collection<ShapePoint> shapePoints = entityStore.getAllShapePoints();
    assertEquals(2677, shapePoints.size());
    AgencyAndId shapeId = new AgencyAndId(agencyId, "cal_sf_gil");
    ShapePoint shapePointA = getShapePoint(shapePoints, shapeId, 1);
    assertEquals(shapeId, shapePointA.getShapeId());
    assertEquals(1, shapePointA.getSequence());
    assertEquals(37.776439059278346, shapePointA.getLat(), 0.0);
    assertEquals(-122.39441156387329, shapePointA.getLon(), 0.0);
    assertFalse(shapePointA.isDistTraveledSet());
    Collection<ServiceCalendar> calendars = entityStore.getAllCalendars();
    assertEquals(6, calendars.size());
    ServiceCalendar calendarA = entityStore.getCalendarForId(new Integer(1));
    assertEquals(new Integer(1), calendarA.getId());
    assertEquals(new AgencyAndId(agencyId, "SN01272009"), calendarA.getServiceId());
    assertEquals(new ServiceDate(2009, 3, 2), calendarA.getStartDate());
    assertEquals(new ServiceDate(2019, 3, 2), calendarA.getEndDate());
    assertEquals(0, calendarA.getMonday());
    assertEquals(0, calendarA.getTuesday());
    assertEquals(0, calendarA.getWednesday());
    assertEquals(0, calendarA.getThursday());
    assertEquals(0, calendarA.getFriday());
    assertEquals(1, calendarA.getSaturday());
    assertEquals(1, calendarA.getSunday());
    Collection<ServiceCalendarDate> calendarDates = entityStore.getAllCalendarDates();
    assertEquals(10, calendarDates.size());
    ServiceCalendarDate cd = entityStore.getCalendarDateForId(new Integer(1));
    assertEquals(new Integer(1), cd.getId());
    assertEquals(new AgencyAndId(agencyId, "SN01272009"), cd.getServiceId());
    assertEquals(new ServiceDate(2009, 5, 25), cd.getDate());
    assertEquals(1, cd.getExceptionType());
    Collection<FareAttribute> fareAttributes = entityStore.getAllFareAttributes();
    assertEquals(6, fareAttributes.size());
    AgencyAndId fareId = new AgencyAndId(agencyId, "OW_1");
    FareAttribute fareAttribute = entityStore.getFareAttributeForId(fareId);
    assertEquals(fareId, fareAttribute.getId());
    assertEquals(2.50, fareAttribute.getPrice(), 0.0);
    assertEquals("USD", fareAttribute.getCurrencyType());
    assertEquals(1, fareAttribute.getPaymentMethod());
    assertFalse(fareAttribute.isTransfersSet());
    assertFalse(fareAttribute.isTransferDurationSet());
    Collection<FareRule> fareRules = entityStore.getAllFareRules();
    assertEquals(36, fareRules.size());
    List<FareRule> fareRuleMatches = GtfsTestData.grep(fareRules, "fare", fareAttribute);
    assertEquals(6, fareRuleMatches.size());
    fareRuleMatches = GtfsTestData.grep(fareRuleMatches, "originId", "1");
    assertEquals(1, fareRuleMatches.size());
    FareRule fareRule = fareRuleMatches.get(0);
    assertEquals(fareAttribute, fareRule.getFare());
    assertEquals("1", fareRule.getOriginId());
    assertEquals("1", fareRule.getDestinationId());
    assertNull(fareRule.getRoute());
    assertNull(fareRule.getContainsId());
}
Also used : FareAttribute(org.onebusaway.gtfs.model.FareAttribute) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) GtfsDao(org.onebusaway.gtfs.services.GtfsDao) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) Route(org.onebusaway.gtfs.model.Route) StopTime(org.onebusaway.gtfs.model.StopTime) ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate) Trip(org.onebusaway.gtfs.model.Trip) Agency(org.onebusaway.gtfs.model.Agency) FareRule(org.onebusaway.gtfs.model.FareRule) File(java.io.File) ServiceCalendar(org.onebusaway.gtfs.model.ServiceCalendar) Test(org.junit.Test)

Example 38 with Stop

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

the class GtfsReaderTest method testTestAgency.

@Test
public void testTestAgency() throws IOException {
    String agencyId = "agency";
    GtfsRelationalDao dao = processFeed(GtfsTestData.getTestAgencyGtfs(), agencyId, false);
    Agency agency = dao.getAgencyForId(agencyId);
    assertEquals(agencyId, agency.getId());
    assertEquals("Fake Agency", agency.getName());
    assertEquals("http://fake.example.com", agency.getUrl());
    assertEquals("America/New_York", agency.getTimezone());
    assertNull(agency.getPhone());
    Stop stopA = dao.getStopForId(new AgencyAndId(agencyId, "A"));
    assertEquals(1, stopA.getWheelchairBoarding());
    Stop stopC = dao.getStopForId(new AgencyAndId(agencyId, "C"));
    assertEquals(0, stopC.getWheelchairBoarding());
    Stop stopF = dao.getStopForId(new AgencyAndId(agencyId, "C"));
    assertEquals(0, stopF.getWheelchairBoarding());
    Trip tripA = dao.getTripForId(new AgencyAndId(agencyId, "1.1"));
    assertEquals(1, tripA.getWheelchairAccessible());
    Trip tripB = dao.getTripForId(new AgencyAndId(agencyId, "2.1"));
    assertEquals(0, tripB.getWheelchairAccessible());
    Trip tripC = dao.getTripForId(new AgencyAndId(agencyId, "4.1"));
    assertEquals(0, tripC.getWheelchairAccessible());
    Trip trip12 = dao.getTripForId(new AgencyAndId(agencyId, "1.2"));
    List<StopTime> stopTimes = dao.getStopTimesForTrip(trip12);
    assertEquals(3, stopTimes.size());
    StopTime stopTimeA = stopTimes.get(0);
    assertTrue(stopTimeA.isArrivalTimeSet());
    assertTrue(stopTimeA.isDepartureTimeSet());
    assertEquals(20 * 60, stopTimeA.getArrivalTime());
    assertEquals(20 * 60, stopTimeA.getDepartureTime());
    assertEquals(0, stopTimeA.getDropOffType());
    assertEquals(0, stopTimeA.getPickupType());
    assertNull(stopTimeA.getRouteShortName());
    assertEquals(0, stopTimeA.getShapeDistTraveled(), 0.0);
    assertEquals(new AgencyAndId(agencyId, "A"), stopTimeA.getStop().getId());
    assertNull(stopTimeA.getStopHeadsign());
    assertEquals(1, stopTimeA.getStopSequence());
    assertEquals(trip12, stopTimeA.getTrip());
    StopTime stopTimeB = stopTimes.get(1);
    assertFalse(stopTimeB.isArrivalTimeSet());
    assertFalse(stopTimeB.isDepartureTimeSet());
    assertEquals(2, stopTimeB.getDropOffType());
    assertEquals(3, stopTimeB.getPickupType());
    assertNull(stopTimeB.getRouteShortName());
    assertFalse(stopTimeB.isShapeDistTraveledSet());
    assertEquals(new AgencyAndId(agencyId, "B"), stopTimeB.getStop().getId());
    assertNull(stopTimeB.getStopHeadsign());
    assertEquals(2, stopTimeB.getStopSequence());
    assertEquals(trip12, stopTimeB.getTrip());
    StopTime stopTimeC = stopTimes.get(2);
    assertTrue(stopTimeC.isArrivalTimeSet());
    assertTrue(stopTimeC.isDepartureTimeSet());
    assertEquals(40 * 60, stopTimeC.getArrivalTime());
    assertEquals(40 * 60, stopTimeC.getDepartureTime());
    assertEquals(0, stopTimeC.getDropOffType());
    assertEquals(0, stopTimeC.getPickupType());
    assertEquals(52.1, stopTimeC.getShapeDistTraveled(), 0.0);
    assertEquals(new AgencyAndId(agencyId, "C"), stopTimeC.getStop().getId());
    assertNull(stopTimeC.getStopHeadsign());
    assertEquals(3, stopTimeC.getStopSequence());
    assertEquals(trip12, stopTimeC.getTrip());
}
Also used : GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) Trip(org.onebusaway.gtfs.model.Trip) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) StopTime(org.onebusaway.gtfs.model.StopTime) Test(org.junit.Test)

Example 39 with Stop

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

the class GtfsReaderTest method testIslandTransit.

@Test
public void testIslandTransit() throws IOException {
    String agencyId = "26";
    GtfsDao entityStore = processFeed(GtfsTestData.getIslandGtfs(), agencyId, false);
    Collection<Agency> agencies = entityStore.getAllAgencies();
    assertEquals(1, agencies.size());
    Agency agency = entityStore.getAgencyForId(agencyId);
    assertNotNull(agency);
    assertEquals("Island Transit", agency.getName());
    assertEquals("http://www.islandtransit.org/", agency.getUrl());
    assertEquals("America/Los_Angeles", agency.getTimezone());
    assertEquals("(360) 678-7771", agency.getPhone());
    assertNull(agency.getLang());
    Collection<Stop> stops = entityStore.getAllStops();
    assertEquals(410, stops.size());
    AgencyAndId stopAId = new AgencyAndId(agencyId, "2");
    Stop stopA = entityStore.getStopForId(stopAId);
    assertEquals(stopAId, stopA.getId());
    assertNull(stopA.getCode());
    assertEquals("blank", stopA.getDesc());
    assertEquals(48.108303, stopA.getLat(), 0.000001);
    assertEquals(-122.580446, stopA.getLon(), 0.000001);
    assertEquals(0, stopA.getLocationType());
    assertEquals("Greenbank Farm: SR 525 at Smugglers Cove Rd", stopA.getName());
    assertEquals("1", stopA.getZoneId());
    assertEquals("http://islandtransit.org/stops/2", stopA.getUrl());
    AgencyAndId stopBId = new AgencyAndId(agencyId, "1178");
    Stop stopB = entityStore.getStopForId(stopBId);
    assertEquals(stopBId, stopB.getId());
    assertNull(stopB.getCode());
    assertEquals("blank", stopB.getDesc());
    assertEquals(48.018190, stopB.getLat(), 0.000001);
    assertEquals(-122.544122, stopB.getLon(), 0.000001);
    assertEquals(0, stopB.getLocationType());
    assertEquals("Bercot at Honeymoon Bay Shipshaven", stopB.getName());
    assertEquals("1", stopB.getZoneId());
    assertEquals("http://islandtransit.org/stops/1178", stopB.getUrl());
    Collection<FareAttribute> fares = entityStore.getAllFareAttributes();
    assertEquals(1, fares.size());
    FareAttribute fare = fares.iterator().next();
    assertEquals(new AgencyAndId(agencyId, "1"), fare.getId());
    assertEquals(0.0, fare.getPrice(), 0.0);
    assertEquals("USD", fare.getCurrencyType());
    assertEquals(0, fare.getPaymentMethod());
    assertFalse(fare.isTransfersSet());
    assertFalse(fare.isTransferDurationSet());
    Collection<FareRule> fareRules = entityStore.getAllFareRules();
    assertEquals(1, fareRules.size());
    FareRule fareRule = fareRules.iterator().next();
    assertEquals(fare, fareRule.getFare());
    assertNull(fareRule.getRoute());
    assertNull(fareRule.getContainsId());
    assertNull(fareRule.getDestinationId());
    assertNull(fareRule.getOriginId());
    Collection<Transfer> transfers = entityStore.getAllTransfers();
    assertEquals(1, transfers.size());
    Transfer transfer = transfers.iterator().next();
    assertEquals(new AgencyAndId(agencyId, "878"), transfer.getFromStop().getId());
    assertEquals(new AgencyAndId(agencyId, "1167"), transfer.getToStop().getId());
    assertEquals(1, transfer.getTransferType());
    assertFalse(transfer.isMinTransferTimeSet());
}
Also used : FareAttribute(org.onebusaway.gtfs.model.FareAttribute) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) GtfsDao(org.onebusaway.gtfs.services.GtfsDao) FareRule(org.onebusaway.gtfs.model.FareRule) Transfer(org.onebusaway.gtfs.model.Transfer) Test(org.junit.Test)

Example 40 with Stop

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

the class GtfsReaderTest method testAllFields.

@Test
public void testAllFields() throws IOException {
    MockGtfs gtfs = MockGtfs.create();
    gtfs.putLines("block.txt", "block_seq_num,block_var_num,block_route_num,block_run_num", "4237385,1,599,1");
    gtfs.putLines("agency.txt", "agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,agency_fare_url", "1,Agency,http://agency.gov/,America/Los_Angeles,en,555-1234,http://agency.gov/fares");
    gtfs.putLines("stops.txt", "stop_id,stop_name,stop_lat,stop_lon,stop_desc,stop_code,stop_direction,location_type,parent_station," + "stop_url,wheelchair_boarding,zone_id,stop_timezone,vehicle_type,platform_code", "S1,Stop,47.0,-122.0,description,123,N,1,1234,http://agency.gov/stop,1,Z,America/New_York,2,9 3/4");
    gtfs.putLines("routes.txt", "agency_id,route_id,route_short_name,route_long_name,route_type,route_desc,route_color,route_text_color," + "route_bikes_allowed,bikes_allowed,route_url,route_sort_order", "1,R1,10,The Ten,3,route desc,FF0000,0000FF,1,2,http://agency.gov/route,100");
    gtfs.putLines("trips.txt", "route_id,service_id,trip_id,trip_headsign,trip_short_name,direction_id,block_id,shape_id,route_short_name," + "trip_bikes_allowed,bikes_allowed,wheelchair_accessible", "R1,WEEK,T1,head-sign,short-name,1,B1,SHP1,10X,1,2,1");
    gtfs.putLines("stop_times.txt", "trip_id,arrival_time,departure_time,stop_id,stop_sequence,stop_headsign,pickup_type,drop_off_type," + "shape_dist_traveled,route_short_name,timepoint", "T1,09:01:30,10:20:02,S1,2,head-sign,1,2,23.1,10X,1");
    gtfs.putLines("calendar.txt", "service_id,start_date,end_date,monday,tuesday,wednesday,thursday,friday,saturday,sunday", "WEEK,20120105,20120215,1,1,1,1,1,1,1");
    gtfs.putLines("calendar_dates.txt", "service_id,date,exception_type", "WEEK,20120304,2");
    gtfs.putLines("fare_attributes.txt", "fare_id,price,currency_type,payment_method,transfers,transfer_duration,journey_duration", "FA1,2.0,USD,1,2,60,61");
    gtfs.putLines("fare_rules.txt", "fare_id,route_id,origin_id,destination_id,contains_id", "FA1,R1,Z1,Z2,Z3");
    gtfs.putLines("shapes.txt", "shape_id,shape_pt_sequence,shape_pt_lat,shape_pt_lon,shape_dist_traveled", "SHP1,2,47.0,-122.0,123.4");
    gtfs.putLines("frequencies.txt", "trip_id,start_time,end_time,headway_secs,exact_times,label_only", "T1,09:01:30,10:20:02,300,1,1");
    gtfs.putLines("transfers.txt", "from_stop_id,from_route_id,from_trip_id,to_stop_id,to_route_id,to_trip_id,transfer_type,min_transfer_time", "S1,R1,T1,S1,R1,T1,2,60");
    gtfs.putLines("feed_info.txt", "feed_publisher_name,feed_publisher_url,feed_lang,feed_start_date,feed_end_date,feed_version", "Test,http://agency.gov/,en,20120110,20120217,2.0");
    gtfs.putLines("pathways.txt", "pathway_id,pathway_type,from_stop_id,to_stop_id,traversal_time,wheelchair_traversal_time", "P1,1,S1,S1,60,61");
    GtfsRelationalDao dao = processFeed(gtfs.getPath(), "1", false);
    Agency agency = dao.getAgencyForId("1");
    assertEquals("1", agency.getId());
    assertEquals("Agency", agency.getName());
    assertEquals("http://agency.gov/", agency.getUrl());
    assertEquals("America/Los_Angeles", agency.getTimezone());
    assertEquals("en", agency.getLang());
    assertEquals("555-1234", agency.getPhone());
    assertEquals("http://agency.gov/fares", agency.getFareUrl());
    Block block = dao.getBlockForId(1);
    assertNotNull(block);
    assertEquals(4237385, block.getBlockSequence());
    assertEquals(1, block.getBlockVariable());
    assertEquals(599, block.getBlockRoute());
    assertEquals(1, block.getBlockRun());
    Stop stop = dao.getStopForId(new AgencyAndId("1", "S1"));
    assertEquals(new AgencyAndId("1", "S1"), stop.getId());
    assertEquals("Stop", stop.getName());
    assertEquals(47.0, stop.getLat(), 0.0);
    assertEquals(-122.0, stop.getLon(), 0.0);
    assertEquals("description", stop.getDesc());
    assertEquals("123", stop.getCode());
    assertEquals("N", stop.getDirection());
    assertEquals(1, stop.getLocationType());
    assertEquals("1234", stop.getParentStation());
    assertEquals("http://agency.gov/stop", stop.getUrl());
    assertEquals(1, stop.getWheelchairBoarding());
    assertEquals("Z", stop.getZoneId());
    assertEquals("America/New_York", stop.getTimezone());
    assertEquals(2, stop.getVehicleType());
    assertEquals("9 3/4", stop.getPlatformCode());
    Route route = dao.getRouteForId(new AgencyAndId("1", "R1"));
    assertEquals(new AgencyAndId("1", "R1"), route.getId());
    assertEquals(agency, route.getAgency());
    assertEquals("10", route.getShortName());
    assertEquals("The Ten", route.getLongName());
    assertEquals(3, route.getType());
    assertEquals("route desc", route.getDesc());
    assertEquals("FF0000", route.getColor());
    assertEquals("0000FF", route.getTextColor());
    assertEquals(1, route.getRouteBikesAllowed());
    assertEquals(2, route.getBikesAllowed());
    assertEquals("http://agency.gov/route", route.getUrl());
    assertEquals(100, route.getSortOrder());
    Trip trip = dao.getTripForId(new AgencyAndId("1", "T1"));
    assertEquals(new AgencyAndId("1", "T1"), trip.getId());
    assertEquals(route, trip.getRoute());
    assertEquals(new AgencyAndId("1", "WEEK"), trip.getServiceId());
    assertEquals("head-sign", trip.getTripHeadsign());
    assertEquals("short-name", trip.getTripShortName());
    assertEquals("1", trip.getDirectionId());
    assertEquals("B1", trip.getBlockId());
    assertEquals(new AgencyAndId("1", "SHP1"), trip.getShapeId());
    assertEquals("10X", trip.getRouteShortName());
    assertEquals(1, trip.getTripBikesAllowed());
    assertEquals(2, trip.getBikesAllowed());
    assertEquals(1, trip.getWheelchairAccessible());
    List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
    StopTime stopTime = stopTimes.get(0);
    assertEquals(trip, stopTime.getTrip());
    assertEquals(stop, stopTime.getStop());
    assertEquals((9 * 60 + 1) * 60 + 30, stopTime.getArrivalTime());
    assertEquals((10 * 60 + 20) * 60 + 2, stopTime.getDepartureTime());
    assertEquals(2, stopTime.getStopSequence());
    assertEquals("head-sign", stopTime.getStopHeadsign());
    assertEquals(1, stopTime.getPickupType());
    assertEquals(2, stopTime.getDropOffType());
    assertEquals(23.1, stopTime.getShapeDistTraveled(), 0.0);
    assertEquals("10X", stopTime.getRouteShortName());
    assertEquals(1, stopTime.getTimepoint());
    ServiceCalendar calendar = dao.getCalendarForServiceId(new AgencyAndId("1", "WEEK"));
    assertEquals(new AgencyAndId("1", "WEEK"), calendar.getServiceId());
    assertEquals(new ServiceDate(2012, 01, 05), calendar.getStartDate());
    assertEquals(new ServiceDate(2012, 02, 15), calendar.getEndDate());
    assertEquals(1, calendar.getMonday());
    assertEquals(1, calendar.getTuesday());
    assertEquals(1, calendar.getWednesday());
    assertEquals(1, calendar.getThursday());
    assertEquals(1, calendar.getFriday());
    assertEquals(1, calendar.getSaturday());
    assertEquals(1, calendar.getSunday());
    List<ServiceCalendarDate> calendarDates = dao.getCalendarDatesForServiceId(new AgencyAndId("1", "WEEK"));
    ServiceCalendarDate calendarDate = calendarDates.get(0);
    assertEquals(new AgencyAndId("1", "WEEK"), calendarDate.getServiceId());
    assertEquals(new ServiceDate(2012, 03, 04), calendarDate.getDate());
    assertEquals(2, calendarDate.getExceptionType());
    FareAttribute fareAttribute = dao.getFareAttributeForId(new AgencyAndId("1", "FA1"));
    assertEquals(new AgencyAndId("1", "FA1"), fareAttribute.getId());
    assertEquals(2.0, fareAttribute.getPrice(), 1.0);
    assertEquals("USD", fareAttribute.getCurrencyType());
    assertEquals(1, fareAttribute.getPaymentMethod());
    assertEquals(2, fareAttribute.getTransfers());
    assertEquals(60, fareAttribute.getTransferDuration());
    assertEquals(61, fareAttribute.getJourneyDuration());
    List<FareRule> rules = dao.getFareRulesForFareAttribute(fareAttribute);
    FareRule fareRule = rules.get(0);
    assertEquals(fareAttribute, fareRule.getFare());
    assertEquals(route, fareRule.getRoute());
    assertEquals("Z1", fareRule.getOriginId());
    assertEquals("Z2", fareRule.getDestinationId());
    assertEquals("Z3", fareRule.getContainsId());
    List<ShapePoint> shapePoints = dao.getShapePointsForShapeId(new AgencyAndId("1", "SHP1"));
    ShapePoint shapePoint = shapePoints.get(0);
    assertEquals(new AgencyAndId("1", "SHP1"), shapePoint.getShapeId());
    assertEquals(2, shapePoint.getSequence());
    assertEquals(47.0, shapePoint.getLat(), 0.0);
    assertEquals(-122.0, shapePoint.getLon(), 0.0);
    assertEquals(123.4, shapePoint.getDistTraveled(), 0.0);
    List<Frequency> frequencies = dao.getFrequenciesForTrip(trip);
    Frequency frequency = frequencies.get(0);
    assertEquals(trip, frequency.getTrip());
    assertEquals((9 * 60 + 1) * 60 + 30, frequency.getStartTime());
    assertEquals((10 * 60 + 20) * 60 + 2, frequency.getEndTime());
    assertEquals(300, frequency.getHeadwaySecs());
    assertEquals(1, frequency.getExactTimes());
    assertEquals(1, frequency.getLabelOnly());
    Transfer transfer = dao.getAllTransfers().iterator().next();
    assertEquals(stop, transfer.getFromStop());
    assertEquals(route, transfer.getFromRoute());
    assertEquals(trip, transfer.getFromTrip());
    assertEquals(stop, transfer.getToStop());
    assertEquals(route, transfer.getToRoute());
    assertEquals(trip, transfer.getToTrip());
    assertEquals(2, transfer.getTransferType(), 1);
    assertEquals(60, transfer.getMinTransferTime());
    FeedInfo feedInfo = dao.getAllFeedInfos().iterator().next();
    assertEquals("Test", feedInfo.getPublisherName());
    assertEquals("http://agency.gov/", feedInfo.getPublisherUrl());
    assertEquals("en", feedInfo.getLang());
    assertEquals(new ServiceDate(2012, 1, 10), feedInfo.getStartDate());
    assertEquals(new ServiceDate(2012, 2, 17), feedInfo.getEndDate());
    assertEquals("2.0", feedInfo.getVersion());
    Pathway pathway = dao.getAllPathways().iterator().next();
    assertEquals(new AgencyAndId("1", "P1"), pathway.getId());
    assertEquals(1, pathway.getPathwayType());
    assertEquals(stop, pathway.getFromStop());
    assertEquals(stop, pathway.getToStop());
    assertEquals(60, pathway.getTraversalTime());
    assertEquals(61, pathway.getWheelchairTraversalTime());
}
Also used : ServiceCalendarDate(org.onebusaway.gtfs.model.ServiceCalendarDate) FareAttribute(org.onebusaway.gtfs.model.FareAttribute) GtfsRelationalDao(org.onebusaway.gtfs.services.GtfsRelationalDao) Trip(org.onebusaway.gtfs.model.Trip) Agency(org.onebusaway.gtfs.model.Agency) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) Stop(org.onebusaway.gtfs.model.Stop) Pathway(org.onebusaway.gtfs.model.Pathway) MockGtfs(org.onebusaway.gtfs.services.MockGtfs) FareRule(org.onebusaway.gtfs.model.FareRule) FeedInfo(org.onebusaway.gtfs.model.FeedInfo) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) ShapePoint(org.onebusaway.gtfs.model.ShapePoint) Transfer(org.onebusaway.gtfs.model.Transfer) Block(org.onebusaway.gtfs.model.Block) 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