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.03.19'

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 @property_RO

572 def iteration(self):

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

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

575 '''

576 return self._iteration

577

578 @Property_RO

579 def _lcc(self):

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

581 '''

582 lcc = _MODS.lcc

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

584

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

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

587

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

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

590 mean height (C{meter}).

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

592 may be negative or greater than 1.0.

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

594

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

596

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

598

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

600

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

602 '''

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

604

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

606 equidistant=None, tol=_TOL_M):

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

608 two other (ellipsoidal) points.

609

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

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

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

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

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

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

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

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

618 takes the heights of the points into account.

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

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

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

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

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

624

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

626

627 @raise ImportError: Package U{geographiclib

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

629 not installed or not found, but only if

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

631

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

633 B{C{equidistant}}.

634

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

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

637

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

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

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

641 BOUNDARIES} for details about the iteration algorithm.

642 '''

643 try:

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

645 height=height, wrap=wrap,

646 equidistant=equidistant,

647 tol=tol, LatLon=self.classof)

648 except (TypeError, ValueError) as x:

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

650 height=height, wrap=wrap, tol=tol)

651 return t.closest

652

653 @Property_RO

654 def _osgr(self):

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

656 based on the OS recommendation.

657 '''

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

659

660 @Property_RO

661 def _osgrTM(self):

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

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

664 '''

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

666

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

668 sep=_COMMA_, name=NN):

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

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

671

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

673 see function L{pygeodesy.parse3llh}.

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

675 C{None}).

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

677 datum I{without conversion}.

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

679 epoch I{without conversion}.

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

681 this reframe I{without conversion}.

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

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

684 this name.

685

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

687

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

689 '''

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

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

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

693 r.datum = datum

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

695 r.epoch = epoch

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

697 r.reframe = reframe

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

699

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

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

702 difference in Gaussian radii of curvature of the given

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

704

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

706 '''

707 if adjust: # Elevation2Tuple or GeoidHeight2Tuple

708 m, t = meter_text2

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

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

711 if n > EPS0:

712 # use ratio, datum and NAD83 units may differ

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

714 _spherical_datum(datum).ellipsoid

715 r = E.rocGauss(self.lat)

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

717 m *= r / n

718 meter_text2 = meter_text2.classof(m, t)

719 return self._xnamed(meter_text2)

720

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

722 def reframe(self):

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

724 '''

725 return self._reframe

726

727 @reframe.setter # PYCHOK setter!

728 def reframe(self, reframe):

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

730

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

732 '''

733 _set_reframe(self, reframe)

734

735 @Property_RO

736 def scale(self):

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

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

739 '''

740 return self._scale

741

742 def toCss(self, **toCss_kwds):

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

744

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

746

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

748

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

750 '''

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

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

753

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

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

756

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

758 @kwarg height: Optional height, overriding the

759 converted height (C{meter}).

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

761

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

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

764 matches this point's C{datum}.

765

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

767

768 @example:

769

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

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

772 '''

773 n = name or self.name

774 d2 = _ellipsoidal_datum(datum2, name=n)

775 if self.datum == d2:

776 r = self.copy(name=name)

777 else:

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

779 epoch=self.epoch, reframe=self.reframe)

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

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

782 return r

783

784 def toEtm(self, **toEtm8_kwds):

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

786

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

788

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

790

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

792 '''

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

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

795

796 def toLcc(self, **toLcc_kwds):

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

798

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

800

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

802

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

804 '''

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

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

807

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

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

810

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

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

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

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

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

816

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

818

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

820 '''

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

822

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

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

825

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

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

828 formulation (C{bool}).

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

830

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

832

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

834 '''

835 if toOsgr_kwds:

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

837 else:

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

839 return r

840

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

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

843

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

845 @kwarg height: Optional height, overriding the converted

846 height (C{meter}).

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

848

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

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

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

852

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

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

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

856

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

858

859 @example:

860

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

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

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

864 '''

865 if not self.reframe:

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

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

868

869 trf = _MODS.trf

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

871

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

873 if xs:

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

875 n = name or self.name

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

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

878 else:

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

880 return ll

881

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

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

884

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

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

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

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

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

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

891

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

893

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

895 '''

896 if self._upsOK(pole, falsed):

897 u = self._ups

898 else:

899 ups = _MODS.ups

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

901 pole=pole, falsed=falsed)

902 return _lowerleft(u, center)

903

904 def toUtm(self, center=False):

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

906

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

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

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

910

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

912

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

914 '''

915 return _lowerleft(self._utm, center)

916

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

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

919

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

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

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

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

924 meter} (C{scalar}).

925

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

927

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

929 '''

930 if self._utmOK():

931 u = self._utm

932 elif self._upsOK(pole):

933 u = self._ups

934 else: # no cover

935 utmups = _MODS.utmups

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

937 Utm=utmups.Utm, Ups=utmups.Ups)

938 if isinstance(u, utmups.Utm):

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

940 elif isinstance(u, utmups.Ups):

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

942 else:

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

944 return _lowerleft(u, center)

945

946 def toWm(self, **toWm_kwds):

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

948

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

950

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

952

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

954 '''

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

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

957

958 @deprecated_method

959 def to3xyz(self): # PYCHOK no cover

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

961

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

963

964 @note: Overloads C{LatLonBase.to3xyz}

965 '''

966 r = self.toEcef()

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

968

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

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

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

972 of three intersecting circles.

973

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

975 as B{C{eps}}).

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

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

978 B{C{eps}}).

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

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

981 B{C{eps}}).

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

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

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

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

986 (C{meter}, conventionally).

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

988

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

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

991 the corresponding trilaterated points C{minPoint} and

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

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

994

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

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

997

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

999 respectively largest I{radial} overlap found.

1000

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

1002 nearest respectively farthest intersection margin.

1003

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

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

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

1007 largest B{C{distance#}}.

1008

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

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

1011 no intersection or all (near-)concentric for

1012 C{B{area}=False}.

1013

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

1015

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

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

1018

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

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

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

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

1023 '''

1024 return _trilaterate5(self, distance1,

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

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

1027 area=area, eps=eps, wrap=wrap)

1028

1029 @Property_RO

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

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

1032 see L{pygeodesy.toUps8}.

1033 '''

1034 ups = _MODS.ups

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

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

1037

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

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

1040 '''

1041 try:

1042 u = self._ups

1043 except RangeError:

1044 return False

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

1046

1047 @Property_RO

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

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

1050 see L{pygeodesy.toUtm8}.

1051 '''

1052 utm = _MODS.utm

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

1054

1055 def _utmOK(self):

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

1057 '''

1058 try:

1059 _ = self._utm

1060 except RangeError:

1061 return False

1062 return True

1063

1064 @Property_RO

1065 def _wm(self):

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

1067 '''

1068 return _MODS.webmercator.toWm(self)

1069

1070

1071 def _lowerleft(utmups, center):

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

1073 '''

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

1075 u = utmups

1076 elif center in (True,):

1077 u = utmups._lowerleft

1078 else:

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

1080 return u

1081

1082

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

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

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

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

1087 '''

1088 try:

1089 p = _xellipsoidal(point=point)

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

1091 height=height, wrap=wrap,

1092 equidistant=equidistant, tol=tol,

1093 LatLon=LatLon, **LatLon_kwds)

1094 except (TypeError, ValueError) as x:

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

1096 return t.closest

1097

1098

1099 def _set_reframe(inst, reframe):

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

1101 '''

1102 if reframe is not None:

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

1104 inst._reframe = reframe

1105 elif inst.reframe is not None:

1106 inst._reframe = None

1107

1108

1109__all__ += _ALL_DOCS(CartesianEllipsoidalBase, LatLonEllipsoidalBase)

1110

1111# **) MIT License

1112#

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

1114#

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

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

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

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

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

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

1121#

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

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

1124#

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

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

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

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

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

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

1131# OTHER DEALINGS IN THE SOFTWARE.