diff --git a/opendm/gcp.py b/opendm/gcp.py index 31408f48..9da1df69 100644 --- a/opendm/gcp.py +++ b/opendm/gcp.py @@ -63,7 +63,7 @@ class GCPFile: utm_zone, hemisphere = location.get_utm_zone_and_hemisphere_from(lon, lat) return "WGS84 UTM %s%s" % (utm_zone, hemisphere) - def create_utm_copy(self, gcp_file_output, filenames=None, rejected_entries=None): + def create_utm_copy(self, gcp_file_output, filenames=None, rejected_entries=None, include_extras=True): """ Creates a new GCP file from an existing GCP file by optionally including only filenames and reprojecting each point to @@ -80,6 +80,8 @@ class GCPFile: for entry in self.iter_entries(): if filenames is None or entry.filename in filenames: entry.x, entry.y, entry.z = transformer.TransformPoint(entry.x, entry.y, entry.z) + if not include_extras: + entry.extras = '' output.append(str(entry)) elif isinstance(rejected_entries, list): rejected_entries.append(entry) diff --git a/opendm/types.py b/opendm/types.py index 99f87369..bb3979da 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -111,7 +111,7 @@ class ODM_Reconstruction(object): # Convert GCP file to a UTM projection since the rest of the pipeline # does not handle other SRS well. rejected_entries = [] - utm_gcp = GCPFile(gcp.create_utm_copy(output_gcp_file, filenames=[p.filename for p in self.photos], rejected_entries=rejected_entries)) + utm_gcp = GCPFile(gcp.create_utm_copy(output_gcp_file, filenames=[p.filename for p in self.photos], rejected_entries=rejected_entries, include_extras=False)) if not utm_gcp.exists(): raise RuntimeError("Could not project GCP file to UTM. Please double check your GCP file for mistakes.") diff --git a/tests/test_gcp.py b/tests/test_gcp.py index 3c75c4a1..061faf57 100644 --- a/tests/test_gcp.py +++ b/tests/test_gcp.py @@ -57,5 +57,13 @@ class TestGcp(unittest.TestCase): gcp = GCPFile(None) self.assertFalse(gcp.exists()) + def test_gcp_extras(self): + gcp = GCPFile('tests/assets/gcp_extras.txt') + self.assertEqual(gcp.get_entry(0).extras, 'gcp1') + + copy = GCPFile(gcp.create_utm_copy("tests/assets/output/gcp_utm_no_extras.txt", include_extras=False)) + self.assertTrue(copy.exists()) + self.assertEqual(copy.get_entry(0).extras, '') + if __name__ == '__main__': unittest.main() \ No newline at end of file