예제 #1
0
    def toLatLon(self,
                 datum=None,
                 LatLon=None,
                 **LatLon_kwds):  # see .ecef.Ecef9Tuple.convertDatum
        '''Convert this cartesian to a geodetic (lat-/longitude) point.

           @kwarg datum: Optional datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}
                         or L{a_f2Tuple}).
           @kwarg LatLon: Optional class to return the geodetic point
                          (C{LatLon}) or C{None}.
           @kwarg LatLon_kwds: Optional, additional B{C{LatLon}}
                               keyword arguments, ignored if
                               C{B{LatLon}=None}.

           @return: The geodetic point (B{C{LatLon}}) or if B{C{LatLon}}
                    is C{None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon,
                    height, C, M, datum)} with C{C} and C{M} if available.

           @raise TypeError: Invalid B{C{datum}} or B{C{LatLon_kwds}}.
        '''
        d = self.datum
        if datum in (None, d):
            r = self.toEcef()
        else:
            c = self.convertDatum(datum)
            d = c.datum
            r = c.Ecef(d).reverse(c, M=True)

        if LatLon is not None:  # class or .classof
            kwds = _xkwds(LatLon_kwds, datum=r.datum, height=r.height)
            r = LatLon(r.lat, r.lon, **kwds)
        _datum_datum(r.datum, d)
        return self._xnamed(r)
예제 #2
0
    def toLatLon(self, datum=None, LatLon=None, **LatLon_kwds):
        '''Convert this cartesian to a geodetic (lat-/longitude) point.

           @kwarg datum: Optional datum (L{Datum}) or C{None}.
           @kwarg LatLon: Optional class to return the geodetic point
                          (C{LatLon}) or C{None}.
           @kwarg LatLon_kwds: Optional, additional B{C{LatLon}}
                               keyword arguments, ignored if
                               B{C{LatLon=None}}.

           @return: The geodetic point (B{C{LatLon}}) or if B{C{LatLon}}
                    is C{None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon,
                    height, C, M, datum)} with C{C} and C{M} if available.

           @raise TypeError: Invalid B{C{datum}} or B{C{LatLon_kwds}}.
        '''
        if datum in (None, self.datum):
            r = self.toEcef()
        else:
            _xinstanceof(Datum, datum=datum)
            c = self.convertDatum(datum)
            r = c.Ecef(c.datum).reverse(c, M=True)

        if LatLon is not None:  # class or .classof
            r = LatLon(r.lat, r.lon,
                       **_xkwds(LatLon_kwds, datum=r.datum, height=r.height))
        _datum_datum(r.datum, datum or self.datum)
        return self._xnamed(r)
예제 #3
0
    def toCartesian(self, Cartesian=None, **Cartesian_kwds):
        '''Convert this point to cartesian (ECEF) coordinates.

           @kwarg Cartesian: Optional class to return the geocentric
                             coordinates (C{Cartesian}) or C{None}.
           @kwarg Cartesian_kwds: Optional, additional B{C{Cartesian}}
                                  keyword arguments, ignored if
                                  B{C{Cartesian=None}}.

           @return: A B{C{Cartesian}} or if B{C{Cartesian}} is C{None},
                    an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C, M,
                    datum)} with C{C=0} and C{M} if available.

           @raise TypeError: Invalid B{C{Cartesian}} or B{C{Cartesian_kwds}}.
        '''
        r = self.toEcef()
        if Cartesian is not None:  # class or .classof
            r = Cartesian(r, **Cartesian_kwds)
            r = self._xnamed(r)
        _datum_datum(r.datum, self.datum)
        return r
예제 #4
0
    def _datumatch(self, latlon):
        '''Check for matching datum ellipsoids.

           @raise CSSError: Ellipsoidal mismatch of B{C{latlon}} and this projection.
        '''
        _datum_datum(self.datum, latlon.datum, Error=CSSError)