Do not include extras in GCP UTM copy

Former-commit-id: c697551057
pull/1161/head
Piero Toffanin 2019-06-24 08:28:44 -04:00
rodzic 8d05670054
commit 1eb60d256e
3 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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.")

Wyświetl plik

@ -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()