Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of project instances reporting functionality #103

Merged
merged 14 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading