Skip to content

Commit 03ec7ed

Browse files
committedJan 6, 2016
More clang warning fixes
1 parent 6051d3a commit 03ec7ed

11 files changed

+70
-70
lines changed
 

‎src/core/raster/qgscolorrampshader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ originally part of the larger QgsRasterLayer class
2020
#define DOUBLE_DIFF_THRESHOLD 0.0000001
2121

2222
#include "qgslogger.h"
23-
23+
#include "qgis.h"
2424
#include "qgscolorrampshader.h"
2525

2626
#include <cmath>
@@ -108,7 +108,7 @@ bool QgsColorRampShader::exactColor( double theValue, int* theReturnRedValue, in
108108
//Start searching from the last index - assumtion is that neighboring pixels tend to be similar values
109109
myColorRampItem = mColorRampItemList.value( mCurrentColorRampItemIndex );
110110
myTinyDiff = qAbs( theValue - myColorRampItem.value );
111-
if ( theValue == myColorRampItem.value || myTinyDiff <= DOUBLE_DIFF_THRESHOLD )
111+
if ( qgsDoubleNear( theValue, myColorRampItem.value ) || myTinyDiff <= DOUBLE_DIFF_THRESHOLD )
112112
{
113113
*theReturnRedValue = myColorRampItem.color.red();
114114
*theReturnGreenValue = myColorRampItem.color.green();
@@ -173,10 +173,10 @@ bool QgsColorRampShader::interpolatedColor( double theValue, int*
173173
myOffsetInRange = theValue - myPreviousColorRampItem.value;
174174
double scale = myOffsetInRange / myCurrentRampRange;
175175

176-
*theReturnRedValue = ( int )(( double ) myPreviousColorRampItem.color.red() + (( double )( myColorRampItem.color.red() - myPreviousColorRampItem.color.red() ) * scale ) );
177-
*theReturnGreenValue = ( int )(( double ) myPreviousColorRampItem.color.green() + (( double )( myColorRampItem.color.green() - myPreviousColorRampItem.color.green() ) * scale ) );
178-
*theReturnBlueValue = ( int )(( double ) myPreviousColorRampItem.color.blue() + (( double )( myColorRampItem.color.blue() - myPreviousColorRampItem.color.blue() ) * scale ) );
179-
*theReturnAlphaValue = ( int )(( double ) myPreviousColorRampItem.color.alpha() + (( double )( myColorRampItem.color.alpha() - myPreviousColorRampItem.color.alpha() ) * scale ) );
176+
*theReturnRedValue = static_cast< int >( static_cast< double >( myPreviousColorRampItem.color.red() ) + ( static_cast< double >( myColorRampItem.color.red() - myPreviousColorRampItem.color.red() ) * scale ) );
177+
*theReturnGreenValue = static_cast< int >( static_cast< double >( myPreviousColorRampItem.color.green() ) + ( static_cast< double >( myColorRampItem.color.green() - myPreviousColorRampItem.color.green() ) * scale ) );
178+
*theReturnBlueValue = static_cast< int >( static_cast< double >( myPreviousColorRampItem.color.blue() ) + ( static_cast< double >( myColorRampItem.color.blue() - myPreviousColorRampItem.color.blue() ) * scale ) );
179+
*theReturnAlphaValue = static_cast< int >( static_cast< double >( myPreviousColorRampItem.color.alpha() ) + ( static_cast< double >( myColorRampItem.color.alpha() - myPreviousColorRampItem.color.alpha() ) * scale ) );
180180
if ( mMaximumColorCacheSize >= mColorCache.size() )
181181
{
182182
QColor myNewColor( *theReturnRedValue, *theReturnGreenValue, *theReturnBlueValue, *theReturnAlphaValue );

‎src/core/raster/qgscontrastenhancement.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ bool QgsContrastEnhancement::generateLookupTable()
217217

218218
for ( int myIterator = 0; myIterator <= mRasterDataTypeRange; myIterator++ )
219219
{
220-
mLookupTable[myIterator] = mContrastEnhancementFunction->enhance(( double )myIterator - mLookupTableOffset );
220+
mLookupTable[myIterator] = mContrastEnhancementFunction->enhance( static_cast< double >( myIterator ) - mLookupTableOffset );
221221
}
222222

223223
return true;
@@ -247,7 +247,7 @@ bool QgsContrastEnhancement::isValueInDisplayableRange( double theValue )
247247
*/
248248
void QgsContrastEnhancement::setContrastEnhancementAlgorithm( ContrastEnhancementAlgorithm theAlgorithm, bool generateTable )
249249
{
250-
QgsDebugMsg( "called algorithm: " + QString::number(( int )theAlgorithm ) + " generate lookup table: " + QString::number(( int )generateTable ) );
250+
QgsDebugMsg( "called algorithm: " + QString::number( static_cast< int >( theAlgorithm ) ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ) );
251251

252252
if ( theAlgorithm != mContrastEnhancementAlgorithm )
253253
{
@@ -310,7 +310,7 @@ void QgsContrastEnhancement::setContrastEnhancementFunction( QgsContrastEnhancem
310310
*/
311311
void QgsContrastEnhancement::setMaximumValue( double theValue, bool generateTable )
312312
{
313-
QgsDebugMsg( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number(( int )generateTable ) );
313+
QgsDebugMsg( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ) );
314314

315315
if ( theValue > maximumValuePossible( mRasterDataType ) )
316316
{
@@ -342,7 +342,7 @@ void QgsContrastEnhancement::setMaximumValue( double theValue, bool generateTabl
342342
*/
343343
void QgsContrastEnhancement::setMinimumValue( double theValue, bool generateTable )
344344
{
345-
QgsDebugMsg( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number(( int )generateTable ) );
345+
QgsDebugMsg( "called value: " + QString::number( theValue ) + " generate lookup table: " + QString::number( static_cast< int >( generateTable ) ) );
346346

347347
if ( theValue < minimumValuePossible( mRasterDataType ) )
348348
{

‎src/core/raster/qgsrasterchecker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ bool QgsRasterChecker::runTest( const QString& theVerifiedKey, QString theVerifi
4545
mReport += "\n\n";
4646

4747
//QgsRasterDataProvider* verifiedProvider = QgsRasterLayer::loadProvider( theVerifiedKey, theVerifiedUri );
48-
QgsRasterDataProvider* verifiedProvider = ( QgsRasterDataProvider* ) QgsProviderRegistry::instance()->provider( theVerifiedKey, theVerifiedUri );
48+
QgsRasterDataProvider* verifiedProvider = dynamic_cast< QgsRasterDataProvider* >( QgsProviderRegistry::instance()->provider( theVerifiedKey, theVerifiedUri ) );
4949
if ( !verifiedProvider || !verifiedProvider->isValid() )
5050
{
5151
error( QString( "Cannot load provider %1 with URI: %2" ).arg( theVerifiedKey, theVerifiedUri ), mReport );
5252
ok = false;
5353
}
5454

5555
//QgsRasterDataProvider* expectedProvider = QgsRasterLayer::loadProvider( theExpectedKey, theExpectedUri );
56-
QgsRasterDataProvider* expectedProvider = ( QgsRasterDataProvider* ) QgsProviderRegistry::instance()->provider( theExpectedKey, theExpectedUri );
56+
QgsRasterDataProvider* expectedProvider = dynamic_cast< QgsRasterDataProvider* >( QgsProviderRegistry::instance()->provider( theExpectedKey, theExpectedUri ) );
5757
if ( !expectedProvider || !expectedProvider->isValid() )
5858
{
5959
error( QString( "Cannot load provider %1 with URI: %2" ).arg( theExpectedKey, theExpectedUri ), mReport );

‎src/core/raster/qgsrasterdataprovider.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ QgsRasterBlock * QgsRasterDataProvider::block( int theBandNo, QgsRectangle cons
181181
return block;
182182
}
183183

184-
qgssize tmpIndex = ( qgssize )tmpRow * ( qgssize )tmpWidth + tmpCol;
185-
qgssize index = row * ( qgssize )theWidth + col;
184+
qgssize tmpIndex = static_cast< qgssize >( tmpRow ) * static_cast< qgssize >( tmpWidth ) + tmpCol;
185+
qgssize index = row * static_cast< qgssize >( theWidth ) + col;
186186

187187
char *tmpBits = tmpBlock->bits( tmpIndex );
188188
char *bits = block->bits( index );
@@ -313,8 +313,8 @@ QgsRasterIdentifyResult QgsRasterDataProvider::identify( const QgsPoint & thePoi
313313
double xres = ( myExtent.width() ) / theWidth;
314314
double yres = ( myExtent.height() ) / theHeight;
315315

316-
int col = ( int ) floor(( thePoint.x() - myExtent.xMinimum() ) / xres );
317-
int row = ( int ) floor(( myExtent.yMaximum() - thePoint.y() ) / yres );
316+
int col = static_cast< int >( floor(( thePoint.x() - myExtent.xMinimum() ) / xres ) );
317+
int row = static_cast< int >( floor(( myExtent.yMaximum() - thePoint.y() ) / yres ) );
318318

319319
double xMin = myExtent.xMinimum() + col * xres;
320320
double xMax = xMin + xres;
@@ -349,7 +349,7 @@ QString QgsRasterDataProvider::lastErrorFormat()
349349
typedef QList<QPair<QString, QString> > *pyramidResamplingMethods_t();
350350
QList<QPair<QString, QString> > QgsRasterDataProvider::pyramidResamplingMethods( const QString& providerKey )
351351
{
352-
pyramidResamplingMethods_t *pPyramidResamplingMethods = ( pyramidResamplingMethods_t * ) cast_to_fptr( QgsProviderRegistry::instance()->function( providerKey, "pyramidResamplingMethods" ) );
352+
pyramidResamplingMethods_t *pPyramidResamplingMethods = reinterpret_cast< pyramidResamplingMethods_t * >( cast_to_fptr( QgsProviderRegistry::instance()->function( providerKey, "pyramidResamplingMethods" ) ) );
353353
if ( pPyramidResamplingMethods )
354354
{
355355
QList<QPair<QString, QString> > *methods = pPyramidResamplingMethods();
@@ -435,7 +435,7 @@ QgsRasterDataProvider* QgsRasterDataProvider::create( const QString &providerKey
435435
const QgsCoordinateReferenceSystem& crs,
436436
const QStringList& createOptions )
437437
{
438-
createFunction_t *createFn = ( createFunction_t* ) cast_to_fptr( QgsProviderRegistry::instance()->function( providerKey, "create" ) );
438+
createFunction_t *createFn = reinterpret_cast< createFunction_t* >( cast_to_fptr( QgsProviderRegistry::instance()->function( providerKey, "create" ) ) );
439439
if ( !createFn )
440440
{
441441
QgsDebugMsg( "Cannot resolve 'create' function in " + providerKey + " provider" );

‎src/core/raster/qgsrasterfilewriter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeDataRaster( const Qgs
220220
QgsRasterBandStats stats = srcProvider->bandStatistics( bandNo, QgsRasterBandStats::Min | QgsRasterBandStats::Max, srcExtent, 250000 );
221221

222222
// Test if we have free (not used) values
223-
double typeMinValue = QgsContrastEnhancement::maximumValuePossible(( QGis::DataType )srcProvider->srcDataType( bandNo ) );
224-
double typeMaxValue = QgsContrastEnhancement::maximumValuePossible(( QGis::DataType )srcProvider->srcDataType( bandNo ) );
223+
double typeMinValue = QgsContrastEnhancement::maximumValuePossible( static_cast< QGis::DataType >( srcProvider->srcDataType( bandNo ) ) );
224+
double typeMaxValue = QgsContrastEnhancement::maximumValuePossible( static_cast< QGis::DataType >( srcProvider->srcDataType( bandNo ) ) );
225225
if ( stats.minimumValue > typeMinValue )
226226
{
227227
destNoDataValue = typeMinValue;
@@ -530,7 +530,7 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeImageRaster( QgsRaste
530530
}
531531

532532
//fill into red/green/blue/alpha channels
533-
qgssize nPixels = ( qgssize )iterCols * iterRows;
533+
qgssize nPixels = static_cast< qgssize >( iterCols ) * iterRows;
534534
// TODO: should be char not int? we are then copying 1 byte
535535
int red = 0;
536536
int green = 0;
@@ -547,15 +547,15 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeImageRaster( QgsRaste
547547
if ( inputDataType == QGis::ARGB32_Premultiplied )
548548
{
549549
double a = alpha / 255.;
550-
QgsDebugMsgLevel( QString( "red = %1 green = %2 blue = %3 alpha = %4 p = %5 a = %6" ).arg( red ).arg( green ).arg( blue ).arg( alpha ).arg(( int )c, 0, 16 ).arg( a ), 5 );
550+
QgsDebugMsgLevel( QString( "red = %1 green = %2 blue = %3 alpha = %4 p = %5 a = %6" ).arg( red ).arg( green ).arg( blue ).arg( alpha ).arg( static_cast< int >( c ), 0, 16 ).arg( a ), 5 );
551551
red /= a;
552552
green /= a;
553553
blue /= a;
554554
}
555-
memcpy(( char* )redData + i, &red, 1 );
556-
memcpy(( char* )greenData + i, &green, 1 );
557-
memcpy(( char* )blueData + i, &blue, 1 );
558-
memcpy(( char* )alphaData + i, &alpha, 1 );
555+
memcpy( reinterpret_cast< char* >( redData ) + i, &red, 1 );
556+
memcpy( reinterpret_cast< char* >( greenData ) + i, &green, 1 );
557+
memcpy( reinterpret_cast< char* >( blueData ) + i, &blue, 1 );
558+
memcpy( reinterpret_cast< char* >( alphaData ) + i, &alpha, 1 );
559559
}
560560
delete inputBlock;
561561

@@ -710,7 +710,7 @@ void QgsRasterFileWriter::buildPyramids( const QString& filename )
710710
{
711711
QgsDebugMsg( "filename = " + filename );
712712
// open new dataProvider so we can build pyramids with it
713-
QgsRasterDataProvider* destProvider = ( QgsRasterDataProvider* ) QgsProviderRegistry::instance()->provider( mOutputProviderKey, filename );
713+
QgsRasterDataProvider* destProvider = dynamic_cast< QgsRasterDataProvider* >( QgsProviderRegistry::instance()->provider( mOutputProviderKey, filename ) );
714714
if ( !destProvider )
715715
{
716716
return;
@@ -948,7 +948,7 @@ void QgsRasterFileWriter::globalOutputParameters( const QgsRectangle& extent, in
948948
//calculate nRows automatically for providers without exact resolution
949949
if ( nRows < 0 )
950950
{
951-
nRows = ( double )nCols / extent.width() * extent.height() + 0.5;
951+
nRows = static_cast< double >( nCols ) / extent.width() * extent.height() + 0.5;
952952
}
953953
geoTransform[0] = extent.xMinimum();
954954
geoTransform[1] = pixelSize;

‎src/core/raster/qgsrasterinterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ QgsRasterBandStats QgsRasterInterface::bandStatistics( int theBandNo,
186186
QgsRasterBlock* blk = block( theBandNo, myPartExtent, myBlockWidth, myBlockHeight );
187187

188188
// Collect the histogram counts.
189-
for ( qgssize i = 0; i < (( qgssize ) myBlockHeight ) * myBlockWidth; i++ )
189+
for ( qgssize i = 0; i < ( static_cast< qgssize >( myBlockHeight ) ) * myBlockWidth; i++ )
190190
{
191191
if ( blk->isNoData( i ) ) continue; // NULL
192192

@@ -468,7 +468,7 @@ QgsRasterHistogram QgsRasterInterface::histogram( int theBandNo,
468468
QgsRasterBlock* blk = block( theBandNo, myPartExtent, myBlockWidth, myBlockHeight );
469469

470470
// Collect the histogram counts.
471-
for ( qgssize i = 0; i < (( qgssize ) myBlockHeight ) * myBlockWidth; i++ )
471+
for ( qgssize i = 0; i < ( static_cast< qgssize >( myBlockHeight ) ) * myBlockWidth; i++ )
472472
{
473473
if ( blk->isNoData( i ) )
474474
{
@@ -533,8 +533,8 @@ void QgsRasterInterface::cumulativeCut( int theBandNo,
533533

534534
double myBinXStep = ( myHistogram.maximum - myHistogram.minimum ) / myHistogram.binCount;
535535
int myCount = 0;
536-
int myMinCount = ( int ) qRound( theLowerCount * myHistogram.nonNullCount );
537-
int myMaxCount = ( int ) qRound( theUpperCount * myHistogram.nonNullCount );
536+
int myMinCount = static_cast< int >( qRound( theLowerCount * myHistogram.nonNullCount ) );
537+
int myMaxCount = static_cast< int >( qRound( theUpperCount * myHistogram.nonNullCount ) );
538538
bool myLowerFound = false;
539539
QgsDebugMsg( QString( "binCount = %1 minimum = %2 maximum = %3 myBinXStep = %4" ).arg( myHistogram.binCount ).arg( myHistogram.minimum ).arg( myHistogram.maximum ).arg( myBinXStep ) );
540540
QgsDebugMsg( QString( "myMinCount = %1 myMaxCount = %2" ).arg( myMinCount ).arg( myMaxCount ) );

‎src/core/raster/qgsrasteriterator.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ bool QgsRasterIterator::readNextRasterPart( int bandNumber,
8787

8888
//get subrectangle
8989
QgsRectangle viewPortExtent = mExtent;
90-
double xmin = viewPortExtent.xMinimum() + pInfo.currentCol / ( double )pInfo.nCols * viewPortExtent.width();
91-
double xmax = viewPortExtent.xMinimum() + ( pInfo.currentCol + nCols ) / ( double )pInfo.nCols * viewPortExtent.width();
92-
double ymin = viewPortExtent.yMaximum() - ( pInfo.currentRow + nRows ) / ( double )pInfo.nRows * viewPortExtent.height();
93-
double ymax = viewPortExtent.yMaximum() - pInfo.currentRow / ( double )pInfo.nRows * viewPortExtent.height();
90+
double xmin = viewPortExtent.xMinimum() + pInfo.currentCol / static_cast< double >( pInfo.nCols ) * viewPortExtent.width();
91+
double xmax = viewPortExtent.xMinimum() + ( pInfo.currentCol + nCols ) / static_cast< double >( pInfo.nCols ) * viewPortExtent.width();
92+
double ymin = viewPortExtent.yMaximum() - ( pInfo.currentRow + nRows ) / static_cast< double >( pInfo.nRows ) * viewPortExtent.height();
93+
double ymax = viewPortExtent.yMaximum() - pInfo.currentRow / static_cast< double >( pInfo.nRows ) * viewPortExtent.height();
9494
QgsRectangle blockRect( xmin, ymin, xmax, ymax );
9595

9696
*block = mInput->block( bandNumber, blockRect, nCols, nRows );

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ QgsRasterLayer::~QgsRasterLayer()
169169
*/
170170
bool QgsRasterLayer::isValidRasterFileName( const QString& theFileNameQString, QString& retErrMsg )
171171
{
172-
isvalidrasterfilename_t *pValid = ( isvalidrasterfilename_t * ) cast_to_fptr( QgsProviderRegistry::instance()->function( "gdal", "isValidRasterFileName" ) );
172+
isvalidrasterfilename_t *pValid = reinterpret_cast< isvalidrasterfilename_t * >( cast_to_fptr( QgsProviderRegistry::instance()->function( "gdal", "isValidRasterFileName" ) ) );
173173
if ( ! pValid )
174174
{
175175
QgsDebugMsg( "Could not resolve isValidRasterFileName in gdal provider library" );
@@ -558,14 +558,14 @@ QPixmap QgsRasterLayer::paletteAsPixmap( int theBandNumber )
558558
myQImage.fill( 0 );
559559
myPalettePixmap.fill();
560560

561-
double myStep = (( double )myColorRampItemList.size() - 1 ) / ( double )( mySize * mySize );
561+
double myStep = ( static_cast< double >( myColorRampItemList.size() ) - 1 ) / static_cast< double >( mySize * mySize );
562562
double myValue = 0.0;
563563
for ( int myRow = 0; myRow < mySize; myRow++ )
564564
{
565-
QRgb* myLineBuffer = ( QRgb* )myQImage.scanLine( myRow );
565+
QRgb* myLineBuffer = reinterpret_cast< QRgb* >( myQImage.scanLine( myRow ) );
566566
for ( int myCol = 0; myCol < mySize; myCol++ )
567567
{
568-
myValue = myStep * ( double )( myCol + myRow * mySize );
568+
myValue = myStep * static_cast< double >( myCol + myRow * mySize );
569569
int c1, c2, c3, c4;
570570
myShader.shade( myValue, &c1, &c2, &c3, &c4 );
571571
myLineBuffer[ myCol ] = qRgba( c1, c2, c3, c4 );
@@ -651,7 +651,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider )
651651

652652
//mBandCount = 0;
653653

654-
mDataProvider = ( QgsRasterDataProvider* )QgsProviderRegistry::instance()->provider( mProviderKey, mDataSource );
654+
mDataProvider = dynamic_cast< QgsRasterDataProvider* >( QgsProviderRegistry::instance()->provider( mProviderKey, mDataSource ) );
655655
if ( !mDataProvider )
656656
{
657657
//QgsMessageLog::logMessage( tr( "Cannot instantiate the data provider" ), tr( "Raster" ) );
@@ -886,8 +886,8 @@ void QgsRasterLayer::setContrastEnhancement( QgsContrastEnhancement::ContrastEnh
886886
{
887887
if ( myBand != -1 )
888888
{
889-
QGis::DataType myType = ( QGis::DataType )mDataProvider->dataType( myBand );
890-
QgsContrastEnhancement* myEnhancement = new QgsContrastEnhancement(( QGis::DataType )myType );
889+
QGis::DataType myType = static_cast< QGis::DataType >( mDataProvider->dataType( myBand ) );
890+
QgsContrastEnhancement* myEnhancement = new QgsContrastEnhancement( static_cast< QGis::DataType >( myType ) );
891891
myEnhancement->setContrastEnhancementAlgorithm( theAlgorithm, theGenerateLookupTableFlag );
892892

893893
double myMin = std::numeric_limits<double>::quiet_NaN();
@@ -1115,7 +1115,7 @@ QPixmap QgsRasterLayer::previewAsPixmap( const QSize& size, const QColor& bgColo
11151115
double myX = 0.0;
11161116
double myY = 0.0;
11171117
QgsRectangle myExtent = mDataProvider->extent();
1118-
if ( myExtent.width() / myExtent.height() >= ( double )myQPixmap.width() / myQPixmap.height() )
1118+
if ( myExtent.width() / myExtent.height() >= static_cast< double >( myQPixmap.width() ) / myQPixmap.height() )
11191119
{
11201120
myMapUnitsPerPixel = myExtent.width() / myQPixmap.width();
11211121
myY = ( myQPixmap.height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
@@ -1167,7 +1167,7 @@ QImage QgsRasterLayer::previewAsImage( const QSize& size, const QColor& bgColor,
11671167
double myX = 0.0;
11681168
double myY = 0.0;
11691169
QgsRectangle myExtent = mDataProvider->extent();
1170-
if ( myExtent.width() / myExtent.height() >= ( double )myQImage.width() / myQImage.height() )
1170+
if ( myExtent.width() / myExtent.height() >= static_cast< double >( myQImage.width() ) / myQImage.height() )
11711171
{
11721172
myMapUnitsPerPixel = myExtent.width() / myQImage.width();
11731173
myY = ( myQImage.height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
@@ -1215,7 +1215,7 @@ void QgsRasterLayer::onProgress( int theType, double theProgress, const QString&
12151215
Q_UNUSED( theType );
12161216
Q_UNUSED( theMessage );
12171217
QgsDebugMsg( QString( "theProgress = %1" ).arg( theProgress ) );
1218-
emit progressUpdate(( int )theProgress );
1218+
emit progressUpdate( static_cast< int >( theProgress ) );
12191219
}
12201220

12211221
//////////////////////////////////////////////////////////
@@ -1309,7 +1309,7 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
13091309
if ( !blendModeNode.isNull() )
13101310
{
13111311
QDomElement e = blendModeNode.toElement();
1312-
setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) e.text().toInt() ) );
1312+
setBlendMode( QgsMapRenderer::getCompositionMode( static_cast< QgsMapRenderer::BlendMode >( e.text().toInt() ) ) );
13131313
}
13141314

13151315
return true;

‎src/core/raster/qgsrasterprojector.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ void QgsRasterProjector::calc()
324324
}
325325
}
326326
QgsDebugMsg( QString( "CPMatrix size: mCPRows = %1 mCPCols = %2" ).arg( mCPRows ).arg( mCPCols ) );
327-
mDestRowsPerMatrixRow = ( float )mDestRows / ( mCPRows - 1 );
328-
mDestColsPerMatrixCol = ( float )mDestCols / ( mCPCols - 1 );
327+
mDestRowsPerMatrixRow = static_cast< float >( mDestRows ) / ( mCPRows - 1 );
328+
mDestColsPerMatrixCol = static_cast< float >( mDestCols ) / ( mCPCols - 1 );
329329

330330
QgsDebugMsgLevel( "CPMatrix:", 5 );
331331
QgsDebugMsgLevel( cpToString(), 5 );
@@ -446,8 +446,8 @@ void QgsRasterProjector::calcSrcRowsCols()
446446
if ( mApproximate )
447447
{
448448
// For now, we take cell sizes projected to source but not to source axes
449-
double myDestColsPerMatrixCell = ( double )mDestCols / mCPCols;
450-
double myDestRowsPerMatrixCell = ( double )mDestRows / mCPRows;
449+
double myDestColsPerMatrixCell = static_cast< double >( mDestCols ) / mCPCols;
450+
double myDestRowsPerMatrixCell = static_cast< double >( mDestRows ) / mCPRows;
451451
QgsDebugMsg( QString( "myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );
452452
for ( int i = 0; i < mCPRows - 1; i++ )
453453
{
@@ -501,8 +501,8 @@ void QgsRasterProjector::calcSrcRowsCols()
501501
QgsDebugMsg( QString( "mSrcExtent.width = %1 mSrcExtent.height = %2" ).arg( mSrcExtent.width() ).arg( mSrcExtent.height() ) );
502502

503503
// we have to round to keep alignment set in calcSrcExtent
504-
mSrcRows = ( int ) qRound( mSrcExtent.height() / myMinYSize );
505-
mSrcCols = ( int ) qRound( mSrcExtent.width() / myMinXSize );
504+
mSrcRows = static_cast< int >( qRound( mSrcExtent.height() / myMinYSize ) );
505+
mSrcCols = static_cast< int >( qRound( mSrcExtent.width() / myMinXSize ) );
506506

507507
QgsDebugMsg( QString( "mSrcRows = %1 mSrcCols = %2" ).arg( mSrcRows ).arg( mSrcCols ) );
508508
}
@@ -516,11 +516,11 @@ inline void QgsRasterProjector::destPointOnCPMatrix( int theRow, int theCol, dou
516516

517517
inline int QgsRasterProjector::matrixRow( int theDestRow )
518518
{
519-
return ( int )( floor(( theDestRow + 0.5 ) / mDestRowsPerMatrixRow ) );
519+
return static_cast< int >( floor(( theDestRow + 0.5 ) / mDestRowsPerMatrixRow ) );
520520
}
521521
inline int QgsRasterProjector::matrixCol( int theDestCol )
522522
{
523-
return ( int )( floor(( theDestCol + 0.5 ) / mDestColsPerMatrixCol ) );
523+
return static_cast< int >( floor(( theDestCol + 0.5 ) / mDestColsPerMatrixCol ) );
524524
}
525525

526526
QgsPoint QgsRasterProjector::srcPoint( int theDestRow, int theCol )
@@ -608,8 +608,8 @@ bool QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int *
608608
return false;
609609
}
610610
// Get source row col
611-
*theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - y ) / mSrcYRes );
612-
*theSrcCol = ( int ) floor(( x - mSrcExtent.xMinimum() ) / mSrcXRes );
611+
*theSrcRow = static_cast< int >( floor(( mSrcExtent.yMaximum() - y ) / mSrcYRes ) );
612+
*theSrcCol = static_cast< int >( floor(( x - mSrcExtent.xMinimum() ) / mSrcXRes ) );
613613
#ifdef QGISDEBUG
614614
QgsDebugMsgLevel( QString( "mSrcExtent.yMinimum() = %1 mSrcExtent.yMaximum() = %2 mSrcYRes = %3" ).arg( mSrcExtent.yMinimum() ).arg( mSrcExtent.yMaximum() ).arg( mSrcYRes ), 5 );
615615
QgsDebugMsgLevel( QString( "theSrcRow = %1 theSrcCol = %2" ).arg( *theSrcRow ).arg( *theSrcCol ), 5 );
@@ -670,8 +670,8 @@ bool QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, i
670670

671671
// TODO: check again cell selection (coor is in the middle)
672672

673-
*theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - mySrcY ) / mSrcYRes );
674-
*theSrcCol = ( int ) floor(( mySrcX - mSrcExtent.xMinimum() ) / mSrcXRes );
673+
*theSrcRow = static_cast< int >( floor(( mSrcExtent.yMaximum() - mySrcY ) / mSrcYRes ) );
674+
*theSrcCol = static_cast< int >( floor(( mySrcX - mSrcExtent.xMinimum() ) / mSrcXRes ) );
675675

676676
// For now silently correct limits to avoid crashes
677677
// TODO: review
@@ -965,7 +965,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
965965
bool inside = srcRowCol( i, j, &srcRow, &srcCol, inverseCt );
966966
if ( !inside ) continue; // we have everything set to no data
967967

968-
qgssize srcIndex = ( qgssize )srcRow * mSrcCols + srcCol;
968+
qgssize srcIndex = static_cast< qgssize >( srcRow ) * mSrcCols + srcCol;
969969
QgsDebugMsgLevel( QString( "row = %1 col = %2 srcRow = %3 srcCol = %4" ).arg( i ).arg( j ).arg( srcRow ).arg( srcCol ), 5 );
970970

971971
// isNoData() may be slow so we check doNoData first
@@ -975,7 +975,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
975975
continue;
976976
}
977977

978-
qgssize destIndex = ( qgssize )i * width + j;
978+
qgssize destIndex = static_cast< qgssize >( i ) * width + j;
979979
char *srcBits = inputBlock->bits( srcIndex );
980980
char *destBits = outputBlock->bits( destIndex );
981981
if ( !srcBits )
@@ -1048,8 +1048,8 @@ bool QgsRasterProjector::extentSize( const QgsCoordinateTransform* ct,
10481048
}
10491049
}
10501050
}
1051-
theDestXSize = std::max( 1, ( int )( theDestExtent.width() / destYRes ) );
1052-
theDestYSize = std::max( 1, ( int )( theDestExtent.height() / destYRes ) );
1051+
theDestXSize = std::max( 1, static_cast< int >( theDestExtent.width() / destYRes ) );
1052+
theDestYSize = std::max( 1, static_cast< int >( theDestExtent.height() / destYRes ) );
10531053

10541054
return true;
10551055
}

‎src/core/raster/qgsrasterresamplefilter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ QgsRasterBlock * QgsRasterResampleFilter::block( int bandNo, QgsRectangle const
173173
}
174174

175175
//effective oversampling factors are different to global one because of rounding
176-
double oversamplingX = (( double )width * oversampling ) / width;
177-
double oversamplingY = (( double )height * oversampling ) / height;
176+
double oversamplingX = ( static_cast< double >( width ) * oversampling ) / width;
177+
double oversamplingY = ( static_cast< double >( height ) * oversampling ) / height;
178178

179179
// TODO: we must also increase the extent to get correct result on borders of parts
180180

‎src/core/raster/qgsrastertransparency.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ int QgsRasterTransparency::alphaValue( double theValue, int theGlobalTransparenc
127127
//if a match was found use the stored transparency percentage
128128
if ( myTransparentPixelFound )
129129
{
130-
return ( int )(( float )theGlobalTransparency *( 1.0 - ( myTransparentPixel.percentTransparent / 100.0 ) ) );
130+
return static_cast< int >( static_cast< float >( theGlobalTransparency ) *( 1.0 - ( myTransparentPixel.percentTransparent / 100.0 ) ) );
131131
}
132132

133133
return theGlobalTransparency;
@@ -155,11 +155,11 @@ int QgsRasterTransparency::alphaValue( double theRedValue, double theGreenValue,
155155
for ( int myListRunner = 0; myListRunner < mTransparentThreeValuePixelList.count(); myListRunner++ )
156156
{
157157
myTransparentPixel = mTransparentThreeValuePixelList[myListRunner];
158-
if ( myTransparentPixel.red == theRedValue )
158+
if ( qgsDoubleNear( myTransparentPixel.red, theRedValue ) )
159159
{
160-
if ( myTransparentPixel.green == theGreenValue )
160+
if ( qgsDoubleNear( myTransparentPixel.green, theGreenValue ) )
161161
{
162-
if ( myTransparentPixel.blue == theBlueValue )
162+
if ( qgsDoubleNear( myTransparentPixel.blue, theBlueValue ) )
163163
{
164164
myTransparentPixelFound = true;
165165
break;
@@ -171,7 +171,7 @@ int QgsRasterTransparency::alphaValue( double theRedValue, double theGreenValue,
171171
//if a match was found use the stored transparency percentage
172172
if ( myTransparentPixelFound )
173173
{
174-
return ( int )(( float )theGlobalTransparency *( 1.0 - ( myTransparentPixel.percentTransparent / 100.0 ) ) );
174+
return static_cast< int >( static_cast< float >( theGlobalTransparency ) *( 1.0 - ( myTransparentPixel.percentTransparent / 100.0 ) ) );
175175
}
176176

177177
return theGlobalTransparency;

0 commit comments

Comments
 (0)
Please sign in to comment.