pygeodesy 24.3.24__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. PyGeodesy-24.3.24.dist-info/METADATA +272 -0
  2. PyGeodesy-24.3.24.dist-info/RECORD +115 -0
  3. PyGeodesy-24.3.24.dist-info/WHEEL +6 -0
  4. PyGeodesy-24.3.24.dist-info/top_level.txt +1 -0
  5. pygeodesy/LICENSE +21 -0
  6. pygeodesy/__init__.py +615 -0
  7. pygeodesy/__main__.py +103 -0
  8. pygeodesy/albers.py +867 -0
  9. pygeodesy/auxilats/_CX_4.py +218 -0
  10. pygeodesy/auxilats/_CX_6.py +314 -0
  11. pygeodesy/auxilats/_CX_8.py +475 -0
  12. pygeodesy/auxilats/__init__.py +54 -0
  13. pygeodesy/auxilats/__main__.py +86 -0
  14. pygeodesy/auxilats/auxAngle.py +548 -0
  15. pygeodesy/auxilats/auxDLat.py +302 -0
  16. pygeodesy/auxilats/auxDST.py +296 -0
  17. pygeodesy/auxilats/auxLat.py +848 -0
  18. pygeodesy/auxilats/auxily.py +272 -0
  19. pygeodesy/azimuthal.py +1150 -0
  20. pygeodesy/basics.py +892 -0
  21. pygeodesy/booleans.py +2031 -0
  22. pygeodesy/cartesianBase.py +1062 -0
  23. pygeodesy/clipy.py +704 -0
  24. pygeodesy/constants.py +516 -0
  25. pygeodesy/css.py +660 -0
  26. pygeodesy/datums.py +752 -0
  27. pygeodesy/deprecated/__init__.py +61 -0
  28. pygeodesy/deprecated/bases.py +40 -0
  29. pygeodesy/deprecated/classes.py +262 -0
  30. pygeodesy/deprecated/consterns.py +54 -0
  31. pygeodesy/deprecated/datum.py +40 -0
  32. pygeodesy/deprecated/functions.py +375 -0
  33. pygeodesy/deprecated/nvector.py +48 -0
  34. pygeodesy/deprecated/rhumbBase.py +32 -0
  35. pygeodesy/deprecated/rhumbaux.py +33 -0
  36. pygeodesy/deprecated/rhumbsolve.py +33 -0
  37. pygeodesy/deprecated/rhumbx.py +33 -0
  38. pygeodesy/dms.py +986 -0
  39. pygeodesy/ecef.py +1348 -0
  40. pygeodesy/elevations.py +279 -0
  41. pygeodesy/ellipsoidalBase.py +1224 -0
  42. pygeodesy/ellipsoidalBaseDI.py +913 -0
  43. pygeodesy/ellipsoidalExact.py +343 -0
  44. pygeodesy/ellipsoidalGeodSolve.py +343 -0
  45. pygeodesy/ellipsoidalKarney.py +403 -0
  46. pygeodesy/ellipsoidalNvector.py +685 -0
  47. pygeodesy/ellipsoidalVincenty.py +590 -0
  48. pygeodesy/ellipsoids.py +2476 -0
  49. pygeodesy/elliptic.py +1198 -0
  50. pygeodesy/epsg.py +243 -0
  51. pygeodesy/errors.py +804 -0
  52. pygeodesy/etm.py +1190 -0
  53. pygeodesy/fmath.py +1013 -0
  54. pygeodesy/formy.py +1818 -0
  55. pygeodesy/frechet.py +865 -0
  56. pygeodesy/fstats.py +760 -0
  57. pygeodesy/fsums.py +1898 -0
  58. pygeodesy/gars.py +358 -0
  59. pygeodesy/geodesicw.py +581 -0
  60. pygeodesy/geodesicx/_C4_24.py +1699 -0
  61. pygeodesy/geodesicx/_C4_27.py +2395 -0
  62. pygeodesy/geodesicx/_C4_30.py +3301 -0
  63. pygeodesy/geodesicx/__init__.py +48 -0
  64. pygeodesy/geodesicx/__main__.py +91 -0
  65. pygeodesy/geodesicx/gx.py +1382 -0
  66. pygeodesy/geodesicx/gxarea.py +535 -0
  67. pygeodesy/geodesicx/gxbases.py +154 -0
  68. pygeodesy/geodesicx/gxline.py +669 -0
  69. pygeodesy/geodsolve.py +426 -0
  70. pygeodesy/geohash.py +914 -0
  71. pygeodesy/geoids.py +1884 -0
  72. pygeodesy/hausdorff.py +892 -0
  73. pygeodesy/heights.py +1155 -0
  74. pygeodesy/interns.py +687 -0
  75. pygeodesy/iters.py +545 -0
  76. pygeodesy/karney.py +919 -0
  77. pygeodesy/ktm.py +633 -0
  78. pygeodesy/latlonBase.py +1766 -0
  79. pygeodesy/lazily.py +960 -0
  80. pygeodesy/lcc.py +684 -0
  81. pygeodesy/ltp.py +1107 -0
  82. pygeodesy/ltpTuples.py +1563 -0
  83. pygeodesy/mgrs.py +721 -0
  84. pygeodesy/named.py +1324 -0
  85. pygeodesy/namedTuples.py +683 -0
  86. pygeodesy/nvectorBase.py +695 -0
  87. pygeodesy/osgr.py +781 -0
  88. pygeodesy/points.py +1686 -0
  89. pygeodesy/props.py +628 -0
  90. pygeodesy/resections.py +1048 -0
  91. pygeodesy/rhumb/__init__.py +46 -0
  92. pygeodesy/rhumb/aux_.py +397 -0
  93. pygeodesy/rhumb/bases.py +1148 -0
  94. pygeodesy/rhumb/ekx.py +563 -0
  95. pygeodesy/rhumb/solve.py +572 -0
  96. pygeodesy/simplify.py +647 -0
  97. pygeodesy/solveBase.py +472 -0
  98. pygeodesy/sphericalBase.py +724 -0
  99. pygeodesy/sphericalNvector.py +1264 -0
  100. pygeodesy/sphericalTrigonometry.py +1447 -0
  101. pygeodesy/streprs.py +627 -0
  102. pygeodesy/trf.py +2079 -0
  103. pygeodesy/triaxials.py +1484 -0
  104. pygeodesy/units.py +969 -0
  105. pygeodesy/unitsBase.py +349 -0
  106. pygeodesy/ups.py +538 -0
  107. pygeodesy/utily.py +1231 -0
  108. pygeodesy/utm.py +762 -0
  109. pygeodesy/utmups.py +318 -0
  110. pygeodesy/utmupsBase.py +517 -0
  111. pygeodesy/vector2d.py +785 -0
  112. pygeodesy/vector3d.py +968 -0
  113. pygeodesy/vector3dBase.py +1049 -0
  114. pygeodesy/webmercator.py +383 -0
  115. pygeodesy/wgrs.py +439 -0
pygeodesy/interns.py ADDED
@@ -0,0 +1,687 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ u'''Single C{str}ing constants, C{intern}'ed across C{pygeodesy}
4
+ modules and function L{pygeodesy.machine}.
5
+ '''
6
+ import sys as _sys
7
+ try:
8
+ _intern = intern # PYCHOK in .lazily
9
+ except NameError: # Python 3+
10
+ _intern = _sys.intern
11
+
12
+ _COMMASPACE_ = ', ' # overriden below
13
+ _pf2List = [] # cached _platform2 list
14
+ _Py3List = [] # cached _pythonarchine list
15
+
16
+ _sub_packages = 'auxilats', 'deprecated', 'geodesicx', 'rhumb' # PYCHOK in .lazily,
17
+ # ... make._dist, MANIFEST, setup.setup, test.bases, test.testModules
18
+
19
+
20
+ class _Dash(str):
21
+ '''(INTERNAL) Extended C{str} for prefix_DASH_.
22
+ '''
23
+ def __call__(self, *args):
24
+ '''Join C{self} plus all B{C{args}} like C{'-'.join((self,) + B{args})}.
25
+ '''
26
+ return _DASH_(self, *args) # re-callable
27
+
28
+
29
+ class _Int(int):
30
+ '''(INTERNAL) Unique C{int}.
31
+ '''
32
+ pass
33
+
34
+
35
+ class Str_(str):
36
+ '''Extended, I{callable} C{str} class, not nameable.
37
+
38
+ @see: Nameable and callable class L{pygeodesy.Str}.
39
+ '''
40
+ def join_(self, *args):
41
+ '''Join all positional B{C{args}} like C{self.join(B{args})}.
42
+
43
+ @return: All B{C{args}} joined by this instance (L{Str_}).
44
+
45
+ @note: An other L{Str_} instance is returned to make the
46
+ result re-callable.
47
+ '''
48
+ return Str_(str.join(self, map(str, args))) # re-callable
49
+
50
+ __call__ = join_
51
+
52
+ NN = Str_('') # PYCHOK Nomen Nescio <https://Wiktionary.org/wiki/N.N.>
53
+
54
+
55
+ class _Prefix(Str_):
56
+ '''(INTERNAL) Extended C{str} for prefix.
57
+ '''
58
+ def __call__(self, *args):
59
+ '''Join C{self} plus all B{C{args}} like C{" ".join((self,) + B{args})}.
60
+ '''
61
+ return _SPACE_.join_(self, *args) # re-callable
62
+
63
+
64
+ class _PyPy__(str): # overwritten by singleton below
65
+ '''(INTERNAL) Extended C{str} for C{"PyPy"} and version.
66
+ '''
67
+ def __call__(self, version=NN):
68
+ '''Return C{"PyPy <version>"} or C{NN}.
69
+ '''
70
+ v = version or _sys.version
71
+ if _PyPy__ in v:
72
+ v = v.split(_PyPy__)[1].split(None, 1)[0] # == _DOT_.join(_sys.pypy_version_info[:3])
73
+ return NN(_PyPy__, v)
74
+ else:
75
+ return NN
76
+
77
+
78
+ class _Python_(str): # overwritten by singleton below
79
+ '''(INTERNAL) Extended C{str} for C{"Python"} and version.
80
+ '''
81
+ def __call__(self, version=NN):
82
+ '''Return C{"Python <version>"}.
83
+ '''
84
+ v = version or _sys.version
85
+ return _SPACE_(self, v.split(None, 1)[0])
86
+
87
+
88
+ class _Range(str):
89
+ '''(INTERNAL) Extended C{str} for C{range} strings.
90
+ '''
91
+ def __call__(self, lo, hi, lopen=False, ropen=False,
92
+ prec=0, sep=_COMMASPACE_):
93
+ '''Return the range as C{"(lo, hi)"}, C{"(lo, hi]"},
94
+ C{"[lo, hi)"} or C{"[lo, hi]"}.
95
+ '''
96
+ from pygeodesy.streprs import Fmt
97
+ r = NN(Fmt.f(lo, prec=prec), sep,
98
+ Fmt.f(hi, prec=prec))
99
+ f = (Fmt.PAREN if ropen else Fmt.LOPEN) if lopen else \
100
+ (Fmt.ROPEN if ropen else Fmt.SQUARE)
101
+ return f(r)
102
+
103
+
104
+ class _Slicer(str):
105
+ '''(INTERNAL) String slicer C{.fromX} or C{.tillY}.
106
+ '''
107
+ def __getattr__(self, name): # .fromX, .tillY
108
+ n = len(name) - 4
109
+ if n > 0:
110
+ # assert len('till') == len(_from_) == 4
111
+ if name.startswith('till'):
112
+ i = self.find(name[4:])
113
+ return self if i < 0 else _Slicer(self[:i + n])
114
+ elif name.startswith(_from_):
115
+ i = self.find(name[4:])
116
+ return self if i < 0 else _Slicer(self[i:])
117
+ return str.__getattr__(self, name) # PYCHOK no cover
118
+
119
+
120
+ class MISSING(object):
121
+ '''(INTERNAL) Singleton C{str}.
122
+ '''
123
+ def toRepr(self, **unused):
124
+ return self.__class__.__name__
125
+
126
+ __repr__ = __str__ = toStr = toRepr
127
+
128
+ MISSING = MISSING() # PYCHOK singleton
129
+ MISSING.__name__ = str(MISSING)
130
+
131
+ # __DUNDER__-style names would get mangled in classes
132
+ _0_ = '0' # PYCHOK 'zero'
133
+ _0to9_ = '0123456789' # PYCHOK OK
134
+ _1_ = '1' # PYCHOK OK
135
+ _2_ = '2' # PYCHOK OK
136
+ _3_ = '3' # PYCHOK OK
137
+ _4_ = '4' # PYCHOK OK
138
+ _a_ = 'a' # PYCHOK OK
139
+ _A_ = 'A' # PYCHOK OK
140
+ _a12_ = 'a12' # PYCHOK OK
141
+ _area_ = 'area' # PYCHOK OK
142
+ _Airy1830_ = 'Airy1830' # PYCHOK OK
143
+ _AiryModified_ = 'AiryModified' # PYCHOK OK
144
+ _ambiguous_ = 'ambiguous' # PYCHOK OK
145
+ _AMPERSAND_ = Str_('&') # PYCHOK OK
146
+ _an_ = 'an' # PYCHOK OK
147
+ _and_ = 'and' # PYCHOK OK
148
+ # _AND_ = _AMPERSAND_ # PYCHOK OK
149
+ _angle_ = 'angle' # PYCHOK OK
150
+ _antipodal_ = 'antipodal' # PYCHOK OK
151
+ _areaOf_ = 'areaOf' # PYCHOK OK
152
+ _arg_ = 'arg' # PYCHOK OK
153
+ # _ASTERISK_ = _STAR_ # PYCHOK OK
154
+ _at_ = 'at' # PYCHOK OK
155
+ _AT_ = Str_('@') # PYCHOK OK
156
+ _AtoZnoIO_ = _Slicer('ABCDEFGHJKLMNPQRSTUVWXYZ') # PYCHOK in .gars, .mgrs and .wgrs
157
+ _attribute_ = 'attribute' # PYCHOK OK
158
+ _azi1_ = 'azi1' # PYCHOK OK
159
+ _azi12_ = 'azi12' # PYCHOK OK
160
+ _azi2_ = 'azi2' # PYCHOK OK
161
+ _azimuth_ = 'azimuth' # PYCHOK OK
162
+ _b_ = 'b' # PYCHOK OK
163
+ _B_ = 'B' # PYCHOK OK
164
+ _BACKSLASH_ = Str_('\\') # PYCHOK OK
165
+ _band_ = 'band' # PYCHOK OK
166
+ _BANG_ = Str_('!') # PYCHOK OK
167
+ _BAR_ = Str_('|') # PYCHOK OK
168
+ _bearing_ = 'bearing' # PYCHOK OK
169
+ _Bessel1841_ = 'Bessel1841' # PYCHOK OK
170
+ _beta_ = 'beta' # PYCHOK OK
171
+ _by_ = 'by' # PYCHOK OK
172
+ _c_ = 'c' # PYCHOK OK
173
+ _C_ = 'C' # PYCHOK OK
174
+ _cartesian_ = 'cartesian' # PYCHOK OK
175
+ _center_ = 'center' # PYCHOK OK
176
+ # _CIRCUMFLEX_ = Str_('^') # PYCHOK OK
177
+ _Clarke1866_ = 'Clarke1866' # PYCHOK OK
178
+ _Clarke1880IGN_ = 'Clarke1880IGN' # PYCHOK OK
179
+ _clip_ = 'clip' # PYCHOK OK
180
+ _clipid_ = 'clipid' # PYCHOK OK
181
+ _coincident_ = 'coincident' # PYCHOK OK
182
+ _colinear_ = 'colinear' # PYCHOK OK
183
+ _COLON_ = Str_(':') # PYCHOK OK
184
+ _COLONSPACE_ = Str_(': ') # PYCHOK OK
185
+ _COMMA_ = Str_(',') # PYCHOK OK
186
+ _COMMASPACE_ = Str_(_COMMASPACE_) # PYCHOK OK
187
+ _composite_ = 'composite' # PYCHOK OK
188
+ _concentric_ = 'concentric' # PYCHOK OK
189
+ _convergence_ = _Prefix('convergence') # PYCHOK OK
190
+ _conversion_ = 'conversion' # PYCHOK OK
191
+ _convex_ = 'convex' # PYCHOK OK
192
+ _cubic_ = 'cubic' # PYCHOK OK
193
+ _d_ = 'd' # PYCHOK OK
194
+ _D_ = 'D' # PYCHOK OK
195
+ _DASH_ = Str_('-') # PYCHOK == _MINUS_
196
+ _datum_ = 'datum' # PYCHOK OK
197
+ _decode3_ = 'decode3' # PYCHOK OK
198
+ _deg_ = 'deg' # PYCHOK OK
199
+ _degrees_ = 'degrees' # PYCHOK OK
200
+ _degrees2_ = 'degrees2' # PYCHOK SQUARED
201
+ _delta_ = 'delta' # PYCHOK OK
202
+ _DEPRECATED_ = 'DEPRECATED' # PYCHOK OK
203
+ _DEQUALSPACED_ = Str_(' == ') # PYCHOK OK
204
+ _distance_ = 'distance' # PYCHOK OK
205
+ _distant_ = _Prefix('distant') # PYCHOK OK
206
+ _doesn_t_exist_ = "doesn't exist" # PYCHOK OK
207
+ _DOT_ = Str_('.') # PYCHOK OK
208
+ _down_ = 'down' # PYCHOK OK
209
+ _e_ = 'e' # PYCHOK OK
210
+ _E_ = 'E' # PYCHOK OK
211
+ _earth_ = 'earth' # PYCHOK OK
212
+ _east_ = 'east' # PYCHOK OK
213
+ _easting_ = 'easting' # PYCHOK OK
214
+ _ecef_ = 'ecef' # PYCHOK OK
215
+ _edge_ = 'edge' # PYCHOK OK
216
+ _elevation_ = 'elevation' # PYCHOK OK
217
+ _ELLIPSIS_ = Str_('...') # PYCHOK OK
218
+ _ELLIPSIS4_ = Str_('....') # PYCHOK OK
219
+ # _ELLIPSISPACED_ = Str_(' ... ') # PYCHOK <https://www.ThePunctuationGuide.com/ellipses.html>
220
+ _ellipsoid_ = 'ellipsoid' # PYCHOK OK
221
+ _ellipsoidal_ = 'ellipsoidal' # PYCHOK OK
222
+ _enabled_ = 'enabled' # PYCHOK OK
223
+ _encode_ = 'encode' # PYCHOK OK
224
+ _end_ = 'end' # PYCHOK OK
225
+ _epoch_ = 'epoch' # PYCHOK OK
226
+ _eps_ = 'eps' # PYCHOK OK
227
+ _EQUAL_ = Str_('=') # PYCHOK OK
228
+ _EQUALSPACED_ = Str_(' = ') # PYCHOK OK
229
+ _Error_ = 'Error' # PYCHOK OK
230
+ _exceed_PI_radians_ = 'exceed PI radians' # PYCHOK OK
231
+ _exceeds_ = _Prefix('exceeds') # PYCHOK OK
232
+ # _EXCLAMATION_ = _BANG_ # PYCHOK OK
233
+ _exists_ = 'exists' # PYCHOK OK
234
+ _f_ = 'f' # PYCHOK OK
235
+ _F_ = 'F' # PYCHOK OK
236
+ _feet_ = 'feet' # PYCHOK OK
237
+ _few_ = 'few' # PYCHOK OK
238
+ _fi_ = 'fi' # PYCHOK OK
239
+ _finite_ = 'finite' # PYCHOK OK
240
+ _from_ = 'from' # PYCHOK OK
241
+ _g_ = 'g' # PYCHOK OK
242
+ _gamma_ = 'gamma' # PYCHOK OK
243
+ _GRS80_ = 'GRS80' # PYCHOK OK
244
+ _h_ = 'h' # PYCHOK OK
245
+ _H_ = 'H' # PYCHOK OK
246
+ _HASH_ = '#' # PYCHOK OK
247
+ _height_ = 'height' # PYCHOK OK
248
+ _hemipole_ = 'hemipole' # PYCHOK OK
249
+ _i_ = 'i' # PYCHOK OK
250
+ _iadd_op_ = '+=' # PYCHOK OK
251
+ _immutable_ = 'immutable' # PYCHOK OK
252
+ _in_ = 'in' # PYCHOK OK
253
+ _incompatible_ = 'incompatible' # PYCHOK OK
254
+ _INF_ = 'INF' # PYCHOK OK
255
+ _infinite_ = 'infinite' # PYCHOK _not_finite_
256
+ _initial_ = 'initial' # PYCHOK OK
257
+ _inside_ = 'inside' # PYCHOK OK
258
+ _insufficient_ = 'insufficient' # PYCHOK OK
259
+ _intersection_ = 'intersection' # PYCHOK OK
260
+ _Intl1924_ = 'Intl1924' # PYCHOK OK
261
+ _invalid_ = 'invalid' # PYCHOK OK
262
+ _invokation_ = 'invokation' # PYCHOK OK
263
+ _isclockwise_ = 'isclockwise' # PYCHOK OK
264
+ _ispolar_ = 'ispolar' # PYCHOK OK
265
+ _j_ = 'j' # PYCHOK OK
266
+ _k0_ = 'k0' # PYCHOK OK
267
+ _kind_ = 'kind' # PYCHOK OK
268
+ _knots_ = 'knots' # PYCHOK OK
269
+ _Krassovski1940_ = 'Krassovski1940' # PYCHOK OK
270
+ _Krassowsky1940_ = 'Krassowsky1940' # PYCHOK OK
271
+ _LANGLE_ = '<' # PYCHOK OK
272
+ _lam_ = 'lam' # PYCHOK OK
273
+ _lat_ = 'lat' # PYCHOK OK
274
+ _lat0_ = 'lat0' # PYCHOK OK
275
+ _lat1_ = 'lat1' # PYCHOK OK
276
+ _lat2_ = 'lat2' # PYCHOK OK
277
+ _latlon_ = 'latlon' # PYCHOK OK
278
+ _LatLon_ = 'LatLon' # PYCHOK OK
279
+ _LCURLY_ = '{' # PYCHOK LBRACE
280
+ _len_ = 'len' # PYCHOK OK
281
+ _limit_ = 'limit' # PYCHOK OK
282
+ _line_ = 'line' # PYCHOK OK
283
+ _linear_ = 'linear' # PYCHOK OK
284
+ _LPAREN_ = '(' # PYCHOK OK
285
+ _lon_ = 'lon' # PYCHOK OK
286
+ _lon0_ = 'lon0' # PYCHOK OK
287
+ _lon1_ = 'lon1' # PYCHOK OK
288
+ _lon2_ = 'lon2' # PYCHOK OK
289
+ _low_ = 'low' # PYCHOK OK
290
+ _LSQUARE_ = '[' # PYCHOK LBRACK
291
+ _ltp_ = 'ltp' # PYCHOK OK
292
+ _m_ = 'm' # PYCHOK OK
293
+ _M_ = 'M' # PYCHOK OK
294
+ _m12_ = 'm12' # PYCHOK OK
295
+ _M12_ = 'M12' # PYCHOK OK
296
+ _M21_ = 'M21' # PYCHOK OK
297
+ _MANT_DIG_ = 'MANT_DIG' # PYCHOK OK
298
+ _MAX_ = 'MAX' # PYCHOK OK
299
+ _mean_ = 'mean' # PYCHOK OK
300
+ _meanOf_ = 'meanOf' # PYCHOK OK
301
+ _meridional_ = 'meridional' # PYCHOK OK
302
+ _meter_ = 'meter' # PYCHOK OK
303
+ _meter2_ = 'meter2' # PYCHOK SQUARED
304
+ _MGRS_ = 'MGRS' # PYCHOK OK
305
+ _MIN_ = 'MIN' # PYCHOK OK
306
+ _MINUS_ = _DASH_ # PYCHOK OK
307
+ _module_ = 'module' # PYCHOK OK
308
+ _n_ = 'n' # PYCHOK OK
309
+ _N_ = 'N' # PYCHOK OK
310
+ _n_a_ = 'n/a' # PYCHOK OK
311
+ _N_A_ = 'N/A' # PYCHOK OK
312
+ _NAD27_ = 'NAD27' # PYCHOK OK
313
+ _NAD83_ = 'NAD83' # PYCHOK OK
314
+ _name_ = 'name' # PYCHOK OK
315
+ _NAN_ = 'NAN' # PYCHOK OK
316
+ _near_ = _Dash('near') # PYCHOK OK
317
+ _nearestOn2_ = 'nearestOn2' # PYCHOK OK
318
+ _negative_ = 'negative' # PYCHOK OK
319
+ _NL_ = Str_('\n') # PYCHOK OK
320
+ _NLATvar_ = Str_(_NL_ + '@var ') # PYCHOK OK
321
+ _NLHASH_ = Str_(_NL_ + '# ') # PYCHOK OK
322
+ # _NLNL_ = _DNL_ # PYCHOK OK
323
+ _NN_ = 'NN' # PYCHOK OK
324
+ _no_ = _Prefix('no') # PYCHOK OK
325
+ _north_ = 'north' # PYCHOK OK
326
+ _northing_ = 'northing' # PYCHOK OK
327
+ _NorthPole_ = 'NorthPole' # PYCHOK OK
328
+ _not_ = _Prefix('not') # PYCHOK OK
329
+ _NOTEQUAL_ = _BANG_ + _EQUAL_ # PYCHOK OK
330
+ _not_finite_ = 'not finite' # PYCHOK _not_(_finite_), _infinite_
331
+ _not_scalar_ = 'not scalar' # PYCHOK _not_(_scalar_)
332
+ _NTF_ = 'NTF' # PYCHOK OK
333
+ _null_ = 'null' # PYCHOK OK
334
+ _number_ = 'number' # PYCHOK OK
335
+ _numpy_ = 'numpy' # PYCHOK OK
336
+ _Nv00_ = 'Nv00' # PYCHOK OK
337
+ _of_ = 'of' # PYCHOK OK
338
+ _on_ = 'on' # PYCHOK OK
339
+ _opposite_ = 'opposite' # PYCHOK OK
340
+ _or_ = 'or' # PYCHOK OK
341
+ _other_ = 'other' # PYCHOK OK
342
+ _outside_ = 'outside' # PYCHOK OK
343
+ _overlap_ = 'overlap' # PYCHOK OK
344
+ _parallel_ = 'parallel' # PYCHOK OK
345
+ _PERCENT_ = '%' # PYCHOK OK
346
+ _PERCENTDOTSTAR_ = '%.*' # PYCHOK _DOT_(_PERCENT_, _STAR_)
347
+ _phi_ = 'phi' # PYCHOK OK
348
+ _PLUS_ = Str_('+') # PYCHOK OK
349
+ _PLUSMINUS_ = _PLUS_ + _MINUS_ # PYCHOK OK
350
+ _point_ = 'point' # PYCHOK OK
351
+ _points_ = 'points' # PYCHOK OK
352
+ _pole_ = 'pole' # PYCHOK OK
353
+ _precision_ = 'precision' # PYCHOK OK
354
+ _prime_vertical_ = 'prime_vertical' # PYCHOK OK
355
+ _pygeodesy_ = 'pygeodesy' # PYCHOK OK
356
+ _pygeodesy_abspath_ = 'pygeodesy_abspath' # PYCHOK OK
357
+ _PyPy__ = _PyPy__('PyPy ') # PYCHOK + _SPACE_
358
+ _Python_ = _Python_('Python') # PYCHOK singleton
359
+ _python_ = 'python' # PYCHOK OK
360
+ _QUOTE1_ = "'" # PYCHOK OK
361
+ _QUOTE2_ = '"' # PYCHOK OK
362
+ # _QUOTE3_ = "'''" # PYCHOK OK
363
+ # _QUOTE6_ = '"""' # PYCHOK OK
364
+ _R_ = 'R' # PYCHOK OK
365
+ _radians_ = 'radians' # PYCHOK OK
366
+ _radians2_ = 'radians2' # PYCHOK SQUARED
367
+ _radius_ = 'radius' # PYCHOK OK
368
+ _radius1_ = 'radius1' # PYCHOK OK
369
+ _radius2_ = 'radius2' # PYCHOK OK
370
+ _range_ = _Range('range') # PYCHOK OK
371
+ _RANGLE_ = '>' # PYCHOK OK
372
+ _RCURLY_ = '}' # PYCHOK RBRACE
373
+ _reciprocal_ = 'reciprocal' # PYCHOK OK
374
+ _reframe_ = 'reframe' # PYCHOK OK
375
+ _resolution_ = 'resolution' # PYCHOK OK
376
+ _rIn_ = 'rIn' # PYCHOK OK
377
+ _RPAREN_ = ')' # PYCHOK OK
378
+ _RSQUARE_ = ']' # PYCHOK RBRACK
379
+ _s_ = 's' # PYCHOK OK
380
+ _S_ = 'S' # PYCHOK OK
381
+ _s12_ = 's12' # PYCHOK OK
382
+ _S12_ = 'S12' # PYCHOK OK
383
+ _scalar_ = 'scalar' # PYCHOK OK
384
+ _scale_ = 'scale' # PYCHOK OK
385
+ _scale0_ = 'scale0' # PYCHOK OK
386
+ _scipy_ = 'scipy' # PYCHOK OK
387
+ _semi_circular_ = 'semi-circular' # PYCHOK OK
388
+ _sep_ = 'sep' # PYCHOK OK
389
+ _singular_ = 'singular' # PYCHOK OK
390
+ _SLASH_ = Str_('/') # PYCHOK OK
391
+ _small_ = 'small' # PYCHOK OK
392
+ _Sphere_ = 'Sphere' # PYCHOK OK
393
+ _spherical_ = 'spherical' # PYCHOK OK
394
+ _SouthPole_ = 'SouthPole' # PYCHOK OK
395
+ _SPACE_ = Str_(' ') # PYCHOK OK
396
+ _specified_ = 'specified' # PYCHOK OK
397
+ _STAR_ = Str_('*') # PYCHOK OK
398
+ _start_ = 'start' # PYCHOK OK
399
+ _std_ = 'std' # PYCHOK OK
400
+ _stdev_ = 'stdev' # PYCHOK OK
401
+ _supported_ = 'supported' # PYCHOK OK
402
+ _tbd_ = 'tbd' # PYCHOK OK
403
+ _TILDE_ = '~' # PYCHOK OK
404
+ _to_ = 'to' # PYCHOK OK
405
+ _tolerance_ = _Prefix('tolerance') # PYCHOK OK
406
+ _too_ = _Prefix('too') # PYCHOK OK
407
+ _transform_ = 'transform' # PYCHOK OK
408
+ _UNDER_ = Str_('_') # PYCHOK OK
409
+ _units_ = 'units' # PYCHOK OK
410
+ _UNUSED_ = 'UNUSED' # PYCHOK OK
411
+ _up_ = 'up' # PYCHOK OK
412
+ _UPS_ = 'UPS' # PYCHOK OK
413
+ _utf_8_ = 'utf-8' # PYCHOK OK
414
+ _UTM_ = 'UTM' # PYCHOK OK
415
+ _V_ = 'V' # PYCHOK OK
416
+ _valid_ = 'valid' # PYCHOK OK
417
+ _value_ = 'value' # PYCHOK OK
418
+ _version_ = 'version' # PYCHOK OK
419
+ _vs_ = 'vs' # PYCHOK OK
420
+ _W_ = 'W' # PYCHOK OK
421
+ _WGS72_ = 'WGS72' # PYCHOK OK
422
+ _WGS84_ = 'WGS84' # PYCHOK OK
423
+ _width_ = 'width' # PYCHOK OK
424
+ _with_ = 'with' # PYCHOK OK
425
+ _x_ = 'x' # PYCHOK OK
426
+ _X_ = 'X' # PYCHOK OK
427
+ _xyz_ = 'xyz' # PYCHOK OK
428
+ _y_ = 'y' # PYCHOK OK
429
+ _Y_ = 'Y' # PYCHOK OK
430
+ _z_ = 'z' # PYCHOK OK
431
+ _Z_ = 'Z' # PYCHOK OK
432
+ _zone_ = 'zone' # PYCHOK OK
433
+
434
+ _EW_ = _E_ + _W_ # PYCHOK common cardinals
435
+ _NE_ = _N_ + _E_ # PYCHOK positive ones
436
+ _NS_ = _N_ + _S_ # PYCHOK OK
437
+ _NSEW_ = _NS_ + _EW_ # PYCHOK OK
438
+ _NW_ = _N_ + _W_ # PYCHOK OK
439
+ _SE_ = _S_ + _E_ # PYCHOK OK
440
+ _SW_ = _S_ + _W_ # PYCHOK negative ones
441
+ # _NESW_ = _NE_ + _SW_ # PYCHOK clockwise
442
+
443
+ _DDOT_ = Str_(_DOT_ * 2) # PYCHOK OK
444
+ # _DEQUAL_ = Str_(_EQUAL_ * 2) # PYCHOK OK
445
+ _DNL_ = Str_(_NL_ * 2) # PYCHOK OK
446
+ # _DSLASH_ = Str_(_SLASH_ * 2) # PYCHOK OK
447
+ # _DSTAR_ = Str_(_STAR_ * 2) # PYCHOK OK
448
+ _DUNDER_ = Str_(_UNDER_ * 2) # PYCHOK OK
449
+
450
+ _LR_PAIRS = {_LANGLE_: _RANGLE_,
451
+ _LCURLY_: _RCURLY_,
452
+ _LPAREN_: _RPAREN_,
453
+ _LSQUARE_: _RSQUARE_} # PYCHOK OK
454
+
455
+
456
+ def _dunder_nameof(inst, *dflt):
457
+ '''(INTERNAL) Get the double_underscore __name__ attr.
458
+ '''
459
+ try:
460
+ return inst.__name__
461
+ except AttributeError:
462
+ pass
463
+ return dflt[0] if dflt else inst.__class__.__name__
464
+
465
+
466
+ def _enquote(strs, quote=_QUOTE2_): # in .basics, .solveBase
467
+ '''(INTERNAL) Enquote a string containing whitespace.
468
+ '''
469
+ if len(strs.split()) > 1:
470
+ strs = NN(quote, strs, quote)
471
+ return strs
472
+
473
+
474
+ def _headof(name):
475
+ '''(INTERNAL) Get the head name of qualified C{name} or the C{name}.
476
+ '''
477
+ i = name.find(_DOT_)
478
+ return name if i < 0 else name[:i]
479
+
480
+
481
+ def _is(a, b): # PYCHOK no cover
482
+ '''(INTERNAL) C{a is b}? in C{PyPy}
483
+ '''
484
+ return (a == b) if _isPyPy() else (a is b)
485
+
486
+
487
+ def _isPyPy():
488
+ '''(INTERNAL) Is this C{PyPy}?
489
+ '''
490
+ # platform.python_implementation() == 'PyPy'
491
+ return _pythonarchine()[0].startswith(_PyPy__)
492
+
493
+
494
+ def _load_lib(name):
495
+ '''(INTERNAL) Load a C{dylib}, B{C{name}} must startwith('lib').
496
+ '''
497
+ # macOS 11+ (aka 10.16) no longer provides direct loading of
498
+ # system libraries. As a result, C{ctypes.util.find_library}
499
+ # will not find any library, unless previously installed by a
500
+ # low-level dlopen(name) call (with the library base C{name}).
501
+ from ctypes import CDLL
502
+ from ctypes.util import find_library
503
+
504
+ ns = find_library(name), name
505
+ if _sys.platform[:6] == 'darwin': # and os.name == 'posix'
506
+ from ctypes import _dlopen, DEFAULT_MODE
507
+ from os.path import join
508
+ ns += (_DOT_(name, 'dylib'),
509
+ _DOT_(name, 'framework'), join(
510
+ _DOT_(name, 'framework'), name))
511
+ else: # non-macOS
512
+ DEFAULT_MODE = 0
513
+
514
+ def _dlopen(*unused):
515
+ return True
516
+
517
+ for n in ns:
518
+ try:
519
+ if n and _dlopen(n, DEFAULT_MODE): # pre-load handle
520
+ lib = CDLL(n) # == ctypes.cdll.LoadLibrary(n)
521
+ if lib._name: # has a qualified name
522
+ return lib
523
+ except (AttributeError, OSError):
524
+ pass
525
+
526
+ return None # raise OSError
527
+
528
+
529
+ def machine():
530
+ '''Return standard C{platform.machine}, but distinguishing Intel I{native}
531
+ from Intel I{emulation} on Apple Silicon (on macOS only).
532
+
533
+ @return: Machine C{'arm64'} for Apple Silicon I{native}, C{'x86_64'}
534
+ for Intel I{native}, C{"arm64_x86_64"} for Intel I{emulation},
535
+ etc. (C{str} with C{comma}s replaced by C{underscore}s).
536
+ '''
537
+ return _platform2()[1]
538
+
539
+
540
+ def _platform2(sep=NN):
541
+ '''(INTERNAL) Get platform architecture and machine as C{2-list} or C{str}.
542
+ '''
543
+ L = _pf2List
544
+ if not L:
545
+ import platform
546
+ m = platform.machine() # ARM64, arm64, x86_64, iPhone13,2, etc.
547
+ m = m.replace(_COMMA_, _UNDER_)
548
+ if m.lower() == 'x86_64': # on Intel or Rosetta2 ...
549
+ v = platform.mac_ver() # ... and only on macOS ...
550
+ if v and _version2(v[0]) > (10, 15): # ... 11+ aka 10.16
551
+ # <https://Developer.Apple.com/forums/thread/659846>
552
+ if _sysctl_uint('sysctl.proc_translated') == 1: # and \
553
+ # _sysctl_uint('hw.optional.arm64') == 1: # PYCHOK indent
554
+ m = _UNDER_('arm64', m) # Apple Si emulating Intel x86-64
555
+ L[:] = [platform.architecture()[0], # bits
556
+ m] # arm64, arm64_x86_64, x86_64, etc.
557
+ return sep.join(L) if sep else L # 2-list()
558
+
559
+
560
+ def _pythonarchine(sep=NN): # in test/bases.py versions
561
+ '''(INTERNAL) Get PyPy and Python versions and C{_platform2} as C{3- or 4-list} or C{str}.
562
+ '''
563
+ L = _Py3List
564
+ if not L:
565
+ v = _sys.version
566
+ L[:] = [_Python_(v)] + _platform2()
567
+ pypy = _PyPy__(v)
568
+ if pypy:
569
+ L.insert(0, pypy)
570
+ return sep.join(L) if sep else L # 3- or 4-list
571
+
572
+
573
+ def _sysctl_uint(name):
574
+ '''(INTERNAL) Get an unsigned int sysctl item by name, use on macOS ONLY!
575
+ '''
576
+ libc = _load_lib('libc')
577
+ if libc: # <https://StackOverflow.com/questions/759892/python-ctypes-and-sysctl>
578
+ from ctypes import byref, c_char_p, c_size_t, c_uint, sizeof # get_errno
579
+ n = name if str is bytes else bytes(name, _utf_8_) # PYCHOK isPython2 = str is bytes
580
+ u = c_uint(0)
581
+ z = c_size_t(sizeof(u))
582
+ r = libc.sysctlbyname(c_char_p(n), byref(u), byref(z), None, c_size_t(0))
583
+ else: # could find or load 'libc'
584
+ r = -2
585
+ return int(r if r else u.value) # -1 ENOENT error, -2 no libc
586
+
587
+
588
+ def _tailof(name):
589
+ '''(INTERNAL) Get the base name of qualified C{name} or the C{name}.
590
+ '''
591
+ i = name.rfind(_DOT_) + 1
592
+ return name[i:] if i > 0 else name
593
+
594
+
595
+ def _under(name): # PYCHOK in .datums, .auxilats, .ups, .utm, .utmupsBase, ...
596
+ '''(INTERNAL) Prefix C{name} with I{underscore}.
597
+ '''
598
+ return name if name.startswith(_UNDER_) else NN(_UNDER_, name)
599
+
600
+
601
+ def _usage(file_py, *args): # in .etm
602
+ '''(INTERNAL) Build "usage: python -m ..." cmd line for module B{C{file_py}}.
603
+ '''
604
+ import os
605
+ m = os.path.dirname(file_py).replace(os.getcwd(), _ELLIPSIS_) \
606
+ .replace(os.sep, _DOT_).strip()
607
+ b, x = os.path.splitext(os.path.basename(file_py))
608
+ if x == '.py' and b != '__main__':
609
+ m = _DOT_(m or _pygeodesy_, b)
610
+ p = NN(_python_, _sys.version_info[0])
611
+ return NN('usage', _SPACE_(_COLON_, p, '-m', _enquote(m), *args))
612
+
613
+
614
+ def _version2(version, n=2):
615
+ '''(INTERNAL) Split C{B{version} str} into a C{1-, 2- or 3-tuple} of C{int}s.
616
+ '''
617
+ t = _version_ints(version.split(_DOT_, 2))
618
+ if len(t) < n:
619
+ t += (0,) * n
620
+ return t[:n]
621
+
622
+
623
+ def _version_info(package): # in .Base.karney, .basics
624
+ '''(INTERNAL) Get the C{package.__version_info__} as a 2- or
625
+ 3-tuple C{(major, minor, revision)} if C{int}s.
626
+ '''
627
+ try:
628
+ return _version_ints(package.__version_info__)
629
+ except AttributeError:
630
+ return _version2(package.__version__.strip(), n=3)
631
+
632
+
633
+ def _version_ints(vs):
634
+ # helper for _version2 and _version_info above
635
+
636
+ def _ints(vs):
637
+ for v in vs:
638
+ try:
639
+ yield int(v.strip())
640
+ except (TypeError, ValueError):
641
+ pass
642
+
643
+ return tuple(_ints(vs))
644
+
645
+
646
+ __all__ = (_NN_, # not MISSING!
647
+ Str_.__name__, # classes
648
+ machine.__name__) # in .lazily
649
+ __version__ = '24.03.20'
650
+
651
+ if __name__ == '__main__':
652
+
653
+ from pygeodesy import itemsorted, printf
654
+
655
+ t = b = 0
656
+ for n, v in itemsorted(locals(), asorted=False, reverse=True):
657
+ if n.endswith(_UNDER_) and n.startswith(_UNDER_) and \
658
+ not n.startswith(_DUNDER_):
659
+ t += 1
660
+ b += len(v)
661
+ m = n[1:-1]
662
+ if m != v and m.replace(_UNDER_, _SPACE_) != v:
663
+ printf('%4d: %s = %r', t, n, v)
664
+ n = len(locals())
665
+ printf('%4d (%d) names, %s chars total, %.2f chars avg', t, n, b, float(b) / t, nl=1)
666
+
667
+ # **) MIT License
668
+ #
669
+ # Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved.
670
+ #
671
+ # Permission is hereby granted, free of charge, to any person obtaining a
672
+ # copy of this software and associated documentation files (the "Software"),
673
+ # to deal in the Software without restriction, including without limitation
674
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
675
+ # and/or sell copies of the Software, and to permit persons to whom the
676
+ # Software is furnished to do so, subject to the following conditions:
677
+ #
678
+ # The above copyright notice and this permission notice shall be included
679
+ # in all copies or substantial portions of the Software.
680
+ #
681
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
682
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
683
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
684
+ # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
685
+ # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
686
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
687
+ # OTHER DEALINGS IN THE SOFTWARE.