private boolean isValidSpeed(long time,double speed,long lastLocationTime,double lastLocationSpeed){
  if (speed == 0) {
    return false;
  }
  if (Math.abs(speed - 128) < 1) {
    return false;
  }
  long timeDifference=time - lastLocationTime;
  double speedDifference=Math.abs(lastLocationSpeed - speed);
  if (speedDifference > MAX_ACCELERATION * timeDifference) {
    return false;
  }
  if (speedBuffer.isFull()) {
    double average=speedBuffer.getAverage();
    double diff=Math.abs(average - speed);
    return (speed < average * 10) && (diff < MAX_ACCELERATION * timeDifference);
  }
 else {
    return true;
  }
}

private boolean isValidSpeed ( long time , double speed , long lastLocationTime , double lastLocationSpeed ) { if ( speed == 0 ) { return false ; } if ( Math . abs ( speed - 128 ) < 1 ) { return false ; } long timeDifference = time - lastLocationTime ; double speedDifference = Math . abs ( lastLocationSpeed - speed ) ; if ( speedDifference > MAX_ACCELERATION * timeDifference ) { return false ; } if ( speedBuffer . isFull ( ) ) { double average = speedBuffer . getAverage ( ) ; double diff = Math . abs ( average - speed ) ; return ( speed < average * 10 ) && ( diff < MAX_ACCELERATION * timeDifference ) ; } else { return true ; } }
returns true if the speed is valid .
