Exemple #1
0
 def philam(self):
     '''Get the lat- and longitude ((L{PhiLam2Tuple}C{(phi, lam)}).
     '''
     if self._philam is None:
         r = self.latlon
         self._philam = PhiLam2Tuple(Phi_(r.lat), Lam_(r.lon))
     return self._xnamed(self._philam)
Exemple #2
0
 def philam(self):
     '''Get the lat- and longitude in C{radians} (L{PhiLam2Tuple}).
     '''
     if self._philam is None:
         self._philam = PhiLam2Tuple(radians(self.latlon.lat),
                                     radians(self.latlon.lon))
     return self._xnamed(self._philam)
Exemple #3
0
    def point(self, point):
        '''Convert C{(lat, lon)} point in degrees to C{(a, b)}
           in radians.

           @return: An L{PhiLam2Tuple}C{(phi, lam)}.
        '''
        return PhiLam2Tuple(radians(point.lat), radians(point.lon))
    def to2ab(self):
        '''Return this point's lat- and longitude in C{radians}.

           @return: A L{PhiLam2Tuple}C{(phi, lam)}.
        '''
        if self._ab is None:
            self._ab = PhiLam2Tuple(radians(self.lat), radians(self.lon))
        return self._xnamed(self._ab)
Exemple #5
0
    def to2ab(self):
        '''Return this point's lat- and longitude in C{radians}.

           @return: A L{PhiLam2Tuple}C{(phi, lambda)}.
        '''
        if not self._ab:
            a, b = map1(radians, self.lat, self.lon)
            self._ab = self._xnamed(PhiLam2Tuple(a, b))
        return self._ab
Exemple #6
0
    def point(self, point):
        '''Convert C{(lat, lon)} point in degrees to C{(a, b)}
           in radians.

           @return: An L{PhiLam2Tuple}C{(phi, lam)}.
        '''
        try:
            return point.philam
        except AttributeError:  # PYCHOK no cover
            return PhiLam2Tuple(radians(point.lat), radians(point.lon))
Exemple #7
0
def n_xyz2philam(x, y, z):
    '''Convert C{n-vector} components to lat- and longitude in C{radians}.

       @arg x: X component (C{scalar}).
       @arg y: Y component (C{scalar}).
       @arg z: Z component (C{scalar}).

       @return: A L{PhiLam2Tuple}C{(phi, lam)}.

       @see: Function L{n_xyz2latlon}.
    '''
    return PhiLam2Tuple(atan2(z, hypot(x, y)), atan2(y, x))
Exemple #8
0
def antipode_(phi, lam):
    '''Return the antipode, the point diametrically opposite
       to a given point in C{radians}.

       @arg phi: Latitude (C{radians}).
       @arg lam: Longitude (C{radians}).

       @return: A L{PhiLam2Tuple}C{(phi, lam)}.

       @see: U{Geosphere<https://CRAN.R-Project.org/web/packages/geosphere/geosphere.pdf>}.
    '''
    return PhiLam2Tuple(-wrapPI_2(phi), wrapPI(lam + PI))
Exemple #9
0
    def to2ab(self):
        '''Convert this vector to (geodetic) lat- and longitude in C{radians}.

           @return: A L{PhiLam2Tuple}C{(phi, lam)}.

           @example:

           >>> v = Vector3d(0.500, 0.500, 0.707)
           >>> a, b = v.to2ab()  # 0.785323, 0.785398
        '''
        a = atan2(self.z, hypot(self.x, self.y))
        b = atan2(self.y, self.x)
        return self._xnamed(PhiLam2Tuple(a, b))
Exemple #10
0
    def philam2(self, ndigits=0):
        '''Return this point's lat- and longitude in C{radians}, rounded.

           @keyword ndigits: Number of decimal digits (C{int}).

           @return: A L{PhiLam2Tuple}C{(phi, lam)}, both C{float}
                    and rounded away from zero.

           @note: The C{round}ed values are always C{float}, also
                  if B{C{ndigits}} is omitted.
        '''
        r = PhiLam2Tuple(round(self.phi, ndigits), round(self.lam, ndigits))
        return self._xnamed(r)
Exemple #11
0
 def philam0(self):
     '''Get the central origin (L{PhiLam2Tuple}C{(phi, lam)}).
     '''
     return self._xnamed(PhiLam2Tuple(self.phi0, self.lam0))
Exemple #12
0
    def testNvectorBase(self, module, **kwds):

        try:
            Nvector = module.Nvector
            c = Nvector.__name__
        except AttributeError:
            Nvector = module.NvectorBase
            c = 'Vector4Tuple'
        self.subtitle(module, Nvector.__name__)

        v = Nvector(0.500, 0.500, 0.707, **kwds)
        s = module.sumOf((v, v), h=0, name='sumOf')
        self.test('sumOf', s.__class__.__name__, c)

        p = v.toLatLon(LatLon=None)
        c = v.toCartesian(Cartesian=None)
        self.test('ecef.x, .y, .z', fstr(p[:3], prec=5), fstr(c[:3], prec=5))
        self.test('ecef.lat, .lon', fstr(p[3:5], prec=6), fstr(c[3:5], prec=6))
        self.test('ecef.height',
                  fstr(p.height, prec=6),
                  fstr(c.height, prec=6),
                  known=True)
        if c.M is not None:
            self.test('ecef.M', fstr(p.M, prec=9), fstr(c.M, prec=9))

        if coverage:
            from pygeodesy.named import LatLon2Tuple, LatLon3Tuple, \
                                        PhiLam2Tuple, PhiLam3Tuple

            self.test('.isEllipsoidal', v.isEllipsoidal, not v.isSpherical)
            self.test('.isSpherical', v.isSpherical, not v.isEllipsoidal)

            self.test('.latlon', v.latlon, LatLon2Tuple(v.lat, v.lon))
            self.test('.philam', v.philam, PhiLam2Tuple(v.phi, v.lam))

            self.test('.latlonheight', v.latlonheight,
                      LatLon3Tuple(v.lat, v.lon, float(v.h)))
            self.test('.philamheight', v.philamheight,
                      PhiLam3Tuple(v.phi, v.lam, float(v.h)))

            t = v.parse('0.5, 0.5, 0.707')
            self.test('parse', t, v)
            self.test('cmp', t.cmp(v), 0)

            self.test('eq', t == v, True)
            self.test('ge', t >= v, True)
            self.test('gt', t > v, False)
            self.test('le', t <= v, True)
            self.test('lt', t < v, False)
            self.test('ne', t != v, False)

            m = t * 2
            self.test('*', m, '(1.0, 1.0, 1.414)')
            self.test('+', t + v, m)
            self.test('/', m / 2, t)
            self.test('-', m - t, t)

            m = v.__matmul__(t)
            self.test('@', m, '(0.0, 0.0, 0.0)')
            r = t.__rmatmul__(m)
            self.test('@', r, m)

            r = v.rotate(m, 45)
            self.test('rotate', r, '(0.26268, 0.26268, 0.37143)')
Exemple #13
0
 def philam(self):
     '''Get the lat-, longitude in C{radians} (L{PhiLam2Tuple}C{(phi, lam)}).
     '''
     return self._xnamed(PhiLam2Tuple(radians(self.lat), radians(self.lon)))
Exemple #14
0
 def philam(self):
     '''Get the lat- and longitude ((L{PhiLam2Tuple}C{(phi, lam)}).
     '''
     if self._philam is None:
         self._philam = PhiLam2Tuple(*map(radians, self.latlon))
     return self._xnamed(self._philam)