Coverage for pygeodesy/deprecated/classes.py: 93%
74 statements
« prev ^ index » next coverage.py v7.2.2, created at 2024-05-02 14:35 -0400
« prev ^ index » next coverage.py v7.2.2, created at 2024-05-02 14:35 -0400
2# -*- coding: utf-8 -*-
4u'''DEPRECATED classes kept for 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 _distance_, _gamma_, _i_, _lat_, _lon_, _ltp_
11from pygeodesy.deprecated.consterns import _Deprecated_Str
12from pygeodesy.karney import _GTuple, Rhumb8Tuple as _Rhumb8Tuple
13from pygeodesy.lazily import _ALL_DEPRECATED, _ALL_DOCS, _ALL_MODS as _MODS
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 TRFXform7Tuple as _TRFXform7Tuple
22from pygeodesy.units import Bearing, Int, Lat, Lon, Meter
24__all__ = _ALL_DEPRECATED.deprecated_classes
25__version__ = '24.04.17'
28class _Deprecated_NamedTuple(_NamedTuple):
29 '''DEPRECATED, C{_NamedTuple} base.
30 '''
31 def __new__(cls, *args, **kwds):
32 deprecated_class(cls)
33 return _NamedTuple.__new__(cls, *args, **kwds)
36def _reNames(names, old, *new):
37 # replace item C{old} with C{new} name
38 i = names.index(old)
39 return names[:i] + new + names[i + 1:]
42class ClipCS3Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
43 '''DEPRECATED, see I{DEPRECATED} function L{pygeodesy.deprecated.clipCS3}.'''
44 assert _ClipCS4Tuple._Names_.index(_i_) == 2
45 _Names_ = _reNames(_ClipCS4Tuple._Names_[:3], _i_, 'index')
46 _Units_ = _ClipCS4Tuple._Units_[:3]
49class EasNorExact4Tuple(_Deprecated_NamedTuple):
50 '''DEPRECATED, use class L{Forward4Tuple}, item C{gamma} for C{convergence}.'''
51 _Names_ = _reNames(_Forward4Tuple._Names_, _gamma_, _convergence_)
52 _Units_ = _Forward4Tuple._Units_
55def EcefCartesian(*args, **kwds):
56 '''DEPRECATED, use class L{LocalCartesian}.'''
57 Ltp = _MODS.ltp.Ltp
59 class EcefCartesian_(Ltp):
60 '''DEPRECATED, use class L{LocalCartesian} or L{Ltp}.
62 @note: This class is named I{incorrectly}, since it provides conversion to
63 and from I{local} cartesian coordinates in a I{local tangent plane}
64 and I{not geocentric} (ECEF) ones, as the name would suggest.
65 '''
66 def __init__(self, latlonh0=0, lon0=0, height0=0, ecef=None, name=NN):
67 deprecated_class(self.__class__)
68 Ltp.__init__(self, latlonh0=latlonh0, lon0=lon0, height0=height0, ecef=ecef, name=name)
70 @deprecated_method
71 def forward(self, latlonh, lon=None, height=0, M=False, name=NN):
72 '''DEPRECATED, use method L{LocalCartesian.forward} or L{Ltp.forward}.
74 @return: I{Incorrectly}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C,
75 M, datum)} with I{local} C{(x, y, z)} coordinates for the given
76 I{geodetic} ones C{(lat, lon, height)}, case C{C=0} always,
77 optionally I{concatenated} L{EcefMatrix} C{M} and C{datum}.
78 '''
79 t = Ltp.forward(self, latlonh, lon=lon, height=height, M=M, name=name)
80 return _MODS.ecef.Ecef9Tuple(t.x, t.y, t.z, t.lat, t.lon, t.height,
81 0, t.M, t.ecef.datum,
82 name=t.name or self.name)
84 @deprecated_method
85 def reverse(self, xyz, y=None, z=None, M=False, name=NN):
86 '''DEPRECATED, use method L{LocalCartesian.reverse} or L{Ltp.reverse}.
88 @return: I{Incorrectly}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C,
89 M, datum)} with I{geodetic} coordinates C{(lat, lon, height)} for
90 the given I{local} ones C{(x, y, z)}, case C{C}, optionally
91 I{concatenated} L{EcefMatrix} C{M} and C{datum}.
92 '''
93 t = Ltp.reverse(self, xyz, y=y, z=z, M=M, name=name)
94 return _MODS.ecef.Ecef9Tuple(t.x, t.y, t.z, t.lat, t.lon, t.height,
95 t.ecef.C, t.M, t.ecef.datum,
96 name=t.name or self.name)
98 return EcefCartesian_(*args, **kwds)
101def Fn_rt(root, *xs, **name_RESIDUAL_raiser): # PYCHOK no cover
102 '''DEPRECATED on 2024.04.17, use class L{Froot}.
103 '''
104 Froot = _MODS.fmath.Froot
106 class Fn_rt(Froot): # PYCHOK no cover
107 '''DEPRECATED on 2024.04.17, use class L{Froot}.
108 '''
109 def __init__(self, root, *xs, **name_RESIDUAL_raiser):
110 deprecated_class(self.__class__)
111 Froot.__init__(self, root, *xs, **name_RESIDUAL_raiser)
114def HeightIDW(knots, **kwds): # PYCHOK no cover
115 '''DEPRECATED, use class L{HeightIDWeuclidean}.'''
116 HeightIDWeuclidean = _MODS.heights.HeightIDWeuclidean
118 class HeightIDW(HeightIDWeuclidean):
119 '''DEPRECATED, use class L{HeightIDWeuclidean}.'''
120 def __init__(self, knots, adjust=True, beta=2, name=NN):
121 deprecated_class(self.__class__)
122 HeightIDWeuclidean.__init__(self, knots, adjust=adjust, beta=beta, name=name)
124 return HeightIDW(knots, **kwds)
127def HeightIDW2(knots, **kwds): # PYCHOK no cover
128 '''DEPRECATED, use class L{HeightIDWequirectangular}.'''
129 HeightIDWequirectangular = _MODS.heights.HeightIDWequirectangular
131 class HeightIDW2(HeightIDWequirectangular):
132 '''DEPRECATED, use class L{HeightIDWequirectangular}.'''
133 def __init__(self, knots, adjust=True, wrap=False, name=NN):
134 deprecated_class(self.__class__)
135 HeightIDWequirectangular.__init__(self, knots, adjust=adjust, wrap=wrap, name=name)
137 return HeightIDW2(knots, **kwds)
140def HeightIDW3(knots, **kwds): # PYCHOK no cover
141 '''DEPRECATED, use class L{HeightIDWhaversine}.'''
142 HeightIDWhaversine = _MODS.heights.HeightIDWhaversine
144 class HeightIDW3(HeightIDWhaversine):
145 '''DEPRECATED, use class L{HeightIDWhaversine}.
146 '''
147 def __init__(self, knots, beta=2, wrap=False, name=NN):
148 deprecated_class(self.__class__)
149 HeightIDWhaversine.__init__(self, knots, beta=beta, wrap=wrap, name=name)
151 return HeightIDW3(knots, **kwds)
154class LatLonExact4Tuple(_Deprecated_NamedTuple):
155 '''DEPRECATED, use class L{Reverse4Tuple}, item C{gamma} for C{convergence}.'''
156 _Names_ = _reNames(_Reverse4Tuple._Names_, _gamma_, _convergence_)
157 _Units_ = _Reverse4Tuple._Units_
160class NearestOn4Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
161 '''DEPRECATED on 2023.10.10, see methods L{RhumbLine.nearestOn4} and L{RhumbLineAux.nearestOn4}.'''
162 _Names_ = (_lat_, _lon_, _distance_, 'normal') # s12, azi02
163 _Units_ = ( Lat, Lon, Meter, Bearing)
166class Ned3Tuple(_Deprecated_NamedTuple): # was in .ellipsoidalNvector
167 '''DEPRECATED, use class L{Ned4Tuple}, ignoring item C{ltp}.'''
168 assert _Ned4Tuple._Names_.index(_ltp_) == 3
169 _Names_ = _Ned4Tuple._Names_[:3]
170 _Units_ = _Ned4Tuple._Units_[:3]
173def RefFrameError(*args, **kwds): # PYCHOK no cover
174 '''DEPRECATED, use class L{TRFError}.'''
175 TRFError = _MODS.errors.TRFError
177 class RefFrameError(TRFError):
178 '''DEPRECATED, use class L{TRFError}.
179 '''
180 def __init__(self, *name_value, **txt_name_values):
181 deprecated_class(self.__class__)
182 TRFError.__init__(self, *name_value, **txt_name_values)
184 return RefFrameError(*args, **kwds)
187class Rhumb7Tuple(_Deprecated_NamedTuple):
188 '''DEPRECATED, use class L{Rhumb8Tuple}, ignoring item C{a12}.'''
189 assert _Rhumb8Tuple._Names_.index(_a12_) == 7
190 _Names_ = _Rhumb8Tuple._Names_[:7]
191 _Units_ = _Rhumb8Tuple._Units_[:7]
193 @deprecated_method
194 def toDirect9Tuple(self, **kwds):
195 return self.toRhumb8Tuple().toDirect9Tuple(self, **kwds)
197 @deprecated_method
198 def toGDict(self, **kwds):
199 return self.toRhumb8Tuple().toGDict(**kwds)
201 @deprecated_method
202 def toInverse10Tuple(self, **kwds):
203 return self.toRhumb8Tuple().toInverse10Tuple(self, **kwds)
205 @deprecated_method
206 def toRhumb8Tuple(self, dflt=NAN):
207 return _Rhumb8Tuple(self + (dflt,), name=self.name)
209 def _to7Tuple(self):
210 '''(INTERNAL) see L{Rhumb8Tuple._to7Tuple}.
211 '''
212 return self
215class RhumbOrder2Tuple(_Deprecated_NamedTuple, _GTuple):
216 '''DEPRECATED, see deprecated method L{Rhumb.orders}.'''
217 # 2-Tuple C{(RAorder, TMorder)} with a I{Rhumb Area} and
218 # I{Transverse Mercator} order, both C{int}.
219 _Names_ = ('RAorder', 'TMorder')
220 _Units_ = ( Int, Int)
223class Transform7Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
224 '''DEPRECATED on 2024.02.02, use class L{TRFXform7Tuple}, I{without} keyword arguments.'''
225 _Names_ = _TRFXform7Tuple._Names_
226 _Units_ = _TRFXform7Tuple._Units_
228 def __new__(cls, tx=0, ty=0, tz=0, s=0,
229 sx=0, sy=0, sz=0, name=NN):
230 t = map(_float, (tx, ty, tz, s, sx, sy, sz))
231 return _Deprecated_NamedTuple.__new__(cls, *t, name=name)
233Helmert7Tuple = Transform7Tuple # PYCHOK likewise
236class TriAngle4Tuple(_Deprecated_NamedTuple):
237 '''DEPRECATED on 2023.09.14, use class L{TriAngle5Tuple}, ignoring item C{area}.'''
238 assert _TriAngle5Tuple._Names_.index(_area_) == 4
239 _Names_ = _TriAngle5Tuple._Names_[:4]
240 _Units_ = _TriAngle5Tuple._Units_[:4]
243class UtmUps4Tuple(_Deprecated_NamedTuple): # PYCHOK no cover
244 '''DEPRECATED and OBSOLETE, expect a L{UtmUps5Tuple} from method C{pygeodesy.Mgrs.toUtm(utm=None)}.
246 4-Tuple C{(zone, hemipole, easting, northing)} with as C{zone} B{C{str}} and no C{band}.
247 '''
248 assert _UtmUps5Tuple._Names_.index(_band_) == 4
249 _Names_ = _UtmUps5Tuple._Names_[ :4] # band
250 _Units_ = (_Deprecated_Str,) + _UtmUps5Tuple._Units_[1:4]
253__all__ += _ALL_DOCS(_Deprecated_NamedTuple)
255# **) MIT License
256#
257# Copyright (C) 2018-2024 -- mrJean1 at Gmail -- All Rights Reserved.
258#
259# Permission is hereby granted, free of charge, to any person obtaining a
260# copy of this software and associated documentation files (the "Software"),
261# to deal in the Software without restriction, including without limitation
262# the rights to use, copy, modify, merge, publish, distribute, sublicense,
263# and/or sell copies of the Software, and to permit persons to whom the
264# Software is furnished to do so, subject to the following conditions:
265#
266# The above copyright notice and this permission notice shall be included
267# in all copies or substantial portions of the Software.
268#
269# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
270# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
271# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
272# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
273# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
274# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
275# OTHER DEALINGS IN THE SOFTWARE.