1

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

3

4 u'''(INTERNAL) Private ellipsoidal base classes C{CartesianEllipsoidalBase}

5 and C{LatLonEllipsoidalBase}.

6

7 A pure Python implementation of geodesy tools for ellipsoidal earth models,

8 transcoded in part from JavaScript originals by I{(C) Chris Veness 2005-2016}

9 and published under the same MIT Licence**, see for example U{latlon-ellipsoidal

10<https://www.Movable-Type.co.UK/scripts/geodesy/docs/latlon-ellipsoidal.js.html>}.

11'''

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

13 from __future__ import division as _; del _ # PYCHOK semicolon

14

15# from pygeodesy.basics import _xinstanceof # from .datums

16 from pygeodesy.constants import EPS, EPS0, EPS1, _0_0, _0_5

17 from pygeodesy.cartesianBase import CartesianBase, _ellipsoidal_ # PYCHOK used!

18 from pygeodesy.datums import Datum, Datums, _ellipsoidal_datum, \

19 _spherical_datum, _WGS84, _xinstanceof

20 from pygeodesy.errors import _incompatible, _IsnotError, RangeError, TRFError, \

21 _ValueError, _xellipsoidal, _xError, _xkwds, \

22 _xkwds_get, _xkwds_not

23# from pygeodesy.interns import _ellipsoidal_ # from .cartesianBase

24 from pygeodesy.interns import MISSING, NN, _COMMA_, _conversion_, _datum_, \

25 _DOT_, _no_, _reframe_, _SPACE_

26 from pygeodesy.latlonBase import fabs, LatLonBase, _trilaterate5, Vector3Tuple

27 from pygeodesy.lazily import _ALL_DOCS, _ALL_LAZY, _ALL_MODS as _MODS

28# from pygeodesy.lcc import toLcc # from ._MODS

29# from pygeodesy.named import notOverloaded # from ._MODS

30# from pygeodesy.namedTuples import Vector3Tuple # from .latlonBase

31 from pygeodesy.props import deprecated_method, deprecated_property_RO, \

32 Property_RO, property_doc_, property_RO, _update_all

33 from pygeodesy.units import Epoch, _1mm as _TOL_M, Radius_

34

35# from math import fabs # from .karney

36

37__all__ = _ALL_LAZY.ellipsoidalBase

38__version__ = '23.04.02'

39

40

41 class CartesianEllipsoidalBase(CartesianBase):

42 '''(INTERNAL) Base class for ellipsoidal C{Cartesian}s.

43 '''

44 _datum = _WGS84 # L{Datum}

45 _reframe = None

46

47# def __matmul__(self, other): # PYCHOK Python 3.5+

48# '''Return C{NotImplemented} for C{c_ = c @ datum}, C{c_ = c @ reframe} and C{c_ = c @ Transform}.

49# '''

50# RefFrame = _MODS.trf.RefFrame

51# return NotImplemented if isinstance(other, (Datum, RefFrame, Transform)) else \

52# _NotImplemented(self, other)

53

54 @deprecated_method

55 def convertRefFrame(self, reframe2, reframe, epoch=None):

56 '''DEPRECATED, use method L{toRefFrame}.'''

57 return self.toRefFrame(reframe2, reframe, epoch=epoch)

58

59 def intersections2(self, radius, center2, radius2, sphere=True,

60 Vector=None, **Vector_kwds):

61 '''Compute the intersection of two spheres or circles, each defined by a

62 cartesian center point and a radius.

63

64 @arg radius: Radius of this sphere or circle (same units as this point's

65 coordinates).

66 @arg center2: Center of the second sphere or circle (C{Cartesian}, L{Vector3d},

67 C{Vector3Tuple} or C{Vector4Tuple}).

68 @arg radius2: Radius of the second sphere or circle (same units as this and

69 the B{C{other}} point's coordinates).

70 @kwarg sphere: If C{True} compute the center and radius of the intersection

71 of two I{spheres}. If C{False}, ignore the C{z}-component and

72 compute the intersection of two I{circles} (C{bool}).

73 @kwarg Vector: Class to return intersections (C{Cartesian}, L{Vector3d} or

74 C{Vector3Tuple}) or C{None} for an instance of this (sub-)class.

75 @kwarg Vector_kwds: Optional, additional B{C{Vector}} keyword arguments,

76 ignored if C{B{Vector} is None}.

77

78 @return: If B{C{sphere}} is C{True}, a 2-tuple of the C{center} and C{radius}

79 of the intersection of the I{spheres}. The C{radius} is C{0.0} for

80 abutting spheres (and the C{center} is aka I{radical center}).

81

82 If B{C{sphere}} is C{False}, a 2-tuple with the two intersection

83 points of the I{circles}. For abutting circles, both points are

84 the same instance, aka I{radical center}.

85

86 @raise IntersectionError: Concentric, invalid or non-intersecting spheres or circles.

87

88 @raise TypeError: Invalid B{C{center2}}.

89

90 @raise UnitError: Invalid B{C{radius}} or B{C{radius2}}.

91

92 @see: U{Sphere-Sphere<https://MathWorld.Wolfram.com/Sphere-SphereIntersection.html>},

93 U{Circle-Circle<https://MathWorld.Wolfram.com/Circle-CircleIntersection.html>}

94 Intersection and function L{pygeodesy.radical2}.

95 '''

96 try:

97 return _MODS.vector3d._intersects2(self, Radius_(radius=radius),

98 center2, Radius_(radius2=radius2),

99 sphere=sphere, clas=self.classof,

100 Vector=Vector, **Vector_kwds)

101 except (TypeError, ValueError) as x:

102 raise _xError(x, center=self, radius=radius, center2=center2, radius2=radius2)

103

104 @property_doc_(''' this cartesian's reference frame (L{RefFrame}).''')

105 def reframe(self):

106 '''Get this cartesian's reference frame (L{RefFrame}) or C{None}.

107 '''

108 return self._reframe

109

110 @reframe.setter # PYCHOK setter!

111 def reframe(self, reframe):

112 '''Set or clear this cartesian's reference frame (L{RefFrame}) or C{None}.

113

114 @raise TypeError: The B{C{reframe}} is not a L{RefFrame}.

115 '''

116 _set_reframe(self, reframe)

117

118 def toRefFrame(self, reframe2, reframe=None, epoch=None):

119 '''Convert this cartesian point from one to an other reference frame.

120

121 @arg reframe2: Reference frame to convert I{to} (L{RefFrame}).

122 @arg reframe: Reference frame to convert I{from} (L{RefFrame}),

123 overriding this cartesian's C{reframe}.

124 @kwarg epoch: Optional epoch to observe (C{scalar}, fractional

125 calendar year), overriding B{C{reframe}}'s epoch.

126

127 @return: The converted point (C{Cartesian}) or this point if

128 conversion is C{nil}.

129

130 @raise TRFError: No conversion available from B{C{reframe}}

131 to B{C{reframe2}} or invalid B{C{epoch}}.

132

133 @raise TypeError: B{C{reframe2}} or B{C{reframe}} not a

134 L{RefFrame}.

135 '''

136 r = self.reframe if reframe is None else reframe

137 if r in (None, reframe2):

138 xs = None # XXX _set_reframe(self, reframe2)?

139 else:

140 trf = _MODS.trf

141 _xinstanceof(trf.RefFrame, reframe2=reframe2, reframe=r)

142 _, xs = trf._reframeTransforms2(reframe2, r, epoch)

143 return self.toTransforms_(*xs) if xs else self

144

145 def toTransforms_(self, *transforms, **datum):

146 '''Apply none, one or several Helmert transforms.

147

148 @arg transforms: Transforms to apply, in order (L{Transform}s).

149 @kwarg datum: Datum for the transformed point (L{Datum}),

150 overriding this point's datum.

151

152 @return: The transformed point (C{Cartesian}) or this point

153 if the B{C{transforms}} produce the same point.

154 '''

155 r = self

156 if transforms:

157 xyz = r.xyz

158 for t in transforms:

159 xyz = t.transform(*xyz)

160 d = _xkwds_get(datum, datum=r.datum)

161 if d != r.datum or xyz != r.xyz:

162 r = r.classof(xyz, datum=d)

163 return r

164

165

166 class LatLonEllipsoidalBase(LatLonBase):

167 '''(INTERNAL) Base class for ellipsoidal C{LatLon}s.

168 '''

169 _datum = _WGS84 # L{Datum}

170 _elevation2to = None # _elevation2 timeout (C{secs})

171 _epoch = None # overriding .reframe.epoch (C{float})

172 _gamma = None # UTM/UPS meridian convergence (C{degrees})

173 _geoidHeight2to = None # _geoidHeight2 timeout (C{secs})

174 _reframe = None # reference frame (L{RefFrame})

175 _scale = None # UTM/UPS scale factor (C{float})

176 _toLLEB_args = () # Etm/Utm/Ups._toLLEB arguments

177

178 def __init__(self, lat, lon, height=0, datum=None, reframe=None,

179 epoch=None, name=NN):

180 '''Create an ellipsoidal C{LatLon} point frome the given

181 lat-, longitude and height on the given datum and with

182 the given reference frame and epoch.

183

184 @arg lat: Latitude (C{degrees} or DMS C{[N|S]}).

185 @arg lon: Longitude (C{degrees} or DMS C{str[E|W]}).

186 @kwarg height: Optional elevation (C{meter}, the same units

187 as the datum's half-axes).

188 @kwarg datum: Optional, ellipsoidal datum to use (L{Datum},

189 L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}).

190 @kwarg reframe: Optional reference frame (L{RefFrame}).

191 @kwarg epoch: Optional epoch to observe for B{C{reframe}}

192 (C{scalar}), a non-zero, fractional calendar

193 year; silently ignored if C{B{reframe} is None}.

194 @kwarg name: Optional name (string).

195

196 @raise RangeError: Value of B{C{lat}} or B{C{lon}} outside the valid

197 range and C{rangerrors} set to C{True}.

198

199 @raise TypeError: B{C{datum}} is not a L{Datum}, B{C{reframe}}

200 is not a L{RefFrame} or B{C{epoch}} is not

201 C{scalar} non-zero.

202

203 @raise UnitError: Invalid B{C{lat}}, B{C{lon}} or B{C{height}}.

204

205 @example:

206

207 >>> p = LatLon(51.4778, -0.0016) # height=0, datum=Datums.WGS84

208 '''

209 LatLonBase.__init__(self, lat, lon, height=height, name=name)

210 if datum not in (None, self._datum):

211 self.datum = _ellipsoidal_datum(datum, name=name)

212 if reframe:

213 self.reframe = reframe

214 self.epoch = epoch

215

216# def __matmul__(self, other): # PYCHOK Python 3.5+

217# '''Return C{NotImplemented} for C{ll_ = ll @ datum} and C{ll_ = ll @ reframe}.

218# '''

219# RefFrame = _MODS.trf.RefFrame

220# return NotImplemented if isinstance(other, (Datum, RefFrame)) else \

221# _NotImplemented(self, other)

222

223 def antipode(self, height=None):

224 '''Return the antipode, the point diametrically opposite

225 to this point.

226

227 @kwarg height: Optional height of the antipode, height

228 of this point otherwise (C{meter}).

229

230 @return: The antipodal point (C{LatLon}).

231 '''

232 lla = LatLonBase.antipode(self, height=height)

233 if lla.datum != self.datum:

234 lla.datum = self.datum

235 return lla

236

237 @deprecated_property_RO

238 def convergence(self):

239 '''DEPRECATED, use property C{gamma}.'''

240 return self.gamma

241

242 @deprecated_method

243 def convertDatum(self, datum2):

244 '''DEPRECATED, use method L{toDatum}.'''

245 return self.toDatum(datum2)

246

247 @deprecated_method

248 def convertRefFrame(self, reframe2):

249 '''DEPRECATED, use method L{toRefFrame}.'''

250 return self.toRefFrame(reframe2)

251

252 @Property_RO

253 def _css(self):

254 '''(INTERNAL) Get this C{LatLon} point as a Cassini-Soldner location (L{Css}).

255 '''

256 css = _MODS.css

257 return css.toCss(self, height=self.height, Css=css.Css, name=self.name)

258

259 @property_doc_(''' this points's datum (L{Datum}).''')

260 def datum(self):

261 '''Get this point's datum (L{Datum}).

262 '''

263 return self._datum

264

265 @datum.setter # PYCHOK setter!

266 def datum(self, datum):

267 '''Set this point's datum I{without conversion} (L{Datum}).

268

269 @raise TypeError: The B{C{datum}} is not a L{Datum}

270 or not ellipsoidal.

271 '''

272 _xinstanceof(Datum, datum=datum)

273 if not datum.isEllipsoidal:

274 raise _IsnotError(_ellipsoidal_, datum=datum)

275 if self._datum != datum:

276 _update_all(self)

277 self._datum = datum

278

279 def distanceTo2(self, other):

280 '''I{Approximate} the distance and (initial) bearing between this

281 and an other (ellipsoidal) point based on the radii of curvature.

282

283 I{Suitable only for short distances up to a few hundred Km

284 or Miles and only between points not near-polar}.

285

286 @arg other: The other point (C{LatLon}).

287

288 @return: An L{Distance2Tuple}C{(distance, initial)}.

289

290 @raise TypeError: The B{C{other}} point is not C{LatLon}.

291

292 @raise ValueError: Incompatible datum ellipsoids.

293

294 @see: Method L{Ellipsoid.distance2} and U{Local, flat earth

295 approximation<https://www.EdWilliams.org/avform.htm#flat>}

296 aka U{Hubeny<https://www.OVG.AT/de/vgi/files/pdf/3781/>}

297 formula.

298 '''

299 return self.ellipsoids(other).distance2(self.lat, self.lon,

300 other.lat, other.lon)

301

302 @Property_RO

303 def _elevation2(self):

304 '''(INTERNAL) Get elevation and data source.

305 '''

306 return _MODS.elevations.elevation2(self.lat, self.lon,

307 timeout=self._elevation2to)

308

309 def elevation2(self, adjust=True, datum=None, timeout=2):

310 '''Return elevation of this point for its or the given datum, ellipsoid

311 or sphere.

312

313 @kwarg adjust: Adjust the elevation for a B{C{datum}} other than

314 C{NAD83} (C{bool}).

315 @kwarg datum: Optional datum overriding this point's datum (L{Datum},

316 L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple} or C{scalar}

317 radius).

318 @kwarg timeout: Optional query timeout (C{seconds}).

319

320 @return: An L{Elevation2Tuple}C{(elevation, data_source)} or

321 C{(None, error)} in case of errors.

322

323 @note: The adjustment applied is the difference in geocentric earth

324 radius between the B{C{datum}} and C{NAV83} upon which the

325 L{elevations.elevation2} is based.

326

327 @note: NED elevation is only available for locations within the

328 U{Conterminous US (CONUS)

329 <https://WikiPedia.org/wiki/Contiguous_United_States>}.

330

331 @see: Function L{elevations.elevation2} and method C{Ellipsoid.Rgeocentric}

332 for further details and possible C{error}s.

333 '''

334 if self._elevation2to != timeout:

335 self._elevation2to = timeout

336 LatLonEllipsoidalBase._elevation2._update(self)

337 return self._Radjust2(adjust, datum, self._elevation2)

338

339 def ellipsoid(self, datum=_WGS84):

340 '''Return the ellipsoid of this point's datum or the given datum.

341

342 @kwarg datum: Default datum (L{Datum}).

343

344 @return: The ellipsoid (L{Ellipsoid} or L{Ellipsoid2}).

345 '''

346 return getattr(self, _datum_, datum).ellipsoid

347

348 def ellipsoids(self, other):

349 '''Check the type and ellipsoid of this and an other point's datum.

350

351 @arg other: The other point (C{LatLon}).

352

353 @return: This point's datum ellipsoid (L{Ellipsoid} or L{Ellipsoid2}).

354

355 @raise TypeError: The B{C{other}} point is not C{LatLon}.

356

357 @raise ValueError: Incompatible datum ellipsoids.

358 '''

359 self.others(other, up=2) # ellipsoids' caller

360

361 E = self.ellipsoid()

362 try: # other may be Sphere, etc.

363 e = other.ellipsoid()

364 except AttributeError:

365 try: # no ellipsoid method, try datum

366 e = other.datum.ellipsoid

367 except AttributeError:

368 e = E # no datum, XXX assume equivalent?

369 if e != E:

370 raise _ValueError(e.named2, txt=_incompatible(E.named2))

371 return E

372

373 @property_doc_(''' this point's observed or C{reframe} epoch (C{float}).''')

374 def epoch(self):

375 '''Get this point's observed or C{reframe} epoch (C{float}) or C{None}.

376 '''

377 return self._epoch or (self.reframe.epoch if self.reframe else None)

378

379 @epoch.setter # PYCHOK setter!

380 def epoch(self, epoch):

381 '''Set or clear this point's observed epoch, a fractional

382 calendar year (L{Epoch}, C{scalar}) or C{None}.

383

384 @raise TRFError: Invalid B{C{epoch}}.

385 '''

386 self._epoch = None if epoch is None else Epoch(epoch)

387

388 @Property_RO

389 def Equidistant(self):

390 '''Get the prefered azimuthal equidistant projection I{class} (L{EquidistantKarney} or L{EquidistantExact}).

391 '''

392 try:

393 _ = self.datum.ellipsoid.geodesic

394 return _MODS.azimuthal.EquidistantKarney

395 except ImportError: # no geographiclib

396 return _MODS.azimuthal.EquidistantExact # XXX no longer L{azimuthal.Equidistant}

397

398 @Property_RO

399 def _etm(self):

400 '''(INTERNAL) Get this C{LatLon} point as an ETM coordinate (L{pygeodesy.toEtm8}).

401 '''

402 etm = _MODS.etm

403 return etm.toEtm8(self, datum=self.datum, Etm=etm.Etm)

404

405 @property_RO

406 def gamma(self):

407 '''Get this point's UTM or UPS meridian convergence (C{degrees}) or

408 C{None} if not available or not converted from L{Utm} or L{Ups}.

409 '''

410 return self._gamma

411

412 @Property_RO

413 def _geoidHeight2(self):

414 '''(INTERNAL) Get geoid height and model.

415 '''

416 return _MODS.elevations.geoidHeight2(self.lat, self.lon, model=0,

417 timeout=self._geoidHeight2to)

418

419 def geoidHeight2(self, adjust=False, datum=None, timeout=2):

420 '''Return geoid height of this point for its or the given datum, ellipsoid

421 or sphere.

422

423 @kwarg adjust: Adjust the geoid height for a B{C{datum}} other than

424 C{NAD83/NADV88} (C{bool}).

425 @kwarg datum: Optional datum overriding this point's datum (L{Datum},

426 L{Ellipsoid}, L{Ellipsoid2}, L{a_f2Tuple} or C{scalar}

427 radius).

428 @kwarg timeout: Optional query timeout (C{seconds}).

429

430 @return: A L{GeoidHeight2Tuple}C{(height, model_name)} or

431 C{(None, error)} in case of errors.

432

433 @note: The adjustment applied is the difference in geocentric earth

434 radius between the B{C{datum}} and C{NAV83/NADV88} upon which

435 the L{elevations.geoidHeight2} is based.

436

437 @note: The geoid height is only available for locations within the

438 U{Conterminous US (CONUS)

439 <https://WikiPedia.org/wiki/Contiguous_United_States>}.

440

441 @see: Function L{elevations.geoidHeight2} and method C{Ellipsoid.Rgeocentric}

442 for further details and possible C{error}s.

443 '''

444 if self._geoidHeight2to != timeout:

445 self._geoidHeight2to = timeout

446 LatLonEllipsoidalBase._geoidHeight2._update(self)

447 return self._Radjust2(adjust, datum, self._geoidHeight2)

448

449 def intermediateTo(self, other, fraction, height=None, wrap=False): # PYCHOK no cover

450 '''(INTERNAL) I{Must be overloaded}, see function C{notOverloaded}.

451 '''

452 _MODS.named.notOverloaded(self, other, fraction, height=height, wrap=wrap)

453

454 def intersection3(self, end1, other, end2, height=None, wrap=True,

455 equidistant=None, tol=_TOL_M):

456 '''Iteratively compute the intersection point of two paths, each

457 defined by two points or a start point and bearing from North.

458

459 @arg end1: End point of this path (C{LatLon}) or the initial

460 bearing at this point (compass C{degrees360}).

461 @arg other: Start point of the other path (C{LatLon}).

462 @arg end2: End point of the other path (C{LatLon}) or the

463 initial bearing at the other point (compass

464 C{degrees360}).

465 @kwarg height: Optional height at the intersection (C{meter},

466 conventionally) or C{None} for the mean height.

467 @kwarg wrap: Wrap and unroll longitudes (C{bool}).

468 @kwarg equidistant: An azimuthal equidistant projection (I{class} or

469 function L{pygeodesy.equidistant}), or C{None}

470 for this point's preferred C{.Equidistant}.

471 @kwarg tol: Tolerance for skew line distance and length and for

472 convergence (C{meter}, conventionally).

473

474 @return: An L{Intersection3Tuple}C{(point, outside1, outside2)}

475 with C{point} a C{LatLon} instance.

476

477 @raise ImportError: Package U{geographiclib

478 <https://PyPI.org/project/geographiclib>}

479 not installed or not found, but only if

480 C{B{equidistant}=}L{EquidistantKarney}.

481

482 @raise IntersectionError: Skew, colinear, parallel or otherwise

483 non-intersecting paths or no convergence

484 for the given B{C{tol}}.

485

486 @raise TypeError: If B{C{end1}}, B{C{other}} or B{C{end2}} point

487 is not C{LatLon}.

488

489 @note: For each path specified with an initial bearing, a pseudo-end

490 point is computed as the C{destination} along that bearing at

491 about 1.5 times the distance from the start point to an initial

492 gu-/estimate of the intersection point (and between 1/8 and 3/8

493 of the authalic earth perimeter).

494

495 @see: U{The B{ellipsoidal} case<https://GIS.StackExchange.com/questions/48937/

496 calculating-intersection-of-two-circles>} and U{Karney's paper

497 <https://ArXiv.org/pdf/1102.1215.pdf>}, pp 20-21, section B{14. MARITIME

498 BOUNDARIES} for more details about the iteration algorithm.

499 '''

500 try:

501 s2 = self.others(other)

502 return _MODS.ellipsoidalBaseDI._intersect3(self, end1,

503 s2, end2,

504 height=height, wrap=wrap,

505 equidistant=equidistant, tol=tol,

506 LatLon=self.classof, datum=self.datum)

507 except (TypeError, ValueError) as x:

508 raise _xError(x, start1=self, end1=end1, other=other, end2=end2,

509 height=height, wrap=wrap, tol=tol)

510

511 def intersections2(self, radius1, other, radius2, height=None, wrap=True,

512 equidistant=None, tol=_TOL_M):

513 '''Iteratively compute the intersection points of two circles,

514 each defined by a center point and a radius.

515

516 @arg radius1: Radius of this circle (C{meter}, conventionally).

517 @arg other: Center of the other circle (C{LatLon}).

518 @arg radius2: Radius of the other circle (C{meter}, same units as

519 B{C{radius1}}).

520 @kwarg height: Optional height for the intersection points (C{meter},

521 conventionally) or C{None} for the I{"radical height"}

522 at the I{radical line} between both centers.

523 @kwarg wrap: Wrap and unroll longitudes (C{bool}).

524 @kwarg equidistant: An azimuthal equidistant projection (I{class} or

525 function L{pygeodesy.equidistant}), or C{None}

526 for this point's preferred C{.Equidistant}.

527 @kwarg tol: Convergence tolerance (C{meter}, same units as

528 B{C{radius1}} and B{C{radius2}}).

529

530 @return: 2-Tuple of the intersection points, each a C{LatLon}

531 instance. For abutting circles, both intersection

532 points are the same instance, aka I{radical center}.

533

534 @raise ImportError: Package U{geographiclib

535 <https://PyPI.org/project/geographiclib>}

536 not installed or not found, but only if

537 C{B{equidistant}=}L{EquidistantKarney}.

538

539 @raise IntersectionError: Concentric, antipodal, invalid or

540 non-intersecting circles or no

541 convergence for the given B{C{tol}}.

542

543 @raise TypeError: Invalid B{C{other}} or B{C{equidistant}}.

544

545 @raise UnitError: Invalid B{C{radius1}}, B{C{radius2}} or B{C{height}}.

546

547 @see: U{The B{ellipsoidal} case<https://GIS.StackExchange.com/questions/48937/

548 calculating-intersection-of-two-circles>}, U{Karney's paper

549 <https://ArXiv.org/pdf/1102.1215.pdf>}, pp 20-21, section B{14. MARITIME BOUNDARIES},

550 U{circle-circle<https://MathWorld.Wolfram.com/Circle-CircleIntersection.html>} and

551 U{sphere-sphere<https://MathWorld.Wolfram.com/Sphere-SphereIntersection.html>}

552 intersections.

553 '''

554 try:

555 c2 = self.others(other)

556 return _MODS.ellipsoidalBaseDI._intersections2(self, radius1,

557 c2, radius2,

558 height=height, wrap=wrap,

559 equidistant=equidistant, tol=tol,

560 LatLon=self.classof, datum=self.datum)

561 except (AssertionError, TypeError, ValueError) as x:

562 raise _xError(x, center=self, radius1=radius1, other=other, radius2=radius2,

563 height=height, wrap=wrap, tol=tol)

564

565 @Property_RO

566 def isEllipsoidalLatLon(self):

567 '''Get C{LatLon} base.

568 '''

569 return True

570

571 def isenclosedBy(self, points, wrap=False):

572 '''Check whether a polygon or composite encloses this point.

573

574 @arg points: The polygon points or clips (C{LatLon}[],

575 L{BooleanFHP} or L{BooleanGH}).

576 @kwarg wrap: Wrap lat-, wrap and unroll longitudes (C{bool}).

577

578 @return: C{True} if this point is inside the polygon or composite,

579 C{False} otherwise.

580

581 @raise PointsError: Insufficient number of B{C{points}}.

582

583 @raise TypeError: Some B{C{points}} are not C{LatLon}.

584

585 @raise ValueError: Invalid B{C{point}}, lat- or longitude.

586

587 @see: Functions L{pygeodesy.isconvex}, L{pygeodesy.isenclosedBy}

588 and L{pygeodesy.ispolar} especially if the B{C{points}} may

589 enclose a pole or wrap around the earth I{longitudinally}.

590 '''

591 return _MODS.points.isenclosedBy(self, points, wrap=wrap)

592

593 @property_RO

594 def iteration(self):

595 '''Get the most recent C{intersections2} or C{nearestOn} iteration

596 number (C{int}) or C{None} if not available/applicable.

597 '''

598 return self._iteration

599

600 @Property_RO

601 def _lcc(self):

602 '''(INTERNAL) Get this C{LatLon} point as a Lambert location (L{Lcc}).

603 '''

604 lcc = _MODS.lcc

605 return lcc.toLcc(self, height=self.height, Lcc=lcc.Lcc, name=self.name)

606

607 def midpointTo(self, other, height=None, fraction=_0_5, wrap=False):

608 '''Find the midpoint on a geodesic between this and an other point.

609

610 @arg other: The other point (C{LatLon}).

611 @kwarg height: Optional height for midpoint, overriding the

612 mean height (C{meter}).

613 @kwarg fraction: Midpoint location from this point (C{scalar}),

614 may be negative or greater than 1.0.

615 @kwarg wrap: Wrap and unroll longitudes (C{bool}).

616

617 @return: Midpoint (C{LatLon}).

618

619 @raise TypeError: The B{C{other}} point is not C{LatLon}.

620

621 @raise ValueError: Invalid B{C{height}}.

622

623 @see: Methods C{intermediateTo} and C{rhumbMidpointTo}.

624 '''

625 return self.intermediateTo(other, fraction, height=height, wrap=wrap)

626

627 def nearestOn(self, point1, point2, within=True, height=None, wrap=True,

628 equidistant=None, tol=_TOL_M):

629 '''Iteratively locate the closest point on the geodesic between

630 two other (ellipsoidal) points.

631

632 @arg point1: Start point (C{LatLon}).

633 @arg point2: End point (C{LatLon}).

634 @kwarg within: If C{True} return the closest point I{between}

635 B{C{point1}} and B{C{point2}}, otherwise the

636 closest point elsewhere on the geodesic (C{bool}).

637 @kwarg height: Optional height for the closest point (C{meter},

638 conventionally) or C{None} or C{False} for the

639 interpolated height. If C{False}, the closest

640 takes the heights of the points into account.

641 @kwarg wrap: Wrap and unroll longitudes (C{bool}).

642 @kwarg equidistant: An azimuthal equidistant projection (I{class} or

643 function L{pygeodesy.equidistant}), or C{None}

644 for this point's preferred C{.Equidistant}.

645 @kwarg tol: Convergence tolerance (C{meter}, conventionally).

646

647 @return: Closest point (C{LatLon}).

648

649 @raise ImportError: Package U{geographiclib

650 <https://PyPI.org/project/geographiclib>}

651 not installed or not found, but only if

652 C{B{equidistant}=}L{EquidistantKarney}.

653

654 @raise TypeError: Invalid B{C{point1}}, B{C{point2}} or

655 B{C{equidistant}}.

656

657 @raise ValueError: Datum or ellipsoid of B{C{point1}} or B{C{point2}} is

658 incompatible or no convergence for the given B{C{tol}}.

659

660 @see: U{The B{ellipsoidal} case<https://GIS.StackExchange.com/questions/48937/

661 calculating-intersection-of-two-circles>} and U{Karney's paper

662 <https://ArXiv.org/pdf/1102.1215.pdf>}, pp 20-21, section B{14. MARITIME

663 BOUNDARIES} for details about the iteration algorithm.

664 '''

665 try:

666 t = _MODS.ellipsoidalBaseDI._nearestOn2(self, point1, point2, within=within,

667 height=height, wrap=wrap,

668 equidistant=equidistant,

669 tol=tol, LatLon=self.classof)

670 except (TypeError, ValueError) as x:

671 raise _xError(x, point=self, point1=point1, point2=point2, within=within,

672 height=height, wrap=wrap, tol=tol)

673 return t.closest

674

675 @Property_RO

676 def _osgr(self):

677 '''(INTERNAL) Get this C{LatLon} point as an OSGR coordinate (L{Osgr}),

678 based on the OS recommendation.

679 '''

680 return _MODS.osgr.toOsgr(self, kTM=False, name=self.name) # datum=self.datum

681

682 @Property_RO

683 def _osgrTM(self):

684 '''(INTERNAL) Get this C{LatLon} point as an OSGR coordinate (L{Osgr})

685 based on I{Karney}'s Krüger implementation.

686 '''

687 return _MODS.osgr.toOsgr(self, kTM=True, name=self.name) # datum=self.datum

688

689 def parse(self, strllh, height=0, datum=None, epoch=None, reframe=None,

690 sep=_COMMA_, name=NN):

691 '''Parse a string representing a similar, ellipsoidal C{LatLon}

692 point, consisting of C{"lat, lon[, height]"}.

693

694 @arg strllh: Lat, lon and optional height (C{str}),

695 see function L{pygeodesy.parse3llh}.

696 @kwarg height: Optional, default height (C{meter} or

697 C{None}).

698 @kwarg datum: Optional datum (L{Datum}), overriding this

699 datum I{without conversion}.

700 @kwarg epoch: Optional datum (L{Epoch}), overriding this

701 epoch I{without conversion}.

702 @kwarg reframe: Optional datum (L{RefFrame}), overriding

703 this reframe I{without conversion}.

704 @kwarg sep: Optional separator (C{str}).

705 @kwarg name: Optional instance name (C{str}), overriding

706 this name.

707

708 @return: The similar point (ellipsoidal C{LatLon}).

709

710 @raise ParseError: Invalid B{C{strllh}}.

711 '''

712 a, b, h = _MODS.dms.parse3llh(strllh, height=height, sep=sep)

713 r = self.classof(a, b, height=h, datum=self.datum)

714 if datum not in (None, self.datum):

715 r.datum = datum

716 if epoch not in (None, self.epoch):

717 r.epoch = epoch

718 if reframe not in (None, self.reframe):

719 r.reframe = reframe

720 return self._xnamed(r, name=name, force=True) if name else r

721

722 def _Radjust2(self, adjust, datum, meter_text2):

723 '''(INTERNAL) Adjust an C{elevation} or C{geoidHeight} with

724 difference in Gaussian radii of curvature of the given

725 datum and NAD83 ellipsoids at this point's latitude.

726

727 @note: This is an arbitrary, possibly incorrect adjustment.

728 '''

729 if adjust: # Elevation2Tuple or GeoidHeight2Tuple

730 m, t = meter_text2

731 if isinstance(m, float) and fabs(m) > EPS:

732 n = Datums.NAD83.ellipsoid.rocGauss(self.lat)

733 if n > EPS0:

734 # use ratio, datum and NAD83 units may differ

735 E = self.ellipsoid() if datum in (None, self.datum) else \

736 _spherical_datum(datum).ellipsoid

737 r = E.rocGauss(self.lat)

738 if r > EPS0 and fabs(r - n) > EPS: # EPS1

739 m *= r / n

740 meter_text2 = meter_text2.classof(m, t)

741 return self._xnamed(meter_text2)

742

743 @property_doc_(''' this point's reference frame (L{RefFrame}).''')

744 def reframe(self):

745 '''Get this point's reference frame (L{RefFrame}) or C{None}.

746 '''

747 return self._reframe

748

749 @reframe.setter # PYCHOK setter!

750 def reframe(self, reframe):

751 '''Set or clear this point's reference frame (L{RefFrame}) or C{None}.

752

753 @raise TypeError: The B{C{reframe}} is not a L{RefFrame}.

754 '''

755 _set_reframe(self, reframe)

756

757 @Property_RO

758 def scale(self):

759 '''Get this point's UTM grid or UPS point scale factor (C{float})

760 or C{None} if not converted from L{Utm} or L{Ups}.

761 '''

762 return self._scale

763

764 def toCss(self, **toCss_kwds):

765 '''Convert this C{LatLon} point to a Cassini-Soldner location.

766

767 @kwarg toCss_kwds: Optional L{pygeodesy.toCss} keyword arguments.

768

769 @return: The Cassini-Soldner location (L{Css}).

770

771 @see: Function L{pygeodesy.toCss}.

772 '''

773 return self._css if not toCss_kwds else _MODS.css.toCss(

774 self, **_xkwds(toCss_kwds, name=self.name))

775

776 def toDatum(self, datum2, height=None, name=NN):

777 '''Convert this point to an other datum.

778

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

780 @kwarg height: Optional height, overriding the

781 converted height (C{meter}).

782 @kwarg name: Optional name (C{str}), iff converted.

783

784 @return: The converted point (ellipsoidal C{LatLon})

785 or a copy of this point if B{C{datum2}}

786 matches this point's C{datum}.

787

788 @raise TypeError: Invalid B{C{datum2}}.

789

790 @example:

791

792 >>> p = LatLon(51.4778, -0.0016) # default Datums.WGS84

793 >>> p.toDatum(Datums.OSGB36) # 51.477284°N, 000.00002°E

794 '''

795 n = name or self.name

796 d2 = _ellipsoidal_datum(datum2, name=n)

797 if self.datum == d2:

798 r = self.copy(name=name)

799 else:

800 kwds = _xkwds_not(None, LatLon=self.classof, name=n,

801 epoch=self.epoch, reframe=self.reframe)

802 c = self.toCartesian().toDatum(d2)

803 r = c.toLatLon(datum=d2, height=height, **kwds)

804 return r

805

806 def toEtm(self, **toEtm8_kwds):

807 '''Convert this C{LatLon} point to an ETM coordinate.

808

809 @kwarg toEtm8_kwds: Optional L{pygeodesy.toEtm8} keyword arguments.

810

811 @return: The ETM coordinate (L{Etm}).

812

813 @see: Function L{pygeodesy.toEtm8}.

814 '''

815 return self._etm if not toEtm8_kwds else _MODS.etm.toEtm8(

816 self, **_xkwds(toEtm8_kwds, name=self.name))

817

818 def toLcc(self, **toLcc_kwds):

819 '''Convert this C{LatLon} point to a Lambert location.

820

821 @kwarg toLcc_kwds: Optional L{pygeodesy.toLcc} keyword arguments.

822

823 @return: The Lambert location (L{Lcc}).

824

825 @see: Function L{pygeodesy.toLcc}.

826 '''

827 return self._lcc if not toLcc_kwds else _MODS.lcc.toLcc(

828 self, **_xkwds(toLcc_kwds, name=self.name))

829

830 def toMgrs(self, center=False, pole=NN):

831 '''Convert this C{LatLon} point to an MGRS coordinate.

832

833 @kwarg center: If C{True}, try to I{un}-center MGRS

834 to its C{lowerleft} (C{bool}) or by

835 C{B{center} meter} (C{scalar}).

836 @kwarg pole: Optional top/center for the MGRS UPS

837 projection (C{str}, 'N[orth]' or 'S[outh]').

838

839 @return: The MGRS coordinate (L{Mgrs}).

840

841 @see: Method L{toUtmUps} and L{Mgrs.toLatLon}.

842 '''

843 return self.toUtmUps(center=center, pole=pole).toMgrs(center=False)

844

845 def toOsgr(self, kTM=False, **toOsgr_kwds):

846 '''Convert this C{LatLon} point to an OSGR coordinate.

847

848 @kwarg kTM: If C{True} use I{Karney}'s Krüger method from module

849 L{ktm}, otherwise I{Ordinance Survery}'s recommended

850 formulation (C{bool}).

851 @kwarg toOsgr_kwds: Optional L{pygeodesy.toOsgr} keyword arguments.

852

853 @return: The OSGR coordinate (L{Osgr}).

854

855 @see: Function L{pygeodesy.toOsgr}.

856 '''

857 if toOsgr_kwds:

858 r = _MODS.osgr.toOsgr(self, kTM=kTM, **_xkwds(toOsgr_kwds, name=self.name))

859 else:

860 r = self._osgrTM if kTM else self._osgr

861 return r

862

863 def toRefFrame(self, reframe2, height=None, name=NN):

864 '''Convert this point to an other reference frame.

865

866 @arg reframe2: Reference frame to convert I{to} (L{RefFrame}).

867 @kwarg height: Optional height, overriding the converted

868 height (C{meter}).

869 @kwarg name: Optional name (C{str}), iff converted.

870

871 @return: The converted point (ellipsoidal C{LatLon}) or this

872 point if conversion is C{nil}, or a copy of this

873 point if the B{C{name}} is non-empty.

874

875 @raise TRFError: This point's C{reframe} is not defined or

876 conversion from this point's C{reframe} to

877 B{C{reframe2}} is not available.

878

879 @raise TypeError: Invalid B{C{reframe2}}, not a L{RefFrame}.

880

881 @example:

882

883 >>> p = LatLon(51.4778, -0.0016, reframe=RefFrames.ETRF2000) # default Datums.WGS84

884 >>> p.toRefFrame(RefFrames.ITRF2014) # 51.477803°N, 000.001597°W, +0.01m

885 >>> p.toRefFrame(RefFrames.ITRF2014, height=0) # 51.477803°N, 000.001597°W

886 '''

887 if not self.reframe:

888 t = _SPACE_(_DOT_(repr(self), _reframe_), MISSING)

889 raise TRFError(_no_(_conversion_), txt=t)

890

891 trf = _MODS.trf

892 trf._xinstanceof(trf.RefFrame, reframe2=reframe2)

893

894 e, xs = trf._reframeTransforms2(reframe2, self.reframe, self.epoch)

895 if xs:

896 c = self.toCartesian().toTransforms_(*xs)

897 n = name or self.name

898 ll = c.toLatLon(datum=self.datum, epoch=e, height=height,

899 LatLon=self.classof, name=n, reframe=reframe2)

900 else:

901 ll = self.copy(name=name) if name else self

902 return ll

903

904 def toUps(self, pole=NN, falsed=True, center=False):

905 '''Convert this C{LatLon} point to a UPS coordinate.

906

907 @kwarg pole: Optional top/center of (stereographic)

908 projection (C{str}, 'N[orth]' or 'S[outh]').

909 @kwarg falsed: False easting and northing (C{bool}).

910 @kwarg center: If C{True}, I{un}-center the UPS

911 to its C{lowerleft} (C{bool}) or

912 by C{B{center} meter} (C{scalar}).

913

914 @return: The UPS coordinate (L{Ups}).

915

916 @see: Function L{pygeodesy.toUps8}.

917 '''

918 if self._upsOK(pole, falsed):

919 u = self._ups

920 else:

921 ups = _MODS.ups

922 u = ups.toUps8(self, datum=self.datum, Ups=ups.Ups,

923 pole=pole, falsed=falsed)

924 return _lowerleft(u, center)

925

926 def toUtm(self, center=False):

927 '''Convert this C{LatLon} point to a UTM coordinate.

928

929 @kwarg center: If C{True}, I{un}-center the UTM

930 to its C{lowerleft} (C{bool}) or

931 by C{B{center} meter} (C{scalar}).

932

933 @return: The UTM coordinate (L{Utm}).

934

935 @see: Method L{Mgrs.toUtm} and function L{pygeodesy.toUtm8}.

936 '''

937 return _lowerleft(self._utm, center)

938

939 def toUtmUps(self, pole=NN, center=False):

940 '''Convert this C{LatLon} point to a UTM or UPS coordinate.

941

942 @kwarg pole: Optional top/center of UPS (stereographic)

943 projection (C{str}, 'N[orth]' or 'S[outh]').

944 @kwarg center: If C{True}, I{un}-center the UTM or UPS to

945 its C{lowerleft} (C{bool}) or by C{B{center}

946 meter} (C{scalar}).

947

948 @return: The UTM or UPS coordinate (L{Utm} or L{Ups}).

949

950 @see: Function L{pygeodesy.toUtmUps8}.

951 '''

952 if self._utmOK():

953 u = self._utm

954 elif self._upsOK(pole):

955 u = self._ups

956 else: # no cover

957 utmups = _MODS.utmups

958 u = utmups.toUtmUps8(self, datum=self.datum, pole=pole, name=self.name,

959 Utm=utmups.Utm, Ups=utmups.Ups)

960 if isinstance(u, utmups.Utm):

961 self._update(False, _utm=u) # PYCHOK kwds

962 elif isinstance(u, utmups.Ups):

963 self._update(False, _ups=u) # PYCHOK kwds

964 else:

965 _xinstanceof(utmups.Utm, utmups.Ups, toUtmUps8=u)

966 return _lowerleft(u, center)

967

968 def toWm(self, **toWm_kwds):

969 '''Convert this C{LatLon} point to a WM coordinate.

970

971 @kwarg toWm_kwds: Optional L{pygeodesy.toWm} keyword arguments.

972

973 @return: The WM coordinate (L{Wm}).

974

975 @see: Function L{pygeodesy.toWm}.

976 '''

977 return self._wm if not toWm_kwds else _MODS.webmercator.toWm(

978 self, **_xkwds(toWm_kwds, name=self.name))

979

980 @deprecated_method

981 def to3xyz(self): # PYCHOK no cover

982 '''DEPRECATED, use method C{toEcef}.

983

984 @return: A L{Vector3Tuple}C{(x, y, z)}.

985

986 @note: Overloads C{LatLonBase.to3xyz}

987 '''

988 r = self.toEcef()

989 return Vector3Tuple(r.x, r.y, r.z, name=self.name)

990

991 def trilaterate5(self, distance1, point2, distance2, point3, distance3,

992 area=True, eps=EPS1, wrap=False):

993 '''Trilaterate three points by area overlap or perimeter intersection

994 of three intersecting circles.

995

996 @arg distance1: Distance to this point (C{meter}), same units

997 as B{C{eps}}).

998 @arg point2: Second center point (C{LatLon}).

999 @arg distance2: Distance to point2 (C{meter}, same units as

1000 B{C{eps}}).

1001 @arg point3: Third center point (C{LatLon}).

1002 @arg distance3: Distance to point3 (C{meter}, same units as

1003 B{C{eps}}).

1004 @kwarg area: If C{True} compute the area overlap, otherwise the

1005 perimeter intersection of the circles (C{bool}).

1006 @kwarg eps: The required I{minimal overlap} for C{B{area}=True}

1007 or the I{intersection margin} for C{B{area}=False}

1008 (C{meter}, conventionally).

1009 @kwarg wrap: Wrap/unroll angular distances (C{bool}).

1010

1011 @return: A L{Trilaterate5Tuple}C{(min, minPoint, max, maxPoint, n)}

1012 with C{min} and C{max} in C{meter}, same units as B{C{eps}},

1013 the corresponding trilaterated points C{minPoint} and

1014 C{maxPoint} as I{ellipsoidal} C{LatLon} and C{n}, the number

1015 of trilatered points found for the given B{C{eps}}.

1016

1017 If only a single trilaterated point is found, C{min I{is}

1018 max}, C{minPoint I{is} maxPoint} and C{n = 1}.

1019

1020 For C{B{area}=True}, C{min} and C{max} are the smallest

1021 respectively largest I{radial} overlap found.

1022

1023 For C{B{area}=False}, C{min} and C{max} represent the

1024 nearest respectively farthest intersection margin.

1025

1026 If C{B{area}=True} and all 3 circles are concentric, C{n=0}

1027 and C{minPoint} and C{maxPoint} are the B{C{point#}} with

1028 the smallest B{C{distance#}} C{min} respectively C{max} the

1029 largest B{C{distance#}}.

1030

1031 @raise IntersectionError: Trilateration failed for the given B{C{eps}},

1032 insufficient overlap for C{B{area}=True} or

1033 no intersection or all (near-)concentric for

1034 C{B{area}=False}.

1035

1036 @raise TypeError: Invalid B{C{point2}} or B{C{point3}}.

1037

1038 @raise ValueError: Coincident B{C{points}} or invalid B{C{distance1}},

1039 B{C{distance2}} or B{C{distance3}}.

1040

1041 @note: Ellipsoidal trilateration invokes methods C{LatLon.intersections2}

1042 and C{LatLon.nearestOn} based on I{Karney}'s Python U{geographiclib

1043 <https://PyPI.org/project/geographiclib>} if installed, otherwise

1044 uses the accurate (but slower) C{ellipsoidalExact.LatLon} methods.

1045 '''

1046 return _trilaterate5(self, distance1,

1047 self.others(point2=point2), distance2,

1048 self.others(point3=point3), distance3,

1049 area=area, eps=eps, wrap=wrap)

1050

1051 @Property_RO

1052 def _ups(self): # __dict__ value overwritten by method C{toUtmUps}

1053 '''(INTERNAL) Get this C{LatLon} point as UPS coordinate (L{Ups}),

1054 see L{pygeodesy.toUps8}.

1055 '''

1056 ups = _MODS.ups

1057 return ups.toUps8(self, datum=self.datum, Ups=ups.Ups,

1058 pole=NN, falsed=True, name=self.name)

1059

1060 def _upsOK(self, pole=NN, falsed=True):

1061 '''(INTERNAL) Check matching C{Ups}.

1062 '''

1063 try:

1064 u = self._ups

1065 except RangeError:

1066 return False

1067 return falsed and (u.pole == pole[:1].upper() or not pole)

1068

1069 @Property_RO

1070 def _utm(self): # __dict__ value overwritten by method C{toUtmUps}

1071 '''(INTERNAL) Get this C{LatLon} point as UTM coordinate (L{Utm}),

1072 see L{pygeodesy.toUtm8}.

1073 '''

1074 utm = _MODS.utm

1075 return utm.toUtm8(self, datum=self.datum, Utm=utm.Utm, name=self.name)

1076

1077 def _utmOK(self):

1078 '''(INTERNAL) Check C{Utm}.

1079 '''

1080 try:

1081 _ = self._utm

1082 except RangeError:

1083 return False

1084 return True

1085

1086 @Property_RO

1087 def _wm(self):

1088 '''(INTERNAL) Get this C{LatLon} point as webmercator (L{Wm}).

1089 '''

1090 return _MODS.webmercator.toWm(self)

1091

1092

1093 def _lowerleft(utmups, center):

1094 '''(INTERNAL) Optionally I{un}-center C{utmups}.

1095 '''

1096 if center in (False, 0, _0_0):

1097 u = utmups

1098 elif center in (True,):

1099 u = utmups._lowerleft

1100 else:

1101 u = _MODS.utmupsBase._lowerleft(utmups, center)

1102 return u

1103

1104

1105 def _nearestOn(point, point1, point2, within=True, height=None, wrap=True,

1106 equidistant=None, tol=_TOL_M, LatLon=None, **LatLon_kwds):

1107 '''(INTERNAL) Get closest point, imported by .ellipsoidalExact,

1108 -GeodSolve, -Karney and -Vincenty to embellish exceptions.

1109 '''

1110 try:

1111 p = _xellipsoidal(point=point)

1112 t = _MODS.ellipsoidalBaseDI._nearestOn2(p, point1, point2, within=within,

1113 height=height, wrap=wrap,

1114 equidistant=equidistant, tol=tol,

1115 LatLon=LatLon, **LatLon_kwds)

1116 except (TypeError, ValueError) as x:

1117 raise _xError(x, point=point, point1=point1, point2=point2)

1118 return t.closest

1119

1120

1121 def _set_reframe(inst, reframe):

1122 '''(INTERNAL) Set or clear an instance's reference frame.

1123 '''

1124 if reframe is not None:

1125 _xinstanceof(_MODS.trf.RefFrame, reframe=reframe)

1126 inst._reframe = reframe

1127 elif inst.reframe is not None:

1128 inst._reframe = None

1129

1130

1131__all__ += _ALL_DOCS(CartesianEllipsoidalBase, LatLonEllipsoidalBase)

1132

1133# **) MIT License

1134#

1135# Copyright (C) 2016-2023 -- mrJean1 at Gmail -- All Rights Reserved.

1136#

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

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

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

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

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

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

1143#

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

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

1146#

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

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

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

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

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

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

1153# OTHER DEALINGS IN THE SOFTWARE.