示例#1
0
    def equirectangularTo(self, other, radius=None, **options):
        '''Compute the distance between this and an other point
           using the U{Equirectangular Approximation / Projection
           <http://www.Movable-Type.co.UK/scripts/latlong.html>}.

           Suitable only for short, non-near-polar distances up to a
           few hundred Km or Miles.  Use method C{haversineTo} or
           C{distanceTo*} for more accurate and/or larger distances.

           See function L{equirectangular_} for more details, the
           available I{options} and errors raised.

           @param other: The other point (C{LatLon}).
           @keyword radius: Optional, mean earth radius (C{meter}) or
                            C{None} for the mean radius of this
                            point's datum ellipsoid.
           @keyword options: Optional keyword arguments for function
                             L{equirectangular}.

           @return: Distance (C{meter}, same units as I{radius}).

           @raise TypeError: The I{other} point is not C{LatLon}.
        '''
        self.others(other)

        r = radius or (self._datum.ellipsoid.R1 if self._datum else R_M)
        return equirectangular(self.lat, self.lon, other.lat, other.lon,
                               radius=r, **options)
示例#2
0
    def distance2To(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 (C{meter}) or
                            C{None}.
           @keyword adjust: Adjust the wrapped, unrolled longitudinal
                            delta by the cosine of the mean latitude
                            (C{bool}).
           @keyword wrap: Wrap and unroll longitudes (C{bool}).

           @return: Approximate distance (C{meter}, same units as I{radius})
                    or distance squared (C{degrees} squared) if I{radius}
                    is C{None} or 0.

           @raise TypeError: The I{other} is not a L{Geohash}, C{LatLon}
                             or C{str}.

           @see: U{Local, flat earth approximation
                 <http://www.EdWilliams.org/avform.htm#flat>}, functions
        '''
        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]