Skip to content

Commit

Permalink
Merge pull request #565 from danangmassandy/feature/mask-activity-online
Browse files Browse the repository at this point in the history
Upload activity masking layers
  • Loading branch information
Samweli authored Nov 25, 2024
2 parents be128a2 + 6bb1a47 commit 312df3c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
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

0 comments on commit 312df3c

Please sign in to comment.