Get distance between pairs of lat-lon points
779318
def Distance(lat1, lon1, lat2, lon2):
    """"""

    az12, az21, dist = wgs84_geod.inv(lon1, lat1, lon2, lat2)
    return az21, dist
159315
def get_bbox(self, points=None):
        
        if points is None:
            x1, y1, x2, y2 = self.get_llur()
            return ((x1, y1), (x1, y2), (x2, y2), (x2, y1))
        else:
            return trcalc.strip_z(trcalc.get_bounds(points))
883099
def gps_distance(lat1, lon1, lat2, lon2):
    ''''''
    lat1 = math.radians(lat1)
    lat2 = math.radians(lat2)
    lon1 = math.radians(lon1)
    lon2 = math.radians(lon2)
    dLat = lat2 - lat1
    dLon = lon2 - lon1

    a = math.sin(0.5*dLat)**2 + math.sin(0.5*dLon)**2 * math.cos(lat1) * math.cos(lat2)
    c = 2.0 * math.atan2(math.sqrt(a), math.sqrt(1.0-a))
    return radius_of_earth * c
803346
def distances(self, points):
        """"""
        return [math.acos(self._pos3d.dot(p.vector)) for p in points]
780899
public double distance(Double lat, Double lon) {
		return calculateDistance(latitude, longitude, lat, lon);
	}
220288
def distance_from(self, lat, lon):
        ''''''
        lat1 = self.pkt['I105']['Lat']['val']
        lon1 = self.pkt['I105']['Lon']['val']
        return mp_util.gps_distance(lat1, lon1, lat, lon)
310430
def distance_to(self, p: Union["Unit", Point2, Point3], bot: "BotAI" = None) -> Union[int, float]:
        
        if bot and isinstance(p, Unit):
            index = bot.distances_tag_dict
            return (bot.unit_distances_dict[index[self.tag]][index[p.tag]]) ** 0.5
        return self.position.distance_to_point2(p.position)
264041
def _lats(self):
        """"""
        lats = _np.linspace(90.0, -90.0 + 180.0 / self.nlat, num=self.nlat)
        return lats
556957
def distance(self, lat, lon):
		''''''
		(tlat, tlon) = self.coord((TILES_WIDTH/2,TILES_HEIGHT/2))
		return mp_util.gps_distance(lat, lon, tlat, tlon)
595043
def getPointOnLine(x1, y1, x2, y2, n):
    
    x = ((x2 - x1) * n) + x1
    y = ((y2 - y1) * n) + y1
    return (x, y)
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;
      }
      
    }
1038426
function distanceFrom(Centroids) {
                var distances = [];

                for(var i = 1; i <= this.Observations.rows(); i++) {
                    var distance = [];

                    for(var j = 1; j <= Centroids.rows(); j++) {
                        distance.push(this.Observations.row(i).distanceFrom(Centroids.row(j)));
                    }

                    distances.push(distance);
                }

                return $M(distances);
            }
1082143
def point_distance(pt1, pt2):
    
    if len(pt1) != len(pt2):
        raise ValueError("The input points should have the same dimension")

    dist_vector = vector_generate(pt1, pt2, normalize=False)
    distance = vector_magnitude(dist_vector)
    return distance
171972
def get_h_distance(self, latlonalt1, latlonalt2):
        ''''''
        (lat1, lon1, alt1) = latlonalt1
        (lat2, lon2, alt2) = latlonalt2

        lat1 = radians(lat1)
        lon1 = radians(lon1)
        lat2 = radians(lat2)
        lon2 = radians(lon2)

        dLat = lat2 - lat1
        dLon = lon2 - lon1

        # math as per mavextra.distance_two()
        a = sin(0.5 * dLat)**2 + sin(0.5 * dLon)**2 * cos(lat1) * cos(lat2)
        c = 2.0 * atan2(sqrt(a), sqrt(1.0 - a))
        return 6371 * 1000 * c
901764
def lonlat2xyz(lon, lat):
    """"""
    lat = xu.deg2rad(lat)
    lon = xu.deg2rad(lon)
    x = xu.cos(lat) * xu.cos(lon)
    y = xu.cos(lat) * xu.sin(lon)
    z = xu.sin(lat)
    return x, y, z
1231945
function distance(from, to) {
  const degrees2radians = Math.PI / 180;
  const dLat = degrees2radians * (to[1] - from[1]);
  const dLon = degrees2radians * (to[0] - from[0]);
  const lat1 = degrees2radians * from[1];
  const lat2 = degrees2radians * to[1];

  const a = Math.pow(Math.sin(dLat / 2), 2) +
        Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
  return Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
1186780
def _get_distance(self, pnt1, pnt2):
        """"""
        lat1, lon1 = pnt1
        lat2, lon2 = pnt2
        radius = 6356752  # km
        dlat = math.radians(lat2 - lat1)
        dlon = math.radians(lon2 - lon1)
        a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) \
            * math.cos(math.radians(lat2)) * math.sin(dlon / 2) * math.sin(dlon / 2)
        c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
        d = radius * c
        return d