@BeforeClass
  public static void setUp() throws Exception {

    context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
    graph = new Graph();

    GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
    factory.run(graph);
    graph.putService(
        CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));

    patternIndex = new HashMap<AgencyAndId, TripPattern>();
    for (TransitStopDepart tsd : filter(graph.getVertices(), TransitStopDepart.class)) {
      for (TransitBoardAlight tba : filter(tsd.getOutgoing(), TransitBoardAlight.class)) {
        if (!tba.isBoarding()) continue;
        TripPattern pattern = tba.getPattern();
        for (Trip trip : pattern.getTrips()) {
          patternIndex.put(trip.getId(), pattern);
        }
      }
    }

    pattern = patternIndex.get(new AgencyAndId("agency", "1.1"));
    timetable = pattern.scheduledTimetable;
  }
Example #2
0
 /**
  * Similar to toString() but doesn't include scheduledTimesMap which can be quite verbose since it
  * often contains times for many stops.
  *
  * @return
  */
 public String toShortString() {
   return "Trip ["
       + "tripId="
       + tripId
       + ", tripShortName="
       + tripShortName
       + ", tripPatternId="
       + (tripPattern != null ? tripPattern.getId() : "null")
       + ", tripIndexInBlock="
       + getIndexInBlock()
       + ", startTime="
       + Time.timeOfDayStr(startTime)
       + ", endTime="
       + Time.timeOfDayStr(endTime)
       + (headsign != null ? ", headsign=\"" + headsign + "\"" : "")
       + ", directionId="
       + directionId
       + ", routeId="
       + routeId
       + ", routeShortName="
       + routeShortName
       + (noSchedule ? ", noSchedule=" + noSchedule : "")
       + (exactTimesHeadway ? ", exactTimesHeadway=" + exactTimesHeadway : "")
       + ", serviceId="
       + serviceId
       + ", blockId="
       + blockId
       + ", shapeId="
       + shapeId
       + "]";
 }
Example #3
0
 /** Required by Hibernate */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Trip other = (Trip) obj;
   if (blockId == null) {
     if (other.blockId != null) return false;
   } else if (!blockId.equals(other.blockId)) return false;
   if (configRev != other.configRev) return false;
   if (directionId == null) {
     if (other.directionId != null) return false;
   } else if (!directionId.equals(other.directionId)) return false;
   if (endTime == null) {
     if (other.endTime != null) return false;
   } else if (!endTime.equals(other.endTime)) return false;
   if (exactTimesHeadway != other.exactTimesHeadway) return false;
   if (headsign == null) {
     if (other.headsign != null) return false;
   } else if (!headsign.equals(other.headsign)) return false;
   if (noSchedule != other.noSchedule) return false;
   if (route == null) {
     if (other.route != null) return false;
   } else if (!route.equals(other.route)) return false;
   if (routeId == null) {
     if (other.routeId != null) return false;
   } else if (!routeId.equals(other.routeId)) return false;
   if (routeShortName == null) {
     if (other.routeShortName != null) return false;
   } else if (!routeShortName.equals(other.routeShortName)) return false;
   if (scheduledTimesList == null) {
     if (other.scheduledTimesList != null) return false;
   } else if (!scheduledTimesList.equals(other.scheduledTimesList)) return false;
   if (serviceId == null) {
     if (other.serviceId != null) return false;
   } else if (!serviceId.equals(other.serviceId)) return false;
   if (shapeId == null) {
     if (other.shapeId != null) return false;
   } else if (!shapeId.equals(other.shapeId)) return false;
   if (startTime == null) {
     if (other.startTime != null) return false;
   } else if (!startTime.equals(other.startTime)) return false;
   if (travelTimes == null) {
     if (other.travelTimes != null) return false;
   } else if (!travelTimes.equals(other.travelTimes)) return false;
   if (tripId == null) {
     if (other.tripId != null) return false;
   } else if (!tripId.equals(other.tripId)) return false;
   if (tripPattern == null) {
     if (other.tripPattern != null) return false;
   } else if (!tripPattern.equals(other.tripPattern)) return false;
   if (tripShortName == null) {
     if (other.tripShortName != null) return false;
   } else if (!tripShortName.equals(other.tripShortName)) return false;
   return true;
 }
Example #4
0
 /* (non-Javadoc)
  * @see java.lang.Object#toString()
  */
 @Override
 public String toString() {
   // Note: the '\n' at beginning is so that when output list of trips
   // each will be on new line
   return "\n    Trip ["
       + "configRev="
       + configRev
       + ", tripId="
       + tripId
       + ", tripShortName="
       + tripShortName
       + ", tripPatternId="
       + (tripPattern != null ? tripPattern.getId() : "null")
       + ", tripIndexInBlock="
       + getIndexInBlock()
       + ", startTime="
       + Time.timeOfDayStr(startTime)
       + ", endTime="
       + Time.timeOfDayStr(endTime)
       + (headsign != null ? ", headsign=\"" + headsign + "\"" : "")
       + ", directionId="
       + directionId
       + ", routeId="
       + routeId
       + ", routeShortName="
       + routeShortName
       + (noSchedule ? ", noSchedule=" + noSchedule : "")
       + (exactTimesHeadway ? ", exactTimesHeadway=" + exactTimesHeadway : "")
       + ", serviceId="
       + serviceId
       + ", blockId="
       + blockId
       + ", shapeId="
       + shapeId
       + ", scheduledTimesList="
       + scheduledTimesList
       + "]";
 }
Example #5
0
 /** Required by Hibernate */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((blockId == null) ? 0 : blockId.hashCode());
   result = prime * result + configRev;
   result = prime * result + ((directionId == null) ? 0 : directionId.hashCode());
   result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
   result = prime * result + (exactTimesHeadway ? 1231 : 1237);
   result = prime * result + ((headsign == null) ? 0 : headsign.hashCode());
   result = prime * result + (noSchedule ? 1231 : 1237);
   result = prime * result + ((route == null) ? 0 : route.hashCode());
   result = prime * result + ((routeId == null) ? 0 : routeId.hashCode());
   result = prime * result + ((routeShortName == null) ? 0 : routeShortName.hashCode());
   result = prime * result + ((scheduledTimesList == null) ? 0 : scheduledTimesList.hashCode());
   result = prime * result + ((serviceId == null) ? 0 : serviceId.hashCode());
   result = prime * result + ((shapeId == null) ? 0 : shapeId.hashCode());
   result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
   result = prime * result + ((travelTimes == null) ? 0 : travelTimes.hashCode());
   result = prime * result + ((tripId == null) ? 0 : tripId.hashCode());
   result = prime * result + ((tripPattern == null) ? 0 : tripPattern.hashCode());
   result = prime * result + ((tripShortName == null) ? 0 : tripShortName.hashCode());
   return result;
 }
Example #6
0
 /**
  * Returns the StopPath for the stopPathIndex specified
  *
  * @param stopPathIndex
  * @return the path specified or null if index out of range
  */
 public StopPath getStopPath(int stopPathIndex) {
   return tripPattern.getStopPath(stopPathIndex);
 }
Example #7
0
 /**
  * Returns the List of the stop paths for the trip pattern
  *
  * @return
  */
 public List<StopPath> getStopPaths() {
   return tripPattern.getStopPaths();
 }
Example #8
0
 /**
  * Returns the StopPath specified by the stopId.
  *
  * @param stopId
  * @return The specified StopPath, or null if the stop is not part of this trip pattern.
  */
 public StopPath getStopPath(String stopId) {
   return tripPattern.getStopPath(stopId);
 }