Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload activity masking layers #565

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/cplus_plugin/api/scenario_task_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,21 @@ def build_scenario_detail_json(self) -> None:
continue
priority_layer["path"] = ""
new_priority_layers.append(priority_layer)

mask_uuids = []
for mask_path in activity["mask_paths"]:
mask_path = mask_path.replace(".shp", ".zip")
if mask_path.startswith("cplus://"):
names = mask_path.split("/")
mask_path.append(names[-2])
elif os.path.exists(mask_path):
if self.path_to_layer_mapping.get(mask_path, None):
mask_uuids.append(
self.path_to_layer_mapping.get(mask_path)["uuid"]
)
activity["priority_layers"] = new_priority_layers
activity["mask_uuids"] = mask_uuids
activity["mask_paths"] = []

self.scenario_detail = {
"scenario_name": old_scenario_dict["name"],
Expand Down
2 changes: 2 additions & 0 deletions src/cplus_plugin/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ def from_dict(cls, activity_dict: typing.Dict):
del pathway["carbon_uuids"]
pathways.append(NcsPathway(**pathway))
activity_dict["pathways"] = pathways
# delete mask_uuids using pop
activity_dict.pop("mask_uuids", None)
return Activity(**activity_dict)

def __post_init__(self):
Expand Down
7 changes: 7 additions & 0 deletions src/cplus_plugin/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def get_masking_layers(self) -> typing.List:
)
masking_layers = masking_layers_paths.split(",") if masking_layers_paths else []
masking_layers.remove("") if "" in masking_layers else None
masking_layers.extend(
[
mask_path
for activity in self.analysis_activities
for mask_path in activity.mask_paths
]
)
return masking_layers

def cancel_task(self, exception=None):
Expand Down
Loading