Ejemplo n.º 1
0
    def toLatLon(self, height=None, LatLon=None, datum=None, **kwds):
        '''Convert this n-vector to an C{Nvector}-based geodetic point.

           @keyword height: Optional height, overriding this n-vector's
                            height (C{meter}).
           @keyword LatLon: Optional (sub-)class to return the
                            point (L{LatLon}) or C{None}.
           @keyword datum: Optional, spherical datum (C{Datum}).
           @keyword kwds: Optional, additional C{name=value} pairs
                          for B{C{LatLon}} instance, provided
                          B{C{LatLon}} is not C{None}.

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

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

           @example:

           >>> v = Nvector(0.5, 0.5, 0.7071)
           >>> p = v.toLatLon()  # 45.0°N, 45.0°E
        '''
        h = self.h if height is None else height
        d = datum or self.datum

        # XXX use self.Cartesian(Cartesian=None) if h == self.h
        # and d == self.datum, for better accuracy of the height
        r = self.Ecef(d).forward(Vector3d.to2ll(self), height=h, M=True)
        if LatLon is not None:  # class or .classof
            r = LatLon(r.lat, r.lon, r.height, datum=r.datum, **kwds)
        return self._xnamed(r)
Ejemplo n.º 2
0
 def _to3LLh(self, LL, height, **kwds):
     '''(INTERNAL) Helper for C{subclass.toLatLon} and C{.to3llh}.
     '''
     h = self.h if height is None else height
     r = Vector3d.to2ll(self)  # LatLon2Tuple
     if LL is None:
         r = r._3Tuple(h)  # already ._xnamed
     else:
         r = self._xnamed(LL(r.lat, r.lon, height=h, **kwds))
     return r