def test_join_on_distance_threshold_4(self): a = [gt.Coords(0, 0), gt.Coords(0, 0)] b = [gt.Coords(0, 0), gt.Coords(0, 0)] self.assertEqual(list(dm.join_on_distance_threshold(a, b, 1)), [ (a[0], b[0]), (a[0], b[1]), (a[1], b[0]), (a[1], b[1]), ])
def test_gc_dist_coords(self): random.seed('test_gc_dist_coords') for di in xrange(-360, 360, 1): c1 = gt.Coords(gm.deg_to_rad(di), gm.deg_to_rad(di) + random.random() * 2 * pi) c2 = gt.Coords( gm.deg_to_rad(di) + random.random() * 2 * pi, gm.deg_to_rad(di) + random.random() * 2 * pi) self.assertEqual(gm.gc_dist_coords_rad(c1, c2), gm.gc_dist_rad(c1.p, c1.l, c2.p, c2.l)) self.assertLess( abs( gm.gc_dist_coords_rad(c1, c2) - gm.gc_dist_coords_rad(c2, c1)), MODICUM)
def path_to_coords_iterator(path): rowi = None for rowi, row in enumerate(fio.get_csv_reader(path), 1): coords = gt.Coords(float(row['Latitude']), float(row['Longitude']), data=row) yield coords
def test_join_on_k_closest_2(self): a = [gt.Coords(0, 0), gt.Coords(0, gm.deg_to_rad(44))] b = [ gt.Coords(0, gm.deg_to_rad(70)), gt.Coords(0, gm.deg_to_rad(60)), gt.Coords(0, gm.deg_to_rad(50)), gt.Coords(0, gm.deg_to_rad(40)), gt.Coords(0, gm.deg_to_rad(30)), gt.Coords(0, gm.deg_to_rad(20)), gt.Coords(0, gm.deg_to_rad(10)), ] self.assertEqual(list(dm.join_on_k_closest(a, b, 2)), [ (a[0], b[5]), (a[0], b[6]), (a[1], b[2]), (a[1], b[3]), ])
def test_join_on_k_closest_1(self): a = [gt.Coords(0, 0)] b = [gt.Coords(0, 0), gt.Coords(45, 180)] self.assertEqual(list(dm.join_on_k_closest(a, b, 1)), [ (a[0], b[0]), ])
def test_join_on_distance_threshold_3(self): a = [gt.Coords(0, 0), gt.Coords(0, 0)] b = [gt.Coords(45, 0)] self.assertEqual(list(dm.join_on_distance_threshold(a, b, 1)), [])
def test_gc_dist_coords_incremental(self): cs = [ gt.Coords(0, 0), gt.Coords(0, pi / 10), gt.Coords(0, pi / 9), gt.Coords(0, pi / 8), gt.Coords(0, pi / 7), gt.Coords(0, pi / 6), gt.Coords(0, pi / 5), gt.Coords(0, pi / 4), gt.Coords(0, pi / 3), gt.Coords(0, pi / 2), gt.Coords(0, pi / 1), ] c1 = cs[0] sor = sorted(cs, key=lambda c2: gm.gc_dist_coords_rad(c1, c2)) self.assertEqual(cs, sor)