Search in sources :

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

Example 62 with Stop

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

the class EnsureDirectionIdExists method getDirectionForTrip.

private String getDirectionForTrip(GtfsMutableRelationalDao dao, Trip trip) {
    List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
    Stop s1 = dao.getStopForId(stopTimes.get(0).getStop().getId());
    Stop s2 = dao.getStopForId(stopTimes.get(stopTimes.size() - 1).getStop().getId());
    return String.valueOf(getDirectionFromStops(s1, s2));
}
Also used : Stop(org.onebusaway.gtfs.model.Stop) StopTime(org.onebusaway.gtfs.model.StopTime)

Example 63 with Stop

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

the class MTAEntrancesStrategy method createStop.

private Stop createStop(AgencyAndId id, Stop stop, int locationType, int wheelchairAccessible) {
    if (stop == null)
        return null;
    Stop entrance = new Stop();
    entrance.setId(id);
    entrance.setName(stop.getName());
    entrance.setLat(stop.getLat());
    entrance.setLon(stop.getLon());
    entrance.setLocationType(locationType);
    entrance.setWheelchairBoarding(wheelchairAccessible);
    entrance.setParentStation(stop.getId().getId());
    newStops.add(entrance);
    return entrance;
}
Also used : Stop(org.onebusaway.gtfs.model.Stop)

Example 64 with Stop

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

the class MTAEntrancesStrategy method getComplexList.

private Map<String, List<Stop>> getComplexList(GtfsDao dao) {
    Map<String, Stop> stops = getStopMap(dao);
    Map<String, List<Stop>> complexes = new HashMap<String, List<Stop>>();
    try (BufferedReader br = new BufferedReader(new FileReader(new File(this.accessibleComplexFile)))) {
        String line;
        while ((line = br.readLine()) != null) {
            List<Stop> complex = new ArrayList<>();
            for (String id : line.split(STOP_SEPARATOR)) {
                Stop stop = stops.get(id);
                if (stop == null)
                    _log.info("null stop: {}", id);
                complex.add(stop);
            }
            complexes.put("complex-" + UUID.randomUUID(), complex);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return complexes;
}
Also used : Stop(org.onebusaway.gtfs.model.Stop) HashMap(java.util.HashMap) BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File)

Example 65 with Stop

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

the class MTAEntrancesStrategy method createStopFromMTAEntrance.

// Utility functions
private Stop createStopFromMTAEntrance(Stop parent, MTAEntrance ent, int num) {
    int wheelchairFlag = NOT_WHEELCHAIR_ACCESSIBLE;
    if (contextualAccessibility && accessibleEntranceTypes.contains(ent.getEntranceType()))
        wheelchairFlag = WHEELCHAIR_ACCESSIBLE;
    Stop entrance = createStop(parent, LOCATION_TYPE_ENTRANCE, wheelchairFlag, "entrance-" + num);
    if (entrance == null)
        return null;
    entrance.setLat(ent.getLatitude());
    entrance.setLon(ent.getLongitude());
    return entrance;
}
Also used : Stop(org.onebusaway.gtfs.model.Stop)

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