InaSAFE Disaster risk assessment tool developed by AusAid - GUI 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.
Todo
Check raster is single band
Dock implementation class for the inaSAFE plugin.
Execute analysis when run button is clicked.
Todo
FIXME (Tim) We may have to implement some polling logic because the button click accept() function and the updating of the web view after model completion are asynchronous (when threading mode is enabled especially)
Deal with user cancelling post processing option dialog.
A helper slot to update dock combos if canvas layerset changes.
Activated when the layerset has been changed (e.g. one or more layer visibilities changed). If self.showOnlyVisibleLayersFlag is set to False this method will simply return, doing nothing.
Slot to check if analysis is feasible when extents change.
For simplicity, we will do all our calcs in geocrs.
Note
The dock is also updated with a message indicating if the memory usage is likely to be too much for the current system.
Establish a signal/slot to listen for changes in the layers loaded in QGIS.
..seealso:: disconnectLayerListener
Destroy the signal/slot to listen for changes in the layers loaded in QGIS.
..seealso:: connectLayerListener
Apply header and footer to html snippet and display in wvResults.
Convert the supplied extent to geographic and return as an array.
Calculate the best extents to use for the assessment.
should be written to the exposure layer. For example if rescaling is required for a raster, the original resolution can be added to the keywords file.
extent that can be used given the input datasets and the current viewport extents.
hazard and exposure rasters.
myExposureLayer: QgsMapLayer - layer representing exposure.
intersection of the two input layers extents and the viewport.
myHazardLayer: QgsMapLayer - layer representing hazard.
Get the QgsMapLayer currently selected in the exposure combo.
Obtain QgsMapLayer id from the userrole of the QtCombo for exposure and return it as a QgsMapLayer.
Get the canonical impact function ID for the currently selected function (or the specified combo entry if theIndex is supplied. Args:
- theIndex int - Optional index position in the combo that you
- want the function id for. Defaults to None. If not set / None the currently selected combo item’s function id will be returned.
Obtain a list of impact functions from the impact calculator.
Get the QgsMapLayer currently selected in the hazard combo.
Obtain QgsMapLayer id from the userrole of the QtCombo for hazard and return it as a QgsMapLayer.
Helper function to obtain a list of layers currently loaded in QGIS.
On invocation, this method will populate cboHazard, cboExposure and cboAggregate on the dialog with a list of available layers. Only singleband raster layers will be added to the hazard layer list,only point vector layers will be added to the exposure layer list and Only polygon vector layers will be added to the aggregate list
Get the QgsMapLayer currently selected in the post processing combo.
Obtain QgsMapLayer id from the userrole of the QtCombo for post processing combo return it as a QgsMapLayer.
disabled, otherwise:
QgsMapLayer - a polygon layer.
Get a standard html footer for wrapping content in.
Initializes and clears self._postProcessingOutput.
Note
Needs to run at the end of postProcess.
Args: None Returns: None
Handler for when the QGIS active layer is changed. If the active layer is changed and it has keywords and a report, show the report..
QGIS <= 1.7.x slot to notify us when a layer was added.
Slot for the old (pre QGIS 1.8 api) to notify us when a layer is added. This is suboptimal since if many layers are added this slot gets called multiple times. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.
Slot for the old (pre QGIS 1.8 api) to notify us when a layer is removed. This is suboptimal since if many layers are removed this slot gets called multiple times. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.
QGIS 1.8+ slot to notify us when a group of layers are added.
Slot for the new (QGIS 1.8 and beyond api) to notify us when a group of layers is are added. This is optimal since if many layers are added this slot gets called only once. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.
Note
Requires QGIS 1.8 and better api.
QGIS 1.8+ slot to notify us when a group of layers are removed. This is optimal since if many layers are removed this slot gets called only once. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.
Note
Requires QGIS 1.8 and better api.
Automatic slot executed when the Exposure combo is changed.
This is here so that we can see if the ok button should be enabled.
Note
Don’t use the @pyqtSlot() decorator for autoslots!
Automatic slot executed when the Function combo is changed.
This is here so that we can see if the ok button should be enabled.
Automatic slot executed when the Hazard combo is changed.
This is here so that we can see if the ok button should be enabled.
Note
Don’t use the @pyqtSlot() decorator for autoslots!
Automatic slot executed when toolFunctionOptions is clicked.
A helper function to perform an optimal clip of the input data. Optimal extent should be considered as the intersection between the three inputs. The inasafe library will perform various checks to ensure that the extent is tenable, includes data from both etc.
The result of this function will be two layers which are clipped and resampled if needed, and in the EPSG:4326 geographic coordinate reference system.
Run all post processing steps.
Called on self.runner SIGNAL(‘done()’) starts all postprocessing steps
Parses the postprocessing output as one table per postprocessor.
A helper function to align the polygons to the postprocLayer polygons. If one input polygon is in two or more postprocLayer polygons then it is divided so that each part is within only one of the postprocLayer polygons. this allows to aggregate in postrocessing using centroid in polygon.
The function assumes EPSG:4326 but no checks are enforced
Slot to print map when print map button pressed.
Helper function to read and validate layer.
Set the dock state from QSettings. Do this on init and after changing options in the options dialog.
Restore the function combo to a known state.
Restore the state of the dock to the last known state.
Save the current state of the ui to an internal class member so that it can be restored again easily.
Helper function to toggle the tool function button based on context.
If there are function parameters to configure then enable it, otherwise disable it.
Helper function to set the ok button status based on form validity.
Initialise ImpactCalculator based on the current state of the ui.
A helper function to indicate the plugin is processing.
..note:: Uses bootstrap css for progress bar.
A helper to spawn an error and halt processing.
An exception will be logged, busy status removed and a message displayed.
Helper function to toggle the aggregation combo enabled status.
Whether the combo is toggled on or off will depend on the current dock status.
Helper method to evaluate the current state of the dialog and determine if it is appropriate for the OK button to be enabled or not.
Note
The enabled state of the OK button on the dialog will NOT be updated (set True or False) depending on the outcome of the UI readiness tests performed - only True or False will be returned by the function.
A two-tuple consisting of:
Example:
flag,myMessage = self.validate()
Obtain the map canvas current extent in EPSG:4326.
Note
Delegates to self.extentToGeoArray()
This module forms part of the InaSAFE tool.