Handle split-merge of shots.geojson

pull/1109/head
Piero Toffanin 2020-05-15 17:22:10 -04:00
rodzic cfd78b9207
commit 42630c0f41
3 zmienionych plików z 37 dodań i 3 usunięć

Wyświetl plik

@ -1 +1 @@
0.9.8
1.0.0

Wyświetl plik

@ -93,5 +93,24 @@ def get_geojson_shots_from_opensfm(reconstruction_file, geocoords_transformation
else:
raise RuntimeError("%s does not exist." % reconstruction_file)
def merge_geojson_shots(geojson_shots_files):
pass
def merge_geojson_shots(geojson_shots_files, output_geojson_file):
result = None
added_files = {}
for shot_file in geojson_shots_files:
with open(shot_file, "r") as f:
shots = json.loads(f.read())
if result is None:
for feat in shots.get('features', []):
added_files[feat['properties']['filename']] = True
# Use first file as base
result = shots
else:
# Append features if filename not already added
for feat in shots.get('features', []):
if not feat['properties']['filename'] in added_files:
result['features'].append(feat)
with open(output_geojson_file, "w") as f:
f.write(json.dumps(result))

Wyświetl plik

@ -15,6 +15,7 @@ from opensfm.large import metadataset
from opendm.cropper import Cropper
from opendm.concurrency import get_max_memory
from opendm.remote import LocalRemoteExecutor
from opendm.shots import merge_geojson_shots
from opendm import point_cloud
from pipes import quote
@ -341,6 +342,20 @@ class ODMMergeStage(types.ODM_Stage):
if args.merge in ['all', 'dem'] and args.dtm:
merge_dems("dtm.tif", "DTM")
self.update_progress(95)
# Merge reports
if not io.dir_exists(tree.odm_report):
system.mkdir_p(tree.odm_report)
geojson_shots = tree.path(tree.odm_report, "shots.geojson")
if not io.file_exists(geojson_shots) or self.rerun():
geojson_shots_files = get_submodel_paths(tree.submodels_path, "odm_report", "shots.geojson")
log.ODM_INFO("Merging %s shots.geojson files" % len(geojson_shots_files))
merge_geojson_shots(geojson_shots_files, geojson_shots)
else:
log.ODM_WARNING("Found merged shots.geojson in %s" % tree.odm_report)
# Stop the pipeline short! We're done.
self.next_stage = None
else: