Skip to content

Commit 9015ebc

Browse files
author
Daniel
committed
set calculatiuon range to submodules value, and add clipping range
1 parent 669a1bd commit 9015ebc

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

algorithms/BegrensSkadeImpactMap.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self):
9898
SETTLEMENT_ENUM = ['SETTLEMENT_ENUM', 'Settlement curves']
9999
enum_settlment = [r'0,5 % av byggegropdybde', r'1 % av byggegropdybde', r'2 % av byggegropdybde', r'3 % av byggegropdybde']
100100
RASTER_ROCK_SURFACE = ['RASTER_ROCK_SURFACE', "Input raster of depth to bedrock"]
101-
CALCULATION_RANGE = ['CALCULATION_RANGE', 'Clip radius [meters] in case of high resolution']
101+
CLIPPING_RANGE = ['CLIPPING_RANGE', 'Clip distance in case of high resolution (buffer distance in [meters])']
102102
POREPRESSURE_ENUM = ['POREPRESSURE_ENUM', 'Pore pressure reduction curves']
103103
enum_porepressure = ["Lav poretrykksreduksjon", "Middels poretrykksreduksjon", "Høy poretrykksreduksjon"]
104104
POREPRESSURE_REDUCTION = ['POREPRESSURE_REDUCTION', 'Porepressure reduction [kPa]']
@@ -196,9 +196,9 @@ def initAlgorithm(self, config):
196196

197197
#DEFINING ADVANCED PARAMETERS
198198
param = QgsProcessingParameterNumber(
199-
self.CALCULATION_RANGE[0],
200-
self.tr(f'{self.CALCULATION_RANGE[1]}'),
201-
defaultValue=380
199+
self.CLIPPING_RANGE[0],
200+
self.tr(f'{self.CLIPPING_RANGE[1]}'),
201+
defaultValue=150
202202
)
203203
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
204204
self.addParameter(param)
@@ -312,7 +312,7 @@ def processAlgorithm(self, parameters, context, feedback):
312312
).postgisSrid()
313313
self.logger.info(f"PROCESS - Output CRS: {output_proj}")
314314

315-
calculation_range = self.parameterAsInt(parameters, self.CALCULATION_RANGE[0], context)
315+
clipping_range = self.parameterAsInt(parameters, self.CLIPPING_RANGE[0], context)
316316
porepressure_index = self.parameterAsEnum(
317317
parameters,
318318
self.POREPRESSURE_ENUM[0],
@@ -347,7 +347,8 @@ def processAlgorithm(self, parameters, context, feedback):
347347
if source_raster_rock_surface is not None:
348348
# Get the file path of the raster layer
349349
path_source_raster_rock_surface = source_raster_rock_surface.source().lower().split('|')[0]
350-
self.logger.info(f"PROCESS - Rock raster DTM File path: {path_source_raster_rock_surface}")
350+
self.logger.info(f"PROCESS - Original raster File path: {path_source_raster_rock_surface}")
351+
feedback.pushInfo(f"PROCESS - Original raster File path: {path_source_raster_rock_surface}")
351352

352353
# Check if the file extension is .tif
353354
if path_source_raster_rock_surface.endswith('.tif') or path_source_raster_rock_surface.endswith('.tiff'):
@@ -357,13 +358,15 @@ def processAlgorithm(self, parameters, context, feedback):
357358
feedback.reportError("The raster layer is not a TIFF file. Convert it to TIF/TIFF!")
358359
return {}
359360
feedback.pushInfo("PROCESS - Running process_raster_for_impactmap...")
360-
path_source_raster_rock_surface = process_raster_for_impactmap(source_excavation_poly=source_excavation_poly,
361+
path_processed_raster = process_raster_for_impactmap(source_excavation_poly=source_excavation_poly,
361362
dtb_raster_layer=source_raster_rock_surface,
362-
calculation_range=calculation_range,
363+
clipping_range=clipping_range,
363364
output_resolution=output_resolution,
364-
output_folder=str(output_folder_path),
365+
output_folder=output_folder_path,
365366
context=context,
366367
logger=self.logger)
368+
self.logger.info(f"PROCESS - Intermediate raster path: {str(path_processed_raster)}")
369+
feedback.pushInfo(f"PROCESS - Intermediate raster path: {str(path_processed_raster)}")
367370
feedback.pushInfo("PROCESS - Done running process_raster_for_impactmap...")
368371
if bShortterm:
369372
self.logger.info(f"PROCESS - ######## SHORTTERM ########")
@@ -396,16 +399,36 @@ def processAlgorithm(self, parameters, context, feedback):
396399

397400
feedback.pushInfo("PROCESS - Running mainBegrensSkade_ImpactMap...")
398401
self.logger.info("PROCESS - Running mainBegrensSkade_ImpactMap...")
402+
feedback.pushInfo(f"PROCESS - PARAM excavationJson: {source_excavation_poly_as_json}")
403+
feedback.pushInfo(f"PROCESS - PARAM output_ws: {str(output_folder_path)}")
404+
feedback.pushInfo(f"PROCESS - PARAM output_name: {feature_name}")
405+
feedback.pushInfo(f"PROCESS - PARAM CALCULATION_RANGE: {380}")
406+
feedback.pushInfo(f"PROCESS - PARAM output_proj: {output_proj}")
407+
feedback.pushInfo(f"PROCESS - PARAM dtb_raster: {str(path_processed_raster)}")
408+
feedback.pushInfo(f"PROCESS - PARAM pw_reduction_curve: {pw_reduction_curve}")
409+
feedback.pushInfo(f"PROCESS - PARAM dry_crust_thk: {dry_crust_thk}")
410+
feedback.pushInfo(f"PROCESS - PARAM dep_groundwater: {dep_groundwater}")
411+
feedback.pushInfo(f"PROCESS - PARAM dry_crust_thk: {dry_crust_thk}")
412+
feedback.pushInfo(f"PROCESS - PARAM density_sat: {density_sat}")
413+
feedback.pushInfo(f"PROCESS - PARAM OCR: {ocr_value}")
414+
feedback.pushInfo(f"PROCESS - PARAM porewp_red: {porewp_red}")
415+
feedback.pushInfo(f"PROCESS - PARAM janbu_ref_stress: {janbu_ref_stress}")
416+
feedback.pushInfo(f"PROCESS - PARAM janbu_const: {janbu_const}")
417+
feedback.pushInfo(f"PROCESS - PARAM janbu_m: {janbu_m}")
418+
feedback.pushInfo(f"PROCESS - PARAM consolidation_time: {consolidation_time}")
419+
feedback.pushInfo(f"PROCESS - PARAM bShortterm: {bShortterm}")
420+
feedback.pushInfo(f"PROCESS - PARAM excavation_depth: {excavation_depth}")
421+
feedback.pushInfo(f"PROCESS - PARAM short_term_curve: {short_term_curve}")
399422

400423
try:
401424
output_raster_path = mainBegrensSkade_ImpactMap(
402425
logger=self.logger,
403426
excavationJson=source_excavation_poly_as_json,
404427
output_ws=str(output_folder_path),
405428
output_name=feature_name,
406-
CALCULATION_RANGE=calculation_range,
429+
CALCULATION_RANGE=380, # hardcoded constant used in the underlying submodule's method.
407430
output_proj=output_proj,
408-
dtb_raster=path_source_raster_rock_surface,
431+
dtb_raster=str(path_processed_raster),
409432
pw_reduction_curve=pw_reduction_curve,
410433
dry_crust_thk=dry_crust_thk,
411434
dep_groundwater=dep_groundwater,

metadata.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ hasProcessingProvider=yes
2424
# changelog=24.01.2024 v.1.0.2
2525
- Update a bug in the utility function get_shapefile_as_json_pyqgis, where excavations containing Z/M-dimentions did not process correctly, resulting in an bug in the underlying submodule.
2626

27-
17.01.2024 v.1.0.1
27+
17.01.2024 v.1.0.1
2828
-Initial "release" of the QGIS implementation of NGI's REMEDY_GIS_RiskTool
2929

3030
# Tags are comma separated with spaces allowed

0 commit comments

Comments
 (0)