-
-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1412 from pierotofy/autobands
Adds support for automatically selecting the proper band filter
- Loading branch information
Showing
13 changed files
with
276 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 2.2.27 on 2023-10-02 10:21 | ||
|
||
import rasterio | ||
import os | ||
import django.contrib.postgres.fields.jsonb | ||
from django.db import migrations | ||
from webodm import settings | ||
|
||
def update_orthophoto_bands_fields(apps, schema_editor): | ||
Task = apps.get_model('app', 'Task') | ||
|
||
for t in Task.objects.all(): | ||
|
||
bands = [] | ||
orthophoto_path = os.path.join(settings.MEDIA_ROOT, "project", str(t.project.id), "task", str(t.id), "assets", "odm_orthophoto", "odm_orthophoto.tif") | ||
|
||
if os.path.isfile(orthophoto_path): | ||
try: | ||
with rasterio.open(orthophoto_path) as f: | ||
names = [c.name for c in f.colorinterp] | ||
for i, n in enumerate(names): | ||
bands.append({ | ||
'name': n, | ||
'description': f.descriptions[i] | ||
}) | ||
except Exception as e: | ||
print(e) | ||
|
||
print("Updating {} (with orthophoto bands: {})".format(t, str(bands))) | ||
|
||
t.orthophoto_bands = bands | ||
t.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('app', '0038_remove_task_console_output'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_orthophoto_bands_fields), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.