def d2yxu(self, i, j): '''Return distance squared, points[i] to -[j] deltas and longitudinal unrollment. ''' p1 = self.pts[i] p2 = self.pts[j] return equirectangular_(p1.lat, p1.lon, p2.lat, p2.lon, **self.options)
def distance2(self, other, radius=R_M, adjust=False, wrap=False): '''Compute the distance between this and an other geohash using the U{Equirectangular Approximation / Projection <http://www.movable-type.co.uk/scripts/latlong.html>}. @param other: The other geohash (L{Geohash}). @keyword radius: Optional, mean earth radius (meter) or None. @keyword adjust: Adjust the wrapped, unrolled longitudinal delta by the cosine of the mean latitude (bool). @keyword wrap: Wrap and unroll longitudes (bool). @return: Approximate distance (meter, same units as I{radius}) or distance squared (degrees squared) if I{radius} is None or 0. @raise TypeError: The I{other} is not a L{Geohash}, I{LatLon} or str. ''' other = _2Geohash(other) a1, b1 = self.latlon a2, b2 = other.latlon if radius: return equirectangular(a1, b1, a2, b2, radius=radius, adjust=adjust, limit=None, wrap=wrap) else: return equirectangular_(a1, b1, a2, b2, adjust=adjust, limit=None, wrap=wrap)[0]
def equirectangular3(lat1, lon1, lat2, lon2, **options): '''For backward compatibility only, obsolete, replaced by function L{utils.equirectangular_}. See function L{utils.equirectangular_} for more details, the available I{options} and errors raised. @return: 3-Tuple (distance2, delta_lat, delta_lon). ''' return utils.equirectangular_(lat1, lon1, lat2, lon2, **options)[:3]
def _degs(n, pts, closed): # angular edge lengths in degrees u = 0 # previous x2's unroll/wrap if closed: j, i = 0, n-1 else: j, i = 1, 0 x1, y1, _ = pts[i] for i in range(j, n): x2, y2, _ = pts[i] # apply previous x2's unroll/wrap to new x1 d2, _, _, u = equirectangular_(y1, x1 + u, y2, x2, adjust=adjust, limit=None, wrap=wrap) yield sqrt(d2) x1, y1 = x2, y2
def _d2yx(p2, p1, u): # equirectangular_ returns a 4-tuple (distance in # degrees squared, delta lat, delta lon, p2.lon # unroll/wrap); the previous p2.lon unroll/wrap # is also applied to the next edge's p1.lon return equirectangular_(p1.lat, p1.lon + u, p2.lat, p2.lon, **options)