Skip to content

Commit f7b0788

Browse files
danpejoboDaniel
andauthored
v.3.1.0 (#10)
* Configure and dd dev-environment * try to get testing to work * testfile * add workflow_dispatch to action * add pycodestyle to makefile * remove qgis 3_22 * trying tests again * test * update action * try another pth * update path in github action * edit path * edit variable * add debug step * add directory * edit paths * edit paths * update import statement and tests * update tests * add _init__ to submodule in github action * edit path * update test paths * edit paths * add submodule * tests update * update test * edit test * tests * test import error * update tests * edit test * update test * test case * short only * test case * run test on main/dev on push/pull-req * add test calls * error in yml file * edit tests * update testcase * edit test case * try cp testfiles * edit steps * edit test and settings * edit test * update test * restructure repo * restructure repo * update readme * update readme * edit readme * update readme * edit makefile to reflect new repo structure * update paths in github actions * edit action and test * change name on utils to utilities * edit github action * edit check plugin load * edit tests, add badge to readme * edit tests * update test * try to fix import. relative to absolute * edit docstring * update docstring * update docstring * update test * edit test * update test * update test * update test * update test * update test * update testing * update test * test update * update test, add feedback if exception * change to absolute import * edit test * edit test * update text for output feature name variable * update test * update test and add test badge to readme * add issue templates * update test * change testcase CRS * exclude long-term from test * update test * remove redundant logger * edit util reproject raster "TARGET_CRS" * edit test * edit test * add context to temp folder * add prefix to logging and feedback in @reproject_layers * try to use postprocessing * edit test * remove intermediate option * remove intermediate laayers #2 * edit algorithm to postprocess * add QgsProcessingException * edit param input for reproject * edit reproject * edit begrensskade * update test * edit post-process * try to edit the addlayerstask * edit test and log values to reproject * edit reproject * is child added * try with reproject raster change input and source_crs * try postprocess with addlayerstask class * add tests and test data * format code * edit add layers class * add docstring to postprocess * edit tests for excavation module * update testcase * remove tricky "lower()" call to raster path. * edit wrong testnumber * add tests to impact map * edit tests * update test. error in calling alg. * update parameters - test for tunnel * update readme * update readme * update testcase * edit copyright dates * edit sub-processes parameters * v.3.0.0 * fix bug in vulnerability analysis: optional fields input allowed * update test with coverage * test - try with coverage * test w/o coverage * edit test_suite * v.3.1.0 --------- Co-authored-by: Daniel <[email protected]>
1 parent af4912e commit f7b0788

File tree

5 files changed

+70
-24
lines changed

5 files changed

+70
-24
lines changed

geovita_processing_plugin/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
__date__ = '2024-01-17'
2727
__copyright__ = '(C) 2024 by DPE'
2828

29-
__version__ = "3.0.0"
29+
__version__ = "3.1.0"
3030

3131
import sys
3232
from pathlib import Path

geovita_processing_plugin/algorithms/BegrensSkadeExcavation.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,29 +413,43 @@ def initAlgorithm(self, config):
413413
param = QgsProcessingParameterField(
414414
self.FILED_NAME_BUILDING_FOUNDATION[0],
415415
self.tr(f"{self.FILED_NAME_BUILDING_FOUNDATION[1]}"),
416+
defaultValue=None,
416417
parentLayerParameterName=self.INPUT_BUILDING_POLY,
417418
allowMultiple=False,
418419
optional=True,
419420
)
420-
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
421+
param.setFlags(
422+
QgsProcessingParameterDefinition.FlagAdvanced
423+
| QgsProcessingParameterDefinition.FlagOptional
424+
)
425+
421426
self.addParameter(param)
422427
param = QgsProcessingParameterField(
423428
self.FILED_NAME_BUILDING_STRUCTURE[0],
424429
self.tr(f"{self.FILED_NAME_BUILDING_STRUCTURE[1]}"),
430+
defaultValue=None,
425431
parentLayerParameterName=self.INPUT_BUILDING_POLY,
426432
allowMultiple=False,
427433
optional=True,
428434
)
429-
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
435+
param.setFlags(
436+
QgsProcessingParameterDefinition.FlagAdvanced
437+
| QgsProcessingParameterDefinition.FlagOptional
438+
)
439+
430440
self.addParameter(param)
431441
param = QgsProcessingParameterField(
432442
self.FILED_NAME_BUILDING_STATUS[0],
433443
self.tr(f"{self.FILED_NAME_BUILDING_STATUS[1]}"),
444+
defaultValue=None,
434445
parentLayerParameterName=self.INPUT_BUILDING_POLY,
435446
allowMultiple=False,
436447
optional=True,
437448
)
438-
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
449+
param.setFlags(
450+
QgsProcessingParameterDefinition.FlagAdvanced
451+
| QgsProcessingParameterDefinition.FlagOptional
452+
)
439453
self.addParameter(param)
440454

441455
# DEFINE OUTPUTS
@@ -621,9 +635,9 @@ def processAlgorithm(self, parameters, context, feedback):
621635
return {}
622636

623637
# Get the file path of the raster layer
624-
path_source_raster_rock_surface = (
625-
source_raster_rock_surface.source().split("|")[0]
626-
)
638+
path_source_raster_rock_surface = source_raster_rock_surface.source().split(
639+
"|"
640+
)[0]
627641
self.logger.info(
628642
f"PROCESS - Rock raster DTM File path: {path_source_raster_rock_surface}"
629643
)
@@ -686,23 +700,30 @@ def processAlgorithm(self, parameters, context, feedback):
686700
if bVulnerability:
687701
self.logger.info("PROCESS - ######## VULNERABILITY ########")
688702
self.logger.info("PROCESS - Defining vulnerability input")
689-
foundation_field = self.parameterAsString(
703+
foundation_field_param = self.parameterAsString(
690704
parameters, self.FILED_NAME_BUILDING_FOUNDATION[0], context
691705
)
706+
foundation_field = (
707+
foundation_field_param if foundation_field_param.strip() else None
708+
)
692709
self.logger.info(
693710
f"PROCESS - Foundation: {foundation_field} Type: {type(foundation_field)}"
694711
)
695712

696-
structure_field = self.parameterAsString(
713+
structure_field_param = self.parameterAsString(
697714
parameters, self.FILED_NAME_BUILDING_STRUCTURE[0], context
698715
)
716+
structure_field = (
717+
structure_field_param if structure_field_param.strip() else None
718+
)
699719
self.logger.info(
700720
f"PROCESS - Structure: {structure_field} Type: {type(structure_field)}"
701721
)
702722

703-
status_field = self.parameterAsString(
723+
status_field_param = self.parameterAsString(
704724
parameters, self.FILED_NAME_BUILDING_STATUS[0], context
705725
)
726+
status_field = status_field_param if status_field_param.strip() else None
706727
self.logger.info(
707728
f"PROCESS - Condition: {status_field} Type: {type(status_field)}"
708729
)
@@ -848,8 +869,8 @@ def postProcessAlgorithm(self, context, feedback):
848869
"""
849870
Handles the post-processing steps of the algorithm, specifically adding output layers to the QGIS project.
850871
851-
This method creates and executes a process to add layers to the QGIS interface, applying predefined styles
852-
and organizing them within a specified group. It leverages the `AddLayersTask` class to manage layer
872+
This method creates and executes a process to add layers to the QGIS interface, applying predefined styles
873+
and organizing them within a specified group. It leverages the `AddLayersTask` class to manage layer
853874
addition in a way that ensures thread safety and proper GUI updates.
854875
855876
Parameters:
@@ -860,7 +881,7 @@ def postProcessAlgorithm(self, context, feedback):
860881
- dict: An empty dictionary. This method does not produce output parameters but instead focuses on the side effect of adding layers to the project.
861882
862883
Note:
863-
This method sets up a task for layer addition, defining success and failure callbacks to provide user feedback.
884+
This method sets up a task for layer addition, defining success and failure callbacks to provide user feedback.
864885
It manually starts the process and handles its completion.
865886
"""
866887
######### EXPERIMENTAL ADD LAYERS TO GUI #########

geovita_processing_plugin/algorithms/BegrensSkadeTunnel.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,29 +433,43 @@ def initAlgorithm(self, config):
433433
param = QgsProcessingParameterField(
434434
self.FILED_NAME_BUILDING_FOUNDATION[0],
435435
self.tr(f"{self.FILED_NAME_BUILDING_FOUNDATION[1]}"),
436+
defaultValue=None,
436437
parentLayerParameterName=self.INPUT_BUILDING_POLY,
437438
allowMultiple=False,
438439
optional=True,
439440
)
440-
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
441+
param.setFlags(
442+
QgsProcessingParameterDefinition.FlagAdvanced
443+
| QgsProcessingParameterDefinition.FlagOptional
444+
)
441445
self.addParameter(param)
446+
442447
param = QgsProcessingParameterField(
443448
self.FILED_NAME_BUILDING_STRUCTURE[0],
444449
self.tr(f"{self.FILED_NAME_BUILDING_STRUCTURE[1]}"),
450+
defaultValue=None,
445451
parentLayerParameterName=self.INPUT_BUILDING_POLY,
446452
allowMultiple=False,
447453
optional=True,
448454
)
449-
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
455+
param.setFlags(
456+
QgsProcessingParameterDefinition.FlagAdvanced
457+
| QgsProcessingParameterDefinition.FlagOptional
458+
)
450459
self.addParameter(param)
460+
451461
param = QgsProcessingParameterField(
452462
self.FILED_NAME_BUILDING_STATUS[0],
453463
self.tr(f"{self.FILED_NAME_BUILDING_STATUS[1]}"),
464+
defaultValue=None,
454465
parentLayerParameterName=self.INPUT_BUILDING_POLY,
455466
allowMultiple=False,
456467
optional=True,
457468
)
458-
param.setFlags(QgsProcessingParameterDefinition.FlagAdvanced)
469+
param.setFlags(
470+
QgsProcessingParameterDefinition.FlagAdvanced
471+
| QgsProcessingParameterDefinition.FlagOptional
472+
)
459473
self.addParameter(param)
460474

461475
# DEFINE OUTPUTS
@@ -713,23 +727,30 @@ def processAlgorithm(self, parameters, context, feedback):
713727
if bVulnerability:
714728
self.logger.info("PROCESS - ######## VULNERABILITY ########")
715729
self.logger.info("PROCESS - Defining vulnerability input")
716-
foundation_field = self.parameterAsString(
730+
foundation_field_param = self.parameterAsString(
717731
parameters, self.FILED_NAME_BUILDING_FOUNDATION[0], context
718732
)
733+
foundation_field = (
734+
foundation_field_param if foundation_field_param.strip() else None
735+
)
719736
self.logger.info(
720737
f"PROCESS - Foundation: {foundation_field} Type: {type(foundation_field)}"
721738
)
722739

723-
structure_field = self.parameterAsString(
740+
structure_field_param = self.parameterAsString(
724741
parameters, self.FILED_NAME_BUILDING_STRUCTURE[0], context
725742
)
743+
structure_field = (
744+
structure_field_param if structure_field_param.strip() else None
745+
)
726746
self.logger.info(
727747
f"PROCESS - Structure: {structure_field} Type: {type(structure_field)}"
728748
)
729749

730-
status_field = self.parameterAsString(
750+
status_field_param = self.parameterAsString(
731751
parameters, self.FILED_NAME_BUILDING_STATUS[0], context
732752
)
753+
status_field = status_field_param if status_field_param.strip() else None
733754
self.logger.info(
734755
f"PROCESS - Condition: {status_field} Type: {type(status_field)}"
735756
)
@@ -880,8 +901,8 @@ def postProcessAlgorithm(self, context, feedback):
880901
"""
881902
Handles the post-processing steps of the algorithm, specifically adding output layers to the QGIS project.
882903
883-
This method creates and executes a process to add layers to the QGIS interface, applying predefined styles
884-
and organizing them within a specified group. It leverages the `AddLayersTask` class to manage layer
904+
This method creates and executes a process to add layers to the QGIS interface, applying predefined styles
905+
and organizing them within a specified group. It leverages the `AddLayersTask` class to manage layer
885906
addition in a way that ensures thread safety and proper GUI updates.
886907
887908
Parameters:
@@ -892,7 +913,7 @@ def postProcessAlgorithm(self, context, feedback):
892913
- dict: An empty dictionary. This method does not produce output parameters but instead focuses on the side effect of adding layers to the project.
893914
894915
Note:
895-
This method sets up a task for layer addition, defining success and failure callbacks to provide user feedback.
916+
This method sets up a task for layer addition, defining success and failure callbacks to provide user feedback.
896917
It manually starts the process and handles its completion.
897918
"""
898919
######### EXPERIMENTAL ADD LAYERS TO GUI #########

geovita_processing_plugin/metadata.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ repository=https://github.com/danpejobo/geovita_processing_plugin
2828

2929
hasProcessingProvider=yes
3030
# Uncomment the following line and add your changelog:
31-
changelog=v.3.0.0 (09.02.2024)
31+
changelog=v.3.1.0 (14.02.2024)
32+
- Minor fix in vulnerability analysis for excavation and tunnel. Fields can be omitted (i.e corresponding analysis are dropped). Any combination of the three vulnerability fields can be assessed.
33+
34+
v.3.0.0 (09.02.2024)
3235
- Restructure codebase
3336
- Implement postprocessing to add layers (was still some threading issues)
3437
- Add tests to try and mitigate the risk of publishing a broken plugin

geovita_processing_plugin/test_suite.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _run_tests(test_suite, package_name, with_coverage=False):
4444
if with_coverage:
4545
cov = coverage.Coverage(
4646
source=['/geovita_processing_plugin'],
47-
omit=['*/test/*'],
47+
omit=['*/test/*', '*/test_suite.py'],
4848
)
4949
cov.start()
5050

@@ -54,6 +54,7 @@ def _run_tests(test_suite, package_name, with_coverage=False):
5454
cov.stop()
5555
cov.save()
5656
report = tempfile.NamedTemporaryFile(delete=False) # pylint: disable=consider-using-with
57+
#report = sys.stdout
5758
cov.report(file=report)
5859
# Produce HTML reports in the `htmlcov` folder and open index.html
5960
# cov.html_report()

0 commit comments

Comments
 (0)