# -*- coding: utf-8 -*- # Test the Frechet distances. __all__ = ('Tests', ) __version__ = '19.08.30' from base import isPython3, isWindows, TestsBase from pygeodesy import fStr, LatLon_, randomrangenerator _rr = randomrangenerator('R') _ms = [ LatLon_(*_ll) for _ll in zip( _rr(-90, 90, 2), # 90 _rr(-180, 180, 4)) ] _ps = [ LatLon_(*_ll) for _ll in zip( _rr(-89, 90, 3), # 60 _rr(-179, 180, 6)) ] class Tests(TestsBase): def test2(self, Frechet, x, y, **kwds): def _tstr(t): s = list(t[:5]) s[0] = fStr(t.fd, prec=5) return '(%s)' % (', '.join(map(str, s)), )
'''Custom Hausdorff.''' def distance(self, p1, p2): dy, dx = abs(p1.phi - p2.phi), abs(p1.lam - p2.lam) if dx < dy: dx, dy = dy, dx return dx + dy * 0.5 def _tstr(t): s = list(t[:5]) s[0] = fStr(t.hd, prec=5) s[4] = None if t.md is None else fStr(t.md, prec=5) return '(%s)' % (', '.join(map(str, s)),) _rr = randomrangenerator('R') # like <https://GitHub.com/mavillan/py-hausdorff> Example _ms = [LatLon_(*_ll) for _ll in zip(_rr( -90, 90, 2), # 90 _rr(-180, 180, 4))] _ps = [LatLon_(*_ll) for _ll in zip(_rr( -89, 90, 3), # 60 _rr(-179, 180, 6))] class Tests(TestsBase): def test4(self, Hausdorff, *tests, **kwds): for s, e, x, y in tests: h = Hausdorff(_ms, seed=s, **kwds)