Get distance in km (approximate)
@param Location $a
@param Location $b
@return float
964385
public static function distance(Location $a, Location $b): float {
        $f1 = deg2rad($a -> latitude);
        $f2 = deg2rad($b -> latitude);
        $df = deg2rad($b -> latitude - $a -> latitude);
        $dl = deg2rad($b -> longitude - $a -> longitude);

        $a = sin($df/2) * sin($df/2) +
            cos($f1) * cos($f2) *
            sin($dl/2) * sin($dl/2);
        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));

        return self::EARTH_RADIUS * $c;
    }
1356571
public static double similarity(String A, String B)
    {
        long distance = distance(A, B);
        if (distance > dictionary.getMaxSynonymItemIdDistance()) return 0.0;

        return (dictionary.getMaxSynonymItemIdDistance() - distance) / (double) dictionary.getMaxSynonymItemIdDistance();
    }
952896
@Unit(NM)
    public static double radius(Location... location)
    {
        Location center = center(location);
        double max = 0;
        for (Location loc : location)
        {
            Distance distance = distance(loc, center);
            double miles = distance.getMiles();
            if (miles > max)
            {
                max = miles;
            }
        }
        return max;
    }
291836
public function coordinatesDistance($lat1, $lng1, $lat2, $lng2, $miles = false)
    {
        $pi80 = M_PI / 180;
        $lat1 *= $pi80;
        $lng1 *= $pi80;
        $lat2 *= $pi80;
        $lng2 *= $pi80;

        $r = 6372.797;
        $dlat = $lat2 - $lat1;
        $dlng = $lng2 - $lng1;

        $a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2);
        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
        $km = $r * $c;

        return $miles ? ($km * 0.621371192) : $km;
    }
207673
public static double distance(double[] pointA, double[] pointB, int offsetB) {
		return Math.sqrt(distanceSquared(pointA, pointB, offsetB));
	}
174679
public function getDistance(string $name1, string $name2): float
    {
        return $this->handle->rawCommand('geodist', [$this->name, $name1, $name2]);
    }
982310
public function dist(&$A, &$B)
    {
        if (is_int(key($A)))
            $v1 = array_count_values($A);
        else
            $v1 = &$A;
        if (is_int(key($B)))
            $v2 = array_count_values($B);
        else
            $v2 = &$B;

        $r = array();
        foreach ($v1 as $k=>$v) {
            $r[$k] = $v;
        }
        foreach ($v2 as $k=>$v) {
            if (isset($r[$k]))
                $r[$k] -= $v;
            else
                $r[$k] = $v;
        }

        return sqrt(
            array_sum(
                array_map(
                    function ($x) {
                        return $x*$x;
                    },
                    $r
                )
            )
        );
    }
807127
public function compute(array $a, array $b) : float
    {
        $deltas = [];

        foreach ($a as $i => $value) {
            $deltas[] = abs($value - $b[$i]);
        }

        return max($deltas);
    }
396258
def ApproximateDistanceBetweenStops(stop1, stop2):
  """"""
  if (stop1.stop_lat is None or stop1.stop_lon is None or
      stop2.stop_lat is None or stop2.stop_lon is None):
    return None
  return ApproximateDistance(stop1.stop_lat, stop1.stop_lon,
                             stop2.stop_lat, stop2.stop_lon)
319084
public static function compare(array $a, array $b)
    {
        if ($a['quality'] !== $b['quality']) {
            return $a['quality'] > $b['quality'] ? -1 : 1;
        }

        if ($a['index'] !== $b['index']) {
            return $a['index'] > $b['index'] ? 1 : -1;
        }

        return 0;
    }
216524
function getDistance(a, b) {
        var x, y;
        x = a.left - b.left;
        y = a.top - b.top;
        return Math.sqrt(x * x + y * y);
    }
747832
public function computeUsingBcMath(DecimalNumber $a, DecimalNumber $b)
    {
        $precision1 = $a->getPrecision();
        $precision2 = $b->getPrecision();

        return new DecimalNumber((string) bcmul($a, $b, $precision1 + $precision2));
    }
736869
public static float distanceSq( float[] a , float[]b ) {
		float ret = 0;
		for( int i = 0; i < a.length; i++ ) {
			float d = a[i] - b[i];
			ret += d*d;
		}
		return ret;
	}
723224
public function compute(array $a, array $b) : float
    {
        $distance = 0.;

        foreach ($a as $i => $value) {
            $distance += abs($value - $b[$i]) ** $this->lambda;
        }

        return $distance ** $this->inverse;
    }
1194820
function geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit='M') {
        
      // calculate miles
      $M =  69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2)))); 

      switch(strtoupper($unit))
      {
        case 'K':
          // kilometers
          return $M * 1.609344;
          break;
        case 'N':
          // nautical miles
          return $M * 0.868976242;
          break;
        case 'F':
          // feet
          return $M * 5280;
          break;            
        case 'I':
          // inches
          return $M * 63360;
          break;            
        case 'M':
        default:
          // miles
          return $M;
          break;
      }
      
    }
590182
public function distance(Location $otherLocation)
    {
        $theta = $this->longitude - $otherLocation->getLongitude();
        $distance = (sin(deg2rad($this->latitude))
            * sin(deg2rad($otherLocation->getLatitude())))
            + (cos(deg2rad($this->latitude))
            * cos(deg2rad($otherLocation->getLatitude()))
            * cos(deg2rad($theta)));
        $distance = acos($distance);
        $distance = rad2deg($distance);

        return (float) $distance * 60 * 1.1515;
    }
863393
function getCoordDistance($latitude1, $longitude1, $latitude2, $longitude2)
        {
            $earth_radius = 6371;

            $latitude1 = floatval($latitude1);
            $longitude1 = floatval($longitude1);
            $latitude2 = floatval($latitude2);
            $longitude2 = floatval($longitude2);

            $dLat = deg2rad($latitude2 - $latitude1);
            $dLon = deg2rad($longitude2 - $longitude1);

            $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($dLon / 2) * sin($dLon / 2);
            $c = 2 * asin(sqrt($a));
            $d = $earth_radius * $c;

            return $d;

        }