Get a primed instance of the distance object
@param string|float $lat1
@param string|float $long1
@param string|float $lat2
@param string|float $long2
@return \Treffynnon\Navigator\Distance
768592
public static function distanceFactory($lat1, $long1, $lat2, $long2) {
        $point1 = new L(new C($lat1), new C($long1));
        $point2 = new L(new C($lat2), new C($long2));
        return new D($point1, $point2);
    }
252351
public static double distanceBetween(double latitude1, double longitude1, double latitude2, double longitude2) {
        double dLat = toRadians(latitude2 - latitude1);
        double dLon = toRadians(longitude2 - longitude1);
        latitude1 = toRadians(latitude1);
        latitude2 = toRadians(latitude2);

        double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(latitude1) * Math.cos(latitude2);
        double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
        return EARTH_RADIUS * c;
    }
421797
public static function WGStoCHy($lat, $long)
    {

        // Converts decimal degrees sexagesimal seconds
        $lat = self::DECtoSEX($lat);
        $long = self::DECtoSEX($long);

        // Auxiliary values (% Bern)
        $lat_aux = ($lat - 169028.66) / 10000;
        $long_aux = ($long - 26782.5) / 10000;

        // Process Y
        $y = 600072.37
            + 211455.93 * $long_aux
            - 10938.51 * $long_aux * $lat_aux
            - 0.36 * $long_aux * pow($lat_aux, 2)
            - 44.54 * pow($long_aux, 3);

        return $y;
    }
1136801
public long distance2(int[] point1, int[] point2) throws Exception {
    if (point1.length == point2.length) {
      long sum = 0;
      for (int i = 0; i < point1.length; i++) {
        sum = sum + (point2[i] - point1[i]) * (point2[i] - point1[i]);
      }
      return sum;
    }
    else {
      throw new Exception("Exception in Euclidean distance: array lengths are not equal");
    }
  }
769587
public static float distance(PointF p1, PointF p2){
        return (float) Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow(p2.y - p1.y,2));
    }
646091
public function getDistance($geo1, $geo2)
    {
        try {
            $lat1 = $geo1['lat'];
            $lng1 = $geo1['lng'];
            $lat2 = $geo2['lat'];
            $lng2 = $geo2['lng'];

            $earthRadius = 6367000; //approximate radius of earth in meters

            $lat1 = ($lat1 * pi() ) / 180;
            $lng1 = ($lng1 * pi() ) / 180;

            $lat2 = ($lat2 * pi() ) / 180;
            $lng2 = ($lng2 * pi() ) / 180;

            $calcLongitude = $lng2 - $lng1;
            $calcLatitude = $lat2 - $lat1;
            $stepOne = pow(sin($calcLatitude / 2), 2) + cos($lat1) * cos($lat2) * pow(sin($calcLongitude / 2), 2);
            $stepTwo = 2 * asin(min(1, sqrt($stepOne)));
            $calculatedDistance = $earthRadius * $stepTwo;

            return round($calculatedDistance);
        } catch (Exception $e) {
            throw $e;
        }
    }
342394
public double distance(int[] point1, int[] point2) throws Exception {
    return Math.sqrt(Long.valueOf(distance2(point1, point2)).doubleValue());
  }
1360991
public function getDistance (MapElement $map)
	{
		if (!$this->_location || !$this->_distance)
			return null;

		$originLat = $this->_location['lat'];
		$originLng = $this->_location['lng'];

		$targetLat = $map->lat;
		$targetLng = $map->lng;

		return (
			$this->_distance *
			rad2deg(
				acos(
					cos(deg2rad($originLat)) *
					cos(deg2rad($targetLat)) *
					cos(deg2rad($originLng) - deg2rad($targetLng)) +
					sin(deg2rad($originLat)) *
					sin(deg2rad($targetLat))
				)
			)
		);
	}
616167
private function longestCommonPrefixLength($string1, $string2)
    {
        $length = min(strlen($string1), strlen($string2));
        $index  = 0;

        while ($index < $length) {
            if ($string1[$index] !== $string2[$index]) {
                break;
            }

            ++$index;
        }

        return $index;
    }
574008
public function closest($date1, $date2)
    {
        return $this->diffInSeconds($date1) < $this->diffInSeconds($date2) ? $date1 : $date2;
    }
756157
public static function between(
        $latitude1,
        $longitude1,
        $latitude2,
        $longitude2,
        $decimals = 1,
        $unit = 'km'
    ) {
        // define calculation variables
        $theta = $longitude1 - $longitude2;
        $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2)))
            + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)))
        ;
        $distance = acos($distance);
        $distance = rad2deg($distance);
        $distance = $distance * 60 * 1.1515;

        // unit is km
        if ($unit == 'km') {
            // redefine distance
            $distance = $distance * 1.609344;
        }

        // return with one decimal
        return round($distance, $decimals);
    }
996230
public function getDistance($X1, $Y1, $X2, $Y2)
    {
        return sqrt(($X2 - $X1) * ($X2 - $X1) + ($Y2 - $Y1) * ($Y2 - $Y1));
    }
1321556
public static double getLongitudeDistance(double minLongitude,
                                              double maxLongitude,
                                              double latitude) {
        LatLng leftMiddle = new LatLng(latitude, minLongitude);
        LatLng middle = new LatLng(latitude, (minLongitude + maxLongitude) / 2.0);
        LatLng rightMiddle = new LatLng(latitude, maxLongitude);

        List<LatLng> path = new ArrayList<LatLng>();
        path.add(leftMiddle);
        path.add(middle);
        path.add(rightMiddle);

        double lonDistance = SphericalUtil.computeLength(path);
        return lonDistance;
    }
779318
def Distance(lat1, lon1, lat2, lon2):
    """"""

    az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
    return az21, dist
803680
@SuppressWarnings("unchecked")
  public static <T> Parser<T> longer(Parser<? extends T> p1, Parser<? extends T> p2) {
    return longest(p1, p2);
  }
1020436
public function whereLocation($lat, $long, $distance_in_meters = 10000)
	{
		$this->query = $this->index->addConditionToQuery($this->query, array(
			'lat'      => $lat,
			'long'     => $long,
			'distance' => $distance_in_meters,
		));
		
		return $this;
	}
771662
public static function levenshteinDistance($string1, $string2,  $costReplace = 1, $encoding = 'UTF-8')
    {
        $mbStringToArrayFunc = function ($string) use ($encoding)
        {
            $arrayResult = [];
            while ($iLen = mb_strlen($string, $encoding)) {
                array_push($arrayResult, mb_substr($string, 0, 1, $encoding));
                $string = mb_substr($string, 1, $iLen, $encoding);
            }
            return $arrayResult;
        };

        $countSameLetter = 0;
        $d = [];
        $mbLen1 = mb_strlen($string1, $encoding);
        $mbLen2 = mb_strlen($string2, $encoding);

        $mbStr1 = $mbStringToArrayFunc($string1, $encoding);
        $mbStr2 = $mbStringToArrayFunc($string2, $encoding);

        $maxCount = count($mbStr1) > count($mbStr2) ? count($mbStr1) : count($mbStr2);

        for ($i1 = 0; $i1 <= $mbLen1; $i1++) {
            $d[$i1] = [];
            $d[$i1][0] = $i1;
        }

        for ($i2 = 0; $i2 <= $mbLen2; $i2++) {
            $d[0][$i2] = $i2;
        }

        for ($i1 = 1; $i1 <= $mbLen1; $i1++) {
            for ($i2 = 1; $i2 <= $mbLen2; $i2++) {
                // $cost = ($str1[$i1 - 1] == $str2[$i2 - 1]) ? 0 : 1;
                if ($mbStr1[$i1 - 1] === $mbStr2[$i2 - 1]) {
                    $cost = 0;
                    $countSameLetter++;
                } else {
                    $cost = $costReplace; //替换
                }
                $d[$i1][$i2] = min($d[$i1 - 1][$i2] + 1, //插入
                    $d[$i1][$i2 - 1] + 1, //删除
                    $d[$i1 - 1][$i2 - 1] + $cost);
            }
        }

        $percent  = round(($maxCount - $d[$mbLen1][$mbLen2]) / $maxCount, 2);

        //return $d[$mbLen1][$mbLen2];
        return ['distance' => $d[$mbLen1][$mbLen2], 'count_same_letter' => $countSameLetter, 'percent' => $percent];
    }