Coverage for pyrdnap / rd0.py: 99%

201 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-06-26 11:46 -0400

1 

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

3 

4u'''(INTERNAL) RijksDriehoeksmeting C{_RD} and reference C{_RD0} 

5constants and classes C{RDNAP7Tuple} and C{LqRD}. 

6''' 

7# make sure int/int division yields float quotient, see .basics 

8from __future__ import division as _; del _ # noqa: E702 ; 

9 

10from pyrdnap.v_grids import _v_assert 

11from pyrdnap.__pygeodesy import (_0_5, _1_0, _2_0, # PYCHOK used! 

12 _isNAN, _isNAN0, _xinstanceof, _xsubclassof, 

13 _LLEB, _xkwds, 

14 _COMMASPACE_, _datum_, _lat_, _lon_, _height_, 

15 _all_OTHER, _FOR_DOCS, _Pass, _NamedTuple) 

16from pygeodesy import (map1, map2, NAN, NN, # basics, "consterns" 

17 Datum, Datums, Similarity, # datums 

18 Ellipsoid, Ellipsoids, LqRD as _LqRD, # ellipsoids, ltp 

19 Bounds4Tuple, LatLon2Tuple, LatLon3Tuple, LatLon4Tuple, # namedTuples 

20 PhiLam2Tuple, PhiLam3Tuple, PhiLam4Tuple, Vector2Tuple, Vector3Tuple, 

21 Property_RO, property_ROnce, pairs, # props, streprs 

22 Height, Lam, Lamd, Lat, Lon, Meter, Phi, Phid, # units 

23 sincos2, tanPI_2_2) # utily 

24 

25from math import atan2, ceil, fabs, floor, log, sin, sqrt 

26 

27__all__ = () 

28__version__ = '26.06.18' 

29 

30_LQRD0 = _LqRD() # get Amersfoort, region4, etc. (deleted below) 

31 

32 

33def _c_f_N_f3(*deg_SW_D): 

34 # return int(ceil) and int(floor) of Normalized 

35 # and (Normalized less floor) of C{deg} degrees 

36 N = _degN(*deg_SW_D) 

37 # assert N >= 0, N 

38 f = floor(N) 

39 return int(ceil(N)), int(f), (N - f) 

40 

41 

42def _degN(deg, degSW, deg_D): 

43 # return C{deg} Normalized 

44 return (deg - degSW) * deg_D 

45 

46 

47class _RDbase(object): 

48 '''(INTERNAL) Base. 

49 ''' 

50 def _preDict(self, _pred, **d): 

51 # return updated dict C{d} 

52 for n in self.__class__.__dict__.keys(): 

53 if _pred(n): 

54 d[n] = getattr(self, n) 

55 return d 

56 

57 def toStr(self, prec=9, **fmt_ints): 

58 # return this C{_RDx} as string 

59 d = self._toDict() # PYCHOK OK 

60 t = pairs(d, prec=prec, **fmt_ints) 

61 return _COMMASPACE_(*t) 

62 

63 

64class _RD(_RDbase): 

65 '''(INTERNAL) Bounds, constants for RDNAP2018 (ASCII.txt). 

66 ''' 

67 lat_D = Lat(lat_D=80.0) # degrees, all 

68 lon_D = Lon(lon_D=50.0) 

69 

70# latD = Lat(latD=1 / lat_D) # degrees, all 

71# lonD = Lon(lonD=1 / lon_D) 

72 

73 def __init__(self): 

74 S, W, N, E = self._region4RD 

75 nlat = _degN(N, S, self.lat_D) + _1_0 # 2.3.2g n-phi 

76 nlon = _degN(E, W, self.lon_D) + _1_0 # 2.3.2g n-lambda 

77 _v_assert(map1(int, nlat, nlon)) 

78 

79 def _c_f_N_f6(self, lat, lon): 

80 # return (int(ceil), int(floor), Normalized less floor) of C{lat}) + \ 

81 # (int(ceil), int(floor), Normalized less floor) of C{lon}) 

82 S, W, _, _ = self._region4RD 

83 return _c_f_N_f3(lat, S, self.lat_D) + \ 

84 _c_f_N_f3(lon, W, self.lon_D) 

85 

86 def isinside(self, lat, lon, asRD=True, eps=0): # eps=_TOL_D, 0 or -_TOLD_D 

87 '''Is C{(lat, lon)} inside the C{RD} or C{ETRS} region, optionally 

88 over-/undersized by positive respectively negative C{eps} degrees? 

89 

90 @return: C{True} if inside or on, otherwise C{False} (C{bool}). 

91 ''' 

92 S, W, N, E = self._region4RD if asRD else self._region4ETRS 

93 # XXX use "< N" and "< E" instead of "<="? 

94 return ((S - lat) <= eps and (lat - N) <= eps and 

95 (W - lon) <= eps and (lon - E) <= eps) if eps else \ 

96 (S <= lat <= N and W <= lon <= E) 

97 

98 @property_ROnce 

99 def _RDNAPv0(self): 

100 from pyrdnap.rdnap2018 import _RDNAPbase 

101 return _RDNAPbase() # singleton, instance! 

102 

103 @property_ROnce 

104 def _region4ETRS(self): # as ETRS L{Bounds4Tuple} 

105 return self._RDNAPv0.region4(False) 

106 

107 _region4RD = _LQRD0.region4() # as RD-Bessel L{Bounds4Tuple}, in .rdnap2018 

108 

109 def _toDict(self): 

110 def _p(n): # lambda 

111 return n.endswith('D') or n.endswith('S') 

112 

113 return self._preDict(_p) 

114 

115 @property_ROnce 

116 def _xETRS2RD(self): # transform ETRS (GRS80) to RD-Bessel 

117 return Similarity(tx=-565.7346, ty=-50.4058, tz=-465.2895, s=-4.07242, 

118 rx=-1.91513, ry=1.60365, rz=-9.09546, name='_xETRS2RD') 

119 

120 @property_ROnce 

121 def _xRD2ETRS(self): # transform RD-Bessel to ETRS (GRS80) 

122 return Similarity(tx=565.7381, ty=50.4018, tz=465.2904, s=4.07244, 

123 rx=1.91514, ry=-1.60363, rz=9.09546, name='_xRD2ETRS') 

124 

125 # % python -c "import pyrdnap; print(pyrdnap.rd0._RD.toStr())" 

126 # _region4ETRS=ETRS region (latS=49.999276, lonW=2.000032, latN=55.998561, lonE=7.999158), 

127 # _region4RD=RD region (latS=50.0, lonW=2.0, latN=56.0, lonE=8.0), 

128 # _xETRS2RD=Similarity(name='_xETRS2RD', tx=-565.73, ty=-50.406, tz=-465.29, s=-4.0724, 

129 # rx=-1.9151, ry=1.6037, rz=-9.0955), 

130 # _xRD2ETRS=Similarity(name='_xRD2ETRS', tx=565.74, ty=50.402, tz=465.29, s=4.0724, 

131 # rx=1.9151, ry=-1.6036, rz=9.0955), 

132 # lat_D=80.0, lon_D=50.0 # latD=0.0125, lonD=0.02 

133 

134_RD = _RD() # PYCHOK singleton, in .test/testRndTrips 

135 

136 

137class _RD0(_RDbase): 

138 '''(INTERNAL) C{RD} Amersfoort, NL / C{RD New} constants for RDNAP2018 (ASCII.txt). 

139 

140 @see: U{EPSG:9809<https://EPSG.io/9809-method>}, U{"Oblique Stereographic" 

141 <https://PROJ.org/en/stable/operations/projections/sterea.html>} and 

142 <http://geotiff.maptools.org/proj_list/oblique_stereographic.html> 

143 ''' 

144 H0 = Meter(H0 =_LQRD0.height0) # Amersfoort.height0 0.0 m 

145 H0_ETRS = Meter(H0_ETRS=_LQRD0.height0_ETRS) # 43.0 m 

146 K0 = 0.9999079 # 2.4.1 scale factor 

147 LAT0 = Lat(LAT0=_LQRD0.Amersfoort.lat) # '52 9 22.178N' == 52.156160555555+° 

148 LON0 = Lon(LON0=_LQRD0.Amersfoort.lon) # ' 5 23 15.5E' == 5.387638888888+° 

149 LAM0 = Lamd(LAM0=LON0) # 𝜆0, 0.094032038 

150 LAM0C = Lam(LAM0C=LAM0) # 𝛬0 on sphere == 𝜆0 

151 PHI0 = Phid(PHI0=LAT0) # 𝜑0 0.910296727, PHI0C 𝛷0 set below 

152 X0 = Meter(X0=155000.0) # false Easting 155029.784? 

153 Y0 = Meter(Y0=463000.0) # false Norting 463109.889? 

154 

155# @property_ROnce 

156# def C0(self): # c, sphere 

157# s, _ = self.sincos2PHI0 

158# w = self._w1(s) 

159# c = (w - _1_0) / (w + _1_0) 

160# return (((self.N0 + s) * (_1_0 - c)) / 

161# ((self.N0 - s) * (_1_0 + c))) 

162 

163# def chilam(self, lat, lon): # EPSG:9809 

164# # return 2-tuple (chi, lam), conformal in radians 

165# s, _ = sincos2d(lat) 

166# w2 = self._w1(s) * self.C0 

167# s = (w2 - _1_0) / (w2 + _1_0) 

168# r = radians(lon - self.LON0) * self.N0 

169# return asin(s), r 

170 

171 @property_ROnce 

172 def D0(self): # lazily 

173 return Datums.Bessel1841 

174 

175 @property_ROnce 

176 def D80(self): # lazily 

177 return Datums.GRS80 

178 

179 @property_ROnce 

180 def E0(self): # lazily 

181 return self.D0.ellipsoid 

182 

183 def log_e_2(self, phi): 

184 e = self.E0.e 

185 p = e * sin(phi) 

186 return log((_1_0 + p) / (_1_0 - p)) * (e * _0_5) 

187 

188 def log_tan(self, phi): 

189 return log(tanPI_2_2(phi)) # tan((phi + PI/2) / 2) 

190 

191 @property_ROnce 

192 def M0(self): # 2.4.1 p 15 m 

193 return self.W0 - self.N0 * self.Q0 

194 

195 @property_ROnce 

196 def N0(self): # 2.4.1 p 15 n, sphere 

197 E = self.E0 

198 _, c = self.sincos2PHI0 

199 return sqrt(c**4 * E.e2 / E.e21 + _1_0) 

200 

201 @property_ROnce 

202 def PHI0C(self): # 2.4.1 p 15 𝛷0 on sphere 

203 m, n = self.Rmn2 

204 s, c = self.sincos2PHI0 

205 return Phi(PHI0C=atan2(m * s, n * c)) # atan((m / n) * tan(PHI0)) 

206 

207 @property_ROnce 

208 def Q0(self): # 2.4.1 p 15 q0 

209 return self.log_tan(self.PHI0) - self.log_e_2(self.PHI0) 

210 

211 @property_ROnce 

212 def R(self): # 2.4.1 p 15 R, radius conformal sphere 

213 m, n = self.Rmn2 

214 return m * n 

215 

216 @property_ROnce 

217 def RK2(self): # 2.4.2 

218 return self.R * self.K0 * _2_0 

219 

220 @property_ROnce 

221 def Rmn2(self): # 2.4.1 p 15 (sqrt(RsubM), sqrt(RsubN)) 

222 # RsubM, RsubN == RHO0, NU0 EPSG:9809 

223 E = self.E0 

224 s, _ = self.sincos2PHI0 

225 s = _1_0 - s**2 * E.e2 

226 # assert s > 0 

227 N = E.a / sqrt(s) 

228 # assert N > 0 

229 M = E.e21 * N / s 

230 # assert M > 0 

231 return map1(sqrt, M, N) # sqrt! 

232 

233 @property_ROnce 

234 def sincos2PHI0(self): # 𝜑0 

235 return sincos2(self.PHI0) 

236 

237 @property_ROnce 

238 def sincos2PHI0C(self): # 𝛷0 

239 return sincos2(self.PHI0C) 

240 

241 def _toDict(self): 

242 def _p(n): # lambda 

243 return n.endswith('0') or n.startswith('R') or \ 

244 n.endswith('0C') # _0_ 

245 

246 return self._preDict(_p, H0_ETRS=self.H0_ETRS) 

247 

248 @property_ROnce 

249 def W0(self): # 2.4.1 p 15 w0 

250 return self.log_tan(self.PHI0C) # 𝛷0 

251 

252# def _w1(self, sphi): # EPSG:9809 

253# w1 = NAN 

254# if _1_0 > sphi > _N_1_0: 

255# e = self.E0.e 

256# S = (_1_0 + sphi) / (_1_0 - sphi) 

257# T = (_1_0 - sphi * e) / (_1_0 + sphi * e) 

258# w1 = pow(pow(T, e) * S, self.N0) 

259# return w1 

260 

261 # % python -c "import pyrdnap; print(pyrdnap.rd0._RD0.toStr())" 

262 # D0=Datum(name='Bessel1841', ellipsoid=Ellipsoids.Bessel1841, transform=Transforms.Bessel1841), 

263 # D80=Datum(name='GRS80', ellipsoid=Ellipsoids.GRS80, transform=Transforms.WGS84), 

264 # E0=Ellipsoid(name='Bessel1841', a=6377397.155, f=0.00334277, f_=299.1528128, b=6356078.962818), 

265 # H0=0.0, H0_ETRS=43.0, K0=0.9999079, LAM0=0.094032038, LAM0C=0.094032038, 

266 # LAT0=52.156160556, LON0=5.387638889, M0=0.003773954, N0=1.000475857, 

267 # PHI0=0.910296727, PHI0C=0.909684757, Q0=1.06531844, 

268 # R=6382644.571035411, RK2=12764113.458940838, Rmn2=(2524.794785679199, 2527.9854850929623), 

269 # sincos2PHI0=(0.7896858198001045, 0.6135114554811807), 

270 # sincos2PHI0C=(0.7893102212553742, 0.6139946047171686), 

271 # W0=1.069599332, X0=155000.0, Y0=463000.0 

272 

273_RD0 = _RD0() # PYCHOK singleton, in .test/testRndTrips 

274 

275 

276class RDNAP7Tuple(_NamedTuple): # in .v_self 

277 '''7-Tuple C{(RDx, RDy, NAPh, lat, lon, height, datum)} with I{local} C{RDx}, 

278 C{RDy} and C{NAPh} quasi-geoid_height, geodetic C{lat}, C{lon}, C{height} 

279 and C{datum} with C{lat} and C{lon} in C{degrees} and with C{RDx}, C{RDy}, 

280 C{NAPh} and C{height} in C{meter}, conventionally. 

281 

282 @note: I{By default} C{lat}, C{lon} and C{datum} are B{GRS80 (ETRS89)} when 

283 returned from L{RDNAP2018v1.reverse} but B{Bessel1841 (RD-Bessel)} 

284 from L{RDNAP2018v2.reverse}. 

285 ''' 

286 _Names_ = ('RDx', 'RDy', 'NAPh', _lat_, _lon_, _height_, _datum_) 

287 _Units_ = ( Meter, Meter, Meter, Lat, Lon, Height, _Pass) 

288 

289 def diff(self, other, datum=None, **name): 

290 '''Return the difference between this and an C{other} C{RDNAP7Tuple}. 

291 

292 @kwarg datum: Datum C{diff} (C{Datum}, None or NAN). 

293 @kwarg name: Optional name (C{str}). 

294 

295 @return: An L{RDNAP7Tuple} with the C{fabs(diff)} for each item, 

296 except C{datum} as B{C{datum}}. 

297 ''' 

298 def _diff(a, b): 

299 try: 

300 return fabs(a - b) 

301 except TypeError: 

302 return datum 

303 

304 _xinstanceof(RDNAP7Tuple, other=other) 

305 t = map2(_diff, self, other) 

306 return RDNAP7Tuple(t, **name) 

307 

308 @Property_RO 

309 def lam(self): 

310 '''Get the longitude (B{C{radians}}). 

311 ''' 

312 return Lamd(self.lon) # PYCHOK lon 

313 

314 @Property_RO 

315 def latlon(self): 

316 '''Get the lat-, longitude in C{degrees} (L{LatLon2Tuple}C{(lat, lon)}). 

317 ''' 

318 return LatLon2Tuple(self.lat, self.lon, name=self.name) 

319 

320 @Property_RO 

321 def latlonheight(self): 

322 '''Get the lat-, longitude in C{degrees} and height (L{LatLon3Tuple}C{(lat, lon, height)}). 

323 ''' 

324 return self.latlon.to3Tuple(self.height) 

325 

326 @Property_RO 

327 def latlonheightdatum(self): 

328 '''Get the lat-, longitude in C{degrees} with height and datum (L{LatLon4Tuple}C{(lat, lon, height, datum)}). 

329 ''' 

330 return self.latlonheight.to4Tuple(self.datum) 

331 

332 @Property_RO 

333 def phi(self): 

334 '''Get the latitude (B{C{radians}}). 

335 ''' 

336 return Phid(self.lat) # PYCHOK lat 

337 

338 @Property_RO 

339 def philam(self): 

340 '''Get the lat- and longitude in C{radians} (L{PhiLam2Tuple}C{(phi, lam)}). 

341 ''' 

342 return PhiLam2Tuple(self.phi, self.lam, name=self.name) # PYCHOK lam, phi 

343 

344 @Property_RO 

345 def philamheight(self): 

346 '''Get the lat-, longitude in C{radians} and height (L{PhiLam3Tuple}C{(phi, lam, height)}). 

347 ''' 

348 return self.philam.to3Tuple(self.height) # PYCHOK height 

349 

350 @Property_RO 

351 def philamheightdatum(self): 

352 '''Get the lat-, longitude in C{radians} with height and datum (L{PhiLamn4Tuple}C{(phi, lam, height, datum)}). 

353 ''' 

354 return self.philamheight.to4Tuple(self.datum) 

355 

356 def toDatum(self, datum2, name=NN): 

357 '''Convert this C{lat}, C{lon} and C{height} to B{C{datum2}}. 

358 

359 @arg datum2: Datum to convert I{to} (L{Datum}). 

360 @kwarg name: Optional name (C{str}), overriding this name. 

361 

362 @return: An L{RDNAP7Tuple} with transformed C{lat}, C{lon} and C{height} 

363 or this L{RDNAP7Tuple} if this.datum is B{C{datum2}}. 

364 

365 @note: This datum conversion is based on C{pygeodesy} which differs from 

366 C{RDNAPTRANS(tm)2018_v220627}. 

367 

368 @see: Methods L{RDNAP7Tuple.asETRS} and L{RDNAP7Tuple.asRD}. 

369 ''' 

370 _xinstanceof(Datum, datum2=datum2) 

371 if self.datum is datum2 or self.datum == datum2: # PYCHOK datum 

372 return self 

373 g = self.toLatLon(_LLEB).toDatum(datum2) 

374 h = NAN if _isNAN(self.height) else g.height # PYCHOK preserve height NAN 

375 return self.dup(lat=g.lat, lon=g.lon, datum=g.datum, height=h, 

376 name=name or self.name) 

377 

378 def toETRS(self, **name): 

379 '''Copy this L{RDNAP7Tuple} with C{lat} and C{lon} C{reverse3} transformed 

380 to ETRS89 (GRS80), provided this C{datum} is RD-Bessel (Bessel1841). 

381 

382 @kwarg name: Optional name (C{str}), overriding this name. 

383 

384 @see: Methods L{RDNAP7Tuple.toRD} and L{RDNAP7Tuple.toDatum}. 

385 ''' 

386 return self._toX(_RD0.D0, _RD._RDNAPv0.reverse3, **name) 

387 

388 def toLatLon(self, LatLon, **LatLon_kwds): 

389 '''Return this C{lat}, C{lon}, C{datum} and C{height} as B{C{LatLon}}. 

390 

391 @arg LatLon: An ellipsoidal C{LatLon} class (C{pygeodesy.ellipsoidal*}). 

392 @kwarg LatLon_kwds: Optional, additional B{C{LatLon}} keyword arguments. 

393 

394 @return: An B{C{LatLon}} instance. 

395 

396 @raise TypeError: B{C{LatLon}} not ellipsoidal or an other issue. 

397 ''' 

398 _xsubclassof(_LLEB, LatLon=LatLon) 

399 h = _isNAN0(self.height) # PYCHOK height 

400 kwds = _xkwds(LatLon_kwds, name=self.name, height=h) 

401 return LatLon(self.lat, self.lon, datum=self.datum, **kwds) # PYCHOK datum 

402 

403 def toRD(self, **name): 

404 '''Copy this L{RDNAP7Tuple} with C{lat} and C{lon} C{forward3} transformed 

405 to RD-Bessel (Bessel1841), provided this C{datum} is ETRS89 (GRS80). 

406 

407 @kwarg name: Optional name (C{str}), overriding this name. 

408 

409 @see: Methods L{RDNAP7Tuple.toETRS} and L{RDNAP7Tuple.toDatum}. 

410 ''' 

411 return self._toX(_RD0.D80, _RD._RDNAPv0.forward3, **name) 

412 

413 def _toX(self, datum, _xform, name=NN): 

414 # helper for C{toETRS} and C{toRD} 

415 if self.datum is datum or self.datum == datum: # PYCHOK datum 

416 lat, lon, d = _xform(*self.latlon) 

417 return self.dup(lat=lat, lon=lon, datum=d, name=name or self.name) 

418 return self 

419 

420 @Property_RO 

421 def xy(self): 

422 '''Get the I{local} C{(RDx, RDy)} coordinates (L{Vector2Tuple}C{(x, y)}). 

423 ''' 

424 return Vector2Tuple(self.RDx, self.RDy, name=self.name) 

425 

426 @Property_RO 

427 def xyz(self): 

428 '''Get the I{local} C{(RDx, RDy, NAPh)} coordinates and height (L{Vector3Tuple}C{(x, y, z)}). 

429 ''' 

430 return Vector3Tuple(self.RDx, self.RDy, self.NAPh, name=self.name) 

431 

432 

433class LqRD(_LqRD): 

434 '''Like U{pygeodesy.LqRD<https://mrJean1.GitHub.io/PyGeodesy/docs/pygeodesy.ltp.LqRD-class.html>} 

435 but with methods C{forward} and C{reverse} returning an L{RDNAP7Tuple} with C{NAPh} replaced 

436 by I{local} C{z}, the perpendicular distance to the local tangent plane (LTP). 

437 

438 This C{quasi-RD} transformer B{does not} implement any U{RD NAP<https://www.NSGI.NL/ 

439 coordinatenstelsels-en-transformaties/coordinatentransformaties/rdnap-etrs89-rdnaptrans>} 

440 specification and B{does not} provide I{Netherlands}' C{B{N}ormaal B{A}msterdams B{P}eil 

441 (NAP)} quasi-geodetic-height. 

442 ''' 

443 if _FOR_DOCS: 

444 __init__ = _LqRD.__init__ 

445 

446 def forward(self, lat_latlonh, lon=None, height=0, **name): # PYCHOK signature 

447 '''Convert I{geodetic} C{(lat, lon, height)} to I{local} C{quasi-RD (x, y, z)}. 

448 

449 @arg lat_latlonh: C{Scalar} (geodetic) latitude (C{degrees}) or a I{local} 

450 C{quasi-RD} L{RDNAP7Tuple}. 

451 @kwarg lon: C{Scalar} (geodetic) longitude (C{degrees}) iff B{C{lat_latlonh}} 

452 is C{scalar}, ignored otherwise. 

453 @kwarg height: Optional height (C{meter}, conventionally) perpendicular to and 

454 above (or below) the ellipsoid's surface, iff B{C{lat_latlonh}} 

455 is C{scalar}, ignored otherwise. 

456 @kwarg name: Optional C{B{name}=NN} (C{str}). 

457 

458 @return: An L{RDNAP7Tuple}C{(RDx, RDy, NAPh, lat, lon, height, datum)} with 

459 C{NAPh} set to I{local} C{z}. 

460 

461 @see: C{pygeodesy.LqRD.forward} for more information. 

462 ''' 

463 t = _LqRD.forward(self, lat_latlonh, lon=lon, height=height) 

464 return LqRD._l9t2r7t(t, **name) 

465 

466 def reverse(self, x_xyz, y=None, z=None, **name): # PYCHOK signature 

467 '''Convert I{local} C{quasi-RD (x, y, z)} to I{geodetic} C{(lat, lon, height)}. 

468 

469 @arg x_xyz: Local C{quasi-RD x} coordinate (C{scalar}) or a I{local} 

470 C{quasi-RD} L{RDNAP7Tuple}. 

471 @kwarg y: Local C{quasi-RD y} coordinate (C{meter}) iff B{C{x_xyz}} is 

472 C{scalar}, ignored otherwise. 

473 @kwarg z: Local C{z} coordinate (C{meter}) iff B{C{x_xyz}} is C{scalar}, 

474 ignored otherwise. 

475 @kwarg name: Optional C{B{name}=NN} (C{str}). 

476 

477 @return: An L{RDNAP7Tuple}C{(RDx, RDy, NAPh, lat, lon, height, datum)} 

478 with C{NAPh} set to I{local} B{C{z}}. 

479 

480 @see: C{pygeodesy.LqRD.reverse} for more information. 

481 ''' 

482 t = _LqRD.reverse(self, x_xyz, y=y, z=z) 

483 return LqRD._l9t2r7t(t, **name) 

484 

485 @staticmethod 

486 def _l9t2r7t(t, name=NN, **unused): # M=False 

487 return RDNAP7Tuple(t.x, t.y, t.z, # NAPh = t.z 

488 t.lat, t.lon, t.height, t.ecef.datum, name=name or t.name) 

489 

490 

491__all__ += _all_OTHER(LqRD, RDNAP7Tuple, # passed along from PyGeodesy 

492 Bounds4Tuple, Datum, Datums, Ellipsoid, Ellipsoids, 

493 LatLon2Tuple, LatLon3Tuple, LatLon4Tuple, 

494 PhiLam2Tuple, PhiLam3Tuple, PhiLam4Tuple, 

495 Similarity, Vector2Tuple, Vector3Tuple) 

496del _all_OTHER, _LQRD0 

497 

498# **) MIT License 

499# 

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

501# 

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

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

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

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

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

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

508# 

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

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

511# 

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

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

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

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

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

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

518# OTHER DEALINGS IN THE SOFTWARE.