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/unitsBase.py ADDED
@@ -0,0 +1,349 @@
1
+
2
+ # -*- coding: utf-8 -*-
3
+
4
+ u'''Basic C{Float}, C{Int} and C{Str}ing units classes.
5
+ '''
6
+
7
+ from pygeodesy.errors import UnitError, _XError, _xkwds_item2
8
+ from pygeodesy.interns import NN, _degrees_, _degrees2_, _invalid_, \
9
+ _meter_, _radians_, _radians2_, \
10
+ _radius_, _UNDER_, _std_ # PYCHOK used!
11
+ from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY
12
+ from pygeodesy.named import modulename, _Named, property_doc_
13
+ # from pygeodesy.props import property_doc_ # from .named
14
+ from pygeodesy.streprs import Fmt, fstr
15
+
16
+ __all__ = _ALL_LAZY.unitsBase
17
+ __version__ = '24.02.20'
18
+
19
+
20
+ class _NamedUnit(_Named):
21
+ '''(INTERNAL) Base class for C{units}.
22
+ '''
23
+ _std_repr = True # set below
24
+ _units = None
25
+
26
+ @property_doc_(' standard C{repr} or named C{toRepr} representation.')
27
+ def std_repr(self):
28
+ '''Get the representation (C{bool}, C{True} means standard).
29
+ '''
30
+ return self._std_repr
31
+
32
+ @std_repr.setter # PYCHOK setter!
33
+ def std_repr(self, std):
34
+ '''Set the representation (C{True} or C{"std"} for standard).
35
+ '''
36
+ self._std_repr = std in (True, _std_)
37
+
38
+ def _toRepr(self, value):
39
+ '''(INTERNAL) Representation "<name> (<value>)" or "<classname>(<value>)".
40
+ '''
41
+ return Fmt.PARENSPACED(self.name, value) if self.name else \
42
+ Fmt.PAREN( self.classname, value)
43
+
44
+ @property_doc_(' units name.')
45
+ def units(self):
46
+ '''Get the units name (C{str}).
47
+ '''
48
+ if self._units is None:
49
+ self._units = self.classname
50
+ return self._units
51
+
52
+ @units.setter # PYCHOK setter!
53
+ def units(self, units):
54
+ '''Set the units name for this instance (C{str} or C{None} for default).
55
+ '''
56
+ self._units = None if units is None else str(units)
57
+
58
+
59
+ class Float(float, _NamedUnit):
60
+ '''Named C{float}.
61
+ '''
62
+ # _std_repr = True # set below
63
+
64
+ def __new__(cls, arg=None, name=NN, Error=UnitError, **name_arg):
65
+ '''New C{Ffloat} instance.
66
+
67
+ @kwarg arg: The value (any C{type} convertable to C{float}).
68
+ @kwarg name: Optional instance name (C{str}).
69
+ @kwarg Error: Optional error to raise, overriding the default
70
+ L{UnitError}.
71
+ @kwarg name_arg: Optional C{name=arg} keyword argument, inlieu
72
+ of B{C{name}} and B{C{arg}}.
73
+
74
+ @returns: A C{Float} instance.
75
+
76
+ @raise Error: Invalid B{C{arg}}.
77
+ '''
78
+ if name_arg:
79
+ name, arg = _xkwds_item2(name_arg)
80
+ try:
81
+ self = float.__new__(cls, arg)
82
+ if name:
83
+ _NamedUnit.name.fset(self, name) # see _Named.name
84
+ except Exception as x: # XXX not ... as x:
85
+ raise _Error(cls, arg, name, Error, x=x)
86
+ return self
87
+
88
+ def __repr__(self): # to avoid MRO(float)
89
+ '''Return a representation of this C{Float}.
90
+
91
+ @see: Method C{Float.toRepr} and property C{Float.std_repr}.
92
+
93
+ @note: Use C{env} variable C{PYGEODESY_FLOAT_STD_REPR=std} prior
94
+ to C{import pygeodesy} to get the standard C{repr} or set
95
+ property C{std_repr=False} to always get the named C{toRepr}
96
+ representation.
97
+ '''
98
+ return self.toRepr(std=self._std_repr)
99
+
100
+ def __str__(self): # to avoid MRO(float)
101
+ '''Return this C{Float} as standard C{str}.
102
+ '''
103
+ # XXX must use super(Float, self)... since super()...
104
+ # only works for Python 3+ and float.__str__(self)
105
+ # invokes .__repr__(self); calling self.toRepr(std=True)
106
+ # super(Float, self).__repr__() mimicks this behavior
107
+ # XXX the default number of decimals is 10-12 when using
108
+ # float.__str__(self) with both python 3.8+ and 2.7-, but
109
+ # float.__repr__(self) shows DIG decimals in python2.7!
110
+ # return super(Float, self).__repr__() # see .test.testCss.py
111
+ return float.__str__(self) # always _std_str_
112
+
113
+ def toRepr(self, std=False, **prec_fmt_ints): # PYCHOK prec=8, ...
114
+ '''Return a representation of this C{Float}.
115
+
116
+ @kwarg std: If C{True} return the standard C{repr},
117
+ otherwise the named representation (C{bool}).
118
+
119
+ @see: Methods L{Float.__repr__}, L{Float.toStr} and function
120
+ L{pygeodesy.fstr} for more documentation.
121
+ '''
122
+ # XXX must use super(Float, self)... since
123
+ # super()... only works for Python 3+
124
+ # return super(Float, self).__repr__() if std else \
125
+ return float.__repr__(self) if std else \
126
+ self._toRepr(self.toStr(**prec_fmt_ints))
127
+
128
+ def toStr(self, prec=12, fmt=Fmt.g, ints=False): # PYCHOK prec=8, ...
129
+ '''Format this C{Float} as C{str}.
130
+
131
+ @see: Method L{Float.__repr__} and function L{pygeodesy.fstr}
132
+ for more documentation.
133
+ '''
134
+ return fstr(self, prec=prec, fmt=fmt, ints=ints)
135
+
136
+
137
+ class Int(int, _NamedUnit):
138
+ '''Named C{int}.
139
+ '''
140
+ # _std_repr = True # set below
141
+
142
+ def __new__(cls, arg=None, name=NN, Error=UnitError, **name_arg):
143
+ '''New C{Int} instance.
144
+
145
+ @kwarg arg: The value (any C{type} convertable to C{float}).
146
+ @kwarg name: Optional instance name (C{str}).
147
+ @kwarg Error: Optional error to raise, overriding the
148
+ default L{UnitError}.
149
+ @kwarg name_arg: Optional C{name=arg} keyword argument,
150
+ inlieu of B{C{name}} and B{C{arg}}.
151
+
152
+ @returns: An C{Int} instance.
153
+
154
+ @raise Error: Invalid B{C{arg}}.
155
+ '''
156
+ if name_arg:
157
+ name, arg = _xkwds_item2(name_arg)
158
+ try:
159
+ self = int.__new__(cls, arg)
160
+ if name:
161
+ _NamedUnit.name.fset(self, name) # see _Named.name
162
+ except Exception as x: # XXX not ... as x:
163
+ raise _Error(cls, arg, name, Error, x=x)
164
+ return self
165
+
166
+ def __repr__(self): # to avoid MRO(int)
167
+ '''Return a representation of this named C{int}.
168
+
169
+ @see: Method C{Int.toRepr} and property C{Int.std_repr}.
170
+
171
+ @note: Use C{env} variable C{PYGEODESY_INT_STD_REPR=std}
172
+ prior to C{import pygeodesy} to get the standard
173
+ C{repr} or set property C{std_repr=False} to always
174
+ get the named C{toRepr} representation.
175
+ '''
176
+ return self.toRepr(std=self._std_repr)
177
+
178
+ def __str__(self): # to avoid MRO(int)
179
+ '''Return this C{Int} as standard C{str}.
180
+ '''
181
+ return self.toStr()
182
+
183
+ def toRepr(self, std=False, **unused): # PYCHOK **unused
184
+ '''Return a representation of this C{Int}.
185
+
186
+ @kwarg std: If C{True} return the standard C{repr},
187
+ otherwise the named representation (C{bool}).
188
+
189
+ @see: Method L{Int.__repr__} for more documentation.
190
+ '''
191
+ r = int.__repr__(self) # self.toStr()
192
+ return r if std else self._toRepr(r)
193
+
194
+ def toStr(self, **unused): # PYCHOK **unused
195
+ '''Return this C{Int} as standard C{str}.
196
+
197
+ @see: Method L{Int.__repr__} for more documentation.
198
+ '''
199
+ # XXX must use '%d' % (self,) since
200
+ # int.__str__(self) fails with 3.8+
201
+ return '%d' % (self,)
202
+
203
+
204
+ class Radius(Float):
205
+ '''Named C{float} representing a radius, conventionally in C{meter}.
206
+ '''
207
+ def __new__(cls, arg=None, name=_radius_, **Error_name_arg):
208
+ '''New L{Radius} instance, see L{Float}.
209
+ '''
210
+ return Float.__new__(cls, arg=arg, name=name, **Error_name_arg)
211
+
212
+
213
+ class Str(str, _NamedUnit):
214
+ '''Named, callable C{str}.
215
+ '''
216
+ # _std_repr = True # set below
217
+
218
+ def __new__(cls, arg=None, name=NN, Error=UnitError, **name_arg):
219
+ '''New C{Str} instance.
220
+
221
+ @kwarg cls: This class (C{Str} or sub-class).
222
+ @kwarg arg: The value (any C{type} convertable to C{str}).
223
+ @kwarg name: Optional instance name (C{str}).
224
+ @kwarg Error: Optional error to raise, overriding the
225
+ default (C{ValueError}).
226
+ @kwarg name_arg: Optional C{name=arg} keyword argument,
227
+ inlieu of B{C{name}} and B{C{arg}}.
228
+
229
+ @returns: A L{Str} instance.
230
+
231
+ @raise Error: Invalid B{C{arg}}.
232
+
233
+ @see: Callable, not-nameable class L{pygeodesy.Str_}.
234
+ '''
235
+ if name_arg:
236
+ name, arg = _xkwds_item2(name_arg)
237
+ try:
238
+ self = str.__new__(cls, arg)
239
+ if name:
240
+ _NamedUnit.name.fset(self, name) # see _Named.name
241
+ except Exception as x: # XXX not ... as x:
242
+ raise _Error(cls, arg, name, Error, x=x)
243
+ return self
244
+
245
+ def __repr__(self):
246
+ '''Return a representation of this C{Str}.
247
+
248
+ @see: Method C{Str.toRepr} and property C{Str.std_repr}.
249
+
250
+ @note: Use C{env} variable C{PYGEODESY_STR_STD_REPR=std}
251
+ prior to C{import pygeodesy} to get the standard
252
+ C{repr} or set property C{std_repr=False} to always
253
+ get the named C{toRepr} representation.
254
+ '''
255
+ return self.toRepr(std=self._std_repr) # see .test/testGars.py
256
+
257
+ def __str__(self):
258
+ '''Return this C{Str} as standard C{str}.
259
+ '''
260
+ return self.toStr()
261
+
262
+ def join_(self, *args, **name_Error):
263
+ '''Join all positional B{C{args}} like C{self.join(B{args})}.
264
+
265
+ @return: All B{C{args}} joined by this instance (L{Str_}).
266
+
267
+ @note: An other L{Str} instance is returned to make the
268
+ result re-callable.
269
+ '''
270
+ return Str(str.join(self, map(str, args)), **name_Error) # re-callable
271
+
272
+ __call__ = join_
273
+
274
+ def toRepr(self, std=False, **unused): # PYCHOK **unused
275
+ '''Return a representation of this C{Str}.
276
+
277
+ @kwarg std: If C{True} return the standard C{repr},
278
+ otherwise the named representation (C{bool}).
279
+
280
+ @see: Method L{Str.__repr__} for more documentation.
281
+ '''
282
+ # must use super(Str, self).. since
283
+ # super()... only works for Python 3+ and
284
+ # str.__repr__(self) fails with Python 3.8+
285
+ r = super(Str, self).__repr__()
286
+ return r if std else self._toRepr(r)
287
+
288
+ def toStr(self, **unused): # PYCHOK **unused
289
+ '''Return this C{Str} as standard C{str}.
290
+ '''
291
+ # must use super(Str, self)... since
292
+ # super()... only works for Python 3+ and
293
+ # str.__str__(self) fails with Python 3.8+
294
+ return super(Str, self).__str__()
295
+
296
+
297
+ _Str_degrees = Str(_degrees_) # PYCHOK in .frechet, .hausdorff
298
+ _Str_degrees2 = Str(_degrees2_) # PYCHOK in .frechet, .hausdorff
299
+ _Str_meter = Str(_meter_) # PYCHOK in .frechet, .hausdorff
300
+ _Str_NN = Str(NN) # PYCHOK in .frechet, .hausdorff
301
+ _Str_radians = Str(_radians_) # PYCHOK in .frechet, .hausdorff
302
+ _Str_radians2 = Str(_radians2_) # PYCHOK in .frechet, .hausdorff
303
+
304
+
305
+ def _Error(clas, arg, name, Error, txt=_invalid_, x=None):
306
+ '''(INTERNAL) Return an error with explanation.
307
+
308
+ @arg clas: The C{units} class or sub-class.
309
+ @arg arg: The original C{unit} value.
310
+ @arg name: The instance name (C{str}).
311
+ @arg Error: The Error class to use (C{Excetion}).
312
+ @kwarg txt: An explanation of the error )C{str}).
313
+ @kwarg x: Caught exception, used for exception
314
+ chaining (iff enabled in Python3+).
315
+
316
+ @returns: An B{C{Error}} instance.
317
+ '''
318
+ if x is not None: # caught exception, cause
319
+ if Error is UnitError: # and isError(x)
320
+ Error = type(x) # i.e. if not overridden
321
+ if txt is _invalid_:
322
+ txt = str(x) # i.e. if not overridden
323
+ n = name if name else modulename(clas).lstrip(_UNDER_)
324
+ return _XError(Error, n, arg, txt=txt, cause=x)
325
+
326
+
327
+ __all__ += _ALL_DOCS(_NamedUnit)
328
+
329
+ # **) MIT License
330
+ #
331
+ # Copyright (C) 2016-2024 -- mrJean1 at Gmail -- All Rights Reserved.
332
+ #
333
+ # Permission is hereby granted, free of charge, to any person obtaining a
334
+ # copy of this software and associated documentation files (the "Software"),
335
+ # to deal in the Software without restriction, including without limitation
336
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
337
+ # and/or sell copies of the Software, and to permit persons to whom the
338
+ # Software is furnished to do so, subject to the following conditions:
339
+ #
340
+ # The above copyright notice and this permission notice shall be included
341
+ # in all copies or substantial portions of the Software.
342
+ #
343
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
344
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
345
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
346
+ # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
347
+ # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
348
+ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
349
+ # OTHER DEALINGS IN THE SOFTWARE.