Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
diachronix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Passy
diachronix
Commits
f029b8c0
Commit
f029b8c0
authored
2 years ago
by
Sylvain Théry
Browse files
Options
Downloads
Patches
Plain Diff
improved push message and execptions
parent
f811d5a7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
active_channel_evolution.py
+80
-66
80 additions, 66 deletions
active_channel_evolution.py
with
80 additions
and
66 deletions
active_channel_evolution.py
+
80
−
66
View file @
f029b8c0
...
...
@@ -283,72 +283,86 @@ class active_channel_evolution:
# When OK is pressed
if
result
:
# we grab the value to use for the width of the cross-sections
cross_section_width
=
self
.
dlg
.
spinBoxWidthTransects
.
value
()
# we grav the value to use as distance between two transects
cross_section_distance
=
self
.
dlg
.
spinBoxDistTransects
.
value
()
# we grab the path where to export the layer containing the blocks of the valley bottom
export_vb
=
self
.
dlg
.
lineEditExportValleyFloorBlocks
.
text
()
# we grab the path where to export the csv containing the blocks of the valley bottom
export_csv_vb
=
self
.
dlg
.
lineEditExportTabValleyFloorBlocks
.
text
()
# we grab if we have to reverse the centerline of the valley floor
flag_reverse_vb
=
self
.
dlg
.
checkBoxReverseValleyFloor
.
isChecked
()
# we grab the layer of the blocks of the valley bottom to use to process the active channel
input_blocks_vb
=
self
.
dlg
.
lineEditInBlocksValleyFloor
.
text
()
# we grab the path where to export the layer containing the blocks of the active channel
export_ac
=
self
.
dlg
.
lineEditExportActiveBandBlocks
.
text
()
export_csv_ac
=
self
.
dlg
.
lineEditExportTabActiveBandBlocks
.
text
()
# we grab the layer of the valley bottom
selected_layer_vb
=
self
.
dlg
.
comboBoxValleyFloor
.
currentLayer
()
# we grab the layer of the active channel
selected_layer_ac
=
self
.
dlg
.
comboBoxActiveBand
.
currentLayer
()
outputs
=
{}
# if the user wants to detect the starting point of the valley bottom
if
flag_detect_start_point
==
True
:
detect_starting_point
(
QgsProject
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_vb
,
name_starting_point
)
# if the user wants to run only the processing of the valley bottom
if
(
flag_run_vb
==
True
and
flag_run_ac
==
False
)
and
flag_detect_start_point
==
False
:
valley_bottom_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_vb
,
flag_reverse_vb
,
cross_section_width
,
cross_section_distance
,
export_vb
,
export_csv_vb
,
flag_load_temp_vb
,
name_valley_bottom_blocks
,
name_valley_bottom_centerline
,
name_valley_bottom_cross_sections
,
name_valley_bottom_rk
)
# if the user wants to run only the processing of the active channel
if
flag_run_ac
==
True
and
flag_run_vb
==
False
:
active_channel_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_ac
,
input_blocks_vb
,
export_ac
,
export_csv_ac
,
flag_load_temp_ac
,
name_active_channel_blocks
,
name_active_channel_centerline
)
# if the user wants to run in one time the processing of the valley bottom followed by the processing
# of the active channel
if
flag_run_vb
==
True
and
flag_run_ac
==
True
:
self
.
iface
.
messageBar
().
pushMessage
(
self
.
tr
(
"
Step 1 - Valley bottom processing
"
),
level
=
Qgis
.
Info
,
duration
=
5
)
try
:
# we grab the value to use for the width of the cross-sections
cross_section_width
=
self
.
dlg
.
spinBoxWidthTransects
.
value
()
# we grav the value to use as distance between two transects
cross_section_distance
=
self
.
dlg
.
spinBoxDistTransects
.
value
()
# we grab the path where to export the layer containing the blocks of the valley bottom
export_vb
=
self
.
dlg
.
lineEditExportValleyFloorBlocks
.
text
()
# we grab the path where to export the csv containing the blocks of the valley bottom
export_csv_vb
=
self
.
dlg
.
lineEditExportTabValleyFloorBlocks
.
text
()
# we grab if we have to reverse the centerline of the valley floor
flag_reverse_vb
=
self
.
dlg
.
checkBoxReverseValleyFloor
.
isChecked
()
# we grab the layer of the blocks of the valley bottom to use to process the active channel
input_blocks_vb
=
self
.
dlg
.
lineEditInBlocksValleyFloor
.
text
()
# we grab the path where to export the layer containing the blocks of the active channel
export_ac
=
self
.
dlg
.
lineEditExportActiveBandBlocks
.
text
()
export_csv_ac
=
self
.
dlg
.
lineEditExportTabActiveBandBlocks
.
text
()
# we grab the layer of the valley bottom
selected_layer_vb
=
self
.
dlg
.
comboBoxValleyFloor
.
currentLayer
()
# we grab the layer of the active channel
selected_layer_ac
=
self
.
dlg
.
comboBoxActiveBand
.
currentLayer
()
outputs
=
{}
# if the user wants to detect the starting point of the valley bottom
if
flag_detect_start_point
==
True
:
detect_starting_point
(
QgsProject
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_vb
,
name_starting_point
)
# if the user wants to run only the processing of the valley bottom
if
(
flag_run_vb
==
True
and
flag_run_ac
==
False
)
and
flag_detect_start_point
==
False
:
valley_bottom_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_vb
,
flag_reverse_vb
,
cross_section_width
,
cross_section_distance
,
export_vb
,
export_csv_vb
,
flag_load_temp_vb
,
name_valley_bottom_blocks
,
name_valley_bottom_centerline
,
name_valley_bottom_cross_sections
,
name_valley_bottom_rk
)
# if the user wants to run only the processing of the active channel
if
flag_run_ac
==
True
and
flag_run_vb
==
False
:
active_channel_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_ac
,
input_blocks_vb
,
export_ac
,
export_csv_ac
,
flag_load_temp_ac
,
name_active_channel_blocks
,
name_active_channel_centerline
)
# if the user wants to run in one time the processing of the valley bottom followed by the processing
# of the active channel
if
flag_run_vb
==
True
and
flag_run_ac
==
True
:
self
.
iface
.
messageBar
().
pushMessage
(
self
.
tr
(
"
Step 1 - Valley bottom processing
"
),
level
=
Qgis
.
Info
)
self
.
iface
.
mainWindow
().
repaint
()
input_blocks_vb
=
valley_bottom_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_vb
,
flag_reverse_vb
,
cross_section_width
,
cross_section_distance
,
export_vb
,
export_csv_vb
,
flag_load_temp_vb
,
name_valley_bottom_blocks
,
name_valley_bottom_centerline
,
name_valley_bottom_cross_sections
,
name_valley_bottom_rk
)
self
.
iface
.
messageBar
().
clearWidgets
()
self
.
iface
.
messageBar
().
pushMessage
(
self
.
tr
(
"
Step 2 - Active channel processing
"
),
level
=
Qgis
.
Info
)
self
.
iface
.
mainWindow
().
repaint
()
active_channel_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_ac
,
input_blocks_vb
,
export_ac
,
export_csv_ac
,
flag_load_temp_ac
,
name_active_channel_blocks
,
name_active_channel_centerline
)
a
=
5
/
0
# Show success message when finished
self
.
iface
.
messageBar
().
clearWidgets
()
self
.
iface
.
messageBar
().
pushMessage
(
"
♪♪ This is the End, my only friend, the End ♪♪
"
,
level
=
Qgis
.
Success
,
duration
=
5
)
# we disconnect from the different menus
self
.
dlg
.
pushButtonExportValleyFloorBlocks
.
clicked
.
disconnect
(
self
.
select_output_blocks_vb
)
self
.
dlg
.
pushButtonExportTabValleyFloorBlocks
.
clicked
.
disconnect
(
self
.
select_output_tab_blocks_vb
)
self
.
dlg
.
pushButtonExportActiveBandBlocks
.
clicked
.
disconnect
(
self
.
select_output_blocks_ac
)
self
.
dlg
.
pushButtonExportTabActiveBandBlocks
.
clicked
.
disconnect
(
self
.
select_output_tab_blocks_ac
)
self
.
dlg
.
pushButtonInBlocksValleyFloor
.
clicked
.
disconnect
(
self
.
select_input_blocks_vb
)
except
Exception
as
inst
:
# print info in console
print
(
type
(
inst
))
# the exception instance
print
(
inst
.
args
)
# arguments stored in .args
print
(
inst
)
# send a message to the user
self
.
iface
.
messageBar
().
clearWidgets
()
self
.
iface
.
mainWindow
().
repaint
()
input_blocks_vb
=
valley_bottom_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_vb
,
flag_reverse_vb
,
cross_section_width
,
cross_section_distance
,
export_vb
,
export_csv_vb
,
flag_load_temp_vb
,
name_valley_bottom_blocks
,
name_valley_bottom_centerline
,
name_valley_bottom_cross_sections
,
name_valley_bottom_rk
)
self
.
iface
.
messageBar
().
pushMessage
(
self
.
tr
(
"
Something went wrong. See Python console for details :/
"
),
level
=
Qgis
.
Critical
)
self
.
iface
.
messageBar
().
pushMessage
(
self
.
tr
(
"
Step 2 - Active channel processing
"
),
level
=
Qgis
.
Info
,
duration
=
5
)
self
.
iface
.
mainWindow
().
repaint
()
active_channel_processing
(
QgsProject
,
QgsVectorLayer
,
outputs
,
QgsProcessing
,
processing
,
selected_layer_ac
,
input_blocks_vb
,
export_ac
,
export_csv_ac
,
flag_load_temp_ac
,
name_active_channel_blocks
,
name_active_channel_centerline
)
# Show success message when finished
self
.
iface
.
messageBar
().
pushMessage
(
"
♪♪ This is the End, my only friend, the End ♪♪
"
,
level
=
Qgis
.
Success
,
duration
=
3
)
# we deconnect from the different menus
self
.
dlg
.
pushButtonExportValleyFloorBlocks
.
clicked
.
disconnect
(
self
.
select_output_blocks_vb
)
self
.
dlg
.
pushButtonExportTabValleyFloorBlocks
.
clicked
.
disconnect
(
self
.
select_output_tab_blocks_vb
)
self
.
dlg
.
pushButtonExportActiveBandBlocks
.
clicked
.
disconnect
(
self
.
select_output_blocks_ac
)
self
.
dlg
.
pushButtonExportTabActiveBandBlocks
.
clicked
.
disconnect
(
self
.
select_output_tab_blocks_ac
)
self
.
dlg
.
pushButtonInBlocksValleyFloor
.
clicked
.
disconnect
(
self
.
select_input_blocks_vb
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment