Coverage for pyaxqg / __pygeodesy.py: 98%
53 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-08-31 15:27 -0400
« prev ^ index » next coverage.py v7.14.0, created at 2026-08-31 15:27 -0400
2# -*- coding: utf-8 -*-
4u'''(INTERNAL) C{pyaxqg} access to some private C{pygeodesy} attributes.
5'''
6_missing_ = 'missing' # PYCHOK used!
7_requires = '26.8.26' # in README.rst twice, requirements.txt, setup.py
10def _PyGeodesy_dir(requires):
11 # Adjust sys.path to enable import pygeodesy
12 d = None
13 try:
14 from pygeodesy import version as _v
15 except ImportError:
16 import os.path as os_path
17 import sys # PYCHOK used!
18 _v = _missing_
19 # PYTHONPATH=.../PyAxQG for development ONLY
20 p = os_path.abspath(__file__)
21 p = os_path.dirname(p) # pyaxqg_abspath
22 p = os_path.dirname(p) # PyAxQG
23 p = os_path.dirname(p) # ../
24 g = os_path.join(p, 'PyGeodesy')
25 if g != p and g not in sys.path:
26 sys.path.insert(0, g)
27 try:
28 from pygeodesy import version as _v # PYCHOK redef
29 d = g
30 except ImportError:
31 pass
32# finally:
33# try:
34# sys.path.remove(g)
35# except ValueError:
36# pass
38 def _t(v):
39 return tuple(map(int, v.split('.'))) # _DOT_
41 if _v == _missing_ or _t(_v) < _t(requires):
42 _v = ' %s, need %s or newer' % (_v, requires)
43 raise ImportError('pygeodesy' + _v)
45 return d # or None
47_PyGeodesy_dir = _PyGeodesy_dir(_requires) # PYCHOK path or None
49from pygeodesy.basics import copysign0, _xinstanceof, _xsubclassof # noqa: F401
50from pygeodesy.constants import _0_0, _1_0, _90_0, _180_0, _isNAN, INT0 # noqa: F401
51from pygeodesy.errors import _ValueError, _xkwds, _xkwds_get # noqa: F401
52from pygeodesy.internals import machine, _secs2str, _versions # noqa: F401
53from pygeodesy.interns import (_DASH_, _DOT_, _h_, _lat_, _lon_, # noqa: F401
54 _N_, _name_, _SPACE_, _x_, _y_, _z_) # noqa: F401
55from pygeodesy.lazily import _ALL_DOCS, _ALL_OTHER, _ALL_STAR, _FOR_DOCS # noqa: F401
56from pygeodesy.named import _NamedBase, _NamedTuple, _Pass # noqa: F401
57from pygeodesy.namedTuples import (_H_lat_lon_height4Tuple, # noqa: F401
58 _isinside, Vector3Tuple) # noqa: F401
59from pygeodesy.streprs import Fmt # noqa: F401
61from pygeodesy import Meter, Property_RO
64class AxQGError(_ValueError): # TriaxialError?
65 '''Error raised for C{pyaxqg}, C{axQG} and other issues.
66 '''
67 pass
70class AxQG8Tuple(_H_lat_lon_height4Tuple):
71 '''8-Tuple C{(x, y, z, H, lat, lon, height, axQG)} with cartesian C{x}, C{y}, C{z}
72 and orthometric height C{H}, geodetic C{lat}, C{lon} and ellipsoidal C{height},
73 C{axQG} the C{Ax*QG} instance with C{lat} and C{lon} in C{degrees} and with C{x},
74 C{y}, C{z}, C{H} and C{height} in C{meter}, conventionally.
75 '''
76 _Names_ = (_x_, _y_, _z_) + _H_lat_lon_height4Tuple._Names_ + ('axQG',)
77 _Units_ = ( Meter, Meter, Meter) + _H_lat_lon_height4Tuple._Units_ + (_Pass,)
79# def diff(self, other, datum=None, **name):
80# '''Return the difference between this and an C{other} C{AxQG8Tuple}.
81#
82# @kwarg datum: Datum C{diff} (C{Datum}, None or NAN).
83# @kwarg name: Optional name (C{str}).
84#
85# @return: An L{AxQG8Tuple} with the C{fabs(diff)} for each item,
86# except C{datum} as B{C{datum}}.
87# '''
88# def _diff(a, b):
89# try:
90# return fabs(a - b)
91# except TypeError:
92# return datum
93#
94# _xinstanceof(AxQG8Tuple, other=other)
95# t = map2(_diff, self, other)
96# return AxQG8Tuple(t, **name)
98 def sideOf(self, **eps):
99 '''Is this cartesian on, above or below this C{axQG.triaxial}'s surface?
101 @kwarg eps: Optional on-surface tolerance (C{meter}, squared), overriding
102 default C{axQG.triaxial.onEPS}.
104 @return: Signed, radial distance I{squared} to this C{axQG.triaxial}'s
105 surface (C{scalar}), C{INT0} if within tolerance B{C{eps}},
106 positive if outside or negative if inside the C{axQG.triaxial}.
107 '''
108 return self.axQG.triaxial.sideOf(*self.xyz, **eps) # PYCHOK axQG
110 @Property_RO
111 def xyz(self):
112 '''Get 3-tuple C{(x, y, z)} (L{Vector3Tuple}C{(x, y, z)}).
113 '''
114 return Vector3Tuple(self.x, self.y, self.z, name=self.name)
116 @Property_RO
117 def xyzH(self):
118 '''Get 4-tuple L{AxyzHeight4Tuple}C{(x, y, z, H)} with orthometric height C{H}.
119 '''
120 return AxyzHeight4Tuple(self.x, self.y, self.z, self.H, name=self.name)
122 @Property_RO
123 def xyzh(self):
124 '''Get 4-tuple L{Axyzheight4Tuple}C{(x, y, z, h)} with ellipsoidal height C{h}.
125 '''
126 return Axyzheight4Tuple(self.x, self.y, self.z, self.height, name=self.name)
128 @Property_RO
129 def xyzN(self):
130 '''Get 4-tuple L{AxyzNgeoid4Tuple}C{(x, y, z, N)} with geoid height C{N}.
131 '''
132 return AxyzNgeoid4Tuple(self.x, self.y, self.z, self.N, name=self.name)
135class AxyzHeight4Tuple(_NamedTuple):
136 '''4-tuple C{(x, y, z, H)} with orthometric height C{H}, all in C{meter}, conventionally.
137 '''
138 _Names_ = AxQG8Tuple._Names_[:4]
139 _Units_ = AxQG8Tuple._Units_[:4]
142class Axyzheight4Tuple(_NamedTuple):
143 '''4-tuple C{(x, y, z, h)} with ellipsoidal height C{h}, all in C{meter}, conventionally.
144 '''
145 _Names_ = AxyzHeight4Tuple._Names_[:3] + (_h_,)
146 _Units_ = AxyzHeight4Tuple._Units_
149class AxyzNgeoid4Tuple(_NamedTuple):
150 '''4-tuple C{(x, y, z, N)} with geoid height C{N}, all in C{meter}, conventionally.
151 '''
152 _Names_ = AxyzHeight4Tuple._Names_[:3] + (_N_,)
153 _Units_ = AxyzHeight4Tuple._Units_
156__all__ = (INT0.name,)
157__all__ += _ALL_OTHER(AxQGError, AxQG8Tuple, AxyzHeight4Tuple,
158 Axyzheight4Tuple, AxyzNgeoid4Tuple, machine, Vector3Tuple)
159__version__ = '26.09.01'
161# **) MIT License
162#
163# Copyright (C) 2026-2026 -- mrJean1 at Gmail -- All Rights Reserved.
164#
165# Permission is hereby granted, free of charge, to any person obtaining a
166# copy of this software and associated documentation files (the "Software"),
167# to deal in the Software without restriction, including without limitation
168# the rights to use, copy, modify, merge, publish, distribute, sublicense,
169# and/or sell copies of the Software, and to permit persons to whom the
170# Software is furnished to do so, subject to the following conditions:
171#
172# The above copyright notice and this permission notice shall be included
173# in all copies or substantial portions of the Software.
174#
175# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
176# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
177# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
178# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
179# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
180# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
181# OTHER DEALINGS IN THE SOFTWARE.