Пример #1
0
 public void dump() {
   List<Ride> rides = Lists.newLinkedList();
   Ride ride = this;
   while (ride != null) {
     rides.add(0, ride);
     ride = ride.previous;
   }
   LOG.info("Path from {} to {}", rides.get(0).from, rides.get(rides.size() - 1).to);
   for (Ride r : rides) LOG.info("  {}", r.toString());
 }
Пример #2
0
 /**
  * Calculates Stats for the transfer to the given ride from the previous ride. This should only be
  * called after all PatternRides have been added to the ride. Distances can be stored in rides,
  * including the first and last distance. But waits must be calculated from full sets of patterns,
  * which are not known until a round is over.
  */
 public Stats calcStatsForTransfer(TimeWindow window, double walkSpeed) {
   List<Integer> arrivals = previous.getSortedStoptimes(window, true);
   List<Integer> departures = this.getSortedStoptimes(window, false);
   List<Integer> waits = Lists.newArrayList();
   Iterator<Integer> departureIterator = departures.iterator();
   int departure = departureIterator.next();
   ARRIVAL:
   for (int arrival : arrivals) {
     int boardTime = arrival + accessTime + ProfileRouter.SLACK;
     while (departure <= boardTime) {
       if (!departureIterator.hasNext()) break ARRIVAL;
       departure = departureIterator.next();
     }
     waits.add(departure - boardTime);
   }
   /* Waits list may be empty if no transfers are possible. */
   if (waits.isEmpty()) return null; // Impossible to make this transfer.
   return new Stats(waits);
 }