def __init__(self, lat, lon, height=0, datum=None, reframe=None, epoch=None, name=''): '''Create an ellipsoidal C{LatLon} point frome the given lat-, longitude and height on the given datum and with the given reference frame and epoch. @param lat: Latitude (C{degrees} or DMS C{[N|S]}). @param lon: Longitude (C{degrees} or DMS C{str[E|W]}). @keyword height: Optional elevation (C{meter}, the same units as the datum's half-axes). @keyword datum: Optional, ellipsoidal datum to use (L{Datum}). @keyword reframe: Optional reference frame (L{RefFrame}). @keyword epoch: Optional epoch to observe for B{C{reframe}} (C{scalar}), a non-zero, fractional calendar year. @keyword name: Optional name (string). @raise TypeError: B{C{datum}} is not a L{datum}, B{C{reframe}} is not a L{RefFrame} or B{C{epoch}} is not C{scalar} non-zero. @example: >>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84 ''' LatLonBase.__init__(self, lat, lon, height=height, name=name) if datum: self.datum = datum if reframe: self.reframe = reframe self.epoch = epoch
def _update(self, updated, *attrs): '''(INTERNAL) Zap cached attributes if updated. ''' if updated: LatLonBase._update(self, updated, '_etm', '_lcc', '_osgr', '_ups', '_utm', '_wm', '_3xyz', *attrs) if self._elevation2: self._elevation2 = () if self._geoidHeight2: self._geoidHeight2 = ()
def _update(self, updated, *attrs, **kwds): # PYCHOK _Nv=None '''(INTERNAL) Zap cached attributes if updated. @see: C{ellipsoidalNvector.LatLon} and C{sphericalNvector.LatLon} for the special case of B{C{_Nv}}. ''' if updated: _Nv = _xkwds_pop(kwds, _Nv=None) if _Nv is not None: if _Nv._fromll is not None: _Nv._fromll = None self._Nv = None LatLonBase._update(self, updated, *attrs)
def others(self, other, name='other'): '''Refine the class comparison. @arg other: The other point (C{LatLon}). @kwarg name: Optional, other's name (C{str}). @raise TypeError: Incompatible B{C{other}} C{type}. ''' try: LatLonBase.others(self, other, name=name) except TypeError: if not isinstance(other, NvectorBase): raise
def others(self, other, name=_other_, up=1): '''Refine the class comparison. @arg other: The other point (C{LatLon}). @kwarg name: Optional, other's name (C{str}). @kwarg up: Number of call stack frames up (C{int}). @raise TypeError: Incompatible B{C{other}} C{type}. ''' try: LatLonBase.others(self, other, name=name, up=up + 1) except TypeError: if not isinstance(other, NvectorBase): raise
def __init__(self, lat, lon, height=0, datum=None, reframe=None, epoch=None, name=NN): '''Create an ellipsoidal C{LatLon} point frome the given lat-, longitude and height on the given datum and with the given reference frame and epoch. @arg lat: Latitude (C{degrees} or DMS C{[N|S]}). @arg lon: Longitude (C{degrees} or DMS C{str[E|W]}). @kwarg height: Optional elevation (C{meter}, the same units as the datum's half-axes). @kwarg datum: Optional, ellipsoidal datum to use (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg reframe: Optional reference frame (L{RefFrame}). @kwarg epoch: Optional epoch to observe for B{C{reframe}} (C{scalar}), a non-zero, fractional calendar year. @kwarg name: Optional name (string). @raise RangeError: Value of B{C{lat}} or B{C{lon}} outside the valid range and C{rangerrors} set to C{True}. @raise TypeError: B{C{datum}} is not a L{datum}, B{C{reframe}} is not a L{RefFrame} or B{C{epoch}} is not C{scalar} non-zero. @raise UnitError: Invalid B{C{lat}}, B{C{lon}} or B{C{height}}. @example: >>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84 ''' LatLonBase.__init__(self, lat, lon, height=height, name=name) if datum not in (None, self._datum): self.datum = _ellipsoidal_datum(datum, name=name) if reframe: self.reframe = reframe self.epoch = epoch
def __init__(self, lat, lon, height=0, datum=None, name=''): '''Create a spherical C{LatLon} point frome the given lat-, longitude and height on the given datum. @param lat: Latitude (C{degrees} or DMS C{[N|S]}). @param lon: Longitude (C{degrees} or DMS C{str[E|W]}). @keyword height: Optional elevation (C{meter}, the same units as the datum's half-axes). @keyword datum: Optional, shperical datum to use (L{Datum}). @keyword name: Optional name (string). @raise TypeError: B{C{datum}} is not a L{datum} or not spherical. @example: >>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84 ''' LatLonBase.__init__(self, lat, lon, height=height, name=name) if datum: self.datum = datum
def antipode(self, height=None): '''Return the antipode, the point diametrically opposite to this point. @keyword height: Optional height of the antipode, height of this point otherwise (C{meter}). @return: The antipodal point (C{LatLon}). ''' lla = LatLonBase.antipode(self, height=height) if lla.datum != self.datum: lla.datum = self.datum return lla
def toNvector(self, Nvector=NvectorBase, **Nvector_kwds): # PYCHOK signature '''Convert this point to C{Nvector} components, I{including height}. @kwarg Nvector_kwds: Optional, additional B{C{Nvector}} keyword arguments, ignored if B{C{Nvector=None}}. @return: An B{C{Nvector}} or a L{Vector4Tuple}C{(x, y, z, h)} if B{C{Nvector}} is C{None}. @raise TypeError: Invalid B{C{Nvector}} or B{C{Nvector_kwds}}. ''' return LatLonBase.toNvector(self, Nvector=Nvector, **Nvector_kwds)
def __init__(self, lat, lon, height=0, datum=None, name=NN): '''Create a spherical C{LatLon} point frome the given lat-, longitude and height on the given datum. @arg lat: Latitude (C{degrees} or DMS C{[N|S]}). @arg lon: Longitude (C{degrees} or DMS C{str[E|W]}). @kwarg height: Optional elevation (C{meter}, the same units as the datum's half-axes). @kwarg datum: Optional, spherical datum to use (L{Datum}, L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple}) or C{scalar} earth radius). @kwarg name: Optional name (string). @raise TypeError: If B{C{datum}} invalid or not not spherical. @example: >>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84 ''' LatLonBase.__init__(self, lat, lon, height=height, name=name) if datum not in (None, self.datum): self._datum = _spherical_datum(datum, name=self.name, raiser=True)
def others(self, *other, **name_other_up): '''Refined class comparison. @arg other: The other instance (C{LatLonNvectorBase}). @kwarg name_other_up: Overriding C{name=other} and C{up=1} keyword arguments. @return: The B{C{other}} if compatible. @raise TypeError: Incompatible B{C{other}} C{type}. ''' if other: other0 = other[0] if isinstance( other0, (self.__class__, LatLonNvectorBase)): # XXX NvectorBase? return other0 other, name, up = _xother3(self, other, **name_other_up) if not isinstance( other, (self.__class__, LatLonNvectorBase)): # XXX NvectorBase? LatLonBase.others(self, other, name=name, up=up + 1) return other
def toNvector(self, **kwds): # PYCHOK signature '''Convert this point to C{Nvector} components, I{including height}. @keyword kwds: Optional, additional B{C{Nvector}} keyword arguments, ignored if C{B{Nvector}=None}. Specify C{Nvector=...} to override this C{Nvector} class or set C{B{Nvector}=None}. @return: The B{C{Nvector}} components (C{Nvector}) or a L{Vector4Tuple}C{(x, y, z, h)} if C{B{Nvector}=None}. @raise TypeError: Invalid B{C{Nvector}} or B{C{kwds}}. ''' kwds = _2kwds(kwds, Nvector=NvectorBase) return LatLonBase.toNvector(self, **kwds)
def _xcopy(self, *attrs): '''(INTERNAL) Make copy with add'l, subclass attributes. ''' return LatLonBase._xcopy(self, '_datum', '_epoch', '_reframe', *attrs)
def _update(self, updated): if updated: # reset cached attrs self._etm = self._lcc = self._osgr = self._ups = \ self._utm = self._wm = self._3xyz = None self._elevation2 = self._geoidHeight2 = () LatLonBase._update(self, updated)