def toLatLon(self, LatLon, datum=None): '''Convert this WM coordinate to a geodetic point. @param LatLon: Ellipsoidal (sub-)class to return the point (C{LatLon}). @keyword datum: Optional datum for ellipsoidal or C{None} for spherical B{C{LatLon}} (C{Datum}). @return: Point of this WM coordinate (B{C{LatLon}}). @raise TypeError: If B{C{LatLon}} and B{C{datum}} are incompatible or if B{C{datum}} is not ellipsoidal. @example: >>> w = Wm(448251.795, 5411932.678) >>> from pygeodesy import sphericalTrigonometry as sT >>> ll = w.toLatLon(sT.LatLon) # 43°39′11.58″N, 004°01′36.17″E ''' e = issubclassof(LatLon, _LLEB) if e and datum: r = LatLon(*self.to2ll(datum=datum), datum=datum) elif LatLon and not (e or datum): r = LatLon(*self.to2ll(datum=None)) else: raise TypeError('%s %r and %s %r' % ('spherical', LatLon, 'datum', datum)) return self._xnamed(r)
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)
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)
def _xtend(self, namedTuple, *items): '''(INTERNAL) Extend this C{_Tuple} with C{items} to an other C{namedTuple}. ''' if not (issubclassof(namedTuple, _NamedTuple) and (len(self._Names_) + len(items)) == len(namedTuple._Names_) and self._Names_ == namedTuple._Names_[:len(self)]): raise TypeError('%s%r vs %s%r' % (self.classname, self._Names_, namedTuple.__name__, namedTuple._Names_)) return self._xnamed(namedTuple(*(self + items)))
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) elif issubclassof(LatLon, _LLEB): ll = _xnamed(LatLon(ll.lat, ll.lon, datum=ll.datum), ll.name) return _ll2datum(ll, datum, 'LatLon') raise TypeError('%s not ellipsoidal: %r' % ('LatLon', LatLon))
def _latlon5(self, LatLon): '''(INTERNAL) Convert cached LatLon ''' ll = self._latlon if LatLon is None: r = LatLonDatum5Tuple(ll.lat, ll.lon, ll.datum, ll.convergence, ll.scale) elif issubclassof(LatLon, _LLEB): r = _xattrs(LatLon(ll.lat, ll.lon, datum=ll.datum), ll, '_convergence', '_scale') else: raise TypeError('%s not ellipsoidal: %r' % ('LatLon', LatLon)) return _xnamed(r, ll.name)
def _latlon5(self, LatLon): '''(INTERNAL) Convert cached LatLon ''' ll = self._latlon if LatLon is None: r = LatLonDatum5Tuple(ll.lat, ll.lon, ll.datum, ll.convergence, ll.scale) elif issubclassof(LatLon, _LLEB): r = _xattrs(LatLon(ll.lat, ll.lon, datum=ll.datum), ll, '_convergence', '_scale') else: raise _IsNotError(_LLEB.__name__, LatLon=LatLon) return _xnamed(r, ll.name)
def reverse(self, easting, northing, LatLon=None): '''Convert a Cassini-Soldner location to (ellipsoidal) geodetic lat- and longitude. @param easting: Easting of the location (C{meter}). @param northing: Northing of the location (C{meter}). @keyword LatLon: Optional, ellipsoidal (sub-)class to return the location as (C{LatLon}) or C{None}. @return: Geodetic location B{C{LatLon}} or a L{LatLon2Tuple}C{(lat, lon)} if B{C{LatLon}} is C{None}. @raise TypeError: If B{C{LatLon}} is not ellipsoidal. ''' r = LatLon2Tuple(*self.reverse4(easting, northing)[:2]) if issubclassof(LatLon, _LLEB): r = LatLon(r.lat, r.lon, datum=self.datum) # PYCHOK expected elif LatLon is not None: raise _IsNotError(_LLEB.__name__, LatLon=LatLon) return self._xnamed(r)
def reverse(self, easting, northing, LatLon=None): '''Convert a Cassini-Soldner location to (ellipsoidal) geodetic lat- and longitude. @param easting: Easting of the location (C{meter}). @param northing: Northing of the location (C{meter}). @keyword LatLon: Optional, ellipsoidal (sub-)class to return the location as (C{LatLon}) or C{None}. @return: Geodetic location B{C{LatLon}} or a L{LatLon2Tuple}C{(lat, lon)} if B{C{LatLon}} is C{None}. @raise TypeError: If B{C{LatLon}} is not ellipsoidal. ''' a, b = self.reverse4(easting, northing)[:2] if LatLon is None: r = LatLon2Tuple(a, b) elif issubclassof(LatLon, _LLEB): r = LatLon(a, b, datum=self.datum) else: raise TypeError('%s not ellipsoidal: %r' % ('LatLon', LatLon)) return self._xnamed(r)