Coverage for pygeodesy/deprecated/classes.py: 93%
70 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-09-15 09:43 -0400
« prev ^ index » next coverage.py v7.2.2, created at 2023-09-15 09:43 -0400
2# -*- coding: utf-8 -*-
4u'''DEPRECATED classes for export and backward compatibility.
5'''
7from pygeodesy.clipy import ClipCS4Tuple as _ClipCS4Tuple
8from pygeodesy.constants import NAN, _float
9from pygeodesy.interns import NN, _a12_, _area_, _band_, _convergence_, \
10 _gamma_, _i_, _ltp_
11from pygeodesy.deprecated.consterns import _Deprecated_Str
12from pygeodesy.karney import Rhumb8Tuple as _Rhumb8Tuple
13from pygeodesy.lazily import _ALL_MODS as _MODS, _ALL_OTHER
14from pygeodesy.ltpTuples import Ned4Tuple as _Ned4Tuple
15# from pygeodesy.named import _NamedTuple # from .namedTuples
16from pygeodesy.namedTuples import Forward4Tuple as _Forward4Tuple, \
17 Reverse4Tuple as _Reverse4Tuple, \
18 UtmUps5Tuple as _UtmUps5Tuple, _NamedTuple
19from pygeodesy.props import deprecated_class, deprecated_method
20from pygeodesy.resections import TriAngle5Tuple as _TriAngle5Tuple
21from pygeodesy.trf import Helmert7Tuple as _Helmert7Tuple
23__all__ = ()
24__version__ = '23.09.12'
27class _Deprecated_NamedTuple(_NamedTuple):
28 '''DEPRECATED, C{_NamedTuple} base.
29 '''
30 def __new__(cls, *args, **kwds):
31 deprecated_class(cls)
32 return _NamedTuple.__new__(cls, *args, **kwds)
35def _reNames(names, old, *new):
36 # replace item C{old} with C{new} name
37 i = names.index(old)
38 return names[:i] + new + names[i + 1:]
41class ClipCS3Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
42 '''DEPRECATED, see I{DEPRECATED} function L{pygeodesy.clipCS3}.'''
43 assert _ClipCS4Tuple._Names_.index(_i_) == 2
44 _Names_ = _reNames(_ClipCS4Tuple._Names_[:3], _i_, 'index')
45 _Units_ = _ClipCS4Tuple._Units_[:3]
48class EasNorExact4Tuple(_Deprecated_NamedTuple):
49 '''DEPRECATED, use class L{Forward4Tuple}, item C{gamma} for C{convergence}.'''
50 _Names_ = _reNames(_Forward4Tuple._Names_, _gamma_, _convergence_)
51 _Units_ = _Forward4Tuple._Units_
54def EcefCartesian(*args, **kwds):
55 '''DEPRECATED, use class L{LocalCartesian}.'''
56 Ltp = _MODS.ltp.Ltp
58 class EcefCartesian_(Ltp):
59 '''DEPRECATED, use class L{LocalCartesian} or L{Ltp}.
61 @note: This class is named I{incorrectly}, since it provides conversion to
62 and from I{local} cartesian coordinates in a I{local tangent plane}
63 and I{not geocentric} (ECEF) ones, as the name would suggest.
64 '''
65 def __init__(self, latlonh0=0, lon0=0, height0=0, ecef=None, name=NN):
66 deprecated_class(self.__class__)
67 Ltp.__init__(self, latlonh0=latlonh0, lon0=lon0, height0=height0, ecef=ecef, name=name)
69 @deprecated_method
70 def forward(self, latlonh, lon=None, height=0, M=False, name=NN):
71 '''DEPRECATED, use method L{LocalCartesian.forward} or L{Ltp.forward}.
73 @return: I{Incorrectly}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C,
74 M, datum)} with I{local} C{(x, y, z)} coordinates for the given
75 I{geodetic} ones C{(lat, lon, height)}, case C{C=0} always,
76 optionally I{concatenated} L{EcefMatrix} C{M} and C{datum}.
77 '''
78 t = Ltp.forward(self, latlonh, lon=lon, height=height, M=M, name=name)
79 return _MODS.ecef.Ecef9Tuple(t.x, t.y, t.z, t.lat, t.lon, t.height,
80 0, t.M, t.ecef.datum,
81 name=t.name or self.name)
83 @deprecated_method
84 def reverse(self, xyz, y=None, z=None, M=False, name=NN):
85 '''DEPRECATED, use method L{LocalCartesian.reverse} or L{Ltp.reverse}.
87 @return: I{Incorrectly}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C,
88 M, datum)} with I{geodetic} coordinates C{(lat, lon, height)} for
89 the given I{local} ones C{(x, y, z)}, case C{C}, optionally
90 I{concatenated} L{EcefMatrix} C{M} and C{datum}.
91 '''
92 t = Ltp.reverse(self, xyz, y=y, z=z, M=M, name=name)
93 return _MODS.ecef.Ecef9Tuple(t.x, t.y, t.z, t.lat, t.lon, t.height,
94 t.ecef.C, t.M, t.ecef.datum,
95 name=t.name or self.name)
97 _MODS.deprecated.EcefCartesian = Ltp
98 return EcefCartesian_(*args, **kwds)
101def HeightIDW(knots, **kwds): # PYCHOK no cover
102 '''DEPRECATED, use class L{HeightIDWeuclidean}.'''
103 HeightIDWeuclidean = _MODS.heights.HeightIDWeuclidean
105 class HeightIDW(HeightIDWeuclidean):
106 '''DEPRECATED, use class L{HeightIDWeuclidean}.'''
107 def __init__(self, knots, adjust=True, beta=2, name=NN):
108 deprecated_class(self.__class__)
109 HeightIDWeuclidean.__init__(self, knots, adjust=adjust, beta=beta, name=name)
111 _MODS.deprecated.HeightIDW = HeightIDW
112 return HeightIDW(knots, **kwds)
115def HeightIDW2(knots, **kwds): # PYCHOK no cover
116 '''DEPRECATED, use class L{HeightIDWequirectangular}.'''
117 HeightIDWequirectangular = _MODS.heights.HeightIDWequirectangular
119 class HeightIDW2(HeightIDWequirectangular):
120 '''DEPRECATED, use class L{HeightIDWequirectangular}.'''
121 def __init__(self, knots, adjust=True, wrap=False, name=NN):
122 deprecated_class(self.__class__)
123 HeightIDWequirectangular.__init__(self, knots, adjust=adjust, wrap=wrap, name=name)
125 _MODS.deprecated.HeightIDW2 = HeightIDW2
126 return HeightIDW2(knots, **kwds)
129def HeightIDW3(knots, **kwds): # PYCHOK no cover
130 '''DEPRECATED, use class L{HeightIDWhaversine}.'''
131 HeightIDWhaversine = _MODS.heights.HeightIDWhaversine
133 class HeightIDW3(HeightIDWhaversine):
134 '''DEPRECATED, use class L{HeightIDWhaversine}.
135 '''
136 def __init__(self, knots, beta=2, wrap=False, name=NN):
137 deprecated_class(self.__class__)
138 HeightIDWhaversine.__init__(self, knots, beta=beta, wrap=wrap, name=name)
140 _MODS.deprecated.HeightIDW3 = HeightIDW3
141 return HeightIDW3(knots, **kwds)
144class LatLonExact4Tuple(_Deprecated_NamedTuple):
145 '''DEPRECATED, used class L{Reverse4Tuple}, item C{gamma} for C{convergence}.'''
146 _Names_ = _reNames(_Reverse4Tuple._Names_, _gamma_, _convergence_)
147 _Units_ = _Reverse4Tuple._Units_
150class Ned3Tuple(_Deprecated_NamedTuple): # was in .ellipsoidalNvector
151 '''DEPRECATED, use class L{Ned4Tuple}, ignoring item C{ltp}.'''
152 assert _Ned4Tuple._Names_.index(_ltp_) == 3
153 _Names_ = _Ned4Tuple._Names_[:3]
154 _Units_ = _Ned4Tuple._Units_[:3]
157def RefFrameError(*args, **kwds): # PYCHOK no cover
158 '''DEPRECATED, use class L{TRFError}.'''
159 TRFError = _MODS.errors.TRFError
161 class RefFrameError(TRFError):
162 '''DEPRECATED, use class L{TRFError}.
163 '''
164 def __init__(self, *name_value, **txt_name_values):
165 deprecated_class(self.__class__)
166 TRFError.__init__(self, *name_value, **txt_name_values)
168 _MODS.deprecated.RefFrameError = RefFrameError
169 return RefFrameError(*args, **kwds)
172class Rhumb7Tuple(_Deprecated_NamedTuple):
173 '''DEPRECATED, use class L{Rhumb8Tuple}, ignoring item C{a12}.'''
174 assert _Rhumb8Tuple._Names_.index(_a12_) == 7
175 _Names_ = _Rhumb8Tuple._Names_[:7]
176 _Units_ = _Rhumb8Tuple._Units_[:7]
178 @deprecated_method
179 def toDirect9Tuple(self, **kwds):
180 return self.toRhumb8Tuple().toDirect9Tuple(self, **kwds)
182 @deprecated_method
183 def toGDict(self, **kwds):
184 return self.toRhumb8Tuple().toGDict(**kwds)
186 @deprecated_method
187 def toInverse10Tuple(self, **kwds):
188 return self.toRhumb8Tuple().toInverse10Tuple(self, **kwds)
190 @deprecated_method
191 def toRhumb8Tuple(self, dflt=NAN):
192 return _Rhumb8Tuple(self + (dflt,), name=self.name)
194 def _to7Tuple(self):
195 '''(INTERNAL) see L{Rhumb8Tuple._to7Tuple}.
196 '''
197 return self
200class Transform7Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
201 '''DEPRECATED, use class L{Helmert7Tuple}, I{without} keyword arguments.'''
202 _Names_ = _Helmert7Tuple._Names_
203 _Units_ = _Helmert7Tuple._Units_
205 def __new__(cls, tx=0, ty=0, tz=0, s=0,
206 sx=0, sy=0, sz=0, name=NN):
207 t = map(_float, (tx, ty, tz, s, sx, sy, sz))
208 return _Deprecated_NamedTuple.__new__(cls, *t, name=name)
211class TriAngle4Tuple(_Deprecated_NamedTuple):
212 '''DEPRECATED, use class L{TriAngle5Tuple}, ignoring item C{area}.'''
213 assert _TriAngle5Tuple._Names_.index(_area_) == 4
214 _Names_ = _TriAngle5Tuple._Names_[:4]
215 _Units_ = _TriAngle5Tuple._Units_[:4]
218class UtmUps4Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
219 '''DEPRECATED and OBSOLETE, expect a L{UtmUps5Tuple} from method C{pygeodesy.Mgrs.toUtm(utm=None)}.
221 4-Tuple C{(zone, hemipole, easting, northing)} with as C{zone} B{C{str}} and no C{band}.
222 '''
223 assert _UtmUps5Tuple._Names_.index(_band_) == 4
224 _Names_ = _UtmUps5Tuple._Names_[ :4] # band
225 _Units_ = (_Deprecated_Str,) + _UtmUps5Tuple._Units_[1:4]
228__all__ += _ALL_OTHER(ClipCS3Tuple, EasNorExact4Tuple, EcefCartesian,
229 HeightIDW, HeightIDW2, HeightIDW3, LatLonExact4Tuple,
230 Ned3Tuple, RefFrameError, Rhumb7Tuple, Transform7Tuple,
231 TriAngle4Tuple, UtmUps4Tuple)
233# **) MIT License
234#
235# Copyright (C) 2018-2023 -- mrJean1 at Gmail -- All Rights Reserved.
236#
237# Permission is hereby granted, free of charge, to any person obtaining a
238# copy of this software and associated documentation files (the "Software"),
239# to deal in the Software without restriction, including without limitation
240# the rights to use, copy, modify, merge, publish, distribute, sublicense,
241# and/or sell copies of the Software, and to permit persons to whom the
242# Software is furnished to do so, subject to the following conditions:
243#
244# The above copyright notice and this permission notice shall be included
245# in all copies or substantial portions of the Software.
246#
247# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
248# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
249# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
250# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
251# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
252# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
253# OTHER DEALINGS IN THE SOFTWARE.