# Coverage for pygeodesy/ellipsoidalVincenty.py : 97%

## 148 statements 144 run 4 missing 5 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | # -*- coding: utf-8 -*- u'''Vincenty's geodetic (lat-/longitude) L{LatLon}, geocentric (ECEF) L{Cartesian} amd L{VincentyError} classes and functions L{areaOf} and L{perimeterOf}, I{all ellipsoidal}. Pure Python implementation of geodesy tools for ellipsoidal earth models, transcribed from JavaScript originals by I{(C) Chris Veness 2005-2016} and published under the same MIT Licence**, see U{Vincenty geodesics <https://www.Movable-Type.co.UK/scripts/LatLongVincenty.html>}. More at U{GeographicLib<https://PyPI.org/project/geographiclib>} and U{GeoPy<https://PyPI.org/project/geopy>}. Calculate geodesic distance between two points using the U{Vincenty <https://WikiPedia.org/wiki/Vincenty's_formulae>} formulae and one of several ellipsoidal earth models. The default model is WGS-84, the most accurate and widely used globally-applicable model for the earth ellipsoid. Other ellipsoids offering a better fit to the local geoid include Airy (1830) in the UK, Clarke (1880) in Africa, International 1924 in much of Europe, and GRS-67 in South America. North America (NAD83) and Australia (GDA) use GRS-80, which is equivalent to the WGS-84 model. Great-circle distance uses a spherical model of the earth with the mean earth radius defined by the International Union of Geodesy and Geophysics (IUGG) as M{(2 * a + b) / 3 = 6371008.7714150598} meter or approx. 6371009 meter (for WGS-84, resulting in an error of up to about 0.5%). Here's an example usage of C{ellipsoidalVincenty}: >>> from pygeodesy.ellipsoidalVincenty import LatLon >>> Newport_RI = LatLon(41.49008, -71.312796) >>> Cleveland_OH = LatLon(41.499498, -81.695391) >>> Newport_RI.distanceTo(Cleveland_OH) 866,455.4329158525 # meter You can change the ellipsoid model used by the Vincenty formulae as follows: >>> from pygeodesy import Datums >>> from pygeodesy.ellipsoidalVincenty import LatLon >>> p = LatLon(0, 0, datum=Datums.OSGB36) or by converting to anothor datum: >>> p = p.convertDatum(Datums.OSGB36) @newfield example: Example, Examples ''' # make sure int division yields float quotient from __future__ import division division = 1 / 2 # double check int division, see .datum.py if not division: raise ImportError('%s 1/2 == %d' % ('division', division)) del division from pygeodesy.datum import Datums from pygeodesy.ecef import EcefVeness from pygeodesy.ellipsoidalBase import CartesianEllipsoidalBase, \ LatLonEllipsoidalBase from pygeodesy.fmath import EPS, fpolynomial, hypot, hypot1, scalar from pygeodesy.lazily import _ALL_LAZY, _2kwds from pygeodesy.named import Bearing2Tuple, Destination2Tuple, Distance3Tuple from pygeodesy.points import ispolar # PYCHOK exported from pygeodesy.utily import degrees90, degrees180, degrees360, sincos2, unroll180 from math import atan2, cos, radians, tan # all public contants, classes and functions __all__ = _ALL_LAZY.ellipsoidalVincenty + ( 'Cartesian', 'LatLon', 'ispolar') # from .points __version__ = '20.01.22' class VincentyError(ValueError): '''Error raised from Vincenty's direct and inverse methods for coincident points or lack of convergence. ''' pass class Cartesian(CartesianEllipsoidalBase): '''Extended to convert geocentric, L{Cartesian} points to Vincenty-based, ellipsoidal, geodetic L{LatLon}. ''' def toLatLon(self, **kwds): # PYCHOK LatLon=LatLon, datum=None '''Convert this cartesian point to a C{Vincenty}-based geodetic point. @keyword kwds: Optional, additional B{C{LatLon}} keyword arguments, ignored if C{B{LatLon}=None}. For example, use C{LatLon=...} to override the L{LatLon} (sub-)class or specify C{B{LatLon}=None}. @return: The B{C{LatLon}} point (L{LatLon}) or if C{B{LatLon}=None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C, M, datum)} with C{C} and C{M} if available. @raise TypeError: Invalid B{C{LatLon}}, B{C{datum}} or B{C{kwds}}. ''' kwds = _2kwds(kwds, LatLon=LatLon, datum=self.datum) return CartesianEllipsoidalBase.toLatLon(self, **kwds) class LatLon(LatLonEllipsoidalBase): '''Using the formulae devised by Thaddeus Vincenty (1975) with an ellipsoidal model of the earth to compute the geodesic distance and bearings between two given points or the destination point given an start point and initial bearing. Set the earth model to be used with the keyword argument datum. The default is Datums.WGS84, which is the most globally accurate. For other models, see the Datums in module datum. Note: This implementation of the Vincenty methods may not converge for some valid points, raising a VincentyError. In that case, a result may be obtained by increasing the epsilon and/or the iteration limit, see properties L{LatLon.epsilon} and L{LatLon.iterations}. ''' _Ecef = EcefVeness #: (INTERNAL) Preferred C{Ecef...} class, backward compatible. _epsilon = 1.0e-12 # about 0.006 mm _iterations = 50 def bearingTo(self, other, wrap=False): '''DEPRECATED, use method C{initialBearingTo}. ''' return self.initialBearingTo(other, wrap=wrap) def bearingTo2(self, other, wrap=False): '''Compute the initial and final bearing (forward and reverse azimuth) from this to an other point, using Vincenty's inverse method. See methods L{initialBearingTo} and L{finalBearingTo} for more details. @param other: The other point (L{LatLon}). @keyword wrap: Wrap and unroll longitudes (C{bool}). @return: A L{Bearing2Tuple}C{(initial, final)}.. @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit and/or if this and the B{C{other}} point are coincident or near-antipodal. ''' r = Bearing2Tuple(*self._inverse(other, True, wrap)[1:]) return self._xnamed(r) def destination(self, distance, bearing, height=None): '''Compute the destination point after having travelled for the given distance from this point along a geodesic given by an initial bearing, using Vincenty's direct method. See method L{destination2} for more details. @param distance: Distance (C{meter}). @param bearing: Initial bearing (compass C{degrees360}). @keyword height: Optional height, overriding the default height (C{meter}, same units as C{distance}). @return: The destination point (L{LatLon}). @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit. @example: >>> p = LatLon(-37.95103, 144.42487) >>> d = p.destination(54972.271, 306.86816) # 37.6528°S, 143.9265°E ''' return self._direct(distance, bearing, True, height=height)[0] def destination2(self, distance, bearing, height=None): '''Compute the destination point and the final bearing (reverse azimuth) after having travelled for the given distance from this point along a geodesic given by an initial bearing, using Vincenty's direct method. The distance must be in the same units as this point's datum axes, conventionally meter. The distance is measured on the surface of the ellipsoid, ignoring this point's height. The initial and final bearing (forward and reverse azimuth) are in compass degrees. The destination point's height and datum are set to this point's height and datum. @param distance: Distance (C{meter}). @param bearing: Initial bearing (compass C{degrees360}). @keyword height: Optional height, overriding the default height (C{meter}, same units as B{C{distance}}). @return: A L{Destination2Tuple}C{(destination, final)}. @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit. @example: >>> p = LatLon(-37.95103, 144.42487) >>> b = 306.86816 >>> d, f = p.destination2(54972.271, b) # 37.652818°S, 143.926498°E, 307.1736 ''' r = Destination2Tuple(*self._direct(distance, bearing, True, height=height)) return self._xnamed(r) def distanceTo(self, other, wrap=False): '''Compute the distance between this and an other point along a geodesic, using Vincenty's inverse method. See method L{distanceTo3} for more details. @param other: The other point (L{LatLon}). @keyword wrap: Wrap and unroll longitudes (C{bool}). @return: Distance (C{meter}). @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit and/or if this and the B{C{other}} point are coincident or near-antipodal. @example: >>> p = LatLon(50.06632, -5.71475) >>> q = LatLon(58.64402, -3.07009) >>> d = p.distanceTo(q) # 969,954.166 m ''' return self._inverse(other, False, wrap) def distanceTo3(self, other, wrap=False): '''Compute the distance, the initial and final bearing along a geodesic between this and an other point, using Vincenty's inverse method. The distance is in the same units as this point's datum axes, conventially meter. The distance is measured on the surface of the ellipsoid, ignoring this point's height. The initial and final bearing (forward and reverse azimuth) are in compass degrees from North. @param other: Destination point (L{LatLon}). @keyword wrap: Wrap and unroll longitudes (C{bool}). @return: A L{Distance3Tuple}C{(distance, initial, final)}. @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit and/or if this and the B{C{other}} point are coincident or near-antipodal. ''' r = Distance3Tuple(*self._inverse(other, True, wrap)) return self._xnamed(r) @property def epsilon(self): '''Get the convergence epsilon (scalar). ''' return self._epsilon @epsilon.setter # PYCHOK setter! def epsilon(self, eps): '''Set the convergence epsilon. @param eps: New epsilon (scalar). @raise TypeError: Non-scalar B{C{eps}}. @raise ValueError: Out of bounds B{C{eps}}. ''' self._epsilon = scalar(eps, name='epsilon') def finalBearingOn(self, distance, bearing): '''Compute the final bearing (reverse azimuth) after having travelled for the given distance along a geodesic given by an initial bearing from this point, using Vincenty's direct method. See method L{destination2} for more details. @param distance: Distance (C{meter}). @param bearing: Initial bearing (compass C{degrees360}). @return: Final bearing (compass C{degrees360}). @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit. @example: >>> p = LatLon(-37.95103, 144.42487) >>> b = 306.86816 >>> f = p.finalBearingOn(54972.271, b) # 307.1736 ''' return self._direct(distance, bearing, False) def finalBearingTo(self, other, wrap=False): '''Compute the final bearing (reverse azimuth) after having travelled along a geodesic from this point to an other point, using Vincenty's inverse method. See method L{distanceTo3} for more details. @param other: The other point (L{LatLon}). @keyword wrap: Wrap and unroll longitudes (C{bool}). @return: Final bearing (compass C{degrees360}). @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit and/or if this and the B{C{other}} point are coincident or near-antipodal. @example: >>> p = new LatLon(50.06632, -5.71475) >>> q = new LatLon(58.64402, -3.07009) >>> f = p.finalBearingTo(q) # 11.2972° >>> p = LatLon(52.205, 0.119) >>> q = LatLon(48.857, 2.351) >>> f = p.finalBearingTo(q) # 157.9 ''' return self._inverse(other, True, wrap)[2] def initialBearingTo(self, other, wrap=False): '''Compute the initial bearing (forward azimuth) to travel along a geodesic from this point to an other point, using Vincenty's inverse method. See method L{distanceTo3} for more details. @param other: The other point (L{LatLon}). @keyword wrap: Wrap and unroll longitudes (C{bool}). @return: Initial bearing (compass C{degrees360}). @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit and/or if this and the B{C{other}} point are coincident or near-antipodal. @example: >>> p = LatLon(50.06632, -5.71475) >>> q = LatLon(58.64402, -3.07009) >>> b = p.initialBearingTo(q) # 9.141877° >>> p = LatLon(52.205, 0.119) >>> q = LatLon(48.857, 2.351) >>> b = p.initialBearingTo(q) # 156.11064° @JSname: I{bearingTo}. ''' return self._inverse(other, True, wrap)[1] @property def iterations(self): '''Get the iteration limit (C{int}). ''' return self._iterations @iterations.setter # PYCHOK setter! def iterations(self, limit): '''Set the iteration limit. @param limit: New iteration limit (scalar). @raise TypeError: Non-scalar B{C{limit}}. @raise ValueError: Out-of-bounds B{C{limit}}. ''' self._iterations = scalar(limit, 4, 200, name='limit') def toCartesian(self, **kwds): # PYCHOK Cartesian=Cartesian, datum=None '''Convert this point to C{Vincenty}-based cartesian (ECEF) coordinates. @keyword kwds: Optional, additional B{C{Cartesian}} keyword arguments, ignored if C{B{Cartesian}=None}. For example, use C{Cartesian=...} to override the L{Cartesian} (sub-)class or specify C{B{Cartesian}=None}. @return: The B{C{Cartesian}} point (L{Cartesian}) or if C{B{Cartesian}=None}, an L{Ecef9Tuple}C{(x, y, z, lat, lon, height, C, M, datum)} with C{C} and C{M} if available. @raise TypeError: Invalid B{C{Cartesian}}, B{C{datum}} or B{C{kwds}}. ''' kwds = _2kwds(kwds, Cartesian=Cartesian, datum=self.datum) return LatLonEllipsoidalBase.toCartesian(self, **kwds) def _direct(self, distance, bearing, llr, height=None): '''(INTERNAL) Direct Vincenty method. @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit. ''' E = self.ellipsoid() c1, s1, t1 = _r3(self.lat, E.f) i = radians(bearing) # initial bearing (forward azimuth) si, ci = sincos2(i) s12 = atan2(t1, ci) * 2 sa = c1 * si c2a = 1 - sa**2 if c2a < EPS: c2a = 0 A, B = 1, 0 else: # e22 == (a / b)**2 - 1 A, B = _p2(c2a * E.e22) s = d = distance / (E.b * A) for _ in range(self._iterations): ss, cs = sincos2(s) c2sm = cos(s12 + s) s_, s = s, d + _ds(B, cs, ss, c2sm) if abs(s - s_) < self._epsilon: break else: raise VincentyError('%s, %r' % ('no convergence', self)) t = s1 * ss - c1 * cs * ci # final bearing (reverse azimuth +/- 180) r = degrees360(atan2(sa, -t)) if llr: # destination latitude in [-90, 90) a = degrees90(atan2(s1 * cs + c1 * ss * ci, (1 - E.f) * hypot(sa, t))) # destination longitude in [-180, 180) b = degrees180(atan2(ss * si, c1 * cs - s1 * ss * ci) - _dl(E.f, c2a, sa, s, cs, ss, c2sm) + radians(self.lon)) h = self.height if height is None else height r = self.classof(a, b, height=h, datum=self.datum), r return r def _inverse(self, other, azis, wrap): '''(INTERNAL) Inverse Vincenty method. @raise TypeError: The B{C{other}} point is not L{LatLon}. @raise ValueError: If this and the B{C{other}} point's L{Datum} ellipsoids are not compatible. @raise VincentyError: Vincenty fails to converge for the current L{LatLon.epsilon} and L{LatLon.iterations} limit and/or if this and the B{C{other}} point are coincident or near-antipodal. ''' E = self.ellipsoids(other) c1, s1, _ = _r3(self.lat, E.f) c2, s2, _ = _r3(other.lat, E.f) c1c2, s1c2 = c1 * c2, s1 * c2 c1s2, s1s2 = c1 * s2, s1 * s2 dl, _ = unroll180(self.lon, other.lon, wrap=wrap) ll = dl = radians(dl) for _ in range(self._iterations): ll_ = ll sll, cll = sincos2(ll) ss = hypot(c2 * sll, c1s2 - s1c2 * cll) if ss < EPS: # coincident or antipodal, ... if self.isantipodeTo(other, eps=self._epsilon): raise VincentyError('%s, %r %sto %r' % ('ambiguous', self, 'antipodal ', other)) d = 0.0 # like Karney, ... if azis: # return zeros d = d, 0, 0 return d cs = s1s2 + c1c2 * cll s = atan2(ss, cs) sa = c1c2 * sll / ss c2a = 1 - sa**2 if abs(c2a) < EPS: c2a = 0 # equatorial line ll = dl + E.f * sa * s else: c2sm = cs - 2 * s1s2 / c2a ll = dl + _dl(E.f, c2a, sa, s, cs, ss, c2sm) if abs(ll - ll_) < self._epsilon: break # # omitted and applied only after failure to converge below, see footnote # # under Inverse at <https://WikiPedia.org/wiki/Vincenty's_formulae> # # <https://GitHub.com/ChrisVeness/geodesy/blob/master/latlon-vincenty.js> # elif abs(ll) > PI and self.isantipodeTo(other, eps=self._epsilon): # raise VincentyError('%s, %r %sto %r' % ('ambiguous', self, # 'antipodal ', other)) else: t = 'antipodal ' if self.isantipodeTo(other, eps=self._epsilon) else '' raise VincentyError('%s, %r %sto %r' % ('no convergence', self, t, other)) if c2a: # e22 == (a / b)**2 - 1 A, B = _p2(c2a * E.e22) s = A * (s - _ds(B, cs, ss, c2sm)) b = E.b # if self.height or other.height: # b += self._havg(other) d = b * s if azis: # forward and reverse azimuth sll, cll = sincos2(ll) f = degrees360(atan2(c2 * sll, c1s2 - s1c2 * cll)) r = degrees360(atan2(c1 * sll, -s1c2 + c1s2 * cll)) d = d, f, r return d def _dl(f, c2a, sa, s, cs, ss, c2sm): '''(INTERNAL) Dl. ''' C = f / 16.0 * c2a * (4 + f * (4 - 3 * c2a)) return (1 - C) * f * sa * (s + C * ss * (c2sm + C * cs * (2 * c2sm**2 - 1))) def _ds(B, cs, ss, c2sm): '''(INTERNAL) Ds. ''' c2sm2 = 2 * c2sm**2 - 1 ss2 = (4 * ss**2 - 3) * (2 * c2sm2 - 1) return B * ss * (c2sm + B / 4.0 * (c2sm2 * cs - B / 6.0 * c2sm * ss2)) def _p2(u2): # e'2 WGS84 = 0.00673949674227643 '''(INTERNAL) Compute A, B polynomials. ''' A = fpolynomial(u2, 16384, 4096, -768, 320, -175) / 16384 B = fpolynomial(u2, 0, 256, -128, 74, -47) / 1024 return A, B def _r3(a, f): '''(INTERNAL) Reduced cos, sin, tan. ''' t = (1 - f) * tan(radians(a)) c = 1 / hypot1(t) s = t * c return c, s, t def areaOf(points, datum=Datums.WGS84, wrap=True): '''DEPRECATED, use function C{ellipsoidalKarney.areaOf}. ''' from pygeodesy.ellipsoidalKarney import areaOf return areaOf(points, datum=datum, wrap=wrap) def perimeterOf(points, closed=False, datum=Datums.WGS84, wrap=True): '''DEPRECATED, use function C{ellipsoidalKarney.perimeterOf}. ''' from pygeodesy.ellipsoidalKarney import perimeterOf return perimeterOf(points, closed=closed, datum=datum, wrap=wrap) # **) MIT License # # Copyright (C) 2016-2020 -- mrJean1 at Gmail -- All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE.