Coverage for pyaxqg / __pygeodesy.py: 98%
53 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-08-23 13:04 -0400
« prev ^ index » next coverage.py v7.14.0, created at 2026-08-23 13:04 -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.18' # in README.rst, 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, # noqa: F401
51 _isNAN, INT0) # noqa: F401
52from pygeodesy.errors import _ValueError, _xkwds, _xkwds_get # noqa: F401
53from pygeodesy.internals import machine, _secs2str, _versions # noqa: F401
54from pygeodesy.interns import (_DASH_, _DOT_, _h_, _lat_, _lon_, # noqa: F401
55 _N_, _name_, _SPACE_, _x_, _y_, _z_) # noqa: F401
56from pygeodesy.lazily import _ALL_DOCS, _ALL_OTHER, _ALL_STAR, _FOR_DOCS # noqa: F401
57from pygeodesy.named import _NamedBase, _NamedTuple, _Pass # noqa: F401
58from pygeodesy.namedTuples import (_H_lat_lon_height4Tuple, # noqa: F401
59 _isinside, Vector3Tuple) # PYCHOK used!
60from pygeodesy.streprs import Fmt # noqa: F401
62from pygeodesy import Meter, Property_RO
65class AxQGError(_ValueError): # TriaxialError?
66 '''Error raised for C{pyaxqg}, C{axQG} and other issues.
67 '''
68 pass
71class AxQG8Tuple(_H_lat_lon_height4Tuple):
72 '''8-Tuple C{(x, y, z, H, lat, lon, height, axQG)} with cartesian C{x}, C{y}, C{z}
73 and orthometric height C{H}, geodetic C{lat}, C{lon} and ellipsoidal C{height},
74 C{axQG} the C{Ax*QG} instance with C{lat} and C{lon} in C{degrees} and with C{x},
75 C{y}, C{z}, C{H} and C{height} in C{meter}, conventionally.
76 '''
77 _Names_ = (_x_, _y_, _z_) + _H_lat_lon_height4Tuple._Names_ + ('axQG',)
78 _Units_ = ( Meter, Meter, Meter) + _H_lat_lon_height4Tuple._Units_ + (_Pass,)
80# def diff(self, other, datum=None, **name):
81# '''Return the difference between this and an C{other} C{AxQG8Tuple}.
82#
83# @kwarg datum: Datum C{diff} (C{Datum}, None or NAN).
84# @kwarg name: Optional name (C{str}).
85#
86# @return: An L{AxQG8Tuple} with the C{fabs(diff)} for each item,
87# except C{datum} as B{C{datum}}.
88# '''
89# def _diff(a, b):
90# try:
91# return fabs(a - b)
92# except TypeError:
93# return datum
94#
95# _xinstanceof(AxQG8Tuple, other=other)
96# t = map2(_diff, self, other)
97# return AxQG8Tuple(t, **name)
99 def sideOf(self, **eps):
100 '''Is this cartesian on, above or below this C{axQG.triaxial}'s surface?
102 @kwarg eps: Optional on-surface tolerance (C{meter}, squared), overriding
103 default C{axQG.triaxial.onEPS}.
105 @return: Signed, radial distance I{squared} to this C{axQG.triaxial}'s
106 surface (C{scalar}), C{INT0} if within tolerance B{C{eps}},
107 positive if outside or negative if inside the C{axQG.triaxial}.
108 '''
109 return self.axQG.triaxial.sideOf(*self.xyz, **eps) # PYCHOK axQG
111 @Property_RO
112 def xyz(self):
113 '''Get 3-tuple C{(x, y, z)} (L{Vector3Tuple}C{(x, y, z)}).
114 '''
115 return Vector3Tuple(self.x, self.y, self.z, name=self.name)
117 @Property_RO
118 def xyzH(self):
119 '''Get 4-tuple L{AxyzHeight4Tuple}C{(x, y, z, H)} with orthometric height C{H}.
120 '''
121 return AxyzHeight4Tuple(self.x, self.y, self.z, self.H, name=self.name)
123 @Property_RO
124 def xyzh(self):
125 '''Get 4-tuple L{Axyzheight4Tuple}C{(x, y, z, h)} with ellipsoidal height C{h}.
126 '''
127 return Axyzheight4Tuple(self.x, self.y, self.z, self.height, name=self.name)
129 @Property_RO
130 def xyzN(self):
131 '''Get 4-tuple L{AxyzNgeoid4Tuple}C{(x, y, z, N)} with geoid height C{N}.
132 '''
133 return AxyzNgeoid4Tuple(self.x, self.y, self.z, self.N, name=self.name)
136class AxyzHeight4Tuple(_NamedTuple):
137 '''4-tuple C{(x, y, z, H)} with orthometric height C{H}, all in C{meter}, conventionally.
138 '''
139 _Names_ = AxQG8Tuple._Names_[:4]
140 _Units_ = AxQG8Tuple._Units_[:4]
143class Axyzheight4Tuple(_NamedTuple):
144 '''4-tuple C{(x, y, z, h)} with ellipsoidal height C{h}, all in C{meter}, conventionally.
145 '''
146 _Names_ = AxyzHeight4Tuple._Names_[:3] + (_h_,)
147 _Units_ = AxyzHeight4Tuple._Units_
150class AxyzNgeoid4Tuple(_NamedTuple):
151 '''4-tuple C{(x, y, z, H)} with geoid height C{N}, all in C{meter}, conventionally.
152 '''
153 _Names_ = AxyzHeight4Tuple._Names_[:3] + (_N_,)
154 _Units_ = AxyzHeight4Tuple._Units_
157__all__ = (INT0.name,)
158__all__ += _ALL_OTHER(AxQGError, AxQG8Tuple, AxyzHeight4Tuple,
159 Axyzheight4Tuple, AxyzNgeoid4Tuple, machine, Vector3Tuple)
160__version__ = '26.08.18'
162# **) MIT License
163#
164# Copyright (C) 2026-2026 -- mrJean1 at Gmail -- All Rights Reserved.
165#
166# Permission is hereby granted, free of charge, to any person obtaining a
167# copy of this software and associated documentation files (the "Software"),
168# to deal in the Software without restriction, including without limitation
169# the rights to use, copy, modify, merge, publish, distribute, sublicense,
170# and/or sell copies of the Software, and to permit persons to whom the
171# Software is furnished to do so, subject to the following conditions:
172#
173# The above copyright notice and this permission notice shall be included
174# in all copies or substantial portions of the Software.
175#
176# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
177# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
179# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
180# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
181# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
182# OTHER DEALINGS IN THE SOFTWARE.