Skip to content

Commit

Permalink
Merge pull request #573 from Samweli/masking_skipping_v2
Browse files Browse the repository at this point in the history
Update masking workflow
  • Loading branch information
Samweli authored Nov 22, 2024
2 parents d246b7d + 0861c64 commit be128a2
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/cplus_plugin/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1416,10 +1416,10 @@ def run_internal_activities_masking(

if len(masking_layers) < 1:
self.log_message(
f"Skipping activities masking "
f"Skipping activity masking "
f"No mask layer(s) for activity {activity.name}"
)
return False
continue
if len(masking_layers) > 1:
initial_mask_layer = self.merge_vector_layers(masking_layers)
else:
Expand All @@ -1428,10 +1428,10 @@ def run_internal_activities_masking(

if not initial_mask_layer.isValid():
self.log_message(
f"Skipping activities masking "
f"Skipping activity masking "
f"using layer {mask_layer_path}, not a valid layer."
)
return False
continue

# see https://qgis.org/pyqgis/master/core/Qgis.html#qgis.core.Qgis.GeometryType
if Qgis.versionInt() < 33000:
Expand All @@ -1445,10 +1445,10 @@ def run_internal_activities_masking(

if not layer_check:
self.log_message(
f"Skipping activities masking "
f"Skipping activity masking "
f"using layer {mask_layer_path}, not a polygon layer."
)
return False
continue

extent_layer = self.layer_extent(extent)

Expand All @@ -1457,14 +1457,14 @@ def run_internal_activities_masking(
"Skipping masking, the mask layers crs"
" do not match the scenario crs."
)
return False
continue

if not extent_layer.extent().intersects(initial_mask_layer.extent()):
self.log_message(
"Skipping masking, the mask layers extent"
" and the scenario extent do not overlap."
)
return False
continue

mask_layer = self.mask_layer_difference(
initial_mask_layer, extent_layer
Expand All @@ -1475,22 +1475,22 @@ def run_internal_activities_masking(

if not mask_layer.isValid():
self.log_message(
f"Skipping activities masking "
f"Skipping activity masking "
f"the created difference mask layer {mask_layer.source()},"
f"is not a valid layer."
)
return False
continue
if activity.path is None or activity.path == "":
if not self.processing_cancelled:
self.set_info_message(
tr(
f"Problem when masking activities, "
f"Problem when masking activity, "
f"there is no map layer for the activity {activity.name}"
),
level=Qgis.Critical,
)
self.log_message(
f"Problem when masking activities, "
f"Problem when masking activity, "
f"there is no map layer for the activity {activity.name}"
)
else:
Expand All @@ -1501,7 +1501,7 @@ def run_internal_activities_masking(
)
self.log_message(f"Processing has been cancelled by the user.")

return False
continue

masked_activities_directory = os.path.join(
self.scenario_directory, "final_masked_activities"
Expand All @@ -1525,14 +1525,14 @@ def run_internal_activities_masking(
f"Skipping masking, activity layer and"
f" mask layer(s) have different CRS"
)
return False
continue

if not activity_layer.extent().intersects(mask_layer.extent()):
self.log_message(
"Skipping masking, the extents of the activity layer "
"and mask layers do not overlap."
)
return False
continue

# Actual processing calculation
alg_params = {
Expand All @@ -1546,7 +1546,7 @@ def run_internal_activities_masking(
}

self.log_message(
f"Used parameters for masking the activities: {alg_params} \n"
f"Used parameters for masking the activity {activity.name}: {alg_params} \n"
)

feedback = QgsProcessingFeedback()
Expand Down

0 comments on commit be128a2

Please sign in to comment.