From dd5cd4d0fc0194b746bf36dd40043ef159c670a4 Mon Sep 17 00:00:00 2001 From: Cameron Poole Date: Sun, 18 Sep 2016 16:49:52 +0800 Subject: [PATCH] Fixed add mask test and function --- frisson/frisson.py | 7 ++----- tests/unit/test_frisson.py | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/frisson/frisson.py b/frisson/frisson.py index c7b40b6..731f212 100644 --- a/frisson/frisson.py +++ b/frisson/frisson.py @@ -60,13 +60,10 @@ def _points_to_string(gcp_points): assert type(gcp) in [list, tuple] assert len(gcp) == 4 gcp_s.append(["-gcp"]) - coords = [] for coord in gcp: if type(coord) == float: coord = str(coord) - coords.append(coord) - - gcp_s[-1].append(" ".join(coords)) + gcp_s[-1].append(coord) return gcp_s @@ -82,7 +79,7 @@ def add_mask(input_filename, output_filename, mask_vectors): "-a_srs", "+init=epsg:4326", "-of", - "VRT"] + [x for y in _points_to_string2(mask_vectors) for x in y] + [ + "VRT"] + [x for y in _points_to_string(mask_vectors) for x in y] + [ input_filename, output_filename, ] diff --git a/tests/unit/test_frisson.py b/tests/unit/test_frisson.py index a30d7bc..149104a 100644 --- a/tests/unit/test_frisson.py +++ b/tests/unit/test_frisson.py @@ -14,18 +14,20 @@ class TestPrintPoint(unittest.TestCase): @classmethod def setUpClass(cls): cls.gcp_points = [ - [12895157.1042, -3756156.6509, 1989.1230, -2999.8393], + [12895157.1042, -3756156.6509, 1989.1230, -2999.8393], [12898106.0028, -3756364.7068, 4083.4782, -3103.3251], [12898161.6258, -3754995.9836, 4108.2269, -2151.3432] ] cls.gcp_string = [ - ["-gcp", "12895157.1042 -3756156.6509 " - "1989.123 -2999.8393"], - ["-gcp", "12898106.0028 -3756364.7068 " - "4083.4782 -3103.3251"], - ["-gcp", "12898161.6258 -3754995.9836 " - "4108.2269 -2151.3432"] + ["-gcp", "12895157.1042", + "-3756156.6509", + "1989.123", "-2999.8393"], + ["-gcp", "12898106.0028", "-3756364.7068", + "4083.4782", "-3103.3251"], + ["-gcp", "12898161.6258", "-3754995.9836", + "4108.2269", "-2151.3432"] ] + def test_input_exists(self): self.assertTrue(path.isfile("tests/cons 1636 item 3706.tif"), "Test File doesn't exist") @@ -67,9 +69,8 @@ def tearDownClass(self): "tests/test_output.dbf", "tests/test_output.shp", "tests/test_output.shx" - ] + ] for tf in test_files: if path.isfile(tf): pass - #remove(tf) - + # remove(tf)