Example #1
0
    def toLatLon(self, LatLon=None, height=None, **LatLon_kwds):
        '''Convert this L{Css} to an (ellipsoidal) geodetic point.

           @kwarg LatLon: Optional, ellipsoidal class to return the
                          geodetic point (C{LatLon}) or C{None}.
           @kwarg height: Optional height for the point, overriding the
                          default height (C{meter}).
           @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}, a L{LatLon4Tuple}C{(lat, lon, height,
                    datum)}.

           @raise TypeError: If B{C{LatLon}} or B{C{datum}} is not
                             ellipsoidal or invalid B{C{height}} or
                             B{C{LatLon_kwds}}.
        '''
        if LatLon:
            _xsubclassof(_LLEB, LatLon=LatLon)

        lat, lon = self.latlon
        d = self.cs0.datum
        h = self.height if height is None else Height(height)

        r = LatLon4Tuple(lat, lon, h, d) if LatLon is None else \
                  LatLon(lat, lon, height=h, datum=d, **LatLon_kwds)
        return self._xnamed(r)
Example #2
0
    def reverse(self, easting, northing, LatLon=None, **LatLon_kwds):
        '''Convert a Cassini-Soldner location to (ellipsoidal) geodetic
           lat- and longitude.

           @arg easting: Easting of the location (C{meter}).
           @arg northing: Northing of the location (C{meter}).
           @kwarg LatLon: Optional, ellipsoidal class to return the
                          geodetic location as (C{LatLon}) or C{None}.
           @kwarg LatLon_kwds: Optional (C{LatLon}) keyword arguments,
                               ignored if B{C{LatLon=None}}.

           @return: Geodetic location B{C{LatLon}} or if B{C{LatLon}}
                    is C{None}, a L{LatLon2Tuple}C{(lat, lon)}.

           @raise CSSError: Ellipsoidal mismatch of B{C{LatLon}} and this projection.

           @raise TypeError: Invalid B{C{LatLon}} or B{C{LatLon_kwds}}.

           @see: Method L{CassiniSoldner.reverse4}, L{CassiniSoldner.forward}
                 and L{CassiniSoldner.forward4}.
        '''
        r = self.reverse4(easting, northing)
        if LatLon is None:
            r = LatLon2Tuple(r.lat, r.lon)  # PYCHOK expected
        else:
            _xsubclassof(_LLEB, LatLon=LatLon)
            kwds = _xkwds(LatLon_kwds, datum=self.datum)
            r = LatLon(r.lat, r.lon, **kwds)  # PYCHOK expected
            self._datumatch(r)
        return self._xnamed(r)
Example #3
0
 def _latlon3(self, LatLon, datum):
     '''(INTERNAL) Convert cached latlon to C{LatLon}
     '''
     ll = self._latlon
     if LatLon is None:
         r = _ll2datum(ll, datum, LatLonDatum3Tuple.__name__)
         r = LatLonDatum3Tuple(r.lat, r.lon, r.datum)
     else:  # must be ellipsoidal
         _xsubclassof(_LLEB, LatLon=LatLon)
         r = _ll2datum(ll, datum, LatLon.__name__)
         r = LatLon(r.lat, r.lon, datum=r.datum)
     r._iteration = ll._iteration
     return _xnamed(r, ll)
Example #4
0
 def _latlon5(self, LatLon, **LatLon_kwds):
     '''(INTERNAL) Convert cached LatLon
     '''
     ll = self._latlon
     if LatLon is None:
         r = LatLonDatum5Tuple(ll.lat, ll.lon, ll.datum, ll.convergence,
                               ll.scale)
     else:
         _xsubclassof(_LLEB, LatLon=LatLon)
         kwds = _xkwds(LatLon_kwds, datum=ll.datum)
         r = _xattrs(LatLon(ll.lat, ll.lon, **kwds), ll, '_convergence',
                     '_scale')
     return _xnamed(r, ll.name)
Example #5
0
 def _latlon3(self, LatLon, datum):
     '''(INTERNAL) Convert cached LatLon
     '''
     ll = self._latlon
     if LatLon is None:
         if datum and datum != ll.datum:
             raise TypeError('no %s.convertDatum: %r' % (LatLon, ll))
         return _xnamed(LatLonDatum3Tuple(ll.lat, ll.lon, ll.datum),
                        ll.name)
     else:
         _xsubclassof(_LLEB, LatLon=LatLon)
         ll = _xnamed(LatLon(ll.lat, ll.lon, datum=ll.datum), ll.name)
         return _ll2datum(ll, datum, 'LatLon')
Example #6
0
 def _latlon3(self, LatLon, datum):
     '''(INTERNAL) Convert cached LatLon
     '''
     ll = self._latlon
     if LatLon is None:
         if datum and datum != ll.datum:
             raise _TypeError(latlon=ll,
                              txt=_item_ps(_no_convertDatum_, datum.name))
         return _xnamed(LatLonDatum3Tuple(ll.lat, ll.lon, ll.datum),
                        ll.name)
     else:
         _xsubclassof(_LLEB, LatLon=LatLon)
         ll = _xnamed(LatLon(ll.lat, ll.lon, datum=ll.datum), ll.name)
         return _ll2datum(ll, datum, _LatLon_)
Example #7
0
    def toLatLon(self, LatLon=None, datum=None, height=None):
        '''Convert this L{Lcc} to an (ellipsoidal) geodetic point.

           @kwarg LatLon: Optional, ellipsoidal class to return the
                          geodetic point (C{LatLon}) or C{None}.
           @kwarg datum: Optional datum to use, otherwise use this
                         B{C{Lcc}}'s conic.datum (L{Datum}, L{Ellipsoid},
                         L{Ellipsoid2} or L{a_f2Tuple}).
           @kwarg height: Optional height for the point, overriding
                          the default height (C{meter}).

           @return: The point (B{C{LatLon}}) or a
                    L{LatLon4Tuple}C{(lat, lon, height, datum)}
                    if B{C{LatLon}} is C{None}.

           @raise TypeError: If B{C{LatLon}} or B{C{datum}} is
                             not ellipsoidal or not valid.
        '''
        if LatLon:
            _xsubclassof(_LLEB, LatLon=LatLon)

        c = self.conic
        if datum not in (None, c.datum):
            c = c.toDatum(datum)

        e = self.easting - c._E0
        n = c._r0 - self.northing + c._N0

        r_ = copysign(hypot(e, n), c._n)
        t_ = pow(r_ / c._aF, c._n_)

        x = c._xdef(t_)  # XXX c._lam0
        while True:
            p, x = x, c._xdef(t_ * c._pdef(x))
            if abs(x - p) < 1e-9:  # XXX EPS too small?
                break
        lat = degrees90(x)
        lon = degrees180((atan(e / n) + c._opt3) * c._n_ + c._lam0)

        h = self.height if height is None else height
        d = c.datum

        r = LatLon4Tuple(lat, lon, h, d) if LatLon is None else \
                  LatLon(lat, lon, height=h, datum=d)
        return self._xnamed(r)
Example #8
0
    def toCartesian(self, Cartesian, **Cartesian_kwds):
        '''Return the geocentric C{(x, y, z)} coordinates as an ellipsoidal or spherical
           C{Cartesian}.

           @arg Cartesian: L{ellipsoidalKarney.Cartesian}, L{ellipsoidalNvector.Cartesian},
                           L{ellipsoidalVincenty.Cartesian}, L{sphericalNvector.Cartesian} or
                           L{sphericalTrigonometry.Cartesian} class to return the C{(x, y, z)}
                           coordinates.
           @kwarg Cartesian_kwds: Optional B{C{Cartesian}} keyword arguments.

           @return: A B{C{Cartesian}}C{(x, y, z)} instance.

           @raise TypeError: Invalid B{C{Cartesian}} or B{C{Cartesian_kwds}}.
        '''
        from pygeodesy.cartesianBase import CartesianBase
        _xsubclassof(CartesianBase, Cartesian=Cartesian)
        r = Cartesian(self, **Cartesian_kwds)
        return self._xnamed(r)