mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-24 00:47:57 -05:00
Now we abort and advise the user if insufficient memory is available to perform the calculation. At some future stage it would be nice to perform the calculations in blocks to allow this scenario, but for now it's better not to crash.
63 lines
2.5 KiB
Plaintext
63 lines
2.5 KiB
Plaintext
struct QgsRasterCalculatorEntry
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsrastercalculator.h>
|
|
%End
|
|
|
|
QString ref; //name
|
|
QgsRasterLayer* raster; //pointer to rasterlayer
|
|
int bandNumber; //raster band number
|
|
};
|
|
|
|
/** Raster calculator class*/
|
|
class QgsRasterCalculator
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsrastercalculator.h>
|
|
%End
|
|
|
|
public:
|
|
|
|
//! Result of the calculation
|
|
enum Result
|
|
{
|
|
Success, /*!< Calculation sucessful */
|
|
CreateOutputError, /*!< Error creating output data file */
|
|
InputLayerError, /*!< Error reading input layer */
|
|
Cancelled, /*!< User cancelled calculation */
|
|
ParserError, /*!< Error parsing formula */
|
|
MemoryError, /*!< Error allocating memory for result */
|
|
};
|
|
|
|
/** QgsRasterCalculator constructor.
|
|
* @param formulaString formula for raster calculation
|
|
* @param outputFile output file path
|
|
* @param outputFormat output file format
|
|
* @param outputExtent output extent. CRS for output is taken from first entry in rasterEntries.
|
|
* @param nOutputColumns number of columns in output raster
|
|
* @param nOutputRows number of rows in output raster
|
|
* @param rasterEntries list of referenced raster layers
|
|
*/
|
|
QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
|
|
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
|
|
|
|
/** QgsRasterCalculator constructor.
|
|
* @param formulaString formula for raster calculation
|
|
* @param outputFile output file path
|
|
* @param outputFormat output file format
|
|
* @param outputExtent output extent, CRS is specified by outputCrs parameter
|
|
* @param outputCrs destination CRS for output raster
|
|
* @param nOutputColumns number of columns in output raster
|
|
* @param nOutputRows number of rows in output raster
|
|
* @param rasterEntries list of referenced raster layers
|
|
* @note added in QGIS 2.10
|
|
*/
|
|
QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
|
|
const QgsRectangle& outputExtent, const QgsCoordinateReferenceSystem& outputCrs, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries );
|
|
|
|
/** Starts the calculation and writes new raster
|
|
@param p progress bar (or 0 if called from non-gui code)
|
|
@return 0 in case of success*/
|
|
int processCalculation( QProgressDialog* p = 0 );
|
|
};
|