From a10943142c4b47ca1ea384567fce8a163b7d0597 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 8 Nov 2024 16:04:23 +0000 Subject: [PATCH 1/2] Implement Make the select country more clear #577 --- geest/gui/panels/setup_panel.py | 18 ++++++++++ geest/ui/setup_panel_base.ui | 62 +++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/geest/gui/panels/setup_panel.py b/geest/gui/panels/setup_panel.py index 2a79b9b..013dc94 100644 --- a/geest/gui/panels/setup_panel.py +++ b/geest/gui/panels/setup_panel.py @@ -85,8 +85,26 @@ def initUI(self): self.working_dir = self.previous_project_combo.currentText() self.set_project_directory() + self.load_boundary_button.clicked.connect(self.load_boundary) + self.progress_bar.setVisible(False) + def load_boundary(self): + """Load a boundary layer from a file.""" + file_dialog = QFileDialog() + file_dialog.setFileMode(QFileDialog.ExistingFile) + file_dialog.setNameFilter("GeoPackage (*.gpkg);;Shapefile (*.shp)") + if file_dialog.exec_(): + file_path = file_dialog.selectedFiles()[0] + layer = QgsVectorLayer(file_path, "Boundary", "ogr") + if not layer.isValid(): + QMessageBox.critical( + self, "Error", "Could not load the boundary layer." + ) + return + self.layer_combo.setLayer(layer) + self.field_combo.setLayer(layer) + def select_directory(self): directory = QFileDialog.getExistingDirectory( self, "Select Working Directory", self.working_dir diff --git a/geest/ui/setup_panel_base.ui b/geest/ui/setup_panel_base.ui index b70e33c..f3dbb31 100644 --- a/geest/ui/setup_panel_base.ui +++ b/geest/ui/setup_panel_base.ui @@ -13,8 +13,8 @@ Form - - + + @@ -27,7 +27,7 @@ - + **Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector** @@ -43,14 +43,14 @@ - + Qt::Horizontal - + To get started, we need to select a project folder. The contents of this folder will be managed by Geest. It will store the project file and the working analysis results. @@ -63,7 +63,7 @@ - + @@ -76,7 +76,7 @@ - + @@ -89,7 +89,7 @@ - + Open an existing project folder @@ -115,27 +115,30 @@ - + Start a new project - - - + + + The folder you select should be empty. + + true + - + 📂 Create or select a project directory - + If you do not have a boundary layer you can quickly add one using the button below: @@ -145,14 +148,14 @@ - + Add World Layer - + For new projects you need to select a boundary layer ... @@ -162,10 +165,17 @@ - + - + + + + ... + + + + ... and the boundary name column: @@ -175,17 +185,17 @@ - + - + Use Coordinate Reference System of your boundary layer - + @@ -215,7 +225,7 @@ - + If needed, use the QGIS selection tool to **select your areas of interest** and then press continue to prepare the project. This may take a few minutes.... @@ -228,7 +238,7 @@ - + ⚙️ Prepare project @@ -238,7 +248,7 @@ - + Qt::Vertical @@ -251,14 +261,14 @@ - + 0 - + This plugin is built with support from the Canada Clean Energy and Forest Climate Facility (CCEFCFy), the Geospatial Operational Support Team (GOST, DECSC) for the project Geospatial Assessment of Women Employment and Business Opportunities in the Renewable Energy Sector. From 435d75e096b00812250011ffd9b1ee26a74642a9 Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Fri, 8 Nov 2024 16:13:52 +0000 Subject: [PATCH 2/2] Fix boundary layer selection --- geest/gui/panels/setup_panel.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/geest/gui/panels/setup_panel.py b/geest/gui/panels/setup_panel.py index e79c4af..bfce728 100644 --- a/geest/gui/panels/setup_panel.py +++ b/geest/gui/panels/setup_panel.py @@ -93,7 +93,7 @@ def load_boundary(self): """Load a boundary layer from a file.""" file_dialog = QFileDialog() file_dialog.setFileMode(QFileDialog.ExistingFile) - file_dialog.setNameFilter("GeoPackage (*.gpkg);;Shapefile (*.shp)") + file_dialog.setNameFilter("Shapefile (*.shp);;GeoPackage (*.gpkg)") if file_dialog.exec_(): file_path = file_dialog.selectedFiles()[0] layer = QgsVectorLayer(file_path, "Boundary", "ogr") @@ -102,6 +102,8 @@ def load_boundary(self): self, "Error", "Could not load the boundary layer." ) return + # Load the layer in QGIS + QgsProject.instance().addMapLayer(layer) self.layer_combo.setLayer(layer) self.field_combo.setLayer(layer)