|
5 | 5 | import fiona
|
6 | 6 | import fiona.crs
|
7 | 7 | import json
|
| 8 | +import zipfile |
8 | 9 | from collections import OrderedDict
|
9 | 10 | from pyproj import CRS
|
10 | 11 |
|
@@ -32,6 +33,7 @@ def process(self, args, outputs):
|
32 | 33 | gcp_export_file = tree.path("odm_georeferencing", "ground_control_points.gpkg")
|
33 | 34 | gcp_gml_export_file = tree.path("odm_georeferencing", "ground_control_points.gml")
|
34 | 35 | gcp_geojson_export_file = tree.path("odm_georeferencing", "ground_control_points.geojson")
|
| 36 | + gcp_geojson_zip_export_file = tree.path("odm_georeferencing", "ground_control_points.zip") |
35 | 37 | unaligned_model = io.related_file_path(tree.odm_georeferencing_model_laz, postfix="_unaligned")
|
36 | 38 | if os.path.isfile(unaligned_model) and self.rerun():
|
37 | 39 | os.unlink(unaligned_model)
|
@@ -104,6 +106,9 @@ def process(self, args, outputs):
|
104 | 106 |
|
105 | 107 | with open(gcp_geojson_export_file, 'w') as f:
|
106 | 108 | f.write(json.dumps(geojson, indent=4))
|
| 109 | + |
| 110 | + with zipfile.ZipFile(gcp_geojson_zip_export_file, 'w', compression=zipfile.ZIP_LZMA) as f: |
| 111 | + f.write(gcp_geojson_export_file, arcname=os.path.basename(gcp_geojson_export_file)) |
107 | 112 |
|
108 | 113 | else:
|
109 | 114 | log.ODM_WARNING("GCPs could not be loaded for writing to %s" % gcp_export_file)
|
@@ -131,11 +136,14 @@ def process(self, args, outputs):
|
131 | 136 | f'--writers.las.a_srs="{reconstruction.georef.proj4()}"' # HOBU this should maybe be WKT
|
132 | 137 | ]
|
133 | 138 |
|
134 |
| - if reconstruction.has_gcp() and io.file_exists(gcp_geojson_export_file): |
135 |
| - log.ODM_INFO("Embedding GCP info in point cloud") |
136 |
| - params += [ |
137 |
| - '--writers.las.vlrs="{\\\"filename\\\": \\\"%s\\\", \\\"user_id\\\": \\\"ODM\\\", \\\"record_id\\\": 1, \\\"description\\\": \\\"Ground Control Points (GeoJSON)\\\"}"' % gcp_geojson_export_file.replace(os.sep, "/") |
138 |
| - ] |
| 139 | + if reconstruction.has_gcp() and io.file_exists(gcp_geojson_zip_export_file): |
| 140 | + if os.path.getsize(gcp_geojson_zip_export_file) <= 65535: |
| 141 | + log.ODM_INFO("Embedding GCP info in point cloud") |
| 142 | + params += [ |
| 143 | + '--writers.las.vlrs="{\\\"filename\\\": \\\"%s\\\", \\\"user_id\\\": \\\"ODM\\\", \\\"record_id\\\": 2, \\\"description\\\": \\\"Ground Control Points (zip)\\\"}"' % gcp_geojson_zip_export_file.replace(os.sep, "/") |
| 144 | + ] |
| 145 | + else: |
| 146 | + log.ODM_WARNING("Cannot embed GCP info in point cloud, %s is too large" % gcp_geojson_zip_export_file) |
139 | 147 |
|
140 | 148 | system.run(cmd + ' ' + ' '.join(stages) + ' ' + ' '.join(params))
|
141 | 149 |
|
|
0 commit comments