public static long distance(double latitude1,double longitude1,double latitude2,double longitude2){
  double latitudeSin=Math.sin(Math.toRadians(latitude2 - latitude1) / 2);
  double longitudeSin=Math.sin(Math.toRadians(longitude2 - longitude1) / 2);
  double a=latitudeSin * latitudeSin + Math.cos(Math.toRadians(latitude1)) * Math.cos(Math.toRadians(latitude2)) * longitudeSin* longitudeSin;
  double c=2 * MathUtil.atan2(Math.sqrt(a),Math.sqrt(1 - a));
  return (long)(6378137 * c);
}

public static long distance ( double latitude1 , double longitude1 , double latitude2 , double longitude2 ) { double latitudeSin = Math . sin ( Math . toRadians ( latitude2 - latitude1 ) / 2 ) ; double longitudeSin = Math . sin ( Math . toRadians ( longitude2 - longitude1 ) / 2 ) ; double a = latitudeSin * latitudeSin + Math . cos ( Math . toRadians ( latitude1 ) ) * Math . cos ( Math . toRadians ( latitude2 ) ) * longitudeSin * longitudeSin ; double c = 2 * MathUtil . atan2 ( Math . sqrt ( a ) , Math . sqrt ( 1 - a ) ) ; return ( long ) ( 6378137 * c ) ; }
returns the distance between 2 points in meters
