public static boolean isValidLocation(final Location test,final boolean strictMode){
  if (test == null) {
    Log.w(TAG,"Invalid location: Location is null");
    return false;
  }
  if (test.getLatitude() == 0 && test.getLongitude() == 0) {
    Log.w(TAG,"Invalid location: only default values provided");
    return false;
  }
  if (test.getLongitude() > 180 || test.getLongitude() < -180) {
    Log.w(TAG,"Invalid longitude: " + test.getLongitude());
    return false;
  }
  if (test.getLatitude() > 90 || test.getLatitude() < -90) {
    Log.w(TAG,"Invalid latitude: " + test.getLatitude());
    return false;
  }
  if (strictMode) {
    final long tomorrow=System.currentTimeMillis() + GeometryUtils.MILLIS_PER_DAY;
    if (test.getTime() < GeometryUtils.MIN_TIMESTAMP || test.getTime() > tomorrow) {
      Log.w(TAG,"Invalid timestamp: either to old or more than one day in the future");
      return false;
    }
    if ((test.hasAltitude()) && (test.getAltitude() < GeometryUtils.MIN_ALTITUDE || test.getAltitude() > MAX_ALTITUDE)) {
      Log.w(TAG,"Altitude out-of-range [" + GeometryUtils.MIN_ALTITUDE + ".."+ MAX_ALTITUDE+ "]:"+ test.getAltitude());
      return false;
    }
    if ((test.hasSpeed()) && (test.getSpeed() < GeometryUtils.MIN_SPEED || test.getSpeed() > GeometryUtils.MAX_SPEED)) {
      Log.w(TAG,"Speed out-of-range [" + GeometryUtils.MIN_SPEED + ".."+ GeometryUtils.MAX_SPEED+ "]:"+ test.getSpeed());
      return false;
    }
  }
  return true;
}

public static boolean isValidLocation ( final Location test , final boolean strictMode ) { if ( test == null ) { Log . w ( TAG , "Invalid location: Location is null" ) ; return false ; } if ( test . getLatitude ( ) == 0 && test . getLongitude ( ) == 0 ) { Log . w ( TAG , "Invalid location: only default values provided" ) ; return false ; } if ( test . getLongitude ( ) > 180 || test . getLongitude ( ) < - 180 ) { Log . w ( TAG , "Invalid longitude: " + test . getLongitude ( ) ) ; return false ; } if ( test . getLatitude ( ) > 90 || test . getLatitude ( ) < - 90 ) { Log . w ( TAG , "Invalid latitude: " + test . getLatitude ( ) ) ; return false ; } if ( strictMode ) { final long tomorrow = System . currentTimeMillis ( ) + GeometryUtils . MILLIS_PER_DAY ; if ( test . getTime ( ) < GeometryUtils . MIN_TIMESTAMP || test . getTime ( ) > tomorrow ) { Log . w ( TAG , "Invalid timestamp: either to old or more than one day in the future" ) ; return false ; } if ( ( test . hasAltitude ( ) ) && ( test . getAltitude ( ) < GeometryUtils . MIN_ALTITUDE || test . getAltitude ( ) > MAX_ALTITUDE ) ) { Log . w ( TAG , "Altitude out-of-range [" + GeometryUtils . MIN_ALTITUDE + ".." + MAX_ALTITUDE + "]:" + test . getAltitude ( ) ) ; return false ; } if ( ( test . hasSpeed ( ) ) && ( test . getSpeed ( ) < GeometryUtils . MIN_SPEED || test . getSpeed ( ) > GeometryUtils . MAX_SPEED ) ) { Log . w ( TAG , "Speed out-of-range [" + GeometryUtils . MIN_SPEED + ".." + GeometryUtils . MAX_SPEED + "]:" + test . getSpeed ( ) ) ; return false ; } } return true ; }
tests if location is valid .
