private static boolean isLayoverInRange(
      BlockStopTimeEntry prevStop, BlockStopTimeEntry nextStop, ScheduledBlockLocation location) {

    if (prevStop.getDistanceAlongBlock() <= location.getDistanceAlongBlock()
        && location.getDistanceAlongBlock() <= nextStop.getDistanceAlongBlock()) return true;

    final double d1 = Math.abs(location.getDistanceAlongBlock() - prevStop.getDistanceAlongBlock());
    final double d2 = Math.abs(location.getDistanceAlongBlock() - nextStop.getDistanceAlongBlock());
    return Math.min(d1, d2) < _layoverStopDistance;
  }
Exemplo n.º 2
0
 public static final double getAvgVelocityBetweenStops(BlockState blockState) {
   final BlockStopTimeEntry nextStop = blockState.getBlockLocation().getNextStop();
   if (nextStop != null && nextStop.getBlockSequence() - 1 > 0) {
     final BlockStopTimeEntry prevStop =
         blockState
             .getBlockInstance()
             .getBlock()
             .getStopTimes()
             .get(nextStop.getBlockSequence() - 1);
     final double avgVelocity =
         (nextStop.getDistanceAlongBlock() - prevStop.getDistanceAlongBlock())
             / (nextStop.getStopTime().getArrivalTime()
                 - prevStop.getStopTime().getDepartureTime());
     return avgVelocity;
   } else {
     return _avgTripVelocity;
   }
 }