[QGIS Commit] r14445 - in trunk/qgis: cmake src/analysis/raster
src/app
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Oct 29 01:24:47 EDT 2010
Author: jef
Date: 2010-10-28 22:24:47 -0700 (Thu, 28 Oct 2010)
New Revision: 14445
Modified:
trunk/qgis/cmake/Bison.cmake
trunk/qgis/cmake/Flex.cmake
trunk/qgis/src/analysis/raster/qgsrastercalcnode.cpp
trunk/qgis/src/analysis/raster/qgsrastercalcnode.h
trunk/qgis/src/analysis/raster/qgsrastercalcparser.yy
trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp
trunk/qgis/src/analysis/raster/qgsrastermatrix.cpp
trunk/qgis/src/app/qgsrastercalcdialog.cpp
Log:
fix nightly build
Modified: trunk/qgis/cmake/Bison.cmake
===================================================================
--- trunk/qgis/cmake/Bison.cmake 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/cmake/Bison.cmake 2010-10-29 05:24:47 UTC (rev 14445)
@@ -93,4 +93,4 @@
SET(${_sources} ${${_sources}} ${_out} )
ENDFOREACH (_current_FILE)
-ENDMACRO(ADD_BISON_FILES)
+ENDMACRO(ADD_BISON_FILES_PREFIX)
Modified: trunk/qgis/cmake/Flex.cmake
===================================================================
--- trunk/qgis/cmake/Flex.cmake 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/cmake/Flex.cmake 2010-10-29 05:24:47 UTC (rev 14445)
@@ -65,12 +65,12 @@
OUTPUT ${_out}
COMMAND ${FLEX_EXECUTABLE}
ARGS
- -P ${prefix}
+ -P${prefix}
-o${_out} -d
${_in}
DEPENDS ${_in}
)
SET(${_sources} ${${_sources}} ${_out} )
- ENDFOREACH (_current_FILE)
+ ENDFOREACH (_current_FILE)
ENDMACRO(ADD_FLEX_FILES_PREFIX)
Modified: trunk/qgis/src/analysis/raster/qgsrastercalcnode.cpp
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastercalcnode.cpp 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/src/analysis/raster/qgsrastercalcnode.cpp 2010-10-29 05:24:47 UTC (rev 14445)
@@ -18,11 +18,11 @@
QgsRasterCalcNode::~QgsRasterCalcNode()
{
- if( mLeft )
+ if ( mLeft )
{
delete mLeft;
}
- if( mRight )
+ if ( mRight )
{
delete mRight;
}
@@ -33,10 +33,10 @@
//if type is raster ref: return a copy of the corresponding matrix
//if type is operator, call the proper matrix operations
- if( mType == tRasterRef )
+ if ( mType == tRasterRef )
{
QMap<QString, QgsRasterMatrix*>::iterator it = rasterData.find( mRasterName );
- if( it == rasterData.end() )
+ if ( it == rasterData.end() )
{
return false;
}
@@ -47,20 +47,20 @@
result.setData(( *it )->nColumns(), ( *it )->nRows(), data );
return true;
}
- else if( mType == tOperator )
+ else if ( mType == tOperator )
{
QgsRasterMatrix leftMatrix, rightMatrix;
QgsRasterMatrix resultMatrix;
- if( !mLeft || !mLeft->calculate( rasterData, leftMatrix ) )
+ if ( !mLeft || !mLeft->calculate( rasterData, leftMatrix ) )
{
return false;
}
- if( mRight && !mRight->calculate( rasterData, rightMatrix ) )
+ if ( mRight && !mRight->calculate( rasterData, rightMatrix ) )
{
return false;
}
- switch( mOperator )
+ switch ( mOperator )
{
case opPLUS:
leftMatrix.add( rightMatrix );
@@ -106,7 +106,7 @@
result.setData( newNColumns, newNRows, leftMatrix.takeData() );
return true;
}
- else if( mType == tNumber )
+ else if ( mType == tNumber )
{
float* data = new float[1];
data[0] = mNumber;
@@ -116,4 +116,9 @@
return false;
}
+QgsRasterCalcNode* QgsRasterCalcNode::parseRasterCalcString( const QString& str, QString& parserErrorMsg )
+{
+ extern QgsRasterCalcNode* localParseRasterCalcString( const QString& str, QString& parserErrorMsg );
+ return localParseRasterCalcString( str, parserErrorMsg );
+}
Modified: trunk/qgis/src/analysis/raster/qgsrastercalcnode.h
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastercalcnode.h 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/src/analysis/raster/qgsrastercalcnode.h 2010-10-29 05:24:47 UTC (rev 14445)
@@ -66,6 +66,8 @@
/**Calculates result (might be real matrix or single number)*/
bool calculate( QMap<QString, QgsRasterMatrix*>& rasterData, QgsRasterMatrix& result ) const;
+ static QgsRasterCalcNode* parseRasterCalcString( const QString& str, QString& parserErrorMsg );
+
private:
Type mType;
QgsRasterCalcNode* mLeft;
@@ -76,4 +78,5 @@
Operator mOperator;
};
+
#endif // QGSRASTERCALCNODE_H
Modified: trunk/qgis/src/analysis/raster/qgsrastercalcparser.yy
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastercalcparser.yy 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/src/analysis/raster/qgsrastercalcparser.yy 2010-10-29 05:24:47 UTC (rev 14445)
@@ -104,7 +104,7 @@
}
-QgsRasterCalcNode* parseRasterCalcString(const QString& str, QString& parserErrorMsg)
+QgsRasterCalcNode* localParseRasterCalcString(const QString& str, QString& parserErrorMsg)
{
// list should be empty when starting
Q_ASSERT(gTmpNodes.count() == 0);
Modified: trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp 2010-10-29 05:24:47 UTC (rev 14445)
@@ -22,11 +22,9 @@
#include "cpl_string.h"
#include <QProgressDialog>
-extern QgsRasterCalcNode* parseRasterCalcString( const QString& str, QString& parserErrorMsg );
-
QgsRasterCalculator::QgsRasterCalculator( const QString& formulaString, const QString& outputFile, const QString& outputFormat,
const QgsRectangle& outputExtent, int nOutputColumns, int nOutputRows, const QVector<QgsRasterCalculatorEntry>& rasterEntries ): mFormulaString( formulaString ), mOutputFile( outputFile ), mOutputFormat( outputFormat ),
- mOutputRectangle( outputExtent ), mNumOutputColumns( nOutputColumns ), mNumOutputRows( nOutputRows ), mRasterEntries( rasterEntries )
+ mOutputRectangle( outputExtent ), mNumOutputColumns( nOutputColumns ), mNumOutputRows( nOutputRows ), mRasterEntries( rasterEntries )
{
}
@@ -38,8 +36,8 @@
{
//prepare search string / tree
QString errorString;
- QgsRasterCalcNode* calcNode = parseRasterCalcString( mFormulaString, errorString );
- if( !calcNode )
+ QgsRasterCalcNode* calcNode = QgsRasterCalcNode::parseRasterCalcString( mFormulaString, errorString );
+ if ( !calcNode )
{
//error
}
@@ -53,19 +51,19 @@
QVector< GDALDatasetH > mInputDatasets; //raster references and corresponding dataset
QVector<QgsRasterCalculatorEntry>::const_iterator it = mRasterEntries.constBegin();
- for( ; it != mRasterEntries.constEnd(); ++it )
+ for ( ; it != mRasterEntries.constEnd(); ++it )
{
- if( !it->raster ) // no raster layer in entry
+ if ( !it->raster ) // no raster layer in entry
{
return 2;
}
GDALDatasetH inputDataset = GDALOpen( it->raster->source().toLocal8Bit().data(), GA_ReadOnly );
- if( inputDataset == NULL )
+ if ( inputDataset == NULL )
{
return 2;
}
GDALRasterBandH inputRasterBand = GDALGetRasterBand( inputDataset, it->bandNumber );
- if( inputRasterBand == NULL )
+ if ( inputRasterBand == NULL )
{
return 2;
}
@@ -77,7 +75,7 @@
//open output dataset for writing
GDALDriverH outputDriver = openOutputDriver();
- if( outputDriver == NULL )
+ if ( outputDriver == NULL )
{
return 1;
}
@@ -85,7 +83,7 @@
GDALRasterBandH outputRasterBand = GDALGetRasterBand( outputDataset, 1 );
float* resultScanLine = ( float * ) CPLMalloc( sizeof( float ) * mNumOutputColumns );
- if( p )
+ if ( p )
{
p->setMaximum( mNumOutputRows );
}
@@ -93,21 +91,21 @@
QgsRasterMatrix resultMatrix;
//read / write line by line
- for( int i = 0; i < mNumOutputRows; ++i )
+ for ( int i = 0; i < mNumOutputRows; ++i )
{
- if( p )
+ if ( p )
{
p->setValue( i );
}
- if( p && p->wasCanceled() )
+ if ( p && p->wasCanceled() )
{
break;
}
//fill buffers
QMap< QString, QgsRasterMatrix* >::iterator bufferIt = inputScanLineData.begin();
- for( ; bufferIt != inputScanLineData.end(); ++bufferIt )
+ for ( ; bufferIt != inputScanLineData.end(); ++bufferIt )
{
double sourceTransformation[6];
GDALRasterBandH sourceRasterBand = mInputRasterBands[bufferIt.key()];
@@ -116,10 +114,10 @@
readRasterPart( targetGeoTransform, 0, i, mNumOutputColumns, 1, sourceTransformation, sourceRasterBand, bufferIt.value()->data() );
}
- if( calcNode->calculate( inputScanLineData, resultMatrix ) )
+ if ( calcNode->calculate( inputScanLineData, resultMatrix ) )
{
//write scanline to the dataset
- if( GDALRasterIO( outputRasterBand, GF_Write, 0, i, mNumOutputColumns, 1, resultMatrix.data(), mNumOutputColumns, 1, GDT_Float32, 0, 0 ) != CE_None )
+ if ( GDALRasterIO( outputRasterBand, GF_Write, 0, i, mNumOutputColumns, 1, resultMatrix.data(), mNumOutputColumns, 1, GDT_Float32, 0, 0 ) != CE_None )
{
qWarning( "RasterIO error!" );
}
@@ -127,7 +125,7 @@
}
- if( p )
+ if ( p )
{
p->setValue( mNumOutputRows );
}
@@ -135,19 +133,19 @@
//close datasets and release memory
delete calcNode;
QMap< QString, QgsRasterMatrix* >::iterator bufferIt = inputScanLineData.begin();
- for( ; bufferIt != inputScanLineData.end(); ++bufferIt )
+ for ( ; bufferIt != inputScanLineData.end(); ++bufferIt )
{
delete bufferIt.value();
}
inputScanLineData.clear();
QVector< GDALDatasetH >::iterator datasetIt = mInputDatasets.begin();
- for( ; datasetIt != mInputDatasets.end(); ++ datasetIt )
+ for ( ; datasetIt != mInputDatasets.end(); ++ datasetIt )
{
GDALClose( *datasetIt );
}
- if( p && p->wasCanceled() )
+ if ( p && p->wasCanceled() )
{
//delete the dataset without closing (because it is faster)
GDALDeleteDataset( outputDriver, mOutputFile.toLocal8Bit().data() );
@@ -169,13 +167,13 @@
//open driver
GDALDriverH outputDriver = GDALGetDriverByName( mOutputFormat.toLocal8Bit().data() );
- if( outputDriver == NULL )
+ if ( outputDriver == NULL )
{
return outputDriver; //return NULL, driver does not exist
}
driverMetadata = GDALGetMetadata( outputDriver, NULL );
- if( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
+ if ( !CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
{
return NULL; //driver exist, but it does not support the create operation
}
@@ -188,7 +186,7 @@
//open output file
char **papszOptions = NULL;
GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toLocal8Bit().data(), mNumOutputColumns, mNumOutputRows, 1, GDT_Float32, papszOptions );
- if( outputDataset == NULL )
+ if ( outputDataset == NULL )
{
return outputDataset;
}
@@ -204,7 +202,7 @@
void QgsRasterCalculator::readRasterPart( double* targetGeotransform, int xOffset, int yOffset, int nCols, int nRows, double* sourceTransform, GDALRasterBandH sourceBand, float* rasterBuffer )
{
//If dataset transform is the same as the requested transform, do a normal GDAL raster io
- if( transformationsEqual( targetGeotransform, sourceTransform ) )
+ if ( transformationsEqual( targetGeotransform, sourceTransform ) )
{
GDALRasterIO( sourceBand, GF_Read, xOffset, yOffset, nCols, nRows, rasterBuffer, nCols, nRows, GDT_Float32, 0, 0 );
return;
@@ -219,10 +217,10 @@
QgsRectangle intersection = targetRect.intersect( &sourceRect );
//no intersection, fill all the pixels with nodata values
- if( intersection.isEmpty() )
+ if ( intersection.isEmpty() )
{
int nPixels = nCols * nRows;
- for( int i = 0; i < nPixels; ++i )
+ for ( int i = 0; i < nPixels; ++i )
{
rasterBuffer[i] = nodataValue;
}
@@ -248,17 +246,17 @@
double targetPixelY = targetGeotransform[3] + targetGeotransform[5] * yOffset + targetGeotransform[5] / 2.0; //coordinates of current target pixel
int sourceIndexX, sourceIndexY; //current raster index in source pixels
double sx, sy;
- for( int i = 0; i < nRows; ++i )
+ for ( int i = 0; i < nRows; ++i )
{
targetPixelX = targetPixelXMin;
- for( int j = 0; j < nCols; ++j )
+ for ( int j = 0; j < nCols; ++j )
{
sx = ( targetPixelX - sourceRasterXMin ) / sourceTransform[1];
sourceIndexX = sx > 0 ? sx : floor( sx );
sy = ( targetPixelY - sourceRasterYMax ) / sourceTransform[5];
sourceIndexY = sy > 0 ? sy : floor( sy );
- if( sourceIndexX >= 0 && sourceIndexX < nSourcePixelsX
- && sourceIndexY >= 0 && sourceIndexY < nSourcePixelsY )
+ if ( sourceIndexX >= 0 && sourceIndexX < nSourcePixelsX
+ && sourceIndexY >= 0 && sourceIndexY < nSourcePixelsY )
{
rasterBuffer[j + i*nRows] = sourceRaster[ sourceIndexX + nSourcePixelsX * sourceIndexY ];
}
@@ -276,7 +274,7 @@
#if 0
//If dataset transform is the same as the requested transform, do a normal GDAL raster io
- if( transformationsEqual( targetGeotransform, sourceTransform ) )
+ if ( transformationsEqual( targetGeotransform, sourceTransform ) )
{
GDALRasterIO( sourceBand, GF_Read, xOffset, yOffset, nCols, nRows, rasterBuffer, nCols, nRows, GDT_Float32, 0, 0 );
return;
@@ -294,10 +292,10 @@
QgsRectangle intersection = targetRect.intersect( &sourceRect );
//no intersection, fill all the pixels with nodata values
- if( intersection.isEmpty() )
+ if ( intersection.isEmpty() )
{
int nPixels = nCols * nRows;
- for( int i = 0; i < nPixels; ++i )
+ for ( int i = 0; i < nPixels; ++i )
{
rasterBuffer[i] = 0;
}
@@ -322,15 +320,15 @@
double targetPixelXMin = targetGeotransform[0] + targetGeotransform[1] * xOffset + targetGeotransform[1] / 2.0;
double targetPixelY = targetGeotransform[3] + targetGeotransform[5] * yOffset + targetGeotransform[5] / 2.0; //coordinates of current target pixel
int sourceIndexX, sourceIndexY; //current raster index in source pixels
- for( int i = 0; i < nRows; ++i )
+ for ( int i = 0; i < nRows; ++i )
{
targetPixelX = targetPixelXMin;
- for( int j = 0; j < nCols; ++j )
+ for ( int j = 0; j < nCols; ++j )
{
sourceIndexX = ( targetPixelX - sourceRasterXMin ) / sourceTransform[1];
sourceIndexY = ( targetPixelY - sourceRasterYMax ) / sourceTransform[5];
- if( sourceIndexX >= 0 && sourceIndexX < nSourcePixelsX
- && sourceIndexY >= 0 && sourceIndexY < nSourcePixelsY )
+ if ( sourceIndexX >= 0 && sourceIndexX < nSourcePixelsX
+ && sourceIndexY >= 0 && sourceIndexY < nSourcePixelsY )
{
rasterBuffer[j + i*nCols] = sourceRaster[ sourceIndexX + nSourcePixelsX * sourceIndexY ];
}
@@ -350,9 +348,9 @@
bool QgsRasterCalculator::transformationsEqual( double* t1, double* t2 ) const
{
- for( int i = 0; i < 6; ++i )
+ for ( int i = 0; i < 6; ++i )
{
- if( !doubleNear( t1[i], t2[i] ) )
+ if ( !doubleNear( t1[i], t2[i] ) )
{
return false;
}
Modified: trunk/qgis/src/analysis/raster/qgsrastermatrix.cpp
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastermatrix.cpp 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/src/analysis/raster/qgsrastermatrix.cpp 2010-10-29 05:24:47 UTC (rev 14445)
@@ -42,7 +42,7 @@
delete[] mData;
}
-QgsRasterMatrix& QgsRasterMatrix::operator=( const QgsRasterMatrix& m )
+QgsRasterMatrix& QgsRasterMatrix::operator=( const QgsRasterMatrix & m )
{
delete[] mData;
mColumns = m.nColumns();
@@ -95,16 +95,16 @@
bool QgsRasterMatrix::squareRoot()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
double value = mData[i];
- if( value >= 0 )
+ if ( value >= 0 )
{
mData[i] = sqrt( value );
}
@@ -118,13 +118,13 @@
bool QgsRasterMatrix::sinus()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = sin( mData[i] );
}
@@ -133,13 +133,13 @@
bool QgsRasterMatrix::asinus()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = asin( mData[i] );
}
@@ -148,13 +148,13 @@
bool QgsRasterMatrix::cosinus()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = cos( mData[i] );
}
@@ -163,13 +163,13 @@
bool QgsRasterMatrix::acosinus()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = acos( mData[i] );
}
@@ -178,13 +178,13 @@
bool QgsRasterMatrix::tangens()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = tan( mData[i] );
}
@@ -193,13 +193,13 @@
bool QgsRasterMatrix::atangens()
{
- if( !mData )
+ if ( !mData )
{
return false;
}
int nEntries = mColumns * mRows;
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = atan( mData[i] );
}
@@ -208,9 +208,9 @@
bool QgsRasterMatrix::twoArgumentOperation( TwoArgOperator op, const QgsRasterMatrix& other )
{
- if( isNumber() && other.isNumber() )
+ if ( isNumber() && other.isNumber() )
{
- switch( op )
+ switch ( op )
{
case opPLUS:
mData[0] = number() + other.number();
@@ -222,7 +222,7 @@
mData[0] = number() * other.number();
break;
case opDIV:
- if( other.number() == 0 )
+ if ( other.number() == 0 )
{
mData[0] = -10000;
}
@@ -232,47 +232,47 @@
}
break;
case opPOW:
- if( !testPowerValidity( mData[0], other.number() ) )
+ if ( !testPowerValidity( mData[0], ( float ) other.number() ) )
{
mData[0] = -10000;
}
else
{
- mData[0] = pow( mData[0], other.number() );
+ mData[0] = pow( mData[0], ( float ) other.number() );
}
break;
}
return true;
}
//two matrices
- if( !isNumber() && !other.isNumber() )
+ if ( !isNumber() && !other.isNumber() )
{
float* matrix = other.mData;
int nEntries = mColumns * mRows;
- switch( op )
+ switch ( op )
{
case opPLUS:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] + matrix[i];
}
break;
case opMINUS:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] - matrix[i];
}
break;
case opMUL:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] * matrix[i];
}
break;
case opDIV:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
- if( matrix[i] == 0 )
+ if ( matrix[i] == 0 )
{
mData[i] = -10000;
}
@@ -283,9 +283,9 @@
}
break;
case opPOW:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
- if( !testPowerValidity( mData[i], matrix[i] ) )
+ if ( !testPowerValidity( mData[i], matrix[i] ) )
{
mData[i] = -10000;
}
@@ -299,7 +299,7 @@
return true;
}
double value = 0;
- if( isNumber() )
+ if ( isNumber() )
{
float* matrix = other.mData;
int nEntries = other.nColumns() * other.nRows();
@@ -307,30 +307,30 @@
delete[] mData;
mData = new float[nEntries]; mColumns = other.nColumns(); mRows = other.nRows();
- switch( op )
+ switch ( op )
{
case opPLUS:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = value + matrix[i];
}
break;
case opMINUS:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = value - matrix[i];
}
break;
case opMUL:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = value * matrix[i];
}
break;
case opDIV:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
- if( matrix[i] == 0 )
+ if ( matrix[i] == 0 )
{
mData[i] = -10000;
}
@@ -341,15 +341,15 @@
}
break;
case opPOW:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
- if( !testPowerValidity( value, matrix[i] ) )
+ if ( !testPowerValidity( value, matrix[i] ) )
{
mData[i] = -10000;
}
else
{
- mData[i] = pow( value, matrix[i] );
+ mData[i] = pow(( float ) value, matrix[i] );
}
}
break;
@@ -359,52 +359,52 @@
{
value = other.number();
int nEntries = mColumns * mRows;
- switch( op )
+ switch ( op )
{
case opPLUS:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] + value;
}
break;
case opMINUS:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] - value;
}
break;
case opMUL:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] * value;
}
break;
case opDIV:
- if( value == 0 )
+ if ( value == 0 )
{
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = -10000;
}
}
else
{
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
mData[i] = mData[i] / value;
}
}
break;
case opPOW:
- for( int i = 0; i < nEntries; ++i )
+ for ( int i = 0; i < nEntries; ++i )
{
- if( !testPowerValidity( mData[i], value ) )
+ if ( !testPowerValidity( mData[i], value ) )
{
mData[i] = -10000;
}
else
{
- mData[i] = pow( mData[i], value );
+ mData[i] = pow( mData[i], ( float ) value );
}
}
break;
@@ -415,7 +415,7 @@
bool QgsRasterMatrix::testPowerValidity( double base, double power )
{
- if(( base == 0 && power < 0 ) || ( power < 0 && ( power - floor( power ) ) > 0 ) )
+ if (( base == 0 && power < 0 ) || ( power < 0 && ( power - floor( power ) ) > 0 ) )
{
return false;
}
Modified: trunk/qgis/src/app/qgsrastercalcdialog.cpp
===================================================================
--- trunk/qgis/src/app/qgsrastercalcdialog.cpp 2010-10-28 21:16:43 UTC (rev 14444)
+++ trunk/qgis/src/app/qgsrastercalcdialog.cpp 2010-10-29 05:24:47 UTC (rev 14445)
@@ -25,8 +25,6 @@
#include <QFileDialog>
#include <QSettings>
-extern QgsRasterCalcNode* parseRasterCalcString( const QString& str, QString& parserErrorMsg );
-
QgsRasterCalcDialog::QgsRasterCalcDialog( QWidget * parent, Qt::WindowFlags f ): QDialog( parent, f )
{
setupUi( this );
@@ -50,21 +48,21 @@
QString outputFileName = mOutputLayerLineEdit->text();
QFileInfo fileInfo( outputFileName );
QString suffix = fileInfo.suffix();
- if( !suffix.isEmpty() )
+ if ( !suffix.isEmpty() )
{
return outputFileName;
}
//add the file format extension if the user did not specify it
int index = mOutputFormatComboBox->currentIndex();
- if( index == -1 )
+ if ( index == -1 )
{
return outputFileName;
}
QString driverShortName = mOutputFormatComboBox->itemData( index ).toString();
QMap<QString, QString>::const_iterator it = mDriverExtensionMap.find( driverShortName );
- if( it == mDriverExtensionMap.constEnd() )
+ if ( it == mDriverExtensionMap.constEnd() )
{
return outputFileName;
}
@@ -75,7 +73,7 @@
QString QgsRasterCalcDialog::outputFormat() const
{
int index = mOutputFormatComboBox->currentIndex();
- if( index == -1 )
+ if ( index == -1 )
{
return "";
}
@@ -93,9 +91,9 @@
QString expressionString = mExpressionTextEdit->toPlainText();
QList<QgsRasterCalculatorEntry>::const_iterator bandIt = mAvailableRasterBands.constBegin();
- for( ; bandIt != mAvailableRasterBands.constEnd(); ++bandIt )
+ for ( ; bandIt != mAvailableRasterBands.constEnd(); ++bandIt )
{
- if( expressionString.contains( bandIt->ref ) )
+ if ( expressionString.contains( bandIt->ref ) )
{
entries.push_back( *bandIt );
}
@@ -110,12 +108,12 @@
QMap<QString, QgsMapLayer*>::const_iterator layerIt = layers.constBegin();
bool firstLayer = true;
- for( ; layerIt != layers.constEnd(); ++layerIt )
+ for ( ; layerIt != layers.constEnd(); ++layerIt )
{
QgsRasterLayer* rlayer = dynamic_cast<QgsRasterLayer*>( layerIt.value() );
- if( rlayer && !rlayer->usesProvider() )
+ if ( rlayer && !rlayer->usesProvider() )
{
- if( firstLayer ) //set bounding box / resolution of output to the values of the first possible input layer
+ if ( firstLayer ) //set bounding box / resolution of output to the values of the first possible input layer
{
mNColumnsSpinBox->setValue( rlayer->width() );
mNRowsSpinBox->setValue( rlayer->height() );
@@ -127,7 +125,7 @@
firstLayer = false;
}
//get number of bands
- for( int i = 0; i < rlayer->bandCount(); ++i )
+ for ( unsigned int i = 0; i < rlayer->bandCount(); ++i )
{
QgsRasterCalculatorEntry entry;
entry.raster = rlayer;
@@ -145,30 +143,30 @@
GDALAllRegister();
int nDrivers = GDALGetDriverCount();
- for( int i = 0; i < nDrivers; ++i )
+ for ( int i = 0; i < nDrivers; ++i )
{
GDALDriverH driver = GDALGetDriver( i );
- if( driver != NULL )
+ if ( driver != NULL )
{
char** driverMetadata = GDALGetMetadata( driver, NULL );
- if( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
+ if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
{
mOutputFormatComboBox->addItem( GDALGetDriverLongName( driver ), QVariant( GDALGetDriverShortName( driver ) ) );
//store the driver shortnames and the corresponding extensions
//(just in case the user does not give an extension for the output file name)
int index = 0;
- while(( driverMetadata ) && driverMetadata[index] != 0 )
+ while (( driverMetadata ) && driverMetadata[index] != 0 )
{
QStringList metadataTokens = QString( driverMetadata[index] ).split( "=", QString::SkipEmptyParts );
- if( metadataTokens.size() < 1 )
+ if ( metadataTokens.size() < 1 )
{
break;
}
- if( metadataTokens[0] == "DMD_EXTENSION" )
+ if ( metadataTokens[0] == "DMD_EXTENSION" )
{
- if( metadataTokens.size() < 2 )
+ if ( metadataTokens.size() < 2 )
{
++index;
continue;
@@ -186,7 +184,7 @@
QSettings s;
QString lastUsedDriver = s.value( "/RasterCalculator/lastOutputFormat", "GeoTIFF" ).toString();
int lastDriverIndex = mOutputFormatComboBox->findText( lastUsedDriver );
- if( lastDriverIndex != -1 )
+ if ( lastDriverIndex != -1 )
{
mOutputFormatComboBox->setCurrentIndex( lastDriverIndex );
}
@@ -219,7 +217,7 @@
void QgsRasterCalcDialog::on_mOutputLayerPushButton_clicked()
{
QString saveFileName = QFileDialog::getSaveFileName( 0, tr( "Enter result file" ) );
- if( !saveFileName.isNull() )
+ if ( !saveFileName.isNull() )
{
mOutputLayerLineEdit->setText( saveFileName );
}
@@ -228,19 +226,19 @@
void QgsRasterCalcDialog::on_mCurrentLayerExtentButton_clicked()
{
QListWidgetItem* currentLayerItem = mRasterBandsListWidget->currentItem();
- if( currentLayerItem )
+ if ( currentLayerItem )
{
QgsRasterLayer* rlayer = 0;
QList<QgsRasterCalculatorEntry>::const_iterator rasterIt = mAvailableRasterBands.constBegin();
- for( ; rasterIt != mAvailableRasterBands.constEnd(); ++rasterIt )
+ for ( ; rasterIt != mAvailableRasterBands.constEnd(); ++rasterIt )
{
- if( rasterIt->ref == currentLayerItem->text() )
+ if ( rasterIt->ref == currentLayerItem->text() )
{
rlayer = rasterIt->raster;
}
}
- if( !rlayer )
+ if ( !rlayer )
{
return;
}
@@ -257,10 +255,10 @@
void QgsRasterCalcDialog::on_mExpressionTextEdit_textChanged()
{
- if( expressionValid() )
+ if ( expressionValid() )
{
mExpressionValidLabel->setText( tr( "Expression valid" ) );
- if( filePathValid() )
+ if ( filePathValid() )
{
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
return;
@@ -280,7 +278,7 @@
void QgsRasterCalcDialog::setAcceptButtonState()
{
- if( expressionValid() && filePathValid() )
+ if ( expressionValid() && filePathValid() )
{
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( true );
}
@@ -293,8 +291,8 @@
bool QgsRasterCalcDialog::expressionValid() const
{
QString errorString;
- QgsRasterCalcNode* testNode = parseRasterCalcString( mExpressionTextEdit->toPlainText(), errorString );
- if( testNode )
+ QgsRasterCalcNode* testNode = QgsRasterCalcNode::parseRasterCalcString( mExpressionTextEdit->toPlainText(), errorString );
+ if ( testNode )
{
delete testNode;
return true;
@@ -305,7 +303,7 @@
bool QgsRasterCalcDialog::filePathValid() const
{
QString outputPath = QFileInfo( mOutputLayerLineEdit->text() ).absolutePath();
- if( QFileInfo( outputPath ).isWritable() )
+ if ( QFileInfo( outputPath ).isWritable() )
{
return true;
}
More information about the QGIS-commit
mailing list