コード例 #1
0
ファイル: css.py プロジェクト: tranngocphu/PyGeodesy
    def toLatLon(self, LatLon=None, height=None):
        '''Convert this L{Css} to an (ellipsoidal) geodetic point.

           @keyword LatLon: Optional, ellipsoidal (sub-)class to return
                            the geodetic point (C{LatLon}) or C{None}.
           @keyword 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.
        '''
        if LatLon and not issubclassof(LatLon, _LLEB):
            raise TypeError('%s not %s: %r' %
                            ('LatLon', 'ellipsoidal', LatLon))

        a, b = self.latlon
        d = self.cs0.datum
        h = self.height if height is None else height

        r = LatLon4Tuple(a, b, h, d) if LatLon is None else \
                  LatLon(a, b, height=h, datum=d)
        return self._xnamed(r)
コード例 #2
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)
コード例 #3
0
    def toLatLon(self, LatLon=None, datum=None, height=None):
        '''Convert this L{Lcc} to an (ellipsoidal) geodetic point.

           @keyword LatLon: Optional, ellipsoidal (sub-)class to return
                            the geodetic point (C{LatLon}) or C{None}.
           @keyword datum: Optional datum to use, otherwise use this
                           B{C{Lcc}}'s conic.datum (C{Datum}).
           @keyword 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.
        '''
        if LatLon and not issubclassof(LatLon, _LLEB):
            raise _IsNotError(_LLEB.__name__, LatLon=LatLon)

        a, b, d = self.to3lld(datum=datum)
        h = self.height if height is None else height

        r = LatLon4Tuple(a, b, h, d) if LatLon is None else \
                  LatLon(a, b, height=h, datum=d)
        return self._xnamed(r)
コード例 #4
0
 def _latlon4(t, h, n):
     if LatLon is None:
         r = LatLon4Tuple(t.lat, t.lon, h, t.datum)
     else:
         kwds = _xkwds(LatLon_kwds, datum=t.datum, height=h)
         r = LatLon(t.lat, t.lon, **kwds)
     r._iteration = t.iteration  # ._iteration for tests
     return _xnamed(r, n)
コード例 #5
0
    def to3llh(self, datum=None):  # PYCHOK no cover
        '''DEPRECATED, use property C{latlonheightdatum} or property C{latlonheight}.

           @return: A L{LatLon4Tuple}C{(lat, lon, height, datum)}.

           @note: This method returns a B{C{-4Tuple}} I{and not a} C{-3Tuple}
                  as its name suggests.
        '''
        t = self.toLatLon(datum=datum, LatLon=None)
        r = LatLon4Tuple(t.lat, t.lon, t.height, t.datum)
        return self._xnamed(r)
コード例 #6
0
    def to3llh(self, datum=None):  # PYCHOK no cover
        '''DEPRECATED, use method C{toLatLon}.

           Convert this cartesian to geodetic lat-, longitude and
           height.

           @keyword datum: Optional datum to use (L{Datum}).

           @return: A L{LatLon4Tuple}C{(lat, lon, height, datum)}.

           @raise TypeError: Invalid B{C{datum}}.
        '''
        t = self.toLatLon(datum=datum, LatLon=None)
        r = LatLon4Tuple(t.lat, t.lon, t.height, t.datum)
        return self._xnamed(r)
コード例 #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)
コード例 #8
0
ファイル: ecef.py プロジェクト: mzy2240/PyGeodesy
    def toLatLon(self, LatLon=None):
        '''Return the geodetic C{(lat, lon, height[, datum])} coordinates.

           @keyword LatLon: Optional (sub-)class to return C{(lat, lon,
                            height[, datum])} or C{None}.

           @return: An instance of C{LatLon}C{(lat, lon, height[, datum])} if
                    B{C{LatLon}} is not C{None} or a L{LatLon3Tuple}C{(lat, lon,
                    height)} or a L{LatLon4Tuple}C{(lat, lon, height, datum)}
                    if C{datum} is unavailable respectively available.
        '''
        lat, lon = self.lat, self.lon  # PYCHOK expected
        h, d = self.height, self.datum  # PYCHOK expected
        if d is None:
            r = LatLon3Tuple(lat, lon, h) if LatLon is None else \
                      LatLon(lat, lon, h)
        elif isinstance(d, Datum):
            r = LatLon4Tuple(lat, lon, h, d) if LatLon is None else \
                      LatLon(lat, lon, height=h, datum=d)
        else:
            raise AssertionError('%r.%s: %r' % (self, 'datum', d))
        return self._xnamed(r)