Coverage for pygeodesy/cartesianBase.py : 90%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
C{Cartesian}s.
After I{(C) Chris Veness 2011-2015} published under the same MIT Licence**, see U{https://www.Movable-Type.co.UK/scripts/latlong.html}, U{https://www.Movable-Type.co.UK/scripts/latlong-vectors.html} and U{https://www.Movable-Type.co.UK/scripts/geodesy/docs/latlon-ellipsoidal.js.html}..
@newfield example: Example, Examples '''
# XXX the following classes are listed only to get # Epydoc to include class and method documentation
'''(INTERNAL) Base class for ellipsoidal and spherical C{Cartesian}. '''
'''New C{Cartesian...}.
@param xyz: An L{Ecef9Tuple}, L{Vector3Tuple}, L{Vector4Tuple} or the C{X} coordinate (C{scalar}). @param y: The C{Y} coordinate (C{scalar}) if B{C{xyz}} C{scalar}. @param z: The C{Z} coordinate (C{scalar}) if B{C{xyz}} C{scalar}. @keyword datum: Optional datum (L{Datum}). @keyword ll: Optional, original latlon (C{LatLon}). @keyword name: Optional name (C{str}).
@raise TypeError: Non-scalar B{C{xyz}}, B{C{y}} or B{C{z}} coordinate or B{C{xyz}} not an L{Ecef9Tuple}, L{Vector3Tuple} or L{Vector4Tuple}. '''
'''(INTERNAL) Make copy with add'l, subclass attributes. ''' return Vector3d._xcopy(self, '_datum', '_Ecef', '_e9t', '_v4t', *attrs)
'''(INTERNAL) Return a new cartesian point by applying a Helmert transform to this point.
@param transform: Transform to apply (L{Transform}). @keyword inverse: Optionally, apply the inverse Helmert transform (C{bool}).
@return: The transformed point (C{Cartesian}). '''
'''Convert this cartesian point from one to an other datum.
@param datum2: Datum to convert I{to} (L{Datum}). @keyword datum: Datum to convert I{from} (L{Datum}).
@return: The converted point (C{Cartesian}).
@raise TypeError: B{C{datum2}} or B{C{datum}} not a L{Datum}. '''
c = self.convertDatum(datum) else:
return c.copy() if c is self else c
else: # neither datum2 nor c.datum is WGS84, invert to WGS84 first
def datum(self): '''Get this point's datum (L{Datum}). '''
def datum(self, datum): '''Set this geocentric point's C{datum} I{without conversion}.
@param datum: New datum (L{Datum}).
@raise TypeError: The B{C{datum}} is not a L{Datum}. ''' raise _IsNotError('ellipsoidal', datum=datum) raise _IsNotError('spherical', datum=datum)
def Ecef(self): '''Get the ECEF I{class} (L{EcefKarney} or L{EcefVeness}). '''
'''Convert this cartesian to geodetic coordinates.
@return: An L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C, M, datum)} with C{C} and C{M} if available.
@raise EcefError: A C{.datum} or an ECEF issue. ''' if self._e9t is None: r = self.Ecef(self.datum).reverse(self, M=True) self._e9t = self._xnamed(r) return self._e9t
'''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)
# def _to3LLh(self, datum, LL, **pairs): # OBSOLETE # '''(INTERNAL) Helper for C{subclass.toLatLon} and C{.to3llh}. # ''' # r = self.to3llh(datum) # LatLon3Tuple # if LL is not None: # r = LL(r.lat, r.lon, height=r.height, datum=datum) # for n, v in pairs.items(): # setattr(r, n, v) # r = self._xnamed(r) # return r
'''Convert this cartesian point to a geodetic point.
@keyword datum: Optional datum (L{Datum}) or C{None}. @keyword LatLon: Optional (sub-)class to return the geodetic point (C{LatLon}) or C{None}. @keyword kwds: Optional, additional B{C{LatLon}} keyword arguments, ignored if C{B{LatLon}=None}.
@return: The B{C{LatLon}} point or if C{B{LatLon}=None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C, M, datum)} with C{C} and C{M} if available.
@raise TypeError: Invalid B{C{datum}} or B{C{kwds}}. '''
datum=c.datum, **kwds)
'''Convert this cartesian to C{n-vector} components.
@keyword Nvector: Optional (sub-)class to return the C{n-vector} components (C{Nvector}) or C{None}. @keyword datum: Optional datum (L{Datum}) overriding this cartesian's datum. @keyword kwds: Optional, additional B{C{Nvector}} keyword arguments, ignored if C{B{Nvector}=None}.
@return: Unit vector B{C{Nvector}} or a L{Vector4Tuple}C{(x, y, z, h)} if B{C{Nvector}=None}.
@raise ValueError: The B{C{Cartesian}} at origin. '''
# Kenneth Gade eqn 23
raise ValueError('%s: %r' % ('origin', self))
raise ValueError('%s: %r' % ('origin', self))
'''Return the string representation of this cartesian.
@keyword prec: Optional number of decimals, unstripped (C{int}). @keyword fmt: Optional enclosing backets format (string). @keyword sep: Optional separator to join (string).
@return: Cartesian represented as "[x, y, z]" (string). '''
# **) MIT License # # Copyright (C) 2016-2020 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. |