Impact Layer Merge Dialog.
Contact : ole.moller.nielsen@gmail.com
Note
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Bases: PyQt4.QtGui.QDialog, Ui_ImpactMergeDialogBase
Tools for merging 2 impact layer based on different exposure.
Generate html file for each aggregation units.
It also saves the path of the each aggregation unit in self.html_reports.
Ex. {"jakarta barat": "/home/jakarta barat.html",
"jakarta timur": "/home/jakarta timur.html"}
Parameters: |
|
---|
Generate dictionary representing report from html dom.
Parameters: | html_dom (str) – Input representing document dom as report from each impact layer report. |
---|---|
Returns: | Dictionary representing html_dom. |
Return type: | dict |
Dictionary Structure:
{ Aggregation_Area:
{Exposure Type:{
Exposure Detail}
}
}
Example:
{"Jakarta Barat":
{"Closed buildings":
{"Total inundated":150,
"Places of Worship": "No data"
}
}
}
Generate report summary for each aggregation area from merged report dictionary.
For each exposure, search for the total only. Report dictionary looks like this:
Parameters: |
|
---|
Dictionary structure:
{ aggregation_area:
{exposure_type:{
exposure_detail}
}
}
Example:
{"Jakarta Barat":
{"Closed buildings":
{"Total inundated":150,
"Places of Worship": "No data"
}
}
}
Generate PDF reports for each aggregation unit using map composer.
First the report template is loaded with the renderer from two impact layers. After it’s loaded, if it is not aggregated then we just use composition to produce report. Since there are two impact maps here, we need to set a new extent for these impact maps by a simple calculation.
If it is not aggregated then we use a powerful QGIS atlas generation on composition. Since we save each report table representing each aggregated area on self.html_report (which is a dictionary with the aggregation area name as a key and its path as a value), and we set the aggregation area name as current filename on atlas generation, we can match these two so that we have the right report table for each report.
For those two cases, we use the same template. The report table is basically an HTML frame. Of course after the merging process is done, we delete each report table on self.html_reports physically on disk.
Show or hide the help tab in the stacked widget.
Parameters: | flag (bool) – Flag indicating whether help should be shown or hidden. |
---|
Load composer template for merged report.
Validate it as well. The template needs to have: 1. QgsComposerMap with id ‘impact-map’ for merged impact map. 2. QgsComposerPicture with id ‘safe-logo’ for InaSAFE logo. 3. QgsComposerLabel with id ‘summary-report’ for a summary of two impacts. 4. QgsComposerLabel with id ‘aggregation-area’ to indicate the area of aggregation. 5. QgsComposerScaleBar with id ‘map-scale’ for impact map scale. 6. QgsComposerLegend with id ‘map-legend’ for impact map legend. 7. QgsComposerPicture with id ‘organisation-logo’ for organisation logo. 8. QgsComposerLegend with id ‘impact-legend’ for map legend. 9. QgsComposerHTML with id ‘merged-report-table’ for the merged report.
Parameters: | map_settings (QgsMapSettings, QgsMapRenderer) – Map settings. |
---|
Fetch all the input from dialog, validate, and store it.
Consider this as a bridge between dialog interface and our logical stored data in this class
Raises: | InvalidLayerError, CanceledImportDialogError |
---|
Ensure directory path entered in dialog exist.
When the path does not exist, this function will ask the user if he wants to create it or not.
Raises: | CanceledImportDialogError - when user chooses ‘No’ in the question dialog for creating directory, or ‘Yes’ but the output directory path is empty |
---|
Validate all layers based on the keywords.
When we do the validation, we also fetch the information we need:
The things that we validate are: