-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_geo_utils.py
54 lines (40 loc) · 2.11 KB
/
test_geo_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from delairstack.core.errors import BoundingBoxError
from delairstack.core.utils.geo_utils import (compute_bbox, compute_bbox_as_polygon)
from tests.delairstacktest import DelairStackTestBase
class TestGeoUtils(DelairStackTestBase):
def test_compute_bbox(self):
with self.assertRaises(BoundingBoxError):
compute_bbox([])
coordinates = [[1.0177519166666666, 44.03104722222222],
[1.017777222222222, 44.03101111111111],
[1.0177857222222222, 44.030974916666665],
[1.0177871944444445, 44.030924166666665],
[1.017757388888889, 44.030880277777776]]
bbox = compute_bbox(coordinates)
self.assertIsNotNone(bbox)
self.assertEqual(len(bbox), 4)
self.assertEqual(bbox[0], 1.0177519166666666)
self.assertEqual(bbox[1], 1.0177871944444445)
self.assertEqual(bbox[2], 44.030880277777776)
self.assertEqual(bbox[3], 44.03104722222222)
def test_compute_bbox_as_polygon(self):
with self.assertRaises(BoundingBoxError):
compute_bbox_as_polygon([])
coordinates = [[1.0177519166666666, 44.03104722222222],
[1.017777222222222, 44.03101111111111],
[1.0177857222222222, 44.030974916666665],
[1.0177871944444445, 44.030924166666665],
[1.017757388888889, 44.030880277777776]]
bbox = compute_bbox_as_polygon(coordinates)
self.assertIsNotNone(bbox)
self.assertEqual(len(bbox), 5)
self.assertEqual(bbox[0][0], 1.0177519166666666)
self.assertEqual(bbox[0][1], 44.030880277777776)
self.assertEqual(bbox[1][0], 1.0177871944444445)
self.assertEqual(bbox[1][1], 44.030880277777776)
self.assertEqual(bbox[2][0], 1.0177871944444445)
self.assertEqual(bbox[2][1], 44.03104722222222)
self.assertEqual(bbox[3][0], 1.0177519166666666)
self.assertEqual(bbox[3][1], 44.03104722222222)
self.assertEqual(bbox[4][0], 1.0177519166666666)
self.assertEqual(bbox[4][1], 44.030880277777776)