Coverage for pygeodesy/solveBase.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 -*-
'''
_EQUAL_, _not_, _SPACE_ Precision_, unroll180 # from pygeodesy.units import Precision_ # from .karney # from pygeodesy.utily import unroll180 # from .karney
def _cmd_stdin_(cmd, stdin): # PYCHOK no cover '''(INTERNAL) Cmd line, stdin and caller as sC{str}. ''' c = Fmt.PAREN(callername(up=3)) t = (c,) if stdin is None else (_BACKSLASH_, str(stdin), c) return _SPACE_.join(cmd + t)
'''(INTERNAL) Invoke C{B{cmd} tuple} and return C{exitcode} and all output to C{stdout/-err}. ''' # executable=sys.executable, shell=True, stdin=_PIPE, stdout=_PIPE, stderr=_STDOUT, **_text_True) # PYCHOK kwArgs
'''(NTERNAL) Base class for C{_Solve} and C{_LineSolve}. ''' _Names_Inverse = ()
'''Get the I{equatorial} radius, semi-axis (C{meter}). '''
def _cmdBasic(self): # PYCHOK no cover '''(INTERNAL) I{Must be overloaded}, see function C{notOverloaded}. ''' notOverloaded(self)
'''Get the ellipsoid (C{Ellipsoid}). '''
'''Get the Solve's C{exact} setting (C{bool}). '''
'''Set the Solve's C{exact} setting (C{bool}), if C{True} use I{exact} version. ''' Exact = bool(Exact) if self._Exact != Exact: _update_all(self) self._Exact = Exact
'''Get the ellipsoid's I{flattening} (C{float}), M{(a - b) / a}, C{0} for spherical, negative for prolate. '''
'''(INTERNAL) Invoke C{Solve}, return results as C{GDict}. ''' raise _AssertionError(cmd=cmd, Names=Names) if len(t) > N: # PYCHOK no cover # unzip instrumented name=value pairs to names and values n, v = _zip(*(p.split(_EQUAL_) for p in t[:-N])) # strict=True v += tuple(t[-N:]) n += Names else: if self.verbose: # PYCHOK no cover self._print(_COMMASPACE_.join(map(Fmt.EQUAL, n, map(fstrzs, v))))
'''Get the most recent C{Solve} invokation number (C{int}). '''
'''Invoke the C{Solve} executable and return the result.
@arg options: No, one or several C{Solve} command line options (C{str}s). @kwarg stdin: Optional input to pass to C{Solve.stdin} (C{str}).
@return: The C{Solve.stdout} and C{.stderr} output (C{str}).
@raise GeodesicError: On any error, including a non-zero return code from C{GeodSolve}.
@raise RhumbError: On any error, including a non-zero return code from C{RhumbSolve}.
@note: The C{Solve} return code is in property L{status}. ''' raise self._Error(cmd=_cmd_stdin_(c, i), status=s, txt=_not_(_0_)) if self.verbose: # PYCHOK no cover self._print(r)
'''(INTERNAL) Invoke the C{Solve} executable, with the given B{C{cmd}} line and optional input to B{C{stdin}}. ''' if self.verbose: # PYCHOK no cover t = _cmd_stdin_(cmd, stdin) self._print(t) raise ValueError(r) except (IOError, OSError, TypeError, ValueError) as x: raise self._Error(cmd=t or _cmd_stdin_(cmd, stdin), txt=str(x))
'''Get the precision, number of (decimal) digits (C{int}). '''
'''Set the precision for C{angles} in C{degrees}, like C{lat}, C{lon}, C{azimuth} and C{arc} in number of decimal digits (C{int}, C{0}..L{DIG}).
@note: The precision for C{distance = B{prec} - 5} or up to 10 decimal digits for C{nanometer} and for C{area = B{prec} - 12} or at most C{millimeter} I{squared}. '''
def _print(self, line): # PYCHOK no cover '''(INTERNAL) Print a status line. ''' if self.status is not None: line = _SPACE_(line, Fmt.PAREN(self.status)) printf('%s %d: %s', self.named2, self.invokation, line)
'''Get the C{azi2} direction (C{bool}). '''
'''Set the direction for C{azi2} (C{bool}), if C{True} reverse C{azi2}. '''
'''(INTERNAL) Set the executable C{path}. ''' _update_all(self) self._Solve_path = path S_p = Solve_path or {self._Solve_name: _enquote(path)} raise self._Error(status=self.status, txt=_not_(_0_), **S_p) finally: # restore in case of error _update_all(self) self._Solve_path = hold
'''Get the most recent C{Solve} return code (C{int}, C{str}) or C{None}. '''
'''Get the C{lon2} unroll'ing (C{bool}). '''
'''Set unroll'ing for C{lon2} (C{bool}), if C{True} unroll C{lon2}, otherwise don't. '''
'''Get the C{verbose} option (C{bool}). '''
'''Set the C{verbose} option (C{bool}), C{True} prints a message around each C{RhumbSolve} invokation. '''
'''Get the result of C{"GeodSolve --version"} or C{"RhumbSolve --version"}. '''
'''(NTERNAL) Base class for C{_GeodesicSolveBase} and C{_RhumbSolveBase}. ''' '''New C{Solve} instance.
@arg a_ellipsoid: An ellipsoid (L{Ellipsoid}) or datum (L{Datum}) or the equatorial radius of the ellipsoid (C{scalar}, conventionally in C{meter}), see B{C{f}}. @arg f: The flattening of the ellipsoid (C{scalar}) if B{C{a_ellipsoid}} is specified as C{scalar}. @kwarg path: Optionally, the (fully qualified) path to the C{GeodSolve} or C{RhumbSolve} executable (C{filename}). @kwarg name: Optional name (C{str}).
@raise TypeError: Invalid B{C{a_ellipsoid}} or B{C{f}}. ''' self._setSolve(path)
'''(INTERNAL) Get the C{Solve} I{Direct} cmd (C{tuple}). '''
'''(INTERNAL) Get the C{Solve} I{Inverse} cmd (C{tuple}). '''
'''Return the C{Direct} result. '''
'''(INTERNAL) Get C{_GenDirect}-like result as C{GDict}. ''' raise self._Error(arcmode=arcmode, txt=str(NotImplemented)) lat, lon, azi, s12_a12)
'''(INTERNAL) Get C{_GenInverse}-like result as C{GDict}, but I{without} C{_SALPs_CALPs_}. ''' lat1, lon1, lat2, lon2)
'''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'?
'''(INTERNAL) Return this C{_Solve} as string.. ''' status=self.status, **Solve)
'''(NTERNAL) Base class for C{GeodesicLineSolve} and C{RhumbLineSolve}. ''' # _caps = 0 # _lla1 = {}
'''(INTERNAL) Get the C{GeodSolve} I{-L} cmd (C{tuple}). '''
'''Get the ellipsoid (C{Ellipsoid}). '''
'''Get the latitude of the first point (C{degrees}). '''
'''Get the longitude of the first point (C{degrees}). '''
'''(INTERNAL) Return this C{_LineSolve} as string.. ''' lat1=self.lat1, lon1=self.lon1, status=self._solve.status, **solve)
# **) MIT License # # Copyright (C) 2016-2022 -- 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. |