Ejemplo n.º 1
0
    def test_set_bounds(self):
        bound = geocluster.GeoBoundBase()

        north=-20.849968961968585
        south=-21.39184466348015
        east=55.99046983169558
        west=55.064185041656515

        bound.set_bounds(north=south, south=north, east=west, west=east)

        self.assertGreater(bound.south, bound.north)
        self.assertGreater(bound.east, bound.west)

        bound_dir = dir(bound)
        self.assertIn('north', bound_dir)
        self.assertEqual(bound.north, geocluster.convert_lat_from_gps(north))

        self.assertIn('south', bound_dir)
        self.assertEqual(bound.south, geocluster.convert_lat_from_gps(south))

        self.assertIn('west', bound_dir)
        self.assertEqual(bound.west, geocluster.convert_lng_from_gps(west))

        self.assertIn('east', bound_dir)
        self.assertEqual(bound.east, geocluster.convert_lng_from_gps(east))
Ejemplo n.º 2
0
    def test_set_bounds(self):
        bound = geocluster.GeoBoundBase()

        north = -20.849968961968585
        south = -21.39184466348015
        east = 55.99046983169558
        west = 55.064185041656515

        bound.set_bounds(north=south, south=north, east=west, west=east)

        self.assertGreater(bound.south, bound.north)
        self.assertGreater(bound.east, bound.west)

        bound_dir = dir(bound)
        self.assertIn('north', bound_dir)
        self.assertEqual(bound.north, geocluster.convert_lat_from_gps(north))

        self.assertIn('south', bound_dir)
        self.assertEqual(bound.south, geocluster.convert_lat_from_gps(south))

        self.assertIn('west', bound_dir)
        self.assertEqual(bound.west, geocluster.convert_lng_from_gps(west))

        self.assertIn('east', bound_dir)
        self.assertEqual(bound.east, geocluster.convert_lng_from_gps(east))
Ejemplo n.º 3
0
    def test_lng_from_gps(self):
        lng = 10
        response = convert_lat_from_gps(lng)
        self.assertEqual(response, lng)

        lng = -1
        response = convert_lat_from_gps(lng)
        self.assertNotEqual(response, lng)
        self.assertEqual(response, 91)
Ejemplo n.º 4
0
    def test_lat_from_gps(self):
        lat = 10
        response = convert_lat_from_gps(lat)
        self.assertEqual(response, lat)

        lat = -1
        response = convert_lat_from_gps(lat)
        self.assertNotEqual(response, lat)
        self.assertEqual(response, 91)
Ejemplo n.º 5
0
    def test_lng_from_gps(self):
        lng = 10
        response = convert_lat_from_gps(lng)
        self.assertEqual(response, lng)

        lng = -1
        response = convert_lat_from_gps(lng)
        self.assertNotEqual(response, lng)
        self.assertEqual(response, 91)
Ejemplo n.º 6
0
    def test_lat_from_gps(self):
        lat = 10
        response = convert_lat_from_gps(lat)
        self.assertEqual(response, lat)

        lat = -1
        response = convert_lat_from_gps(lat)
        self.assertNotEqual(response, lat)
        self.assertEqual(response, 91)
Ejemplo n.º 7
0
    def test_get_width(self):
        bound = geocluster.GeoBoundBase()

        north=-20.849968961968585
        south=-21.39184466348015
        east=55.99046983169558
        west=55.064185041656515

        bound.set_bounds(north=north, south=south, east=east, west=west)
        self.assertEqual(bound.get_height(), geocluster.convert_lat_from_gps(south) - geocluster.convert_lat_from_gps(north))
Ejemplo n.º 8
0
    def test_get_width(self):
        bound = geocluster.GeoBoundBase()

        north = -20.849968961968585
        south = -21.39184466348015
        east = 55.99046983169558
        west = 55.064185041656515

        bound.set_bounds(north=north, south=south, east=east, west=west)
        self.assertEqual(bound.get_height(), geocluster.convert_lat_from_gps(south) - geocluster.convert_lat_from_gps(north))
Ejemplo n.º 9
0
    def test_type(self):
        lat_f = 10.0
        lat_i = 10
        lat_s = '10'

        lng_f = 10.0
        lng_i = 10
        lng_s = '10'

        # Test correct arguments type
        convert_lat_from_gps(lat_f)
        convert_lat_from_gps(lat_i)
        convert_lng_from_gps(lng_f)
        convert_lng_from_gps(lng_i)

        # Test wrong argument type
        with self.assertRaises(AssertionError):
            convert_lat_from_gps(lat_s)

        with self.assertRaises(AssertionError):
            convert_lng_from_gps(lng_s)

        convert_lat_from_degrees(lat_f)
        convert_lat_from_degrees(lat_i)
        convert_lng_from_degrees(lng_f)
        convert_lng_from_degrees(lng_i)

        # Test wrong argument type
        with self.assertRaises(AssertionError):
            convert_lat_from_degrees(lat_s)

        with self.assertRaises(AssertionError):
            convert_lng_from_degrees(lng_s)
Ejemplo n.º 10
0
    def test_type(self):
        lat_f = 10.0
        lat_i = 10
        lat_s = '10'

        lng_f = 10.0
        lng_i = 10
        lng_s = '10'

        # Test correct arguments type
        convert_lat_from_gps(lat_f)
        convert_lat_from_gps(lat_i)
        convert_lng_from_gps(lng_f)
        convert_lng_from_gps(lng_i)

        # Test wrong argument type
        with self.assertRaises(AssertionError):
            convert_lat_from_gps(lat_s)

        with self.assertRaises(AssertionError):
            convert_lng_from_gps(lng_s)

        convert_lat_from_degrees(lat_f)
        convert_lat_from_degrees(lat_i)
        convert_lng_from_degrees(lng_f)
        convert_lng_from_degrees(lng_i)

        # Test wrong argument type
        with self.assertRaises(AssertionError):
            convert_lat_from_degrees(lat_s)

        with self.assertRaises(AssertionError):
            convert_lng_from_degrees(lng_s)
Ejemplo n.º 11
0
    def test_set_grid(self):
        cluster = geocluster.GeoCluster()
        north = -20.849968961968585
        south = -21.39184466348015
        east = 55.99046983169558
        west = 55.064185041656515

        cluster.set_bounds(north=north, south=south, east=east, west=west)
        cluster.set_grid(10, 10)
        self.assertEqual(len(cluster.rectangles), 10)

        lat = geocluster.convert_lat_from_gps(north)

        for rect in cluster.rectangles:
            self.assertEqual(len(rect), 10)
            lat += rect[0].get_height()
            lng = geocluster.convert_lng_from_gps(west)
            for r in rect:
                lng += r.get_width()
                self.assertIsInstance(r, geocluster.GeoBound)
            self.assertEqual(lng, geocluster.convert_lng_from_gps(east))

        self.assertEqual(lat, geocluster.convert_lat_from_gps(south))