Ejemplo n.º 1
0
  /**
   * Initialize from stop attributes. A trip will be created to the stop if toStop is true, else a
   * trip will be created from the stop. Use after all stop locations are known, or else reset the
   * stop origin and destination mgras accordingly after using.
   *
   * @param tour
   * @param stop
   * @param toStop
   */
  public void initializeFromStop(VisitorTour tour, VisitorStop stop, boolean toStop) {

    this.inbound = stop.isInbound();
    this.destinationIsTourDestination = false;
    this.originIsTourDestination = false;

    // if trip to stop, destination is stop mgra; else origin is stop mgra
    if (toStop) {
      this.destinationMgra = stop.getMgra();
      this.destinationPurpose = stop.getPurpose();
    } else {
      this.originMgra = stop.getMgra();
      this.originPurpose = stop.getPurpose();
    }
    VisitorStop[] stops;

    if (!inbound) stops = tour.getOutboundStops();
    else stops = tour.getInboundStops();

    // if outbound, and trip is to stop
    if (!inbound && toStop) {

      // first trip on outbound journey, origin is tour origin
      if (stop.getId() == 0) {
        this.originMgra = tour.getOriginMGRA();
        this.originPurpose = -1;
        this.period = (byte) tour.getDepartTime();
      } else {
        // not first trip on outbound journey, origin is last stop
        this.originMgra = stops[stop.getId() - 1].getMgra(); // last stop location
        this.originPurpose = stops[stop.getId() - 1].getPurpose(); // last stop location
        this.period = (byte) stops[stop.getId() - 1].getStopPeriod();
      }
    } else if (!inbound && !toStop) {
      // outbound and trip is from stop to either next stop or tour destination.

      // last trip on outbound journey, destination is tour destination
      if (stop.getId() == (stops.length - 1)) {
        this.destinationMgra = tour.getDestinationMGRA();
        this.destinationPurpose = tour.getPurpose();
        this.destinationIsTourDestination = true;
      } else {
        // not last trip on outbound journey, destination is next stop
        this.destinationMgra = stops[stop.getId() + 1].getMgra();
        this.destinationPurpose = stops[stop.getId() + 1].getPurpose();
      }

      // the period for the trip is the origin for the trip
      if (stop.getId() == 0) this.period = (byte) tour.getDepartTime();
      else this.period = (byte) stops[stop.getId() - 1].getStopPeriod();

    } else if (inbound && toStop) {
      // inbound, trip is to stop from either tour destination or last stop.

      // first inbound trip; origin is tour destination
      if (stop.getId() == 0) {
        this.originMgra = tour.getDestinationMGRA();
        this.originPurpose = tour.getPurpose();
        this.originIsTourDestination = true;
      } else {
        // not first inbound trip; origin is last stop
        this.originMgra = stops[stop.getId() - 1].getMgra(); // last stop location
        this.originPurpose = stops[stop.getId() - 1].getPurpose();
      }

      // the period for the trip is the destination for the trip
      if (stop.getId() == stops.length - 1) this.period = (byte) tour.getArriveTime();
      else this.period = (byte) stops[stop.getId() + 1].getStopPeriod();
    } else {
      // inbound, trip is from stop to either next stop or tour origin.

      // last trip, destination is back to tour origin
      if (stop.getId() == (stops.length - 1)) {
        this.destinationMgra = tour.getOriginMGRA();
        this.destinationPurpose = -1;
        this.period = (byte) tour.getArriveTime();
      } else {
        // not last trip, destination is next stop
        this.destinationMgra = stops[stop.getId() + 1].getMgra();
        this.destinationPurpose = stops[stop.getId() + 1].getPurpose();
        this.period = (byte) stops[stop.getId() + 1].getStopPeriod();
      }
    }

    // code period for first trip on tour
    if (toStop && !inbound && stop.getId() == 0) {
      this.firstTrip = true;
      this.lastTrip = false;
      this.period = (byte) tour.getDepartTime();
    }
    // code period for last trip on tour
    if (!toStop && inbound && stop.getId() == (stops.length - 1)) {
      this.firstTrip = false;
      this.lastTrip = true;
      this.period = (byte) tour.getArriveTime();
    }
  }
Ejemplo n.º 2
0
 /**
  * Initilize from the tour.
  *
  * @param tour The tour.
  * @param outbound Outbound direction.
  */
 public void initializeFromTour(VisitorTour tour, boolean outbound) {
   // Note: mode is unknown
   if (outbound) {
     this.originMgra = tour.getOriginMGRA();
     this.destinationMgra = tour.getDestinationMGRA();
     this.originPurpose = -1;
     this.destinationPurpose = tour.getPurpose();
     this.period = (byte) tour.getDepartTime();
     this.inbound = false;
     this.firstTrip = true;
     this.lastTrip = false;
     this.originIsTourDestination = false;
     this.destinationIsTourDestination = true;
     this.bestWtwTapPairs = tour.getBestWtwTapPairsOut();
     this.bestDtwTapPairs = tour.getBestDtwTapPairsOut();
     this.bestWtdTapPairs = tour.getBestWtdTapPairsOut();
   } else {
     this.originMgra = tour.getDestinationMGRA();
     this.destinationMgra = tour.getOriginMGRA();
     this.originPurpose = tour.getPurpose();
     this.destinationPurpose = -1;
     this.period = (byte) tour.getArriveTime();
     this.inbound = true;
     this.firstTrip = false;
     this.lastTrip = true;
     this.originIsTourDestination = true;
     this.destinationIsTourDestination = false;
     this.bestWtwTapPairs = tour.getBestWtwTapPairsIn();
     this.bestDtwTapPairs = tour.getBestDtwTapPairsIn();
     this.bestWtdTapPairs = tour.getBestWtdTapPairsIn();
   }
 }