Example #1
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 #2
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 #3
0
  /**
   * Creates a copy of the Trip object but adjusts the startTime, endTime, and scheduledTimesMap
   * according to the frequenciesBasedStartTime. This is used when the frequencies.txt file
   * specifies exact_times for a trip.
   *
   * @param tripFromStopTimes
   * @param frequenciesBasedStartTime
   */
  public Trip(Trip tripFromStopTimes, int frequenciesBasedStartTime) {
    this.configRev = tripFromStopTimes.configRev;
    this.tripId = tripFromStopTimes.tripId;
    this.tripShortName = tripFromStopTimes.tripShortName;
    this.directionId = tripFromStopTimes.directionId;
    this.routeId = tripFromStopTimes.routeId;
    this.routeShortName = tripFromStopTimes.routeShortName;
    this.serviceId = tripFromStopTimes.serviceId;
    this.headsign = tripFromStopTimes.headsign;
    this.shapeId = tripFromStopTimes.shapeId;
    this.tripPattern = tripFromStopTimes.tripPattern;
    this.travelTimes = tripFromStopTimes.travelTimes;

    // Set the updated start and end times by using the frequencies
    // based start time.
    this.startTime = tripFromStopTimes.startTime + frequenciesBasedStartTime;
    this.endTime = tripFromStopTimes.endTime + frequenciesBasedStartTime;

    // Since frequencies being used for configuration we will have multiple
    // trips with the same ID. But need a different block ID for each one.
    // Therefore use the original trip's block ID but then append the
    // start time as a string to make it unique.
    this.blockId = tripFromStopTimes.blockId + "_" + Time.timeOfDayStr(this.startTime);

    // Set the scheduledTimesMap by using the frequencies based start time
    for (ScheduleTime schedTimeFromStopTimes : tripFromStopTimes.scheduledTimesList) {
      Integer arrivalTime = null;
      if (schedTimeFromStopTimes.getArrivalTime() != null)
        arrivalTime = schedTimeFromStopTimes.getArrivalTime() + frequenciesBasedStartTime;
      Integer departureTime = null;
      if (schedTimeFromStopTimes.getDepartureTime() != null)
        departureTime = schedTimeFromStopTimes.getDepartureTime() + frequenciesBasedStartTime;

      ScheduleTime schedTimeFromFrequency = new ScheduleTime(arrivalTime, departureTime);
      this.scheduledTimesList.add(schedTimeFromFrequency);
    }

    // Since this constructor is only for frequency based trips where
    // exact_times is true set the corresponding members to indicate such
    this.noSchedule = false;
    this.exactTimesHeadway = true;
  }