Coverage for pygeodesy/hausdorff.py : 96%

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
# -*- coding: utf-8 -*-
Classes L{Hausdorff}, L{HausdorffDegrees}, L{HausdorffRadians}, L{HausdorffCosineAndoyerLambert}, L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffCosineLaw}, L{HausdorffDistanceTo}, L{HausdorffEquirectangular}, L{HausdorffEuclidean}, L{HausdorffFlatLocal}, L{HausdorffFlatPolar}, L{HausdorffHaversine}, L{HausdorffHubeny}, L{HausdorffKarney}, L{HausdorffThomas} and L{HausdorffVincentys} to compute U{Hausdorff <https://WikiPedia.org/wiki/Hausdorff_distance>} distances between two sets of C{LatLon}, C{NumPy}, C{tuples} or other types of points.
Only L{HausdorffDistanceTo} -iff used with L{ellipsoidalKarney.LatLon} points- and L{HausdorffKarney} requires installation of I{Charles Karney}'s U{geographiclib<https://PyPI.org/project/geographiclib>}.
Typical usage is as follows. First, create a C{Hausdorff} calculator from a given set of C{LatLon} points, called the C{model} or C{template} points.
C{h = HausdorffXyz(points1, ...)}
Get the C{directed} or C{symmetric} Hausdorff distance to a second set of C{LatLon} points, named the C{target} points, by using
C{t6 = h.directed(points2)}
respectively
C{t6 = h.symmetric(points2)}.
Or, use function C{hausdorff_} with a proper C{distance} function and optionally a C{point} function passed as keyword arguments as follows
C{t6 = hausdorff_(points1, points2, ..., distance=..., point=...)}.
In all cases, the returned result C{t6} is a L{Hausdorff6Tuple}.
For C{(lat, lon, ...)} points in a C{NumPy} array or plain C{tuples}, wrap the points in a L{Numpy2LatLon} respectively L{Tuple2LatLon} instance, more details in the documentation thereof.
For other points, create a L{Hausdorff} sub-class with the appropriate C{distance} method overloading L{Hausdorff.distance} and optionally a C{point} method overriding L{Hausdorff.point} as the next example.
>>> from pygeodesy import Hausdorff, hypot_ >>> >>> class H3D(Hausdorff): >>> """Custom Hausdorff example. >>> """ >>> def distance(self, p1, p2): >>> return hypot_(p1.x - p2.x, p1.y - p2.y, p1.z - p2.z) >>> >>> h3D = H3D(xyz1, ..., units="...") >>> d6 = h3D.directed(xyz2)
Transcribed from the original SciPy U{Directed Hausdorff Code <https://GitHub.com/scipy/scipy/blob/master/scipy/spatial/_hausdorff.pyx>} version 0.19.0, Copyright (C) Tyler Reddy, Richard Gowers, and Max Linke, 2016, distributed under the same BSD license as SciPy, including C{early breaking} and C{random sampling} as in U{Abdel Aziz Taha, Allan Hanbury "An Efficient Algorithm for Calculating the Exact Hausdorff Distance" <https://Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}, IEEE Trans. Pattern Analysis Machine Intelligence (PAMI), vol 37, no 11, pp 2153-2163, Nov 2015. '''
cosineLaw_, euclidean_, flatPolar_, haversine_, \ thomas_, vincentys_, _scale_rad _points_, _units_, _0_0 _Str_radians, _Str_radians2, _xUnit, _xUnits
'''Hausdorff issue. '''
'''Hausdorff base class, requires method L{Hausdorff.distance} to be overloaded. '''
'''New C{Hausdorff...} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}). @kwarg units: Optional, the distance units (C{Unit} or C{str}). @kwarg wrap_adjust: Optionally, C{wrap} and unroll longitudes, iff applicable (C{bool}) and C{adjust} wrapped, unrolled longitudinal delta by the cosine of the mean latitude, iff applicable.
@raise HausdorffError: Insufficient number of B{C{points}} or an invalid B{C{point}}, B{C{seed}} or B{C{wrap}} or B{C{ajust}} not applicable. ''' self.name = name self.units = units
'''Get the adjust setting (C{bool} or C{None} if not applicable). '''
'''Get the datum of this calculator (L{Datum} or C{None} if not applicable). '''
'''(INTERNAL) Set the datum.
@raise TypeError: Invalid B{C{datum}}. ''' if d not in (None, self._datum): # PYCHOK no cover self._datum = _ellipsoidal_datum(d, name=self.name)
'''Compute only the C{forward Hausdorff} distance.
@arg points: Second set of points, aka the C{target} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg early: Enable or disable U{early breaking<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>} (C{bool}).
@return: A L{Hausdorff6Tuple}C{(hd, i, j, mn, md, units)}.
@raise HausdorffError: Insufficient number of B{C{points}} or an invalid B{C{point}}.
@note: See B{C{points}} note at L{HausdorffDistanceTo}. ''' self.units, self.distance, self.point)
'''(INTERNAL) I{Must be overloaded}, see function C{notOverloaded}. ''' notOverloaded(self, point1, point2) # PYCHOK no cover
'''Convert a C{model} or C{target} point for the C{.distance} method. '''
'''(INTERNAL) Check a set of points. '''
'''Get the random sampling seed (C{any} or C{None}). '''
'''Set the random sampling seed.
@arg seed: Valid L{Random(seed)} or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}.
@raise HausdorffError: Invalid B{C{seed}}. ''' except (TypeError, ValueError) as x: raise HausdorffError(seed=seed, txt=str(x)) else: self._seed = None
'''Compute the combined C{forward and reverse Hausdorff} distance.
@arg points: Second set of points, aka the C{target} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg early: Enable or disable U{early breaking<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>} (C{bool}).
@return: A L{Hausdorff6Tuple}C{(hd, i, j, mn, md, units)}.
@raise HausdorffError: Insufficient number of B{C{points}} or an invalid B{C{point}}.
@note: See B{C{points}} note at L{HausdorffDistanceTo}. ''' self.units, self.distance, self.point)
'''Get the distance units (C{Unit} or C{str}). '''
'''Set the distance units.
@arg units: New units name (C{Unit} or C{str}).
@raise TypeError: Invalid B{C{units}}. ''' self._units = _xUnits(units, Base=Float)
'''Get the wrap setting (C{bool} or C{None} if not applicable). '''
'''L{Hausdorff} base class for distances from C{LatLon} points in C{degrees}. '''
if _FOR_DOCS: __init__ = Hausdorff.__init__ directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''L{Hausdorff} base class for distances from C{LatLon} points converted from C{degrees} to C{radians}. '''
if _FOR_DOCS: __init__ = Hausdorff.__init__ directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Convert C{(lat, lon)} point in degrees to C{(a, b)} in radians.
@return: An L{PhiLam2Tuple}C{(phi, lam)}. ''' except AttributeError: return PhiLam2Tuple(radians(point.lat), radians(point.lon))
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.cosineAndoyerLambert_}.
@see: L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffDistanceTo}, L{HausdorffExact}, L{HausdorffFlatLocal}, L{HausdorffHubeny}, L{HausdorffThomas} and L{HausdorffKarney}. '''
'''New L{HausdorffCosineAndoyerLambert} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{points}}' datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}.
@raise TypeError: Invalid B{C{datum}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.cosineAndoyerLambert_} distance in C{radians}. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.cosineForsytheAndoyerLambert_}.
@see: L{HausdorffCosineAndoyerLambert}, L{HausdorffDistanceTo}, L{HausdorffExact}, L{HausdorffFlatLocal}, L{HausdorffHubeny}, L{HausdorffThomas} and L{HausdorffKarney}. '''
'''New L{HausdorffCosineForsytheAndoyerLambert} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{points}}' datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}.
@raise TypeError: Invalid B{C{datum}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.cosineForsytheAndoyerLambert_} distance in C{radians}. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.cosineLaw_}.
@note: See note at function L{pygeodesy.vincentys_}.
@see: L{HausdorffEquirectangular}, L{HausdorffEuclidean}, L{HausdorffExact}, L{HausdorffFlatLocal}, L{HausdorffHubeny}, L{HausdorffFlatPolar}, L{HausdorffHaversine}, L{HausdorffKarney} and L{HausdorffVincentys}. '''
'''New L{HausdorffCosineLaw} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.cosineLaw_} distance in C{radians}. '''
'''Compute the C{Hausdorff} distance based on the distance from the points' C{LatLon.distanceTo} method, conventionally in C{meter}.
@see: L{HausdorffCosineAndoyerLambert}, L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffExact}, L{HausdorffFlatLocal}, L{HausdorffHubeny}, L{HausdorffThomas} and L{HausdorffKarney}. '''
'''New L{HausdorffDistanceTo} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[]). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}). @kwarg distanceTo_kwds: Optional keyword arguments for the B{C{points}}' C{LatLon.distanceTo} method.
@raise HausdorffError: Insufficient number of B{C{points}} or an invalid B{C{point}} or B{C{seed}}.
@raise ImportError: Package U{geographiclib <https://PyPI.org/project/geographiclib>} missing iff B{C{points}} are L{ellipsoidalKarney.LatLon}s.
@note: All C{model}, C{template} and C{target} B{C{points}} I{must} be instances of the same ellipsoidal or spherical C{LatLon} class. ''' self._distanceTo_kwds = distanceTo_kwds
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the distance in C{meter}. '''
'''(INTERNAL) Check a set of points. ''' i = Fmt.SQUARE(_points_, i) raise HausdorffError(i, p, txt=_distanceTo_)
'''Compute the C{Hausdorff} distance based on the C{equirectangular} distance in C{radians squared} like function L{pygeodesy.equirectangular_}.
@see: L{HausdorffCosineLaw}, L{HausdorffEuclidean} L{HausdorffExact}, L{HausdorffFlatPolar}, L{HausdorffHaversine} and L{HausdorffVincentys}. '''
'''New L{HausdorffEquirectangular} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg adjust: Adjust the wrapped, unrolled longitudinal delta by the cosine of the mean latitude (C{bool}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}. ''' adjust=adjust, wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.equirectangular_} distance in C{radians squared}. '''
'''Compute the C{Hausdorff} distance based on the C{Euclidean} distance in C{radians} from function L{pygeodesy.euclidean_}.
@see: L{HausdorffCosineLaw}, L{HausdorffEquirectangular}, L{HausdorffExact}, L{HausdorffFlatPolar}, L{HausdorffHaversine} and L{HausdorffVincentys}. '''
'''New L{HausdorffEuclidean} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg adjust: Adjust the wrapped, unrolled longitudinal delta by the cosine of the mean latitude (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}. ''' wrap=True) self._adjust = False
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.euclidean_} distance in C{radians}. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{degrees} from method L{GeodesicExact}C{.Inverse}.
@see: L{HausdorffCosineAndoyerLambert}, L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffDistanceTo}, L{HausdorffFlatLocal}, L{HausdorffHubeny}, L{HausdorffKarney} and L{HausdorffThomas}. '''
'''New L{HausdorffKarney} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{points}}' datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unroll180} longitudes (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}.
@raise ImportError: Package U{geographiclib <https://PyPI.org/project/geographiclib>} missing.
@raise TypeError: Invalid B{C{datum}}. ''' HausdorffDegrees.__init__(self, points, seed=seed, name=name, wrap=wrap) self._datum_setter(datum) self._Inverse1 = self.datum.ellipsoid.geodesicx.Inverse1 # note -x
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the non-negative I{angular} distance in C{degrees}. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians squared} like function L{pygeodesy.flatLocal_}/L{pygeodesy.hubeny_}.
@see: L{HausdorffCosineAndoyerLambert}, L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffDistanceTo}, L{HausdorffExact}, L{HausdorffHubeny}, L{HausdorffThomas} and L{HausdorffKarney}. '''
'''New L{HausdorffFlatLocal}/L{HausdorffHubeny} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{points}}' datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}.
@raise TypeError: Invalid B{C{datum}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.flatLocal_}/L{pygeodesy.hubeny_} distance in C{radians squared}. '''
'''(INTERNAL) Get and cache the C{.datum.ellipsoid._hubeny_2} method. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.flatPolar_}.
@see: L{HausdorffCosineLaw}, L{HausdorffEquirectangular}, L{HausdorffEuclidean}, L{HausdorffExact}, L{HausdorffHaversine} and L{HausdorffVincentys}. '''
'''New L{HausdorffFlatPolar} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.flatPolar_} distance in C{radians}. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.haversine_}.
@note: See note under L{HausdorffVincentys}.
@see: L{HausdorffEquirectangular}, L{HausdorffEuclidean}, L{HausdorffExact}, L{HausdorffFlatPolar} and L{HausdorffVincentys}. '''
'''New L{HausdorffHaversine} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.haversine_} distance in C{radians}. '''
if _FOR_DOCS: __doc__ = HausdorffFlatLocal.__doc__ __init__ = HausdorffFlatLocal.__init__ directed = HausdorffFlatLocal.directed distance = HausdorffFlatLocal.distance symmetric = HausdorffFlatLocal.symmetric
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{degrees} from I{Karney}'s U{geographiclib <https://PyPI.org/project/geographiclib>} U{Geodesic <https://GeographicLib.SourceForge.io/html/python/code.html>} Inverse method.
@see: L{HausdorffCosineAndoyerLambert}, L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffDistanceTo}, L{HausdorffExact}, L{HausdorffFlatLocal}, L{HausdorffHubeny} and L{HausdorffThomas}. ''' '''New L{HausdorffKarney} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{points}}' datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unroll180} longitudes (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}.
@raise ImportError: Package U{geographiclib <https://PyPI.org/project/geographiclib>} missing.
@raise TypeError: Invalid B{C{datum}}. ''' wrap=wrap)
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.thomas_}.
@see: L{HausdorffCosineAndoyerLambert}, L{HausdorffCosineForsytheAndoyerLambert}, L{HausdorffDistanceTo}, L{HausdorffExact}, L{HausdorffFlatLocal}, L{HausdorffHubeny} and L{HausdorffKarney}. '''
'''New L{HausdorffThomas} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg datum: Optional datum overriding the default C{Datums.WGS84} and first B{C{points}}' datum (L{Datum}, L{Ellipsoid}, L{Ellipsoid2} or L{a_f2Tuple}). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}.
@raise TypeError: Invalid B{C{datum}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.thomas_} distance in C{radians}. '''
'''Compute the C{Hausdorff} distance based on the I{angular} distance in C{radians} from function L{pygeodesy.vincentys_}.
@note: See note at function L{pygeodesy.vincentys_}.
@see: L{HausdorffCosineLaw}, L{HausdorffEquirectangular}, L{HausdorffEuclidean}, L{HausdorffExact}, L{HausdorffFlatPolar} and L{HausdorffHaversine}. '''
'''New L{HausdorffVincentys} calculator.
@arg points: Initial set of points, aka the C{model} or C{template} (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg wrap: Optionally, wrap and L{pygeodesy.unrollPI} longitudes (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https:// Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg name: Optional name for this interpolator (C{str}).
@raise HausdorffError: Insufficient number of B{C{points}} or invalid B{C{seed}}. ''' wrap=wrap)
if _FOR_DOCS: directed = Hausdorff.directed symmetric = Hausdorff.symmetric
'''Return the L{pygeodesy.vincentys_} distance in C{radians}. '''
'''(INTERNAL) Core of function L{hausdorff_} and methods C{directed} and C{symmetric} of classes C{hausdorff.Hausdorff...}. ''' # shuffling the points generally increases the # chance of an early break in the inner j loop
# forward or forward and backward else: # no early break else: # swap model and target
'''Default B{C{point}} callable for function L{hausdorff_}.
@arg p: The original C{model} or C{target} point (C{any}).
@return: The point, suitable for the L{hausdorff_} B{C{distance}} callable. '''
distance=None, point=_point): '''Compute the C{directed} or C{symmetric} U{Hausdorff <https://WikiPedia.org/wiki/Hausdorff_distance>} distance between 2 sets of points with or without U{early breaking<https://Publik.TUWien.ac.AT/files/PubDat_247739.pdf>} and U{random sampling<https://Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}.
@arg model: First set of points (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @arg target: Second set of points (C{LatLon}[], C{Numpy2LatLon}[], C{Tuple2LatLon}[] or C{other}[]). @kwarg both: Return the C{directed} (forward only) or the C{symmetric} (combined forward and reverse) C{Hausdorff} distance (C{bool}). @kwarg early: Enable or disable U{early breaking<https://Publik.TUWien.ac.AT/ files/PubDat_247739.pdf>} (C{bool}). @kwarg seed: Random sampling seed (C{any}) or C{None}, C{0} or C{False} for no U{random sampling<https://Publik.TUWien.ac.AT/files/PubDat_247739.pdf>}. @kwarg units: Optional, the distance units (C{Unit} or C{str}). @kwarg distance: Callable returning the distance between a B{C{model}} and B{C{target}} point (signature C{(point1, point2)}). @kwarg point: Callable returning the B{C{model}} or B{C{target}} point suitable for B{C{distance}} (signature C{(point)}).
@return: A L{Hausdorff6Tuple}C{(hd, i, j, mn, md, units)}.
@raise HausdorffError: Insufficient number of B{C{model}} or B{C{target}} points.
@raise TypeError: If B{C{distance}} or B{C{point}} is not callable. ''' raise _IsnotError(callable.__name__, distance=distance) raise _IsnotError(callable.__name__, point=point)
'''6-Tuple C{(hd, i, j, mn, md, units)} with the U{Hausdorff <https://WikiPedia.org/wiki/Hausdorff_distance>} distance C{hd}, indices C{i} and C{j}, the total count C{mn}, the C{I{mean} Hausdorff} distance C{md} and the class or name of both distance C{units}.
For C{directed Hausdorff} distances, count C{mn} is the number of model points considered. For C{symmetric Hausdorff} distances count C{mn} twice that.
Indices C{i} and C{j} are the C{model} respectively C{target} point with the C{hd} distance.
Mean distance C{md} is C{None} if an C{early break} occurred and U{early breaking<https://Publik.TUWien.ac.AT/files/PubDat_247739.pdf>} was enabled by keyword argument C{early=True}. '''
'''Overloaded C{_NamedTuple.toUnits} for C{hd} and C{md} units. ''' + (M,) + Hausdorff6Tuple._Units_[5:]
'''Return a C{seed}ed random range function generator.
@arg seed: Initial, internal L{Random} state (C{hashable} or C{None}).
@note: L{Random} with C{B{seed} is None} seeds from the current time or from a platform-specific randomness source, if available.
@return: A function to generate random ranges.
@example:
>>> rrange = randomrangenerator('R') >>> for r in rrange(n): >>> ... # r is random in 0..n-1 '''
'''Like standard L{range}C{start, stop=..., step=...)}, except the returned values are in random order.
@note: Especially C{range(n)} behaves like standard L{Random.sample}C{(range(n), n)} but avoids creating a tuple with the entire C{population} and a list containing all sample values (for large C{n}). '''
else:
# **) MIT License # # Copyright (C) 2016-2022 -- 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. |