Return distance between two coordinates using Haversine formula
@param {Object} coordinateOne Object containing latitude, and longitude keys
@param {Object} coordinateTwo Object containing latitude, and longitude keys
@return {Float}
482675
function _haversineCalculation(coordinateOne, coordinateTwo) {
// Credits
// https://www.movable-type.co.uk/scripts/latlong.html
// https://en.wikipedia.org/wiki/Haversine_formula
  let latitudeOneRadians = _convertDegreesToRadians(coordinateOne.latitude);
  let latitudeTwoRadians = _convertDegreesToRadians(coordinateTwo.latitude);

  let longitudeOneRadians = _convertDegreesToRadians(coordinateOne.longitude);
  let longitudeTwoRadians = _convertDegreesToRadians(coordinateTwo.longitude);

  let differenceOfLatitude = latitudeOneRadians - latitudeTwoRadians;
  let differenceOfLongitude = longitudeOneRadians - longitudeTwoRadians;

  // The square of half the chord length between the points
  let a = Math.sin(differenceOfLatitude / 2) * Math.sin(differenceOfLatitude / 2)
    + Math.sin(differenceOfLongitude / 2) * Math.sin(differenceOfLongitude / 2)
    * Math.cos(latitudeOneRadians) * Math.cos(latitudeTwoRadians);

  let angularDistanceInRadians = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

  let distanceBetweenKM = EARTH_RADIUS_KM * angularDistanceInRadians;

  return distanceBetweenKM;
}
737182
final double calculateRMin(double lat, double lon, int paddingTiles) {
        GHPoint query = new GHPoint(lat, lon);
        long key = keyAlgo.encode(query);
        GHPoint center = new GHPoint();
        keyAlgo.decode(key, center);

        // deltaLat and deltaLon comes from the LocationIndex:
        double minLat = center.lat - (0.5 + paddingTiles) * deltaLat;
        double maxLat = center.lat + (0.5 + paddingTiles) * deltaLat;
        double minLon = center.lon - (0.5 + paddingTiles) * deltaLon;
        double maxLon = center.lon + (0.5 + paddingTiles) * deltaLon;

        double dSouthernLat = query.lat - minLat;
        double dNorthernLat = maxLat - query.lat;
        double dWesternLon = query.lon - minLon;
        double dEasternLon = maxLon - query.lon;

        // convert degree deltas into a radius in meter
        double dMinLat, dMinLon;
        if (dSouthernLat < dNorthernLat) {
            dMinLat = distCalc.calcDist(query.lat, query.lon, minLat, query.lon);
        } else {
            dMinLat = distCalc.calcDist(query.lat, query.lon, maxLat, query.lon);
        }

        if (dWesternLon < dEasternLon) {
            dMinLon = distCalc.calcDist(query.lat, query.lon, query.lat, minLon);
        } else {
            dMinLon = distCalc.calcDist(query.lat, query.lon, query.lat, maxLon);
        }

        double rMin = Math.min(dMinLat, dMinLon);
        return rMin;
    }
313406
def distance(latitude_1, longitude_1, latitude_2, longitude_2):
    

    coef = mod_math.cos(latitude_1 / 180. * mod_math.pi)
    x = latitude_1 - latitude_2
    y = (longitude_1 - longitude_2) * coef

    return mod_math.sqrt(x * x + y * y) * ONE_DEGREE
624473
public double getDistance(Coordinate coordinate) {
		double distance = Double.MAX_VALUE;
		if (!isEmpty()) {
			for (LineString lineString : lineStrings) {
				double d = lineString.getDistance(coordinate);
				if (d < distance) {
					distance = d;
				}
			}
		}
		return distance;
	}
1019031
public Double haversine(Position other) {
		double lon0r = toRadians(this.longitude);
		double lat0r = toRadians(this.latitude);
		double lon1r = toRadians(other.longitude);
		double lat1r = toRadians(other.latitude);
		double a = pow(sin((lat1r - lat0r) / 2.0), 2);
		double b = cos(lat0r) * cos(lat1r) * pow(sin((lon1r - lon0r) / 2.0), 2);

		return 6371000.0 * 2 * asin(sqrt(a + b));
	}
1339016
function (coord) {
        var extent = this._extent;
        var min = Math.min(extent[0], extent[1]);
        var max = Math.max(extent[0], extent[1]);
        return coord >= min && coord <= max;
    }
514484
function (other) { // (LatLng) -> Number
		other = L.latLng(other);

		var R = 6378137, // earth radius in meters
		    d2r = L.LatLng.DEG_TO_RAD,
		    dLat = (other.lat - this.lat) * d2r,
		    dLon = (other.lng - this.lng) * d2r,
		    lat1 = this.lat * d2r,
		    lat2 = other.lat * d2r,
		    sin1 = Math.sin(dLat / 2),
		    sin2 = Math.sin(dLon / 2);

		var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2);

		return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
	}
618887
def distance(self, loc):
        
        assert type(loc) == type(self)

        # convert decimal degrees to radians
        lon1, lat1, lon2, lat2 = map(radians, [
            self.lon,
            self.lat,
            loc.lon,
            loc.lat,
        ])

        # haversine formula
        dlon = lon2 - lon1
        dlat = lat2 - lat1
        a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
        c = 2 * asin(sqrt(a))
        r = 6371000 # Radius of earth in meters.
        return c * r
1243610
@Pure
	public double distance(double x, double y) {
		if (isValidPrimitive()) {
			final GeoLocationPoint p = getGeoPosition();
			return Point2D.getDistancePointPoint(p.getX(), p.getY(), x, y);
		}
		return Double.NaN;
	}
740807
public float distance(float x, float y, float z, float w) {
        return (float) Math.sqrt(distanceSquared(x, y, z, w));
    }
276917
def distance(latitude_1, longitude_1, elevation_1, latitude_2, longitude_2, elevation_2,
             haversine=None):
    

    # If points too distant -- compute haversine distance:
    if haversine or (abs(latitude_1 - latitude_2) > .2 or abs(longitude_1 - longitude_2) > .2):
        return haversine_distance(latitude_1, longitude_1, latitude_2, longitude_2)

    coef = math.cos(latitude_1 / 180. * math.pi)
    #pylint: disable=invalid-name
    x = latitude_1 - latitude_2
    y = (longitude_1 - longitude_2) * coef

    distance_2d = math.sqrt(x * x + y * y) * ONE_DEGREE

    if elevation_1 is None or elevation_2 is None or elevation_1 == elevation_2:
        return distance_2d

    return math.sqrt(distance_2d ** 2 + (elevation_1 - elevation_2) ** 2)
353238
function (wgsLon, wgsLat) {
        if (this.outOfChina(wgsLat, wgsLon))
            return [wgsLon, wgsLat];

        var d = this.delta(wgsLat, wgsLon);
        return [wgsLon + d.lon, wgsLat + d.lat];
    }
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;
      }
      
    }
878109
private Coordinate[] getOrderedNodes( Coordinate c, Coordinate coordinate1, Coordinate coordinate2, Coordinate coordinate3 ) {
        double d = distance3d(c, coordinate1, null);
        Coordinate nearest = coordinate1;
        Coordinate c2 = coordinate2;
        Coordinate c3 = coordinate3;

        double d2 = distance3d(c, coordinate2, null);
        if (d2 < d) {
            nearest = coordinate2;
            d = d2;
            c2 = coordinate1;
            c3 = coordinate3;
        }
        double d3 = distance3d(c, coordinate3, null);
        if (d3 < d) {
            nearest = coordinate3;
            c2 = coordinate1;
            c3 = coordinate2;
        }
        return new Coordinate[]{nearest, c2, c3};
    }
847936
function getDistanceInKilometers(p1, p2) {
  // Credit: adapts code for Haversine formula and degrees-to-radian conversion found at:
  // http://www.movable-type.co.uk/scripts/latlong.html

  var R = 6371; // earth's radius in kilometers
  var dLat = degreesToRadians(p2.lat - p1.lat);
  var dLon = degreesToRadians(p2.lng - p1.lng); 
  var lat1 = degreesToRadians(p1.lat);
  var lat2 = degreesToRadians(p2.lat);

  var a = 
    Math.sin(dLat/2) * Math.sin(dLat/2)
    + Math.sin(dLon/2) * Math.sin(dLon/2)
    * Math.cos(lat1) * Math.cos(lat2);

  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  var distance = R * c; // kilomter
  return distance;
}
272310
public double distanceSquared(Vector o) {
        return NumberConversions.square(x - o.x) + NumberConversions.square(y - o.y) + NumberConversions.square(z - o.z);
    }
260687
function getElementCoords (element, coords) {
  coords = coords || element.node().getBBox()
  const ctm = element.node().getCTM()
  const xn = ctm.e + coords.x * ctm.a
  const yn = ctm.f + coords.y * ctm.d
  return {
    left: xn,
    top: yn,
    width: coords.width,
    height: coords.height
  }
}