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

42 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-09-09 13:03 -0400

1 

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

3 

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

5''' 

6 

7# from pygeodesy.basics import copysign0 # _MODS_ 

8from pygeodesy.constants import EPS, R_M, float0_ 

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

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

11 _scalar_, _sep_, _SPACE_, _UNDER_, _value_ 

12from pygeodesy.lazily import _ALL_DEPRECATED, _ALL_MODS as _MODS 

13from pygeodesy.props import deprecated_function 

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

15from pygeodesy.units import _1mm, Number_, Scalar_ 

16 

17__all__ = _ALL_DEPRECATED.deprecated_functions 

18__version__ = '24.12.31' 

19 

20_WGS84 = _UTM = object() 

21 

22 

23@deprecated_function 

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

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

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

27 

28 

29@deprecated_function 

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

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

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

33 

34 

35@deprecated_function 

36def atand(x): # PYCHOK no cover 

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

38 return _MODS.utily.atan1d(x) 

39 

40 

41@deprecated_function 

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

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

44 

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

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

47 ''' 

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

49 

50 

51@deprecated_function 

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

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

54 

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

56 edge of the I{clipped} path. 

57 ''' 

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

59 closed=closed, inull=inull): 

60 yield ClipCS3Tuple(p1, p2, j) 

61 

62 

63@deprecated_function 

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

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

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

67 

68 

69@deprecated_function 

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

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

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

73 

74 

75@deprecated_function 

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

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

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

79 **useZ_Clas_and_kwds) 

80 

81 

82@deprecated_function 

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

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

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

86 

87 

88@deprecated_function 

89def cosineAndoyerLambert(lat1, lon1, lat2, lon2, **datum_wrap): 

90 '''DEPRECATED on 2024.12.31, use function L{pygeodesy.cosineLaw} with C{B{corr}=1}.''' 

91 return _MODS.formy.cosineLaw(lat1, lon1, lat2, lon2, corr=1, **datum_wrap) 

92 

93 

94@deprecated_function 

95def cosineAndoyerLambert_(phi2, phi1, lam21, **datum): 

96 '''DEPRECATED on 2024.12.31, use function L{pygeodesy.cosineLaw_} with C{B{corr}=1}.''' 

97 return _MODS.formy.cosineLaw_(phi2, phi1, lam21, corr=1, **datum) 

98 

99 

100@deprecated_function 

101def cosineForsytheAndoyerLambert(lat1, lon1, lat2, lon2, **datum_wrap): 

102 '''DEPRECATED on 2024.12.31, use function L{pygeodesy.cosineLaw} with C{B{corr}=2}.''' 

103 return _MODS.formy.cosineLaw(lat1, lon1, lat2, lon2, corr=2, **datum_wrap) 

104 

105 

106@deprecated_function 

107def cosineForsytheAndoyerLambert_(phi2, phi1, lam21, **datum): 

108 '''DEPRECATED on 2024.12.31, use function L{pygeodesy.cosineLaw_} with C{B{corr}=2}.''' 

109 return _MODS.formy.cosineLaw_(phi2, phi1, lam21, corr=2, **datum) 

110 

111 

112@deprecated_function 

113def decodeEPSG2(arg): # PYCHOK no cover 

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

115 

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

117 ''' 

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

119 

120 

121@deprecated_function 

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

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

124 

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

126 ''' 

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

128 

129 

130@deprecated_function 

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

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

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

134 

135 

136@deprecated_function 

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

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

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

140 

141 

142@deprecated_function 

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

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

145 

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

147 ''' 

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

149 

150 

151@deprecated_function 

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

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

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

155 

156 

157@deprecated_function 

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

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

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

161 

162 

163@deprecated_function 

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

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

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

167 

168 

169@deprecated_function 

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

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

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

173 

174 

175@deprecated_function 

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

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

178 

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

180 

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

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

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

184 

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

186 

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

188 ''' 

189 t = NN 

190 if len(name_value) == 1: 

191 try: 

192 for f in name_value.values(): 

193 f = float(f) 

194 if falsed and f < 0: 

195 break 

196 return f 

197 t = _COMMASPACE_('falsed', _negative_) 

198 except (TypeError, ValueError) as x: 

199 t = str(x) 

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

201 

202 

203@deprecated_function 

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

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

206 return float0_(*xs) 

207 

208 

209@deprecated_function 

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

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

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

213 

214 

215@deprecated_function 

216def fStrzs(floatstr): # PYCHOK no cover 

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

218 return _MODS.streprs.fstrzs(floatstr) 

219 

220 

221@deprecated_function 

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

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

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

225 _ = F.f2product(True) 

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

227 

228 

229@deprecated_function 

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

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

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

233 

234 

235@deprecated_function 

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

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

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

239 

240 

241@deprecated_function 

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

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

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

245 

246 

247@deprecated_function 

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

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

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

251 

252 

253@deprecated_function 

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

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

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

257 

258 

259@deprecated_function 

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

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

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

263 

264 

265@deprecated_function 

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

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

268 

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

270 ''' 

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

272 

273 

274@deprecated_function 

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

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

277 

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

279 ''' 

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

281 

282 

283@deprecated_function 

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

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

286 

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

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

289 ''' 

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

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

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

293 if isinstance(r, tuple): # UtmUps5Tuple 

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

295 return r 

296 

297 

298@deprecated_function 

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

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

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

302 

303 

304@deprecated_function 

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

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

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

308 

309 

310@deprecated_function 

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

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

313 

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

315 

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

317 ''' 

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

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

320 

321 

322@deprecated_function 

323def simplify2(points, pipe=_1mm, **radius_shortest_indices_options): # PYCHOK no cover 

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

325 return _MODS.simplify.simplifyRW(points, pipe=pipe, **radius_shortest_indices_options) 

326 

327 

328@deprecated_function 

329def simplifyRDPm(points, distance=_1mm, **radius_shortest_indices_options): 

330 '''DEPRECATED on 2024.11.28, use function L{pygeodesy.simplifyRDP}C{(points, modified=True, ...)}.''' 

331 return _MODS.simplify.simplifyRDP(points, modified=True, distance=distance, **radius_shortest_indices_options) 

332 

333 

334@deprecated_function 

335def simplifyVWm(points, area=_1mm, **radius_attr_indices_options): 

336 '''DEPRECATED on 2024.11.28, use function L{pygeodesy.simplifyVW}C{(points, modified=True, ...)}.''' 

337 return _MODS.simplify.simplifyVW(points, modified=True, area=area, **radius_attr_indices_options) 

338 

339 

340@deprecated_function 

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

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

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

344 

345 

346@deprecated_function 

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

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

349 

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

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

352 ''' 

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

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

355 if isinstance(r, tuple): # UtmUps8Tuple 

356 # no hemisphere/pole and datum 

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

358 return r 

359 

360 

361# @deprecated_function 

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

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

364# 

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

366# ''' 

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

368# return (t,) if t else t 

369 

370 

371@deprecated_function 

372def triAngle4(a, b, c): 

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

374 

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

376 ''' 

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

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

379 

380 

381@deprecated_function 

382def unsign0(x): # PYCHOK no cover 

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

384 return _MODS.basics.unsigned0(x) 

385 

386 

387@deprecated_function 

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

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

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

391 

392 

393@deprecated_function 

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

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

396 

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

398 ''' 

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

400 return r.zone, r.band 

401 

402# **) MIT License 

403# 

404# Copyright (C) 2018-2025 -- mrJean1 at Gmail -- All Rights Reserved. 

405# 

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

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

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

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

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

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

412# 

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

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

415# 

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

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

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

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

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

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

422# OTHER DEALINGS IN THE SOFTWARE.