def __init__(self, x, y, z, h=0, datum=None, ll=None, name=''): '''New n-vector normal to the earth's surface. @param x: X component (C{meter}). @param y: Y component (C{meter}). @param z: Z component (C{meter}). @keyword h: Optional height above model surface (C{meter}). @keyword datum: Optional datum this n-vector is defined within (L{Datum}). @keyword ll: Optional, original latlon (I{LatLon}). @keyword name: Optional name (C{str}). @raise TypeError: If I{datum} is not a L{Datum}. @example: >>> from ellipsoidalNvector import Nvector >>> v = Nvector(0.5, 0.5, 0.7071, 1) >>> v.toLatLon() # 45.0°N, 045.0°E, +1.00m ''' NvectorBase.__init__(self, x, y, z, h=h, ll=ll, name=name) if datum: if not isinstance(datum, Datum): raise TypeError('%s invalid: %r' % ('datum', datum)) self._datum = datum
def copy(self): '''Copy this vector. @return: Copy (L{Nvector}). ''' n = NvectorBase.copy(self) if self.datum != n.datum: n._datum = self._datum return n
def unit(self): '''Normalize this vector to unit length. @return: Normalised vector (L{Nvector}). ''' if self._united is None: u = NvectorBase.unit(self) if u.datum != self.datum: u._datum = self.datum # self._united = u._united = u return self._united
def unit(self, ll=None): '''Normalize this vector to unit length. @keyword ll: Optional, original latlon (C{LatLon}). @return: Normalised vector (L{Nvector}). ''' if self._united is None: u = NvectorBase.unit(self, ll=ll) if u.datum != self.datum: u._datum = self.datum # self._united = u._united = u return self._united
def __init__(self, x, y, z, h=0, datum=None): '''New n-vector normal to the earth's surface. @param x: X component (scalar). @param y: Y component (scalar). @param z: Z component (scalar). @keyword h: Height above surface (meter). @keyword datum: Optional datum this n-vector is defined within (L{Datum}). @raise TypeError: If datum is not a L{Datum}. @example: >>> from ellipsoidalNvector import Nvector >>> v = Nvector(0.5, 0.5, 0.7071, 1) >>> v.toLatLon() # 45.0°N, 045.0°E, +1.00m ''' NvectorBase.__init__(self, x, y, z, h=h) if datum: if not isinstance(datum, Datum): raise TypeError('%s invalid: %r' % ('datum', datum)) self._datum = datum
def toLatLon(self, height=None, LatLon=LatLon): '''Convert this n-vector to an (ellipsoidal) geodetic point. @keyword height: Optional height, overriding the default height (C{meter}). @keyword LatLon: Optional ellipsoidal (sub-)class to return the point (L{LatLon}) or C{None}. @return: Point equivalent to this n-vector (B{C{LatLon}}) or a L{LatLon3Tuple}C{(lat, lon, height)} if B{C{LatLon}} is C{None}. @example: >>> v = Nvector(0.5, 0.5, 0.7071) >>> p = v.toLatLon() # 45.0°N, 45.0°E ''' return NvectorBase._to3LLh(self, LatLon, height, datum=self.datum)