-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.py
More file actions
93 lines (73 loc) · 3.18 KB
/
Copy pathtest.py
File metadata and controls
93 lines (73 loc) · 3.18 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import unittest
from src.pdal_parallelizer import cloud, bounds, file_manager, tile
import pdal
class TestBounds(unittest.TestCase):
def test_getDistX(self):
bds = bounds.Bounds(10, 10, 30, 30)
result = bds.get_dist_x()
self.assertEqual(result, 20)
def test_getDistY(self):
bds = bounds.Bounds(10, 10, 30, 50)
result = bds.get_dist_y()
self.assertEqual(result, 40)
class TestCloud(unittest.TestCase):
def test_getCount(self):
cld = cloud.Cloud("test/data/input/echantillon_10pts.laz")
result = cld.get_num_points()
self.assertEqual(result, 10)
def test_bounds(self):
b = bounds.Bounds(10, 10, 20, 40)
cld = cloud.Cloud("test/data/input/echantillon_10pts.laz", b)
result = cld.bounds
self.assertEqual(result.min_x, b.min_x)
self.assertEqual(result.min_y, b.min_y)
self.assertEqual(result.max_x, b.max_x)
self.assertEqual(result.max_y, b.max_y)
def test_has_ClassFlags_dimension(self):
cld = cloud.Cloud("test/data/input/echantillon_10pts.laz")
result = cld.has_ClassFlags_dimension()
self.assertTrue(result)
def test_split(self):
cld = cloud.Cloud("test/data/input/echantillon_10pts.laz")
tiles = cld.split((0.3, 0.3), "../test/data/pipeline.json", "../test/data/output")
self.assertEqual(len(tiles), 12)
def test_split_2(self):
cld = cloud.Cloud("test/data/input/echantillon_10pts.laz")
tiles = cld.split((100, 100), "../test/data/pipeline.json", "../test/data/output")
self.assertEqual(len(tiles), 1)
def test_split_3(self):
cld = cloud.Cloud("test/data/input/echantillon_10pts.laz")
tiles = cld.split((0.3, 0.3), "../test/data/pipeline.json", "../test/data/output", 10)
self.assertEqual(len(tiles), 10)
class TestFileManager(unittest.TestCase):
def test_getFiles_all(self):
result = file_manager.get_files("../test/data/input")
self.assertGreater(len(list(next(result))), 3)
def test_getFiles_nFiles(self):
result = file_manager.get_files("../test/data/input", 2)
self.assertEqual(len(list(result)), 2)
def test_getSerializedPipelines(self):
result = file_manager.get_serialized_tiles("../test/data/temp")
self.assertGreater(len(list(result)), 0)
class TestTile(unittest.TestCase):
bds = bounds.Bounds(685019.31, 7047019.02, 685019.93, 7047019.98)
cld = cloud.Cloud("../test/data/input/echantillon_10pts.laz", bds)
t = tile.Tile("t1",
cld,
bds,
"../test/data/pipeline.json",
"../test/data/output",
(10, 5),
False
)
def test_pipeline(self):
result = self.t.link_pipeline(False)
self.assertIsInstance(result, pdal.Pipeline)
def test_positive_buffer(self):
self.t.add_buffer()
self.assertEqual(self.t.bounds.min_x, 685009.31)
self.assertEqual(self.t.bounds.min_y, 7047014.02)
self.assertEqual(self.t.bounds.max_x, 685029.93)
self.assertEqual(self.t.bounds.max_y, 7047024.98)
if __name__ == "__main__":
unittest.main()