Coverage for pygeodesy/karney.py : 95%

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{GeodesicLine} and functions C{AngDiff}, C{AngNormalize}, C{LatFix} and C{sum} from U{geographiclib<https://PyPI.org/project/geographiclib>}, provided that package is installed.
The I{wrapped} class methods return a C{named._NamedDict} instance providing access to the C{dict} items by key or attribute.
Following are U{PyGeodesy<https://PyPI.org/project/PyGeodesy>} classes and functions I{transcribed} from I{Karney}'s original U{GeographicLib <https://GeographicLib.SourceForge.io/html/annotated.html>} in C++:
- L{AlbersEqualArea}, L{AlbersEqualArea2}, L{AlbersEqualArea4}, L{AlbersEqualAreaCylindrical}, L{AlbersEqualAreaNorth}, L{AlbersEqualAreaSouth} -- U{AlbersEqualArea<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1AlbersEqualArea.html>}
- L{CassiniSoldner} -- U{CassiniSoldner<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1CassiniSoldner.html>}
- L{EcefKarney} -- U{Geocentric<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1Geocentric.html>}
- L{EcefCartesian} -- U{LocalCartesian<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1LocalCartesian.html>}
- L{EquidistantKarney} -- U{AzimuthalEquidistant<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1AzimuthalEquidistant.html>}
- L{Elliptic} -- U{EllipticFunction<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1EllipticFunction.html>}
- L{Etm}, L{ExactTransverseMercator} -- U{TransverseMercatorExact <https://GeographicLib.SourceForge.io/html/classGeographicLib_1_1TransverseMercatorExact.html>}
- L{GeoidKarney} -- U{Geoid<https://GeographicLib.SourceForge.io/html/geoid.html>}
- L{Georef} -- U{Georef<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1Georef.html>}
- L{GnomonicKarney} -- U{Gnomonic<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1Gnomonic.html>}
- L{Ups} -- U{PolarStereographic<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1PolarStereographic.html>}
- L{Utm} -- U{TransverseMercator<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1TransverseMercator.html>}
- L{UtmUps}, L{Epsg} -- U{UTMUPS<https://GeographicLib.SourceForge.io/html/ classGeographicLib_1_1UTMUPS.html>}
- L{atan2d}, L{sincos2}, L{sincos2d}-- U{Math<https://GeographicLib.sourceforge.io/html/ classGeographicLib_1_1Math.html>}
The following U{PyGeodesy<https://PyPI.org/project/PyGeodesy>} classes and module are I{wrappers} around some of I{Karney}'s Python U{geographiclib <https://PyPI.org/project/geographiclib>}:
- L{EquidistantKarney}, L{GnomonicKarney}, L{ellipsoidalKarney}, L{FrechetKarney}, L{HeightIDWkarney}, L{karney} '''
'''(INTERNAL) Basic C{dict} with key I{and} attribute access to the C{dict} items, minimal version of C{named._NamedDict}. ''' except KeyError: return dict.__getattr__(self, name)
''''(INTERNAL) Wrapper for some of I{Karney}'s U{geographiclib <https://PyPI.org/project/geographiclib>} classes. '''
'''Get the I{wrapped} C{Geodesic} class, provided the U{geographiclib <https://PyPI.org/project/geographiclib>} package is installed, otherwise an C{ImportError}. '''
'''I{Karney}'s U{Geodesic<https://GeographicLib.SourceForge.io/html/ python/code.html#geographiclib.geodesic.Geodesic>} wrapper. '''
'''Return the C{Direct} result. '''
'''Return the destination lat, lon and reverse azimuth (final bearing) in C{degrees}. '''
'''Return the C{Inverse} result. '''
'''Return the non-negative, I{angular} distance in C{degrees}. ''' # see .FrechetKarney.distance, .HausdorffKarney._distance # and .HeightIDWkarney._distances # XXX self.DISTANCE needed for 'a12'?
'''Return the distance in C{meter} and the forward and reverse azimuths (initial and final bearing) in C{degrees}. '''
# Geodesic.Direct.__doc__ = _Geodesic.Direct.__doc__ # Geodesic.Inverse.__doc__ = _Geodesic.Inverse.__doc__ # Geodesic.Line.__doc__ = _Geodesic.Line.__doc__
'''Get the I{wrapped} C{GeodesicLine} class, provided the U{geographiclib <https://PyPI.org/project/geographiclib>} package is installed, otherwise an C{ImportError}. '''
'''I{Karney}'s U{GeodesicLine <https://GeographicLib.SourceForge.io/html/ python/code.html#geographiclib.geodesicline.GeodesicLine>} wrapper. '''
# GeodesicLine.ArcPosition.__doc__ = _GeodesicLine.ArcPosition.__doc__ # GeodesicLine.Position.__doc__ = _GeodesicLine.Position.__doc__
'''Get the I{wrapped} C{Geodesic.WGS84} I{instance} provided the U{geographiclib<https://PyPI.org/project/geographiclib>} package is installed, otherwise an C{ImportError}. '''
'''Get the imported C{geographiclib}, provided the U{geographiclib <https://PyPI.org/project/geographiclib>} package is installed, otherwise an C{ImportError}. ''' return self._xgeographiclib(_Wrapped.geographiclib)
'''Get the C{Math} class, provided the U{geographiclib <https://PyPI.org/project/geographiclib>} package is installed, otherwise C{None}. ''' # override karney.- with Math.attrs
'''(INTERNAL) Import C{geographiclib}. '''
'''Compute C{deg - deg0}, reduced to C{[-180,180]} accurately.
@return: 2-Tuple C{(delta_angle, residual)} in C{degrees}. '''
d = -_180_0
'''Replace angle in C{degrees} outside [-90,90] by NAN.
@return: Angle C{degrees} or NAN. '''
'''Cascaded summation, like C{.fmath.fsum_}.
@arg vs: Values to be added (C{scalar}[]).
@return: 2-Tuple C{(sum_of_vs, residual)}.
@note: NOT "error-free", see .test/testKarney.py.
@see: U{Algorithm 4.1<http://www.ti3.TUHH.De/paper/rump/OgRuOi05.pdf>}. '''
'''Reduce angle in C{degrees} to (-180,180].
@return: Reduced angle C{degrees}. '''
# with Python 2.7.16 and 3.7.3 on macOS 10.13.6 # fmod( 0, 360) == 0.0 # fmod( 360, 360) == 0.0 # fmod(-0, 360) == 0.0 # fmod(-0.0, 360) == -0.0 # fmod(-360, 360) == -0.0 # however, using the % operator ... # 0 % 360 == 0 # 360 % 360 == 0 # 360.0 % 360 == 0.0 # -0 % 360 == 0 # -360 % 360 == 0 # -0.0 % 360 == 0.0 # -360.0 % 360 == 0.0
# On Windows 32-bit with Python 2.7, math.fmod(-0.0, 360) # == +0.0. This fixes this bug. See also Math::AngNormalize # in the C++ library. Math::sincosd has a similar fix. if d <= _180_0 else (d - _360_0))
'''Error-free summation like C{Math::sum}.
@return: 2-Tuple C{(sum_u_plus_v, residual)}.
@note: The C{residual} can be the same as B{C{u}} or B{C{v}}.
@see: U{Algorithm 3.1<http://www.ti3.TUHH.De/paper/rump/OgRuOi05.pdf>}. ''' return M.sum(u, v)
# if True: # Algorithm 3.1
# else: # in Math C/C++ # r -= u # t -= v # t = -(r + t)
# u + v = s + t # = round(u + v) + t
'''Unroll B{C{lon2 - lon1}} like C{geodesic.Geodesic.Inverse}.
@return: 2-Tuple C{(lon2 - lon1, lon2)} with B{C{lon2}} unrolled if B{C{wrap}} is C{True}, normalized otherwise. ''' else: lon2 = _norm180(lon2)
# **) 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. |