Coverage for pygeodesy/deprecated/functions.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-12 16:17 -0500

1 

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

3 

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

5''' 

6 

7from pygeodesy.constants import EPS, R_M, float0_ 

8from pygeodesy.deprecated.classes import ClipCS3Tuple, TriAngle4Tuple, _TriAngle5Tuple 

9from pygeodesy.interns import NN, _area_, _COMMASPACE_, _negative_, \ 

10 _scalar_, _sep_, _SPACE_, _UNDER_, _value_ 

11from pygeodesy.lazily import _ALL_DEPRECATED, _ALL_MODS as _MODS 

12from pygeodesy.props import deprecated_function 

13# from pygeodesy.resections import TriAngle5Tuple as _TriAngle5Tuple # from .classes 

14from pygeodesy.units import Number_, Scalar_ 

15 

16__all__ = _ALL_DEPRECATED.deprecated_functions 

17__version__ = '24.11.07' 

18 

19_WGS84 = _UTM = object() 

20 

21 

22@deprecated_function 

23def anStr(name, OKd='._-', sub=_UNDER_): # PYCHOK no cover 

24 '''DEPRECATED, use function L{pygeodesy.anstr}.''' 

25 return _MODS.streprs.anstr(name, OKd=OKd, sub=sub) 

26 

27 

28@deprecated_function 

29def areaof(points, adjust=True, radius=R_M, wrap=True): # PYCHOK no cover 

30 '''DEPRECATED, use function L{pygeodesy.areaOf}.''' 

31 return _MODS.points.areaOf(points, adjust=adjust, radius=radius, wrap=wrap) 

32 

33 

34@deprecated_function 

35def atand(x): # PYCHOK no cover 

36 '''DEPRECATED on 2023.09.28, use function L{pygeodesy.atan1d}.''' 

37 return _MODS.utily.atan1d(x) 

38 

39 

40@deprecated_function 

41def bounds(points, wrap=True, LatLon=None): # PYCHOK no cover 

42 '''DEPRECATED, use function L{pygeodesy.boundsOf}. 

43 

44 @return: 2-Tuple C{(latlonSW, latlonNE)}, each a B{C{LatLon}} or 

45 4-Tuple C{(latS, lonW, latN, lonE)} if C{B{LatLon} is None}. 

46 ''' 

47 return tuple(_MODS.points.boundsOf(points, wrap=wrap, LatLon=LatLon)) 

48 

49 

50@deprecated_function 

51def clipCS3(points, lowerleft, upperright, closed=False, inull=False): # PYCHOK no cover 

52 '''DEPRECATED, use function L{pygeodesy.clipCS4}. 

53 

54 @return: Yield a L{ClipCS3Tuple}C{(start, end, index)} for each 

55 edge of the I{clipped} path. 

56 ''' 

57 for p1, p2, _, j in _MODS.clipy.clipCS4(points, lowerleft, upperright, 

58 closed=closed, inull=inull): 

59 yield ClipCS3Tuple(p1, p2, j) 

60 

61 

62@deprecated_function 

63def clipDMS(deg, limit): # PYCHOK no cover 

64 '''DEPRECATED, use function L{pygeodesy.clipDegrees}.''' 

65 return _MODS.dms.clipDegrees(deg, limit) 

66 

67 

68@deprecated_function 

69def clipStr(bstr, limit=50, white=NN): # PYCHOK no cover 

70 '''DEPRECATED, use function L{pygeodesy.clips}.''' 

71 return _MODS.basics.clips(bstr, limit=limit, white=white) 

72 

73 

74@deprecated_function 

75def collins(pointA, pointB, pointC, alpha, beta, **useZ_Clas_and_kwds): 

76 '''DEPRECATED, use function L{pygeodesy.collins5}.''' 

77 return _MODS.resections.collins5(pointA, pointB, pointC, alpha, beta, 

78 **useZ_Clas_and_kwds) 

79 

80 

81@deprecated_function 

82def copysign(x, y): # PYCHOK no cover 

83 '''DEPRECATED, use function L{pygeodesy.copysign0}.''' 

84 return _MODS.basics.copysign0(x, y) 

85 

86 

87@deprecated_function 

88def decodeEPSG2(arg): # PYCHOK no cover 

89 '''DEPRECATED, use function L{epsg.decode2}. 

90 

91 @return: 2-Tuple C{(zone, hemipole)} 

92 ''' 

93 return tuple(_MODS.epsg.decode2(arg)) 

94 

95 

96@deprecated_function 

97def encodeEPSG(zone, hemipole=NN, band=NN): # PYCHOK no cover 

98 '''DEPRECATED, use function L{epsg.encode}. 

99 

100 @return: C{EPSG} code (C{int}). 

101 ''' 

102 return int(_MODS.epsg.encode(zone, hemipole=hemipole, band=band)) 

103 

104 

105@deprecated_function 

106def enStr2(easting, northing, prec, *extras): # PYCHOK no cover 

107 '''DEPRECATED, use function L{pygeodesy.enstr2}.''' 

108 return _MODS.streprs.enstr2(easting, northing, (int(prec) // 2 - 5), *extras) 

109 

110 

111@deprecated_function 

112def equirectangular_(lat1, lon1, lat2, lon2, **options): # PYCHOK no cover 

113 '''DEPRECATED on 2024.05.25, use function L{pygeodesy.equirectangular4}.''' 

114 return _MODS.formy.equirectangular4(lat1, lon1, lat2, lon2, **options) 

115 

116 

117@deprecated_function 

118def equirectangular3(lat1, lon1, lat2, lon2, **options): # PYCHOK no cover 

119 '''DEPRECATED, use function L{pygeodesy.equirectangular4}. 

120 

121 @return: 3-Tuple C{(distance2, delta_lat, delta_lon)}. 

122 ''' 

123 return tuple(_MODS.formy.equirectangular4(lat1, lon1, lat2, lon2, **options)[:3]) 

124 

125 

126@deprecated_function 

127def excessAbc(A, b, c): # PYCHOK no cover 

128 '''DEPRECATED on 2023.04.04, use function L{pygeodesy.excessAbc_}.''' 

129 return _MODS.formy.excessAbc_(A, b, c) 

130 

131 

132@deprecated_function 

133def excessGirard(A, B, C): # PYCHOK no cover 

134 '''DEPRECATED on 2023.04.04, use function L{pygeodesy.excessGirard_}.''' 

135 return _MODS.formy.excessGirard_(A, B, C) 

136 

137 

138@deprecated_function 

139def excessLHuilier(a, b, c): # PYCHOK no cover 

140 '''DEPRECATED on 2023.04.04, use function L{pygeodesy.excessLHuilier_}.''' 

141 return _MODS.formy.excessLHuilier_(a, b, c) 

142 

143 

144@deprecated_function 

145def false2f(value, name=_value_, false=True, Error=ValueError): # PYCHOK no cover 

146 '''DEPRECATED, use class L{Easting} or L{Northing}.''' 

147 return falsed2f(falsed=false, Error=Error, **{name: value}) 

148 

149 

150@deprecated_function 

151def falsed2f(falsed=True, Error=ValueError, **name_value): # PYCHOK no cover 

152 '''DEPRECATED, use class L{Easting} or L{Northing}. 

153 

154 Convert a falsed east-/northing to non-negative C{float}. 

155 

156 @kwarg falsed: Value includes false origin (C{bool}). 

157 @kwarg Error: Optional, overriding error (C{Exception}). 

158 @kwarg name_value: One C{B{name}=value} pair. 

159 

160 @return: The value (C{float}). 

161 

162 @raise Error: Invalid or negative C{B{name}=value}. 

163 ''' 

164 t = NN 

165 if len(name_value) == 1: 

166 try: 

167 for f in name_value.values(): 

168 f = float(f) 

169 if falsed and f < 0: 

170 break 

171 return f 

172 t = _COMMASPACE_('falsed', _negative_) 

173 except (TypeError, ValueError) as x: 

174 t = str(x) 

175 raise _MODS.errors._InvalidError(Error=Error, txt=t, **name_value) 

176 

177 

178@deprecated_function 

179def float0(*xs): # PYCHOK no cover 

180 '''DEPRECATED on 2023.04.21, use function L{pygeodesy.float0_}.''' 

181 return float0_(*xs) 

182 

183 

184@deprecated_function 

185def fStr(floats, prec=6, fmt=_MODS.streprs.Fmt.f, ints=False, sep=_COMMASPACE_): # PYCHOK no cover 

186 '''DEPRECATED, use function L{fstr}.''' 

187 return _MODS.streprs.fstr(floats, prec=prec, fmt=fmt, ints=ints, sep=sep) 

188 

189 

190@deprecated_function 

191def fStrzs(floatstr): # PYCHOK no cover 

192 '''DEPRECATED, use function L{pygeodesy.fstrzs}.''' 

193 return _MODS.streprs.fstrzs(floatstr) 

194 

195 

196@deprecated_function 

197def Fsum2product(*xs, **kwds): 

198 '''DEPRECATED on 2024.09.19, use L{Fsum}C{(*B{xs}, B{f2product}=True, ...)}.''' 

199 F = _MODS.fsums.Fsum(**kwds) 

200 _ = F.f2product(True) 

201 return F._facc_args(xs, up=False) if xs else F 

202 

203 

204@deprecated_function 

205def hypot3(x, y, z): # PYCHOK no cover 

206 '''DEPRECATED, use function L{pygeodesy.hypot_}.''' 

207 return _MODS.fmath.hypot_(x, y, z) 

208 

209 

210@deprecated_function 

211def inStr(inst, *args, **kwds): # PYCHOK no cover 

212 '''DEPRECATED, use function L{pygeodesy.instr}.''' 

213 return _MODS.streprs.instr(inst, *args, **kwds) 

214 

215 

216@deprecated_function 

217def isenclosedby(point, points, wrap=False): # PYCHOK no cover 

218 '''DEPRECATED, use function L{pygeodesy.isenclosedBy}.''' 

219 return _MODS.points.isenclosedBy(point, points, wrap=wrap) 

220 

221 

222@deprecated_function 

223def istuplist(obj, minum=0): # PYCHOK no cover 

224 '''DEPRECATED on 2023.03.31, use function L{pygeodesy.islistuple}.''' 

225 return _MODS.basics.islistuple(obj, minum=minum) 

226 

227 

228@deprecated_function 

229def joined(*words, **sep): # PYCHOK no cover 

230 '''DEPRECATED, use C{NN(...)}, C{NN.join_} or C{B{sep}.join}.''' 

231 return sep.get(_sep_, NN).join(map(str, words)) 

232 

233 

234@deprecated_function 

235def joined_(*words, **sep): # PYCHOK no cover 

236 '''DEPRECATED, use C{_SPACE_(...)}, C{_SPACE_.join_} or C{B{sep}.join}, sep=" ".''' 

237 return sep.get(_sep_, _SPACE_).join(map(str, words)) 

238 

239 

240@deprecated_function 

241def nearestOn3(point, points, closed=False, wrap=False, **options): # PYCHOK no cover 

242 '''DEPRECATED, use function L{pygeodesy.nearestOn5}. 

243 

244 @return: 3-Tuple C{(lat, lon, distance)} 

245 ''' 

246 return tuple(_MODS.points.nearestOn5(point, points, closed=closed, wrap=wrap, **options)[:3]) 

247 

248 

249@deprecated_function 

250def nearestOn4(point, points, closed=False, wrap=False, **options): # PYCHOK no cover 

251 '''DEPRECATED, use function L{pygeodesy.nearestOn5}. 

252 

253 @return: 4-Tuple C{(lat, lon, distance, angle)} 

254 ''' 

255 return tuple(_MODS.points.nearestOn5(point, points, closed=closed, wrap=wrap, **options)[:4]) 

256 

257 

258@deprecated_function 

259def parseUTM(strUTM, datum=_WGS84, Utm=_UTM, name=NN): # PYCHOK no cover 

260 '''DEPRECATED, use function L{parseUTM5}. 

261 

262 @return: The UTM coordinate (B{L{Utm}}) or 4-tuple C{(zone, 

263 hemisphere, easting, northing)} if C{B{Utm} is None}. 

264 ''' 

265 d = _MODS.datums.Datums.WGS84 if datum is _WGS84 else datum # PYCHOK shadows? 

266 U = _MODS.utm.Utm if Utm is _UTM else Utm 

267 r = _MODS.utm.parseUTM5(strUTM, datum=d, Utm=U, name=name) 

268 if isinstance(r, tuple): # UtmUps5Tuple 

269 r = r.zone, r.hemipole, r.easting, r.northing # no band 

270 return r 

271 

272 

273@deprecated_function 

274def perimeterof(points, closed=False, adjust=True, radius=R_M, wrap=True): # PYCHOK no cover 

275 '''DEPRECATED, use function L{pygeodesy.perimeterOf}.''' 

276 return _MODS.points.perimeterOf(points, closed=closed, adjust=adjust, radius=radius, wrap=wrap) 

277 

278 

279@deprecated_function 

280def polygon(points, closed=True, base=None): # PYCHOK no cover 

281 '''DEPRECATED, use function L{pygeodesy.points2}.''' 

282 return _MODS.deprecated.bases.points2(points, closed=closed, base=base) 

283 

284 

285@deprecated_function 

286def scalar(value, low=EPS, high=1.0, name=_scalar_, Error=ValueError): # PYCHOK no cover 

287 '''DEPRECATED, use class L{Number_} or L{Scalar_}. 

288 

289 @return: New value (C{float} or C{int} for C{int} B{C{low}}). 

290 

291 @raise Error: Invalid B{C{value}}. 

292 ''' 

293 C_ = Number_ if _MODS.basics.isint(low) else Scalar_ 

294 return C_(value, name=name, Error=Error, low=low, high=high) 

295 

296 

297@deprecated_function 

298def simplify2(points, pipe, radius=R_M, shortest=False, indices=False, **options): # PYCHOK no cover 

299 '''DEPRECATED, use function L{pygeodesy.simplifyRW}. 

300 ''' 

301 return _MODS.simplify.simplifyRW(points, pipe, radius=radius, shortest=shortest, 

302 indices=indices, **options) 

303 

304 

305@deprecated_function 

306def tienstra(pointA, pointB, pointC, alpha, **beta_gamma_useZ_Clas_and_kwds): 

307 '''DEPRECATED, use function L{pygeodesy.tienstra7}.''' 

308 return _MODS.resections.tienstra7(pointA, pointB, pointC, alpha, **beta_gamma_useZ_Clas_and_kwds) 

309 

310 

311@deprecated_function 

312def toUtm(latlon, lon=None, datum=None, Utm=_UTM, cmoff=True, name=NN): # PYCHOK no cover 

313 '''DEPRECATED, use function L{pygeodesy.toUtm8}. 

314 

315 @return: The UTM coordinate (B{C{Utm}}) or a 6-tuple C{(zone, easting, northing, 

316 band, convergence, scale)} if C{B{Utm} is None} or C{B{cmoff} is False}. 

317 ''' 

318 U = _MODS.utm.Utm if Utm is _UTM else Utm 

319 r = _MODS.utm.toUtm8(latlon, lon=lon, datum=datum, Utm=U, name=name, falsed=cmoff) 

320 if isinstance(r, tuple): # UtmUps8Tuple 

321 # no hemisphere/pole and datum 

322 r = r.zone, r.easting, r.northing, r.band, r.gamma, r.scale 

323 return r 

324 

325 

326# @deprecated_function 

327# def trfTransforms(reframe, epoch, reframe2, epoch2): 

328# '''DEPRECATED on 2024.02.02, use function L{trfTransform0}C{(reframe, reframe2, epoch=None, epoch2=None)}. 

329# 

330# @return: A 0-, 1- or 2-tuple of Helmert L{Transform}s or C{None} if no conversion exists. 

331# ''' 

332# t = _MODS.trf.trfTransform0(reframe, reframe2, epoch=epoch, epoch2=epoch2) 

333# return (t,) if t else t 

334 

335 

336@deprecated_function 

337def triAngle4(a, b, c): 

338 '''DEPRECATED on 2023.09.14, use function L{pygeodesy.triAngle5}. 

339 

340 @return: A I{DEPRECATED} L{TriAngle4Tuple}C{(radA, radB, radC, rIn)}. 

341 ''' 

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

343 return TriAngle4Tuple(_MODS.resections.triAngle5(a, b, c)[:4]) 

344 

345 

346@deprecated_function 

347def unsign0(x): # PYCHOK no cover 

348 '''DEPRECATED, use function L{pygeodesy.unsigned0}.''' 

349 return _MODS.basics.unsigned0(x) 

350 

351 

352@deprecated_function 

353def unStr(name, *args, **kwds): # PYCHOK no cover 

354 '''DEPRECATED, use function L{pygeodesy.unstr}.''' 

355 return _MODS.streprs.unstr(name, *args, **kwds) 

356 

357 

358@deprecated_function 

359def utmZoneBand2(lat, lon): # PYCHOK no cover 

360 '''DEPRECATED, use function L{pygeodesy.utmZoneBand5}. 

361 

362 @return: 2-Tuple C{(zone, band)}. 

363 ''' 

364 r = _MODS.utm.utmZoneBand5(lat, lon) # UtmUpsLatLon5Tuple 

365 return r.zone, r.band 

366 

367# **) MIT License 

368# 

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

370# 

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

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

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

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

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

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

377# 

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

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

380# 

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

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

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

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

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

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

387# OTHER DEALINGS IN THE SOFTWARE.