pygeodesy 24.6.24__py2.py3-none-any.whl → 24.7.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.
pygeodesy/geodsolve.py CHANGED
@@ -10,48 +10,31 @@ of the C{GeodSolve} executable.
10
10
  '''
11
11
 
12
12
  from pygeodesy.basics import _xinstanceof
13
- # from pygeodesy.constants import NAN, _0_0 # from .karney
13
+ # from pygeodesy.constants import NAN, _0_0 # from .karney
14
14
  # from pygeodesy.geodesicx import GeodesicAreaExact # _MODS
15
- from pygeodesy.interns import NN, _a12_, _azi1_, _azi2_, \
16
- _lat1_, _lat2_, _lon1_, _lon2_, _m12_, \
17
- _M12_, _M21_, _s12_, _S12_, _UNDER_
18
- from pygeodesy.interns import _UNUSED_, _not_ # PYCHOK used!
19
- from pygeodesy.karney import _Azi, Caps, _Deg, GeodesicError, _GTuple, \
20
- _Pass, _Lat, _Lon, _M, _M2, _sincos2d, \
21
- _0_0, NAN
15
+ from pygeodesy.interns import NN, _UNDER_
16
+ from pygeodesy.karney import Caps, GeodesicError, GeodSolve12Tuple, \
17
+ _sincos2d, _0_0, NAN
22
18
  from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS, \
23
19
  _getenv, _PYGEODESY_GEODSOLVE_
24
20
  from pygeodesy.named import _name1__
25
21
  from pygeodesy.namedTuples import Destination3Tuple, Distance3Tuple
26
22
  from pygeodesy.props import Property, Property_RO, property_RO
27
- from pygeodesy.solveBase import _SolveBase, _SolveLineBase
23
+ from pygeodesy.solveBase import _SolveGDictBase, _SolveGDictLineBase
28
24
  from pygeodesy.utily import _unrollon, _Wrap, wrap360
29
25
 
30
26
  __all__ = _ALL_LAZY.geodsolve
31
- __version__ = '24.06.26'
27
+ __version__ = '24.07.11'
32
28
 
33
29
 
34
- class GeodSolve12Tuple(_GTuple):
35
- '''12-Tuple C{(lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12)} with
36
- angles C{lat1}, C{lon1}, C{azi1}, C{lat2}, C{lon2} and C{azi2} and arc C{a12} all in
37
- C{degrees}, initial C{azi1} and final C{azi2} forward azimuths, distance C{s12} and
38
- reduced length C{m12} in C{meter}, area C{S12} in C{meter} I{squared} and geodesic
39
- scale factors C{M12} and C{M21}, both C{scalar}, see U{GeodSolve
40
- <https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>}.
41
- '''
42
- # from GeodSolve --help option -f ... lat1 lon1 azi1 lat2 lon2 azi2 s12 a12 m12 M12 M21 S12
43
- _Names_ = (_lat1_, _lon1_, _azi1_, _lat2_, _lon2_, _azi2_, _s12_, _a12_, _m12_, _M12_, _M21_, _S12_)
44
- _Units_ = (_Lat, _Lon, _Azi, _Lat, _Lon, _Azi, _M, _Deg, _Pass, _Pass, _Pass, _M2)
45
-
46
-
47
- class _GeodesicSolveBase(_SolveBase):
30
+ class _GeodesicSolveBase(_SolveGDictBase):
48
31
  '''(INTERNAL) Base class for L{GeodesicSolve} and L{GeodesicLineSolve}.
49
32
  '''
50
33
  _Error = GeodesicError
51
34
  _Names_Direct = \
52
35
  _Names_Inverse = GeodSolve12Tuple._Names_
53
- _Solve_name = 'GeodSolve'
54
- _Solve_path = _getenv(_PYGEODESY_GEODSOLVE_, _PYGEODESY_GEODSOLVE_)
36
+ _Xable_name = 'GeodSolve'
37
+ _Xable_path = _getenv(_PYGEODESY_GEODSOLVE_, _PYGEODESY_GEODSOLVE_)
55
38
 
56
39
  @Property_RO
57
40
  def _b_option(self):
@@ -67,16 +50,12 @@ class _GeodesicSolveBase(_SolveBase):
67
50
  self._p_option +
68
51
  self._u_option)
69
52
 
70
- @Property_RO
71
- def _E_option(self):
72
- return ('-E',) if self.Exact else ()
73
-
74
53
  @Property
75
54
  def GeodSolve(self):
76
55
  '''Get the U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>}
77
56
  executable (C{filename}).
78
57
  '''
79
- return self._Solve_path
58
+ return self._Xable_path
80
59
 
81
60
  @GeodSolve.setter # PYCHOK setter!
82
61
  def GeodSolve(self, path):
@@ -86,20 +65,20 @@ class _GeodesicSolveBase(_SolveBase):
86
65
  @raise GeodesicError: Invalid B{C{path}}, B{C{path}} doesn't exist or
87
66
  isn't the C{GeodSolve} executable.
88
67
  '''
89
- self._setSolve(path)
68
+ self._setXable(path)
90
69
 
91
70
  def toStr(self, **prec_sep): # PYCHOK signature
92
71
  '''Return this C{GeodesicSolve} as string.
93
72
 
94
- @kwarg prec_sep: Keyword argumens C{B{prec}=6} and C{B{sep}=', '}
95
- for the C{float} C{prec}ision, number of decimal digits
96
- (0..9) and the C{sep}arator string to join. Trailing
97
- zero decimals are stripped for B{C{prec}} values of
98
- 1 and above, but kept for negative B{C{prec}} values.
73
+ @kwarg prec_sep: Keyword argumens C{B{prec}=6} and C{B{sep}=", "}
74
+ for the C{float} C{prec}ision, number of decimal digits
75
+ (0..9) and the C{sep}arator string to join. Trailing
76
+ zero decimals are stripped for B{C{prec}} values of 1
77
+ and above, but kept for negative B{C{prec}} values.
99
78
 
100
79
  @return: GeodesicSolve items (C{str}).
101
80
  '''
102
- return _SolveBase._toStr(self, GeodSolve=self.GeodSolve, **prec_sep)
81
+ return _SolveGDictBase._toStr(self, GeodSolve=self.GeodSolve, **prec_sep)
103
82
 
104
83
  @Property_RO
105
84
  def _u_option(self):
@@ -119,11 +98,11 @@ class GeodesicSolve(_GeodesicSolveBase):
119
98
  '''
120
99
 
121
100
  def Area(self, polyline=False, **name):
122
- '''Set up a L{GeodesicAreaExact} to compute area and
123
- perimeter of a polygon.
101
+ '''Set up a L{GeodesicAreaExact} to compute area and perimeter
102
+ of a polygon.
124
103
 
125
- @kwarg polyline: If C{True} perimeter only, otherwise
126
- area and perimeter (C{bool}).
104
+ @kwarg polyline: If C{True} perimeter only, otherwise area
105
+ and perimeter (C{bool}).
127
106
  @kwarg name: Optional C{B{name}=NN} (C{str}).
128
107
 
129
108
  @return: A L{GeodesicAreaExact} instance.
@@ -139,8 +118,8 @@ class GeodesicSolve(_GeodesicSolveBase):
139
118
  Polygon = Area # for C{geographiclib} compatibility
140
119
 
141
120
  def Direct3(self, lat1, lon1, azi1, s12): # PYCHOK outmask
142
- '''Return the destination lat, lon and reverse azimuth
143
- (final bearing) in C{degrees}.
121
+ '''Return the destination lat, lon and reverse azimuth (final bearing)
122
+ in C{degrees}.
144
123
 
145
124
  @return: L{Destination3Tuple}C{(lat, lon, final)}.
146
125
  '''
@@ -203,6 +182,15 @@ class GeodesicSolve(_GeodesicSolveBase):
203
182
  ll2 = _unrollon(ll1, _Wrap.point(ll2))
204
183
  return self.InverseLine(ll1.lat, ll1.lon, ll2.lat, ll2.lon, **caps_name)
205
184
 
185
+ # def _InverseLine2(self, lat1, lon1, lat2, lon2, **caps_name): # in .geodesici
186
+ # '''(INTERNAL) Helper for L{InverseLine} and L{_InverseLine}.
187
+ # '''
188
+ # r = self.Inverse(lat1, lon1, lat2, lon2)
189
+ # gl = GeodesicLineSolve(self, lat1, lon1, r.azi1, **_name1__(caps_name, _or_nameof=self))
190
+ # gl._a13 = r.a12 # gl.SetArc(r.a12)
191
+ # gl._s13 = r.s12 # gl.SetDistance(r.s12)
192
+ # return gl, r
193
+
206
194
  def InverseLine(self, lat1, lon1, lat2, lon2, **caps_name): # PYCHOK no cover
207
195
  '''Set up a L{GeodesicLineSolve} to compute several points
208
196
  on a single geodesic.
@@ -231,7 +219,7 @@ class GeodesicSolve(_GeodesicSolveBase):
231
219
  return gl
232
220
 
233
221
 
234
- class GeodesicLineSolve(_GeodesicSolveBase, _SolveLineBase):
222
+ class GeodesicLineSolve(_GeodesicSolveBase, _SolveGDictLineBase):
235
223
  '''Wrapper to invoke I{Karney}'s U{GeodSolve<https://GeographicLib.SourceForge.io/C++/doc/GeodSolve.1.html>}
236
224
  as an C{Exact} version of I{Karney}'s Python class U{GeodesicLine<https://GeographicLib.SourceForge.io/C++/doc/
237
225
  python/code.html#geographiclib.geodesicline.GeodesicLine>}.
@@ -269,7 +257,7 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveLineBase):
269
257
  _xinstanceof(GeodesicSolve, geodesic=geodesic)
270
258
  if (caps & Caps.LINE_OFF): # copy to avoid updates
271
259
  geodesic = geodesic.copy(deep=False, name=_UNDER_(NN, geodesic.name)) # NOT _under!
272
- _SolveLineBase.__init__(self, geodesic, lat1, lon1, caps, azi1=azi1, **name)
260
+ _SolveGDictLineBase.__init__(self, geodesic, lat1, lon1, caps, azi1=azi1, **name)
273
261
  try:
274
262
  self.GeodSolve = geodesic.GeodSolve # geodesic or copy of geodesic
275
263
  except GeodesicError:
@@ -299,7 +287,7 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveLineBase):
299
287
  @return: A C{GDict} with 12 items C{lat1, lon1, azi1, lat2, lon2,
300
288
  azi2, m12, a12, s12, M12, M21, S12}.
301
289
  '''
302
- return self._GDictInvoke(self._cmdArc, True, self._Names_Direct, a12)._unCaps(outmask)
290
+ return self._GDictInvoke(self._cmdArc, self._Names_Direct, a12)._unCaps(outmask)
303
291
 
304
292
  @Property_RO
305
293
  def azi1(self):
@@ -350,7 +338,7 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveLineBase):
350
338
  @return: A C{GDict} with 12 items C{lat1, lon1, azi1, lat2, lon2,
351
339
  azi2, m12, a12, s12, M12, M21, S12}, possibly C{a12=NAN}.
352
340
  '''
353
- return self._GDictInvoke(self._cmdDistance, True, self._Names_Direct, s12)._unCaps(outmask)
341
+ return self._GDictInvoke(self._cmdDistance, self._Names_Direct, s12)._unCaps(outmask)
354
342
 
355
343
  @Property_RO
356
344
  def s13(self):
@@ -392,16 +380,16 @@ class GeodesicLineSolve(_GeodesicSolveBase, _SolveLineBase):
392
380
  def toStr(self, **prec_sep): # PYCHOK signature
393
381
  '''Return this C{GeodesicLineSolve} as string.
394
382
 
395
- @kwarg prec_sep: Keyword argumens C{B{prec}=6} and C{B{sep}=', '}
396
- for the C{float} C{prec}ision, number of decimal digits
397
- (0..9) and the C{sep}arator string to join. Trailing
398
- zero decimals are stripped for B{C{prec}} values of
399
- 1 and above, but kept for negative B{C{prec}} values.
383
+ @kwarg prec_sep: Keyword argumens C{B{prec}=6} and C{B{sep}=", "}
384
+ for the C{float} C{prec}ision, number of decimal digits
385
+ (0..9) and the C{sep}arator string to join. Trailing
386
+ zero decimals are stripped for B{C{prec}} values of 1
387
+ and above, but kept for negative B{C{prec}} values.
400
388
 
401
389
  @return: GeodesicLineSolve items (C{str}).
402
390
  '''
403
- return _SolveLineBase._toStr(self, azi1=self.azi1, geodesic=self._solve,
404
- GeodSolve=self.GeodSolve, **prec_sep)
391
+ return _SolveGDictLineBase._toStr(self, azi1=self.azi1, geodesic=self._solve,
392
+ GeodSolve=self.GeodSolve, **prec_sep)
405
393
 
406
394
 
407
395
  __all__ += _ALL_DOCS(_GeodesicSolveBase)
@@ -415,7 +403,7 @@ if __name__ == '__main__':
415
403
  gS.verbose = '--verbose' in argv # or '-v' in argv
416
404
 
417
405
  if gS.GeodSolve in (_PYGEODESY_GEODSOLVE_, None): # not set
418
- gS.GeodSolve = '/opt/local/bin/GeodSolve' # '/opt/local/Cellar/geographiclib/1.51/bin/GeodSolve' # HomeBrew
406
+ gS.GeodSolve = '/opt/local/bin/GeodSolve' # '/opt/local/Cellar/geographiclib/2.3/bin/GeodSolve' # HomeBrew
419
407
  printf('version: %s', gS.version)
420
408
 
421
409
  r = gS.Direct(40.6, -73.8, 51, 5.5e6)
pygeodesy/geoids.py CHANGED
@@ -93,15 +93,14 @@ from pygeodesy.fmath import favg, Fdot, fdot, Fhorner, frange
93
93
  from pygeodesy.heights import _as_llis2, _ascalar, _height_called, HeightError, \
94
94
  _HeightsBase, _ellipsoidal_datum, _Wrap
95
95
  # from pygeodesy.internals import _version2 # _MODS
96
- from pygeodesy.interns import MISSING, NN, _4_, _COLONSPACE_, _COMMASPACE_, \
97
- _cubic_, _E_, _height_, _in_, _kind_, _lat_, \
98
- _linear_, _lon_, _mean_, _N_, _n_a_, _numpy_, \
99
- _on_, _outside_, _S_, _s_, _scipy_, _SPACE_, \
100
- _stdev_, _tbd_, _W_, _width_
96
+ from pygeodesy.interns import MISSING, NN, _4_, _COLONSPACE_, _COMMASPACE_, _cubic_, \
97
+ _E_, _height_, _in_, _kind_, _lat_, _linear_, _lon_, \
98
+ _mean_, _N_, _n_a_, _numpy_, _on_, _outside_, _S_, _s_, \
99
+ _scipy_, _SPACE_, _stdev_, _tbd_, _W_, _width_
101
100
  from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS, _FOR_DOCS
102
101
  from pygeodesy.named import _name__, _Named, _NamedTuple
103
102
  # from pygeodesy.namedTuples import LatLon3Tuple # _MODS
104
- from pygeodesy.props import deprecated_method, Property_RO, property_RO
103
+ from pygeodesy.props import deprecated_method, Property_RO, property_RO, property_ROver
105
104
  from pygeodesy.streprs import attrs, Fmt, fstr, pairs
106
105
  from pygeodesy.units import Height, Int_, Lat, Lon
107
106
  # from pygeodesy.utily import _Wrap # from .heights
@@ -118,7 +117,7 @@ except ImportError: # Python 3+
118
117
  from io import BytesIO as _BytesIO # PYCHOK expected
119
118
 
120
119
  __all__ = _ALL_LAZY.geoids
121
- __version__ = '24.06.11'
120
+ __version__ = '24.07.12'
122
121
 
123
122
  _assert_ = 'assert'
124
123
  _bHASH_ = b'#'
@@ -473,12 +472,11 @@ class _GeoidBase(_HeightsBase):
473
472
  '''(INTERNAL) I{Must be overloaded}.'''
474
473
  self._notOverloaded(lat, lon)
475
474
 
476
- @property_RO
475
+ @property_ROver
477
476
  def _LL3T(self):
478
477
  '''(INTERNAL) Get L{LatLon3Tuple}, I{once}.
479
478
  '''
480
- _GeoidBase._LL3T = T = _MODS.namedTuples.LatLon3Tuple # overwrite poperty_RO
481
- return T
479
+ return _MODS.namedTuples.LatLon3Tuple # overwrite property_ROver
482
480
 
483
481
  def _llh3(self, lat, lon):
484
482
  return self._LL3T(lat, lon, self._hGeoid(lat, lon), name=self.name)
pygeodesy/internals.py CHANGED
@@ -4,9 +4,9 @@ u'''Mostly INTERNAL functions, except L{machine}, L{print_} and L{printf}.
4
4
  '''
5
5
  # from pygeodesy.basics import isiterablen # _MODS
6
6
  # from pygeodesy.errors import _AttributeError, _error_init, _UnexpectedError, _xError2 # _MODS
7
- from pygeodesy.interns import NN, _COLON_, _DOT_, _ELLIPSIS_, _EQUALSPACED_, \
8
- _immutable_, _NL_, _pygeodesy_, _PyPy__, _python_, \
9
- _QUOTE1_, _QUOTE2_, _s_, _SPACE_, _sys, _UNDER_, _utf_8_
7
+ from pygeodesy.interns import NN, _BAR_, _COLON_, _DASH_, _DOT_, _ELLIPSIS_, _EQUALSPACED_, \
8
+ _immutable_, _NL_, _pygeodesy_, _PyPy__, _python_, _QUOTE1_, \
9
+ _QUOTE2_, _s_, _SPACE_, _sys, _UNDER_, _utf_8_
10
10
  from pygeodesy.interns import _COMMA_, _Python_ # PYCHOK used!
11
11
  # from pygeodesy.streprs import anstr, pairs, unstr # _MODS
12
12
 
@@ -360,10 +360,10 @@ def _passargs(*args):
360
360
  return args
361
361
 
362
362
 
363
- def _plural(noun, n):
363
+ def _plural(noun, n, nn=NN):
364
364
  '''(INTERNAL) Return C{noun}['s'] or C{NN}.
365
365
  '''
366
- return NN(noun, _s_) if n > 1 else (noun if n else NN)
366
+ return NN(noun, _s_) if n > 1 else (noun if n else nn)
367
367
 
368
368
 
369
369
  def print_(*args, **nl_nt_prec_prefix__end_file_flush_sep__kwds): # PYCHOK no cover
@@ -504,17 +504,44 @@ def _under(name): # PYCHOK in .datums, .auxilats, .ups, .utm, .utmupsBase, ...
504
504
  return name if name.startswith(_UNDER_) else NN(_UNDER_, name)
505
505
 
506
506
 
507
- def _usage(file_py, *args): # in .etm
507
+ def _usage(file_py, *args, **opts_help): # in .etm, .geodesici
508
508
  '''(INTERNAL) Build "usage: python -m ..." cmd line for module B{C{file_py}}.
509
509
  '''
510
- m = _os_path.dirname(file_py).replace(_os.getcwd(), _ELLIPSIS_) \
511
- .replace(_os.sep, _DOT_).strip()
512
- b, x = _os_path.splitext(_os_path.basename(file_py))
510
+ if opts_help:
511
+
512
+ def _help(alts=(), help=NN, **unused):
513
+ if alts and help:
514
+ h = NN(help, _SPACE_).lstrip(_DASH_)
515
+ for a in alts:
516
+ if a.startswith(h):
517
+ return NN(_DASH_, a),
518
+
519
+ def _opts(opts=NN, alts=(), **unused):
520
+ # opts='T--v-C-R meter-c|i|n|o'
521
+ d, fmt = NN, _MODS.streprs.Fmt.SQUARE
522
+ for o in (opts + _BAR_(*alts)).split(_DASH_):
523
+ if o:
524
+ yield fmt(NN(d, _DASH_, o.replace(_BAR_, ' | -')))
525
+ d = NN
526
+ else:
527
+ d = _DASH_
528
+
529
+ args = _help(**opts_help) or (tuple(_opts(**opts_help)) + args)
530
+
531
+ u = _COLON_(_dunder_nameof(_usage)[1:], NN)
532
+ return _SPACE_(u, *_usage_argv(file_py, *args))
533
+
534
+
535
+ def _usage_argv(argv0, *args):
536
+ '''(INTERNAL) Return 3-tuple C{(python, '-m', module, *args)}.
537
+ '''
538
+ m = _os_path.dirname(argv0).replace(_os.getcwd(), _ELLIPSIS_) \
539
+ .replace(_os.sep, _DOT_).strip()
540
+ b, x = _os_path.splitext(_os_path.basename(argv0))
513
541
  if x == '.py' and not _dunder_ismain(b):
514
542
  m = _DOT_(m or _pygeodesy_, b)
515
- p = NN(_python_, _sys.version_info[0])
516
- u = _COLON_(_dunder_nameof(_usage)[1:], NN)
517
- return _SPACE_(u, p, '-m', _enquote(m), *args)
543
+ p = NN(_python_, _sys.version_info[0])
544
+ return (p, '-m', _enquote(m)) + args
518
545
 
519
546
 
520
547
  def _version2(version, n=2):
@@ -550,7 +577,7 @@ def _version_ints(vs):
550
577
 
551
578
 
552
579
  __all__ = tuple(map(_dunder_nameof, (machine, print_, printf)))
553
- __version__ = '24.06.05'
580
+ __version__ = '24.07.04'
554
581
 
555
582
  if _dunder_ismain(__name__): # PYCHOK no cover
556
583