Skip to content

Commit

Permalink
Merge pull request #103 from Samweli/project_instances_reporting
Browse files Browse the repository at this point in the history
Implementation of project instances reporting functionality
  • Loading branch information
Samweli committed Oct 15, 2024
2 parents a2f07c0 + 04ed301 commit 00a81b3
Show file tree
Hide file tree
Showing 16 changed files with 4,473 additions and 642 deletions.
16 changes: 11 additions & 5 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"general": {
"name" : "QGIS GEA afforestation tool",
"name": "QGIS GEA afforestation tool",
"qgisMinimumVersion": 3.20,
"qgisMaximumVersion": 3.99,
"icon": "icon.png",
Expand All @@ -9,14 +9,20 @@
"homepage": "https://github.com/kartoza/qgis-gea-plugin",
"tracker": "https://github.com/kartoza/qgis-gea-plugin/issues",
"repository": "https://github.com/kartoza/qgis-gea-plugin",
"tags": ["gea", "maps", "afforestation"],
"category": ["plugins"],
"tags": [
"gea",
"maps",
"afforestation"
],
"category": [
"plugins"
],
"hasProcessingProvider": "no",
"about": "Adds functionality inside QGIS to enable GEA afforestation visualization and analysis.",
"author": "Kartoza",
"email": "[email protected]",
"description": "View, browse and navigate through imagery.",
"version": "0.0.1",
"version": "1.0.1dev",
"changelog": ""
}
}
}
1 change: 1 addition & 0 deletions src/qgis_gea_plugin/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Settings(enum.Enum):
ANIMATION_LOOP = 'animation_loop'

LAST_SITE_LAYER_PATH = 'last_site_layer_path'
CURRENT_PROJECT_LAYER_PATH = 'current_project_layer_path'


class SettingsManager(QtCore.QObject):
Expand Down
1,646 changes: 1,646 additions & 0 deletions src/qgis_gea_plugin/data/report_templates/project_instance.qpt

Large diffs are not rendered by default.

1,449 changes: 1,148 additions & 301 deletions src/qgis_gea_plugin/data/report_templates/reforestation_site.qpt

Large diffs are not rendered by default.

971 changes: 971 additions & 0 deletions src/qgis_gea_plugin/data/style/project_instances_style.qml

Large diffs are not rendered by default.

21 changes: 5 additions & 16 deletions src/qgis_gea_plugin/definitions/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ANIMATION_PLAY_ICON = ":/images/themes/default/mActionPlay.svg"
ANIMATION_PAUSE_ICON = ":/images/themes/default/temporal_navigation/pause.svg"


COUNTRY_NAMES = [
"Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antigua and Barbuda",
"Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas",
Expand Down Expand Up @@ -64,6 +65,10 @@
PROJECT_INSTANCES_GROUP_NAME = "Project Instances"

SITE_REPORT_TEMPLATE_NAME = "reforestation_site.qpt"
PROJECT_INSTANCE_REPORT_TEMPLATE_NAME = "project_instance.qpt"

PROJECT_INSTANCE_STYLE = "project_instances_style.qml"


FARMER_ID_FIELD = "FarmerID"

Expand All @@ -80,20 +85,4 @@
"joinstyle": "round"
}

# Style for the project instances in the map and report

PROJECT_INSTANCE_BOUNDARY_STYLE = {
'border_width_map_unit_scale': '3x:0,0,0,0,0,0',
'color': '243,166,178,0,rgb:0.95294117647058818,0.65098039215686276,0.69803921568627447,0',
'joinstyle': 'bevel',
'offset': '0,0',
'offset_map_unit_scale': '3x:0,0,0,0,0,0',
'offset_unit': 'MM',
'outline_color': '59,255,59,255',
'outline_style': 'solid',
'outline_width': '0.3',
'outline_width_unit': 'MM',
'style': 'no'
}

REPORT_LANDSCAPE_DESCRIPTION_SUFFIX = "with and without exclusion masks and proposed site:"
31 changes: 19 additions & 12 deletions src/qgis_gea_plugin/gui/attribute_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ def accept(self):

self.layer.startEditing()

incep_date = datetime.now().strftime('%m:%Y')

fields = self.layer.fields()

new_fields = ['author', 'project', 'IncepDate', 'area (ha)']
new_fields = ['author', 'project','area (ha)']
attributes = []

for field in new_fields:
Expand All @@ -95,7 +93,8 @@ def accept(self):
self,
tr("QGIS GEA PLUGIN"),
tr('Field "{}" already exists in the layer.'
'Do you want to proceed and overwrite it?').format(field),
'Do you want to proceed and overwrite it?').
format(field),

QtWidgets.QMessageBox.Yes,
QtWidgets.QMessageBox.No,
Expand All @@ -106,9 +105,12 @@ def accept(self):
self.layer.commitChanges()
return
else:
# If not found in the layer add it to the list of attributes that will
# be added to layer fields later
attributes.append(QgsField(field, QtCore.QVariant.String))
# If not found in the layer add it to the list
# of attributes that will be added to layer fields later
attributes.append(QgsField(
field,
QtCore.QVariant.String)
)

provider = self.layer.dataProvider()
provider.addAttributes(attributes)
Expand All @@ -125,16 +127,21 @@ def accept(self):
area = geom.area() / 10000
feature_area = f"{area:,.2f}"

feature.setAttribute("author", self.report_author_le.text())
feature.setAttribute("project", self.project_cmb_box.currentText())
feature.setAttribute("IncepDate", incep_date)
feature.setAttribute(
"author",
self.report_author_le.text()
)
feature.setAttribute(
"project",
self.project_cmb_box.currentText()
)
feature.setAttribute("area (ha)", feature_area)

self.layer.updateFeature(feature)
feature = next(features, None) # Retrieve the next feature
# Retrieve the next feature
feature = next(features, None)

self.layer.commitChanges()

self.layer.setReadOnly(True)

super().accept()
Expand Down
Loading

0 comments on commit 00a81b3

Please sign in to comment.