Coverage for pygeodesy/deprecated/classes.py: 93%

74 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2024-02-25 12:57 -0500

1 

2# -*- coding: utf-8 -*- 

3 

4u'''DEPRECATED classes kept for backward compatibility. 

5''' 

6 

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 

23 

24__all__ = _ALL_DEPRECATED.deprecated_classes 

25__version__ = '24.02.02' 

26 

27 

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) 

34 

35 

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:] 

40 

41 

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] 

47 

48 

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_ 

53 

54 

55def EcefCartesian(*args, **kwds): 

56 '''DEPRECATED, use class L{LocalCartesian}.''' 

57 Ltp = _MODS.ltp.Ltp 

58 

59 class EcefCartesian_(Ltp): 

60 '''DEPRECATED, use class L{LocalCartesian} or L{Ltp}. 

61 

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) 

69 

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}. 

73 

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) 

83 

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}. 

87 

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) 

97 

98 return EcefCartesian_(*args, **kwds) 

99 

100 

101def HeightIDW(knots, **kwds): # PYCHOK no cover 

102 '''DEPRECATED, use class L{HeightIDWeuclidean}.''' 

103 HeightIDWeuclidean = _MODS.heights.HeightIDWeuclidean 

104 

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) 

110 

111 return HeightIDW(knots, **kwds) 

112 

113 

114def HeightIDW2(knots, **kwds): # PYCHOK no cover 

115 '''DEPRECATED, use class L{HeightIDWequirectangular}.''' 

116 HeightIDWequirectangular = _MODS.heights.HeightIDWequirectangular 

117 

118 class HeightIDW2(HeightIDWequirectangular): 

119 '''DEPRECATED, use class L{HeightIDWequirectangular}.''' 

120 def __init__(self, knots, adjust=True, wrap=False, name=NN): 

121 deprecated_class(self.__class__) 

122 HeightIDWequirectangular.__init__(self, knots, adjust=adjust, wrap=wrap, name=name) 

123 

124 return HeightIDW2(knots, **kwds) 

125 

126 

127def HeightIDW3(knots, **kwds): # PYCHOK no cover 

128 '''DEPRECATED, use class L{HeightIDWhaversine}.''' 

129 HeightIDWhaversine = _MODS.heights.HeightIDWhaversine 

130 

131 class HeightIDW3(HeightIDWhaversine): 

132 '''DEPRECATED, use class L{HeightIDWhaversine}. 

133 ''' 

134 def __init__(self, knots, beta=2, wrap=False, name=NN): 

135 deprecated_class(self.__class__) 

136 HeightIDWhaversine.__init__(self, knots, beta=beta, wrap=wrap, name=name) 

137 

138 return HeightIDW3(knots, **kwds) 

139 

140 

141class LatLonExact4Tuple(_Deprecated_NamedTuple): 

142 '''DEPRECATED, use class L{Reverse4Tuple}, item C{gamma} for C{convergence}.''' 

143 _Names_ = _reNames(_Reverse4Tuple._Names_, _gamma_, _convergence_) 

144 _Units_ = _Reverse4Tuple._Units_ 

145 

146 

147class NearestOn4Tuple(_Deprecated_NamedTuple): # PYCHOK no cover 

148 '''DEPRECATED on 2023.10.10, see methods L{RhumbLine.nearestOn4} and L{RhumbLineAux.nearestOn4}.''' 

149 _Names_ = (_lat_, _lon_, _distance_, 'normal') # s12, azi02 

150 _Units_ = ( Lat, Lon, Meter, Bearing) 

151 

152 

153class Ned3Tuple(_Deprecated_NamedTuple): # was in .ellipsoidalNvector 

154 '''DEPRECATED, use class L{Ned4Tuple}, ignoring item C{ltp}.''' 

155 assert _Ned4Tuple._Names_.index(_ltp_) == 3 

156 _Names_ = _Ned4Tuple._Names_[:3] 

157 _Units_ = _Ned4Tuple._Units_[:3] 

158 

159 

160def RefFrameError(*args, **kwds): # PYCHOK no cover 

161 '''DEPRECATED, use class L{TRFError}.''' 

162 TRFError = _MODS.errors.TRFError 

163 

164 class RefFrameError(TRFError): 

165 '''DEPRECATED, use class L{TRFError}. 

166 ''' 

167 def __init__(self, *name_value, **txt_name_values): 

168 deprecated_class(self.__class__) 

169 TRFError.__init__(self, *name_value, **txt_name_values) 

170 

171 return RefFrameError(*args, **kwds) 

172 

173 

174class Rhumb7Tuple(_Deprecated_NamedTuple): 

175 '''DEPRECATED, use class L{Rhumb8Tuple}, ignoring item C{a12}.''' 

176 assert _Rhumb8Tuple._Names_.index(_a12_) == 7 

177 _Names_ = _Rhumb8Tuple._Names_[:7] 

178 _Units_ = _Rhumb8Tuple._Units_[:7] 

179 

180 @deprecated_method 

181 def toDirect9Tuple(self, **kwds): 

182 return self.toRhumb8Tuple().toDirect9Tuple(self, **kwds) 

183 

184 @deprecated_method 

185 def toGDict(self, **kwds): 

186 return self.toRhumb8Tuple().toGDict(**kwds) 

187 

188 @deprecated_method 

189 def toInverse10Tuple(self, **kwds): 

190 return self.toRhumb8Tuple().toInverse10Tuple(self, **kwds) 

191 

192 @deprecated_method 

193 def toRhumb8Tuple(self, dflt=NAN): 

194 return _Rhumb8Tuple(self + (dflt,), name=self.name) 

195 

196 def _to7Tuple(self): 

197 '''(INTERNAL) see L{Rhumb8Tuple._to7Tuple}. 

198 ''' 

199 return self 

200 

201 

202class RhumbOrder2Tuple(_Deprecated_NamedTuple, _GTuple): 

203 '''DEPRECATED, see deprecated method L{Rhumb.orders}.''' 

204 # 2-Tuple C{(RAorder, TMorder)} with a I{Rhumb Area} and 

205 # I{Transverse Mercator} order, both C{int}. 

206 _Names_ = ('RAorder', 'TMorder') 

207 _Units_ = ( Int, Int) 

208 

209 

210class Transform7Tuple(_Deprecated_NamedTuple): # PYCHOK no cover 

211 '''DEPRECATED on 2024.02.02, use class L{TRFXform7Tuple}, I{without} keyword arguments.''' 

212 _Names_ = _TRFXform7Tuple._Names_ 

213 _Units_ = _TRFXform7Tuple._Units_ 

214 

215 def __new__(cls, tx=0, ty=0, tz=0, s=0, 

216 sx=0, sy=0, sz=0, name=NN): 

217 t = map(_float, (tx, ty, tz, s, sx, sy, sz)) 

218 return _Deprecated_NamedTuple.__new__(cls, *t, name=name) 

219 

220Helmert7Tuple = Transform7Tuple # PYCHOK likewise 

221 

222 

223class TriAngle4Tuple(_Deprecated_NamedTuple): 

224 '''DEPRECATED on 2023.09.14, use class L{TriAngle5Tuple}, ignoring item C{area}.''' 

225 assert _TriAngle5Tuple._Names_.index(_area_) == 4 

226 _Names_ = _TriAngle5Tuple._Names_[:4] 

227 _Units_ = _TriAngle5Tuple._Units_[:4] 

228 

229 

230class UtmUps4Tuple(_Deprecated_NamedTuple): # PYCHOK no cover 

231 '''DEPRECATED and OBSOLETE, expect a L{UtmUps5Tuple} from method C{pygeodesy.Mgrs.toUtm(utm=None)}. 

232 

233 4-Tuple C{(zone, hemipole, easting, northing)} with as C{zone} B{C{str}} and no C{band}. 

234 ''' 

235 assert _UtmUps5Tuple._Names_.index(_band_) == 4 

236 _Names_ = _UtmUps5Tuple._Names_[ :4] # band 

237 _Units_ = (_Deprecated_Str,) + _UtmUps5Tuple._Units_[1:4] 

238 

239 

240__all__ += _ALL_DOCS(_Deprecated_NamedTuple) 

241 

242# **) MIT License 

243# 

244# Copyright (C) 2018-2024 -- mrJean1 at Gmail -- All Rights Reserved. 

245# 

246# Permission is hereby granted, free of charge, to any person obtaining a 

247# copy of this software and associated documentation files (the "Software"), 

248# to deal in the Software without restriction, including without limitation 

249# the rights to use, copy, modify, merge, publish, distribute, sublicense, 

250# and/or sell copies of the Software, and to permit persons to whom the 

251# Software is furnished to do so, subject to the following conditions: 

252# 

253# The above copyright notice and this permission notice shall be included 

254# in all copies or substantial portions of the Software. 

255# 

256# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 

257# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

258# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 

259# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 

260# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 

261# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 

262# OTHER DEALINGS IN THE SOFTWARE.