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

1

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

3

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

5'''

6

7# from pygeodesy.basics import copysign0 # _MODS_

8 from pygeodesy.constants import EPS, R_M, float0_

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

10# from pygeodesy.ellipses import Ellipse # _MODS

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

12 _scalar_, _sep_, _SPACE_, _UNDER_, _value_

13 from pygeodesy.lazily import _ALL_DEPRECATED, _ALL_MODS as _MODS

14 from pygeodesy.props import deprecated_function

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

16 from pygeodesy.units import _1mm, Number_, Scalar_

17

18 __all__ = _ALL_DEPRECATED.deprecated_functions

19 __version__ = '26.02.12'

20

21 _WGS84 = _UTM = object()

22

23

24@deprecated_function

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

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

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

28

29

30@deprecated_function

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

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

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

34

35

36@deprecated_function

37 def atand(x): # PYCHOK no cover

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

39 return _MODS.utily.atan1d(x)

40

41

42@deprecated_function

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

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

45

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

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

48 '''

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

50

51

52@deprecated_function

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

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

55

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

57 edge of the I{clipped} path.

58 '''

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

60 closed=closed, inull=inull):

61 yield ClipCS3Tuple(p1, p2, j)

62

63

64@deprecated_function

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

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

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

68

69

70@deprecated_function

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

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

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

74

75

76@deprecated_function

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

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

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

80 **useZ_Clas_and_kwds)

81

82

83@deprecated_function

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

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

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

87

88

89@deprecated_function

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

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

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

93

94

95@deprecated_function

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

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

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

99

100

101@deprecated_function

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

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

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

105

106

107@deprecated_function

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

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

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

111

112

113@deprecated_function

114 def decodeEPSG2(arg): # PYCHOK no cover

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

116

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

118 '''

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

120

121

122@deprecated_function

123 def elliperim(a, b, *deg2_1): # PYCHOK no cover

124 '''DEPRECATED on 2026.02.12, use method L{pygeodesy.Ellipse.arc} or property L{pygeodesy.Ellipse.perimeter2k_}.'''

125 E = _MODS.ellipses.Ellipse(a, b)

126 return E.arc(*deg2_1) if deg2_1 else E.perimeter2k_

127

128

129@deprecated_function

130 def elliperim_(a, b, *rad2_1): # PYCHOK no cover

131 '''DEPRECATED on 2026.02.12, use method L{pygeodesy.Ellipse.arc_} or property L{pygeodesy.Ellipse.perimeter2k_}.'''

132 E = _MODS.ellipses.Ellipse(a, b)

133 return E.arc_(*rad2_1) if rad2_1 else E.perimeter2k_

134

135

136@deprecated_function

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

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

139

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

141 '''

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

143

144

145@deprecated_function

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

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

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

149

150

151@deprecated_function

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

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

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

155

156

157@deprecated_function

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

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

160

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

162 '''

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

164

165

166@deprecated_function

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

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

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

170

171

172@deprecated_function

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

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

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

176

177

178@deprecated_function

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

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

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

182

183

184@deprecated_function

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

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

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

188

189

190@deprecated_function

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

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

193

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

195

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

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

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

199

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

201

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

203 '''

204 t = NN

205 if len(name_value) == 1:

206 try:

207 for f in name_value.values():

208 f = float(f)

209 if falsed and f < 0:

210 break

211 return f

212 t = _COMMASPACE_('falsed', _negative_)

213 except (TypeError, ValueError) as x:

214 t = str(x)

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

216

217

218@deprecated_function

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

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

221 return float0_(*xs)

222

223

224@deprecated_function

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

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

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

228

229

230@deprecated_function

231 def fStrzs(floatstr): # PYCHOK no cover

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

233 return _MODS.streprs.fstrzs(floatstr)

234

235

236@deprecated_function

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

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

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

240 _ = F.f2product(True)

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

242

243

244@deprecated_function

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

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

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

248

249

250@deprecated_function

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

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

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

254

255

256@deprecated_function

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

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

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

260

261

262@deprecated_function

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

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

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

266

267

268@deprecated_function

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

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

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

272

273

274@deprecated_function

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

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

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

278

279

280@deprecated_function

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

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

283

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

285 '''

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

287

288

289@deprecated_function

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

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

292

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

294 '''

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

296

297

298@deprecated_function

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

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

301

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

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

304 '''

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

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

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

308 if isinstance(r, tuple): # UtmUps5Tuple

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

310 return r

311

312

313@deprecated_function

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

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

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

317

318

319@deprecated_function

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

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

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

323

324

325@deprecated_function

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

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

328

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

330

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

332 '''

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

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

335

336

337@deprecated_function

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

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

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

341

342

343@deprecated_function

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

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

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

347

348

349@deprecated_function

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

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

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

353

354

355@deprecated_function

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

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

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

359

360

361@deprecated_function

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

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

364

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

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

367 '''

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

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

370 if isinstance(r, tuple): # UtmUps8Tuple

371 # no hemisphere/pole and datum

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

373 return r

374

375

376# @deprecated_function

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

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

379#

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

381# '''

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

383# return (t,) if t else t

384

385

386@deprecated_function

387 def triAngle4(a, b, c):

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

389

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

391 '''

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

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

394

395

396@deprecated_function

397 def unsign0(x): # PYCHOK no cover

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

399 return _MODS.basics.unsigned0(x)

400

401

402@deprecated_function

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

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

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

406

407

408@deprecated_function

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

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

411

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

413 '''

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

415 return r.zone, r.band

416

417# **) MIT License

418#

419# Copyright (C) 2018-2026 -- mrJean1 at Gmail -- All Rights Reserved.

420#

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

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

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

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

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

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

427#

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

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

430#

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

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

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

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

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

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

437# OTHER DEALINGS IN THE SOFTWARE.