Beispiel #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))
    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))
Beispiel #3
0
    def test_get_height(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_width(), geocluster.convert_lng_from_gps(east) - geocluster.convert_lng_from_gps(west))
    def test_get_height(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_width(), geocluster.convert_lng_from_gps(east) - geocluster.convert_lng_from_gps(west))
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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))