Skip to content

Commit 15bce99

Browse files
author
jef
committedMar 8, 2011
fix a few warnings and indentation
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15393 c8812cc2-4d05-0410-92ff-de0c093fc19c

18 files changed

+767
-695
lines changed
 

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void QgsRasterLayerProperties::sync()
516516
break;
517517
}
518518

519-
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
519+
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
520520
{
521521
delete tabPageSymbology;
522522
delete tabPageColormap;
@@ -525,12 +525,12 @@ void QgsRasterLayerProperties::sync()
525525
tabBar->setCurrentWidget( tabPageMetadata );
526526
}
527527

528-
if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
528+
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
529529
{
530530
delete tabPagePyramids;
531531
}
532532

533-
if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
533+
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
534534
{
535535
delete tabPageHistogram;
536536
}
@@ -562,8 +562,8 @@ void QgsRasterLayerProperties::sync()
562562
//
563563
// Populate the various controls on the form
564564
//
565-
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
566-
{
565+
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
566+
{
567567
QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
568568
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
569569
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
@@ -593,7 +593,7 @@ void QgsRasterLayerProperties::sync()
593593
}
594594
}
595595

596-
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
596+
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
597597
{
598598
if ( rbtnThreeBand->isChecked() )
599599
{
@@ -782,7 +782,7 @@ void QgsRasterLayerProperties::sync()
782782

783783
//display the raster dimensions and no data value
784784
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
785-
{
785+
{
786786
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
787787
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
788788
}
@@ -793,8 +793,8 @@ void QgsRasterLayerProperties::sync()
793793
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
794794
}
795795

796-
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
797-
{
796+
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
797+
{
798798
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
799799
}
800800
else
@@ -843,7 +843,7 @@ void QgsRasterLayerProperties::syncColormapTab()
843843
return;
844844
}
845845

846-
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
846+
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
847847
{
848848
return;
849849
}
@@ -935,7 +935,7 @@ bool QgsRasterLayerProperties::validUserDefinedMinMax()
935935
*/
936936
void QgsRasterLayerProperties::apply()
937937
{
938-
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
938+
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
939939
{
940940
QgsDebugMsg( "apply processing symbology tab" );
941941
/*
@@ -1425,7 +1425,7 @@ void QgsRasterLayerProperties::apply()
14251425
mRasterLayer->triggerRepaint();
14261426

14271427
//Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
1428-
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
1428+
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
14291429
{
14301430
if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
14311431
{
@@ -1668,7 +1668,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
16681668

16691669
void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged( const QString& theText )
16701670
{
1671-
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
1671+
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
16721672
{
16731673
return;
16741674
}
@@ -2586,9 +2586,9 @@ void QgsRasterLayerProperties::on_pbtnLoadColorMapFromFile_clicked()
25862586

25872587
void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
25882588
{
2589-
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
2590-
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
2591-
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
2589+
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
2590+
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
2591+
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
25922592
{
25932593
QgsRasterBandStats myRasterBandStats;
25942594
double myMinimumMaximum[2];

‎src/core/qgsrasterdataprovider.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323
#include <QTime>
2424
#include <QMap>
2525

26-
void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data )
26+
void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data )
2727
{
28-
QgsDebugMsg("Entered");
28+
QgsDebugMsg( "Entered" );
2929
QgsDebugMsg( "viewExtent = " + viewExtent.toString() );
3030

31-
if ( ! theSrcCRS.isValid() || ! theDestCRS.isValid() ) {
31+
if ( ! theSrcCRS.isValid() || ! theDestCRS.isValid() )
32+
{
3233
readBlock( bandNo, viewExtent, width, height, data );
3334
return;
3435
}
@@ -38,21 +39,21 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt
3839

3940
double mMaxSrcXRes = 0;
4041
double mMaxSrcYRes = 0;
41-
42-
if ( capabilities() & QgsRasterDataProvider::ExactResolution )
42+
43+
if ( capabilities() & QgsRasterDataProvider::ExactResolution )
4344
{
44-
mMaxSrcXRes = extent().width()/xSize();
45-
mMaxSrcYRes = extent().height()/ySize();
45+
mMaxSrcXRes = extent().width() / xSize();
46+
mMaxSrcYRes = extent().height() / ySize();
4647
}
4748

48-
QgsRasterProjector myProjector = QgsRasterProjector ( theSrcCRS, theDestCRS, viewExtent, height, width, mMaxSrcXRes, mMaxSrcYRes );
49+
QgsRasterProjector myProjector = QgsRasterProjector( theSrcCRS, theDestCRS, viewExtent, height, width, mMaxSrcXRes, mMaxSrcYRes );
4950

5051
QgsDebugMsg( QString( "create projector time (ms): %1" ).arg( time.elapsed() ) );
5152

5253
// TODO: init data by nulls
5354

5455
// Allocate memory for not projected source data
55-
int mySize = dataTypeSize(bandNo)/8;
56+
int mySize = dataTypeSize( bandNo ) / 8;
5657
void *mySrcData = malloc( mySize * myProjector.srcRows() * myProjector.srcCols() );
5758

5859
time.restart();
@@ -67,13 +68,15 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt
6768
int mySrcCol;
6869
int mySrcOffset;
6970
int myDestOffset;
70-
for ( int r = 0; r < height; r++) {
71-
for ( int c = 0; c < width; c++) {
72-
myProjector.srcRowCol ( r, c, &mySrcRow, &mySrcCol );
71+
for ( int r = 0; r < height; r++ )
72+
{
73+
for ( int c = 0; c < width; c++ )
74+
{
75+
myProjector.srcRowCol( r, c, &mySrcRow, &mySrcCol );
7376
mySrcOffset = mySize * ( mySrcRow * myProjector.srcCols() + mySrcCol );
7477
myDestOffset = mySize * ( r * width + c );
75-
// retype to char is just to avoid g++ warning
76-
memcpy( (char*) data + myDestOffset, (char*)mySrcData + mySrcOffset, mySize );
78+
// retype to char is just to avoid g++ warning
79+
memcpy(( char* ) data + myDestOffset, ( char* )mySrcData + mySrcOffset, mySize );
7780
}
7881
}
7982
QgsDebugMsg( QString( "reproject block time (ms): %1" ).arg( time.elapsed() ) );

‎src/core/qgsrasterdataprovider.h

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,29 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
8181
/*! Complex Float64 */ CFloat64 = 11,
8282
/*! Color, alpha, red, green, blue, 4 bytes */ ARGBDataType = 12,
8383
TypeCount = 13 /* maximum type # + 1 */
84-
};
84+
};
8585

8686
// This is modified copy of GDALColorInterp
8787
enum ColorInterpretation
8888
{
89-
UndefinedColorInterpretation=0,
90-
/*! Greyscale */ GrayIndex=1,
91-
/*! Paletted (see associated color table) */ PaletteIndex=2,
92-
/*! Red band of RGBA image */ RedBand=3,
93-
/*! Green band of RGBA image */ GreenBand=4,
94-
/*! Blue band of RGBA image */ BlueBand=5,
95-
/*! Alpha (0=transparent, 255=opaque) */ AlphaBand=6,
96-
/*! Hue band of HLS image */ HueBand=7,
97-
/*! Saturation band of HLS image */ SaturationBand=8,
98-
/*! Lightness band of HLS image */ LightnessBand=9,
99-
/*! Cyan band of CMYK image */ CyanBand=10,
100-
/*! Magenta band of CMYK image */ MagentaBand=11,
101-
/*! Yellow band of CMYK image */ YellowBand=12,
102-
/*! Black band of CMLY image */ BlackBand=13,
103-
/*! Y Luminance */ YCbCr_YBand=14,
104-
/*! Cb Chroma */ YCbCr_CbBand=15,
105-
/*! Cr Chroma */ YCbCr_CrBand=16,
106-
/*! Max current value */ ColorInterpretationMax=16
89+
UndefinedColorInterpretation = 0,
90+
/*! Greyscale */ GrayIndex = 1,
91+
/*! Paletted (see associated color table) */ PaletteIndex = 2,
92+
/*! Red band of RGBA image */ RedBand = 3,
93+
/*! Green band of RGBA image */ GreenBand = 4,
94+
/*! Blue band of RGBA image */ BlueBand = 5,
95+
/*! Alpha (0=transparent, 255=opaque) */ AlphaBand = 6,
96+
/*! Hue band of HLS image */ HueBand = 7,
97+
/*! Saturation band of HLS image */ SaturationBand = 8,
98+
/*! Lightness band of HLS image */ LightnessBand = 9,
99+
/*! Cyan band of CMYK image */ CyanBand = 10,
100+
/*! Magenta band of CMYK image */ MagentaBand = 11,
101+
/*! Yellow band of CMYK image */ YellowBand = 12,
102+
/*! Black band of CMLY image */ BlackBand = 13,
103+
/*! Y Luminance */ YCbCr_YBand = 14,
104+
/*! Cb Chroma */ YCbCr_CbBand = 15,
105+
/*! Cr Chroma */ YCbCr_CrBand = 16,
106+
/*! Max current value */ ColorInterpretationMax = 16
107107
};
108108

109109
QgsRasterDataProvider();
@@ -164,23 +164,23 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
164164
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box
165165

166166
/** Returns data type for the band specified by number */
167-
virtual int dataType ( int bandNo ) const
167+
virtual int dataType( int bandNo ) const
168168
{
169-
return srcDataType ( bandNo );
169+
return srcDataType( bandNo );
170170
}
171171

172172
/** Returns source data type for the band specified by number,
173-
* source data type may be shorter than dataType
173+
* source data type may be shorter than dataType
174174
*/
175-
virtual int srcDataType ( int bandNo ) const
175+
virtual int srcDataType( int bandNo ) const
176176
{
177177
return QgsRasterDataProvider::UnknownDataType;
178178
}
179179

180-
int typeSize ( int dataType ) const
180+
int typeSize( int dataType ) const
181181
{
182182
// modified copy from GDAL
183-
switch( dataType )
183+
switch ( dataType )
184184
{
185185
case Byte:
186186
return 8;
@@ -210,24 +210,27 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
210210
return 0;
211211
}
212212
}
213-
int dataTypeSize ( int bandNo ) const
213+
int dataTypeSize( int bandNo ) const
214214
{
215-
return typeSize ( dataType ( bandNo ) );
215+
return typeSize( dataType( bandNo ) );
216216
}
217217

218218
/** Get numbur of bands */
219-
virtual int bandCount() const {
219+
virtual int bandCount() const
220+
{
220221
return 1;
221222
}
222223

223224
/** Returns data type for the band specified by number */
224-
virtual int colorInterpretation ( int theBandNo ) const {
225+
virtual int colorInterpretation( int theBandNo ) const
226+
{
225227
return QgsRasterDataProvider::UndefinedColorInterpretation;
226228
}
227229

228-
QString colorName ( int colorInterpretation ) const {
230+
QString colorName( int colorInterpretation ) const
231+
{
229232
// Modified copy from GDAL
230-
switch( colorInterpretation )
233+
switch ( colorInterpretation )
231234
{
232235
case UndefinedColorInterpretation:
233236
return "Undefined";
@@ -285,23 +288,24 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
285288
}
286289
}
287290
/** Reload data (data could change) */
288-
virtual bool reload ( ) { return true; }
291+
virtual bool reload( ) { return true; }
289292

290-
virtual QString colorInterpretationName ( int theBandNo ) const {
291-
return colorName ( colorInterpretation ( theBandNo ) );
293+
virtual QString colorInterpretationName( int theBandNo ) const
294+
{
295+
return colorName( colorInterpretation( theBandNo ) );
292296
}
293297

294298
/** Get block size */
295299
virtual int xBlockSize() const { return 0; }
296300
virtual int yBlockSize() const { return 0; }
297-
301+
298302
/** Get raster size */
299303
virtual int xSize() const { return 0; }
300304
virtual int ySize() const { return 0; }
301305

302306
/** read block of data */
303307
// TODO clarify what happens on the last block (the part outside raster)
304-
virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ){}
308+
virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ) {}
305309

306310
/** read block of data using give extent and size */
307311
virtual void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data ) {};
@@ -312,30 +316,31 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
312316
/** value representing null data */
313317
virtual double noDataValue() const { return 0; }
314318

315-
virtual double minimumValue(int bandNo)const { return 0; }
316-
virtual double maximumValue(int bandNo)const { return 0; }
319+
virtual double minimumValue( int bandNo )const { return 0; }
320+
virtual double maximumValue( int bandNo )const { return 0; }
317321

318-
virtual QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const { return QList<QgsColorRampShader::ColorRampItem>(); }
322+
virtual QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const { return QList<QgsColorRampShader::ColorRampItem>(); }
319323

320324
// Defined in parent
321325
/** \brief Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS */
322-
virtual QStringList subLayers() const {
326+
virtual QStringList subLayers() const
327+
{
323328
return QStringList();
324329
}
325330

326331
/** \brief Populate the histogram vector for a given band */
327332

328333
virtual void populateHistogram( int theBandNoInt,
329-
QgsRasterBandStats & theBandStats,
330-
int theBinCountInt = 256,
331-
bool theIgnoreOutOfRangeFlag = true,
332-
bool theThoroughBandScanFlag = false
333-
) {};
334+
QgsRasterBandStats & theBandStats,
335+
int theBinCountInt = 256,
336+
bool theIgnoreOutOfRangeFlag = true,
337+
bool theThoroughBandScanFlag = false
338+
) {};
334339

335340
/** \brief Create pyramid overviews */
336341
virtual QString buildPyramids( const QList<QgsRasterPyramid> & thePyramidList,
337-
const QString & theResamplingMethod = "NEAREST",
338-
bool theTryInternalFlag = false ) { return "FAILED_NOT_SUPPORTED"; };
342+
const QString & theResamplingMethod = "NEAREST",
343+
bool theTryInternalFlag = false ) { return "FAILED_NOT_SUPPORTED"; };
339344

340345
/** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
341346
* POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
@@ -346,7 +351,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
346351

347352

348353
/** \brief helper function to create zero padded band names */
349-
QString generateBandName( int theBandNumber )
354+
QString generateBandName( int theBandNumber )
350355
{
351356
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
352357
}

‎src/core/qgsrasterprojector.cpp

Lines changed: 157 additions & 128 deletions
Large diffs are not rendered by default.

‎src/core/qgsrasterprojector.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@
3737
//class QgsRectangle;
3838
class QgsPoint;
3939

40-
//class CORE_EXPORT QgsRasterProjector
41-
class QgsRasterProjector
40+
//class CORE_EXPORT QgsRasterProjector
41+
class QgsRasterProjector
4242
{
4343
// Q_OBJECT
4444
public:
45-
/** \brief QgsRasterProjector implements approximate projection support for
45+
/** \brief QgsRasterProjector implements approximate projection support for
4646
* it calculates grid of points in source CRS for target CRS + extent
4747
* which are used to calculate affine transformation matrices.
4848
* */
49-
QgsRasterProjector(
50-
QgsCoordinateReferenceSystem theSrcCRS,
51-
QgsCoordinateReferenceSystem theDestCRS,
52-
QgsRectangle theDestExtent,
49+
QgsRasterProjector(
50+
QgsCoordinateReferenceSystem theSrcCRS,
51+
QgsCoordinateReferenceSystem theDestCRS,
52+
QgsRectangle theDestExtent,
5353
int theDestRows, int theDestCols,
5454
double theMaxSrcXRes, double theMaxSrcYRes
5555
);
@@ -59,17 +59,17 @@ class QgsRasterProjector
5959

6060

6161
/** \brief get destination point for _current_ destination position */
62-
void destPointOnCPMatrix ( int theRow, int theCol, double *theX, double *theY );
62+
void destPointOnCPMatrix( int theRow, int theCol, double *theX, double *theY );
6363

6464
/** \brief Get matrix upper left row/col indexes for destination row/col */
65-
int matrixRow ( int theDestRow );
66-
int matrixCol ( int theDestCol );
65+
int matrixRow( int theDestRow );
66+
int matrixCol( int theDestCol );
6767

6868
/** \brief get destination point for _current_ matrix position */
69-
QgsPoint srcPoint ( int theRow, int theCol );
69+
QgsPoint srcPoint( int theRow, int theCol );
7070

7171
/** \brief Get source row and column indexes for current source extent and resolution */
72-
void srcRowCol ( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
72+
void srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
7373

7474
/** \brief insert rows to matrix */
7575
void insertRows();
@@ -78,7 +78,7 @@ class QgsRasterProjector
7878
void insertCols();
7979

8080
/* calculate single control point in current matrix */
81-
void calcCP ( int theRow, int theCol );
81+
void calcCP( int theRow, int theCol );
8282

8383
/** \brief calculate matrix row */
8484
bool calcRow( int theRow );
@@ -90,25 +90,25 @@ class QgsRasterProjector
9090
void calcSrcExtent();
9191

9292
/** \brief calculate minimum source width and height */
93-
void calcSrcRowsCols ();
93+
void calcSrcRowsCols();
9494

9595
/** \brief check error along columns
9696
* returns true if within threshold */
97-
bool checkCols ();
98-
97+
bool checkCols();
98+
9999
/** \brief check error along rows
100100
* returns true if within threshold */
101-
bool checkRows ();
101+
bool checkRows();
102102

103103
/** Calculate array of src helper points */
104104
//void calcHelper ( int theMatrixRow, QList<QgsPoint> *thePoints );
105-
void calcHelper ( int theMatrixRow, QgsPoint *thePoints );
105+
void calcHelper( int theMatrixRow, QgsPoint *thePoints );
106106

107107
/** Calc / switch helper */
108108
void nextHelper();
109109

110110
/** get source extent */
111-
QgsRectangle srcExtent() { return mSrcExtent; }
111+
QgsRectangle srcExtent() { return mSrcExtent; }
112112

113113
/** get/set source width/height */
114114
int srcRows() { return mSrcRows; }

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 159 additions & 154 deletions
Large diffs are not rendered by default.

‎src/core/raster/qgsrasterlayer.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,14 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
298298
//
299299

300300
/** \brief Initialize default values */
301-
void init ();
301+
void init();
302302

303303
// For backward compatibility (Python) get rid of it once python is updated
304304
void setDataProvider( const QString & provider,
305305
const QStringList & layers,
306306
const QStringList & styles,
307307
const QString & format,
308-
const QString & crs);
308+
const QString & crs );
309309
/** [ data provider interface ] Set the data provider */
310310
void setDataProvider( const QString & provider,
311311
const QStringList & layers,
@@ -314,9 +314,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
314314
const QString & crs,
315315
bool loadDefaultStyleFlag );
316316

317-
static QLibrary* loadProviderLibrary( QString theProviderKey);
318-
static QgsRasterDataProvider* loadProvider( QString theProviderKey, QString theDataSource = 0);
319-
317+
static QLibrary* loadProviderLibrary( QString theProviderKey );
318+
static QgsRasterDataProvider* loadProvider( QString theProviderKey, QString theDataSource = 0 );
319+
320320

321321
/** \brief Accessor for blue band name mapping */
322322
QString blueBandName() const { return mBlueBandName; }
@@ -657,7 +657,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
657657
bool theTryInternalFlag = false );
658658

659659
/** \brief Populate the histogram vector for a given band */
660-
660+
661661
void populateHistogram( int theBandNoInt,
662662
int theBinCountInt = 256,
663663
bool theIgnoreOutOfRangeFlag = true,
@@ -692,9 +692,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
692692
//
693693
/** \brief Drawing routine for color type data */
694694
void drawSingleBandColorData( QPainter * theQPainter,
695-
QgsRasterViewPort * theRasterViewPort,
696-
const QgsMapToPixel* theQgsMapToPixel,
697-
int theBandNoInt );
695+
QgsRasterViewPort * theRasterViewPort,
696+
const QgsMapToPixel* theQgsMapToPixel,
697+
int theBandNoInt );
698698

699699
/** \brief Drawing routine for multiband image */
700700
void drawMultiBandColor( QPainter * theQPainter,
@@ -912,7 +912,7 @@ class CORE_EXPORT QgsRasterImageBuffer
912912
{
913913
public:
914914
QgsRasterImageBuffer( QgsRasterDataProvider *dataProvider, int bandNo, QPainter* p,
915-
QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* mGeoTransform );
915+
QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* mGeoTransform );
916916
~QgsRasterImageBuffer();
917917
void reset( int maxPixelsInVirtualMemory = 5000000 );
918918
/**Returns a pointer to the next scan line (or 0 if end)*/
@@ -948,7 +948,7 @@ class CORE_EXPORT QgsRasterImageBuffer
948948
int mCurrentPartImageRow; //current image row
949949
int mNumCurrentImageRows; //number of image rows for the current part
950950

951-
int mCurrentPart;
951+
int mCurrentPart;
952952

953953
//current memory image and gdal scan data
954954
QImage* mCurrentImage;

‎src/core/raster/qgsrasterviewport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct QgsRasterViewPort
4040
QgsPoint bottomRightPoint;
4141
/** \brief Distance in map units from left edge to right edge for the part of the raster that
4242
* is to be rendered.*/
43-
43+
4444
int drawableAreaXDim;
4545
/** \brief Distance in map units from bottom edge to top edge for the part of the raster that
4646
* is to be rendered.*/

‎src/providers/gdal/qgsgdalprovider.cpp

Lines changed: 145 additions & 142 deletions
Large diffs are not rendered by default.

‎src/providers/gdal/qgsgdalprovider.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ class QgsGdalProvider : public QgsRasterDataProvider
186186
*/
187187
int capabilities() const;
188188

189-
int dataType ( int bandNo ) const;
190-
int srcDataType ( int bandNo ) const;
189+
int dataType( int bandNo ) const;
190+
int srcDataType( int bandNo ) const;
191191

192-
int dataTypeFormGdal ( int theGdalDataType ) const;
192+
int dataTypeFormGdal( int theGdalDataType ) const;
193193

194194
int bandCount() const;
195195

196-
int colorInterpretation ( int bandNo ) const;
196+
int colorInterpretation( int bandNo ) const;
197197

198198
int xBlockSize() const;
199199
int yBlockSize() const;
@@ -206,18 +206,18 @@ class QgsGdalProvider : public QgsRasterDataProvider
206206
void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );
207207

208208
double noDataValue() const;
209-
void computeMinMax(int bandNo);
210-
double minimumValue(int bandNo) const;
211-
double maximumValue(int bandNo) const;
209+
void computeMinMax( int bandNo );
210+
double minimumValue( int bandNo ) const;
211+
double maximumValue( int bandNo ) const;
212212

213-
QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const;
213+
QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const;
214214

215215

216216
/**
217217
* Get metadata in a format suitable for feeding directly
218218
* into a subset of the GUI raster properties "Metadata" tab.
219219
*/
220-
QString metadata();
220+
QString metadata();
221221

222222
// Following methods specific for WMS are not used at all in this provider and should be removed IMO from qgsdataprovider.h
223223
void addLayers( QStringList const & layers, QStringList const & styles = QStringList() ) {}
@@ -233,11 +233,11 @@ class QgsGdalProvider : public QgsRasterDataProvider
233233
QStringList subLayers() const;
234234

235235
void populateHistogram( int theBandNoInt,
236-
QgsRasterBandStats & theBandStats,
237-
int theBinCountInt = 256,
238-
bool theIgnoreOutOfRangeFlag = true,
239-
bool theThoroughBandScanFlag = false
240-
);
236+
QgsRasterBandStats & theBandStats,
237+
int theBinCountInt = 256,
238+
bool theIgnoreOutOfRangeFlag = true,
239+
bool theThoroughBandScanFlag = false
240+
);
241241

242242
QString buildPyramids( const QList<QgsRasterPyramid> &,
243243
const QString & theResamplingMethod = "NEAREST",
@@ -258,9 +258,9 @@ class QgsGdalProvider : public QgsRasterDataProvider
258258
/** \brief Whether this raster has overviews / pyramids or not */
259259
bool mHasPyramids;
260260

261-
/** \brief Gdal data types used to represent data in in QGIS,
262-
may be longer than source data type to keep nulls
263-
indexed from 0
261+
/** \brief Gdal data types used to represent data in in QGIS,
262+
may be longer than source data type to keep nulls
263+
indexed from 0
264264
*/
265265
QList<int>mGdalDataType;
266266

‎src/providers/grass/qgis.d.rast.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int main( int argc, char **argv )
8080
G_adjust_Cell_head( &window, 1, 1 );
8181
G_set_window( &window );
8282

83-
raster_type = G_raster_map_type ( name, "" );
83+
raster_type = G_raster_map_type( name, "" );
8484
fp = G_raster_map_is_fp( name, mapset );
8585

8686
/* use DCELL even if the map is FCELL */
@@ -180,7 +180,7 @@ static int cell_draw( char *name,
180180
alpha = 0;
181181
}
182182

183-
if ( strcmp(format,"color") == 0 )
183+
if ( strcmp( format, "color" ) == 0 )
184184
{
185185
// We need data suitable for QImage 32-bpp
186186
// the data are stored in QImage as QRgb which is unsigned int.
@@ -198,28 +198,35 @@ static int cell_draw( char *name,
198198
}
199199
else
200200
{
201-
int *val;
202-
val = (int*) (ptr);
203-
//G_debug ( 0, "val = %d", *val );
204-
if ( data_type == CELL_TYPE) {
205-
//G_debug ( 0, "valx = %d", *((CELL *) ptr));
201+
int *val;
202+
val = ( int* )( ptr );
203+
//G_debug ( 0, "val = %d", *val );
204+
if ( data_type == CELL_TYPE )
205+
{
206+
//G_debug ( 0, "valx = %d", *((CELL *) ptr));
207+
}
208+
if ( G_is_null_value( ptr, data_type ) )
209+
{
210+
if ( data_type == CELL_TYPE )
211+
{
212+
int nul = -2147483647;
213+
fwrite( &nul , 4, 1, fo );
206214
}
207-
if ( G_is_null_value(ptr, data_type) ) {
208-
if ( data_type == CELL_TYPE) {
209-
int nul = -2147483647;
210-
fwrite( &nul , 4, 1, fo );
211-
} else if ( data_type == DCELL_TYPE) {
212-
double nul = 2.2250738585072014e-308;
213-
fwrite( &nul , 8, 1, fo );
214-
} else if ( data_type == FCELL_TYPE) {
215-
double nul = 1.17549435e-38F;
216-
fwrite( &nul , 4, 1, fo );
217-
}
215+
else if ( data_type == DCELL_TYPE )
216+
{
217+
double nul = 2.2250738585072014e-308;
218+
fwrite( &nul , 8, 1, fo );
218219
}
219-
else
220+
else if ( data_type == FCELL_TYPE )
220221
{
221-
fwrite( ptr, raster_size, 1, fo );
222+
double nul = 1.17549435e-38F;
223+
fwrite( &nul , 4, 1, fo );
222224
}
225+
}
226+
else
227+
{
228+
fwrite( ptr, raster_size, 1, fo );
229+
}
223230
}
224231
ptr = G_incr_void_ptr( ptr, raster_size );
225232
}

‎src/providers/grass/qgis.g.info.c

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -95,44 +95,45 @@ int main( int argc, char **argv )
9595
// raster informations
9696
else if ( strcmp( "info", info_opt->answer ) == 0 )
9797
{
98-
struct FPRange range;
99-
double zmin, zmax;
98+
struct FPRange range;
99+
double zmin, zmax;
100100

101-
// Data type
102-
RASTER_MAP_TYPE raster_type = G_raster_map_type ( rast_opt->answer, "" );
103-
fprintf( stdout, "TYPE:%d\n", raster_type );
101+
// Data type
102+
RASTER_MAP_TYPE raster_type = G_raster_map_type( rast_opt->answer, "" );
103+
fprintf( stdout, "TYPE:%d\n", raster_type );
104104

105-
// Statistics
106-
if (G_read_fp_range( rast_opt->answer, "", &range) < 0) {
107-
G_fatal_error(("Unable to read range file"));
108-
}
109-
G_get_fp_range_min_max(&range, &zmin, &zmax);
110-
fprintf( stdout, "MIN_VALUE:%f\n", zmin );
111-
fprintf( stdout, "MAX_VALUE:%f\n", zmax );
105+
// Statistics
106+
if ( G_read_fp_range( rast_opt->answer, "", &range ) < 0 )
107+
{
108+
G_fatal_error(( "Unable to read range file" ) );
109+
}
110+
G_get_fp_range_min_max( &range, &zmin, &zmax );
111+
fprintf( stdout, "MIN_VALUE:%f\n", zmin );
112+
fprintf( stdout, "MAX_VALUE:%f\n", zmax );
112113
}
113114
else if ( strcmp( "colors", info_opt->answer ) == 0 )
114115
{
115-
// Color table
116-
struct Colors colors;
117-
int i, ccount;
118-
if( G_read_colors( rast_opt->answer, "", &colors ) == 1 )
116+
// Color table
117+
struct Colors colors;
118+
int i, ccount;
119+
if ( G_read_colors( rast_opt->answer, "", &colors ) == 1 )
120+
{
121+
//int maxcolor;
122+
//CELL min, max;
123+
124+
//G_get_color_range ( &min, &max, &colors);
125+
ccount = G_colors_count( &colors );
126+
for ( i = ccount - 1; i >= 0; i-- )
119127
{
120-
//int maxcolor;
121-
//CELL min, max;
122-
123-
//G_get_color_range ( &min, &max, &colors);
124-
ccount = G_colors_count ( &colors );
125-
for( i = ccount-1; i >= 0; i-- )
126-
{
127-
DCELL val1, val2;
128-
unsigned char r1, g1, b1, r2, g2, b2;
128+
DCELL val1, val2;
129+
unsigned char r1, g1, b1, r2, g2, b2;
129130

130-
G_get_f_color_rule ( &val1, &r1, &g1, &b1, &val2, &r2, &g2, &b2, &colors, i );
131-
fprintf ( stdout, "%e %e %d %d %d %d %d %d\n", val1, val2, r1, g1, b1, r2, g2, b2 );
132-
}
133-
}
131+
G_get_f_color_rule( &val1, &r1, &g1, &b1, &val2, &r2, &g2, &b2, &colors, i );
132+
fprintf( stdout, "%e %e %d %d %d %d %d %d\n", val1, val2, r1, g1, b1, r2, g2, b2 );
133+
}
134+
}
134135
}
135-
136+
136137
else if ( strcmp( "query", info_opt->answer ) == 0 )
137138
{
138139
double x, y;

‎src/providers/grass/qgsgrass.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ void GRASS_EXPORT QgsGrass::size( QString gisdbase, QString location, QString ma
11941194
QMessageBox::warning( 0, QObject::tr( "Warning" ),
11951195
QObject::tr( "Cannot get raster extent" ) + "\n" + e.what() );
11961196
}
1197-
1197+
11981198
QgsDebugMsg( QString( "raster size = %1 %2" ).arg( *cols ).arg( *rows ) );
11991199
}
12001200

@@ -1208,8 +1208,9 @@ QHash<QString, QString> GRASS_EXPORT QgsGrass::info( QString gisdbase, QString l
12081208
QString str = QgsGrass::getInfo( "info", gisdbase, location, mapset, map, type );
12091209
QgsDebugMsg( str );
12101210
QStringList list = str.split( "\n" );
1211-
for ( int i = 0; i < list.size(); i++ ) {
1212-
QStringList keyVal = list[i].split(':');
1211+
for ( int i = 0; i < list.size(); i++ )
1212+
{
1213+
QStringList keyVal = list[i].split( ':' );
12131214
if ( list[i].isEmpty() ) { continue; }
12141215
if ( keyVal.size() != 2 )
12151216
{
@@ -1223,7 +1224,7 @@ QHash<QString, QString> GRASS_EXPORT QgsGrass::info( QString gisdbase, QString l
12231224
QMessageBox::warning( 0, QObject::tr( "Warning" ),
12241225
QObject::tr( "Cannot get map info" ) + "\n" + e.what() );
12251226
}
1226-
return inf;
1227+
return inf;
12271228
}
12281229

12291230
QList<QgsGrass::Color> GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString location, QString mapset, QString map )
@@ -1236,24 +1237,23 @@ QList<QgsGrass::Color> GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString
12361237
QString str = QgsGrass::getInfo( "colors", gisdbase, location, mapset, map, QgsGrass::Raster );
12371238
QgsDebugMsg( str );
12381239
QStringList list = str.split( "\n" );
1239-
for ( int i = 0; i < list.size(); i++ ) {
1240-
double v1, v2;
1241-
int r1, r2, g1, g2, b1, b2;
1240+
for ( int i = 0; i < list.size(); i++ )
1241+
{
12421242
QgsGrass::Color c;
12431243
if ( list[i].isEmpty() ) { continue; }
1244-
if ( sscanf( list[i].toUtf8().data(), "%lf %lf %d %d %d %d %d %d", &(c.value1), &(c.value2), &(c.red1), &(c.green1), &(c.blue1), &(c.red2), &(c.green2), &(c.blue2) ) != 8 )
1244+
if ( sscanf( list[i].toUtf8().data(), "%lf %lf %d %d %d %d %d %d", &( c.value1 ), &( c.value2 ), &( c.red1 ), &( c.green1 ), &( c.blue1 ), &( c.red2 ), &( c.green2 ), &( c.blue2 ) ) != 8 )
12451245
{
12461246
throw QgsGrass::Exception( "Cannot parse GRASS colors" + list[i] + " (" + str + " ) " );
12471247
}
1248-
ct.append( c);
1248+
ct.append( c );
12491249
}
12501250
}
12511251
catch ( QgsGrass::Exception &e )
12521252
{
12531253
QMessageBox::warning( 0, QObject::tr( "Warning" ),
12541254
QObject::tr( "Cannot get colors" ) + "\n" + e.what() );
12551255
}
1256-
return ct;
1256+
return ct;
12571257
}
12581258

12591259
QMap<QString, QString> GRASS_EXPORT QgsGrass::query( QString gisdbase, QString location, QString mapset, QString map, MapType type, double x, double y )

‎src/providers/grass/qgsgrass.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class QgsGrass
5252
Exception( const QString &msg ) : std::runtime_error( msg.toUtf8().constData() ) {}
5353
};
5454

55-
struct Color {
55+
struct Color
56+
{
5657
double value1, value2;
5758
int red1, red2, green1, green2, blue1, blue2;
5859
};
@@ -196,7 +197,7 @@ class QgsGrass
196197

197198
// ! Get raster map size
198199
static GRASS_EXPORT void size( QString gisdbase, QString location,
199-
QString mapset, QString map, int *cols, int *rows );
200+
QString mapset, QString map, int *cols, int *rows );
200201

201202
// ! Get raster info
202203
static GRASS_EXPORT QHash<QString, QString> info( QString gisdbase, QString location,

‎src/providers/grass/qgsgrassrasterprovider.cpp

Lines changed: 79 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
7676
QgsDebugMsg( QString( "mapset: %1" ).arg( mMapset ) );
7777
QgsDebugMsg( QString( "mapName: %1" ).arg( mMapName ) );
7878

79-
mValidNoDataValue = true;
79+
mValidNoDataValue = true;
8080

8181
mCrs = QgsGrass::crs( mGisdbase, mLocation );
8282

@@ -91,15 +91,15 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
9191

9292
// TODO: refresh mRows and mCols if raster was rewritten
9393
// We have to decide some reasonable block size, not to big to occupate too much
94-
// memory, not too small to result in too many calls to readBlock -> qgis.d.rast
94+
// memory, not too small to result in too many calls to readBlock -> qgis.d.rast
9595
// for statistics
9696
int cache_size = 10000000; // ~ 10 MB
97-
mYBlockSize = cache_size / (dataTypeSize(dataType ( 1 ) )/8) / mCols;
98-
if ( mYBlockSize > mRows )
97+
mYBlockSize = cache_size / ( dataTypeSize( dataType( 1 ) ) / 8 ) / mCols;
98+
if ( mYBlockSize > mRows )
9999
{
100100
mYBlockSize = mRows;
101101
}
102-
QgsDebugMsg( "mYBlockSize = " + QString::number ( mYBlockSize ) );
102+
QgsDebugMsg( "mYBlockSize = " + QString::number( mYBlockSize ) );
103103
}
104104

105105
QgsGrassRasterProvider::~QgsGrassRasterProvider()
@@ -153,7 +153,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void
153153
{
154154
QgsDebugMsg( "Entered" );
155155
// TODO: optimize, see extent()
156-
156+
157157
QgsDebugMsg( "yBlock = " + QString::number( yBlock ) );
158158

159159
QStringList arguments;
@@ -167,13 +167,13 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void
167167
double yMaximum = ext.yMaximum() - cellHeight * yBlock * mYBlockSize;
168168
double yMinimum = yMaximum - cellHeight * mYBlockSize;
169169

170-
QgsDebugMsg( "mYBlockSize = " + QString::number ( mYBlockSize ) );
170+
QgsDebugMsg( "mYBlockSize = " + QString::number( mYBlockSize ) );
171171
arguments.append(( QString( "window=%1,%2,%3,%4,%5,%6" )
172172
.arg( ext.xMinimum() ).arg( yMinimum )
173173
.arg( ext.xMaximum() ).arg( yMaximum )
174-
.arg( mCols ).arg( mYBlockSize ) ) );
174+
.arg( mCols ).arg( mYBlockSize ) ) );
175175

176-
arguments.append( "format=value");
176+
arguments.append( "format=value" );
177177
QProcess process( this );
178178
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
179179
QByteArray data;
@@ -191,13 +191,14 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void
191191
QgsDebugMsg( QString( "%1 bytes read from modules stdout" ).arg( data.size() ) );
192192
// byteCount() in Qt >= 4.6
193193
//int size = image->byteCount() < data.size() ? image->byteCount() : data.size();
194-
int size = mCols * mYBlockSize * dataTypeSize(bandNo) / 8;
195-
QgsDebugMsg ( QString ( "mCols = %1 mYBlockSize = %2 dataTypeSize = %3" ).arg ( mCols ).arg ( mYBlockSize ).arg ( dataTypeSize(bandNo) ) );
196-
if ( size != data.size() ) {
197-
QMessageBox::warning( 0, QObject::tr( "Warning" ),
198-
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg(size).arg(data.size() ) );
194+
int size = mCols * mYBlockSize * dataTypeSize( bandNo ) / 8;
195+
QgsDebugMsg( QString( "mCols = %1 mYBlockSize = %2 dataTypeSize = %3" ).arg( mCols ).arg( mYBlockSize ).arg( dataTypeSize( bandNo ) ) );
196+
if ( size != data.size() )
197+
{
198+
QMessageBox::warning( 0, QObject::tr( "Warning" ),
199+
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg( size ).arg( data.size() ) );
199200
size = size < data.size() ? size : data.size();
200-
}
201+
}
201202
memcpy( block, data.data(), size );
202203
}
203204

@@ -215,7 +216,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx
215216
.arg( viewExtent.xMinimum() ).arg( viewExtent.yMinimum() )
216217
.arg( viewExtent.xMaximum() ).arg( viewExtent.yMaximum() )
217218
.arg( pixelWidth ).arg( pixelHeight ) ) );
218-
arguments.append( "format=value");
219+
arguments.append( "format=value" );
219220
QProcess process( this );
220221
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
221222
QByteArray data;
@@ -234,61 +235,72 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx
234235
QgsDebugMsg( QString( "%1 bytes read from modules stdout" ).arg( data.size() ) );
235236
// byteCount() in Qt >= 4.6
236237
//int size = image->byteCount() < data.size() ? image->byteCount() : data.size();
237-
int size = pixelWidth * pixelHeight * dataTypeSize(bandNo) / 8;
238-
if ( size != data.size() ) {
239-
QMessageBox::warning( 0, QObject::tr( "Warning" ),
240-
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg(size).arg(data.size() ) );
238+
int size = pixelWidth * pixelHeight * dataTypeSize( bandNo ) / 8;
239+
if ( size != data.size() )
240+
{
241+
QMessageBox::warning( 0, QObject::tr( "Warning" ),
242+
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg( size ).arg( data.size() ) );
241243
size = size < data.size() ? size : data.size();
242-
}
244+
}
243245
memcpy( block, data.data(), size );
244246
}
245247

246-
double QgsGrassRasterProvider::noDataValue() const {
248+
double QgsGrassRasterProvider::noDataValue() const
249+
{
247250
double nul;
248-
if ( mGrassDataType == CELL_TYPE ) {
251+
if ( mGrassDataType == CELL_TYPE )
252+
{
249253
nul = -2147483647;
250-
} else if ( mGrassDataType == DCELL_TYPE ) {
254+
}
255+
else if ( mGrassDataType == DCELL_TYPE )
256+
{
251257
nul = 2.2250738585072014e-308;
252-
} else if ( mGrassDataType == FCELL_TYPE ) {
258+
}
259+
else if ( mGrassDataType == FCELL_TYPE )
260+
{
253261
nul = 1.17549435e-38F;
254262
}
255263
QgsDebugMsg( QString( "noDataValue = %1" ).arg( nul ) );
256264
return nul;
257265
}
258266

259-
double QgsGrassRasterProvider::minimumValue( int bandNo ) const {
267+
double QgsGrassRasterProvider::minimumValue( int bandNo ) const
268+
{
260269
return mInfo["MIN_VALUE"].toDouble();
261270
}
262-
double QgsGrassRasterProvider::maximumValue( int bandNo ) const {
271+
double QgsGrassRasterProvider::maximumValue( int bandNo ) const
272+
{
263273
return mInfo["MAX_VALUE"].toDouble();
264274
}
265275

266-
QList<QgsColorRampShader::ColorRampItem> QgsGrassRasterProvider::colorTable(int bandNo)const {
276+
QList<QgsColorRampShader::ColorRampItem> QgsGrassRasterProvider::colorTable( int bandNo )const
277+
{
267278
QList<QgsColorRampShader::ColorRampItem> ct;
268-
279+
269280
// TODO: check if color can be realy discontinuous in GRASS,
270281
// for now we just believe that they are continuous, i.e. end and beginning
271282
// of the ramp with the same value has the same color
272283
// we are also expecting ordered CT records in the list
273284
QList<QgsGrass::Color> colors = QgsGrass::colors( mGisdbase, mLocation, mMapset, mMapName );
274285
QList<QgsGrass::Color>::iterator i;
275-
286+
276287
double v, r, g, b;
277-
for (i = colors.begin(); i != colors.end(); ++i)
288+
for ( i = colors.begin(); i != colors.end(); ++i )
278289
{
279-
if ( ct.count() == 0 || i->value1 != v || i->red1 != r || i->green1 != g || i->blue1 != b ) {
290+
if ( ct.count() == 0 || i->value1 != v || i->red1 != r || i->green1 != g || i->blue1 != b )
291+
{
280292
// not added in previous rule
281293
QgsColorRampShader::ColorRampItem ctItem1;
282294
ctItem1.value = i->value1;
283-
ctItem1.color = QColor::fromRgb( i->red1, i->green1, i->blue1);
284-
ct.append(ctItem1);
285-
QgsDebugMsg( QString("color %1 %2 %3 %4").arg(i->value1).arg(i->red1).arg(i->green1).arg(i->blue1) );
295+
ctItem1.color = QColor::fromRgb( i->red1, i->green1, i->blue1 );
296+
ct.append( ctItem1 );
297+
QgsDebugMsg( QString( "color %1 %2 %3 %4" ).arg( i->value1 ).arg( i->red1 ).arg( i->green1 ).arg( i->blue1 ) );
286298
}
287299
QgsColorRampShader::ColorRampItem ctItem2;
288300
ctItem2.value = i->value2;
289-
ctItem2.color = QColor::fromRgb( i->red2, i->green2, i->blue2);
290-
ct.append(ctItem2);
291-
QgsDebugMsg( QString("color %1 %2 %3 %4").arg(i->value2).arg(i->red2).arg(i->green2).arg(i->blue2) );
301+
ctItem2.color = QColor::fromRgb( i->red2, i->green2, i->blue2 );
302+
ct.append( ctItem2 );
303+
QgsDebugMsg( QString( "color %1 %2 %3 %4" ).arg( i->value2 ).arg( i->red2 ).arg( i->green2 ).arg( i->blue2 ) );
292304

293305
v = i->value2; r = i->red2; g = i->green2; b = i->blue2;
294306
}
@@ -311,14 +323,15 @@ QgsRectangle QgsGrassRasterProvider::extent()
311323
}
312324

313325
// this is only called once when statistics are calculated
314-
int QgsGrassRasterProvider::xBlockSize() const { return mCols; }
315-
int QgsGrassRasterProvider::yBlockSize() const {
316-
return mYBlockSize;
326+
int QgsGrassRasterProvider::xBlockSize() const { return mCols; }
327+
int QgsGrassRasterProvider::yBlockSize() const
328+
{
329+
return mYBlockSize;
317330
}
318331

319332
// TODO this should be always refreshed if raster has changed ?
320333
// maybe also only for stats
321-
int QgsGrassRasterProvider::xSize() const { return mCols; }
334+
int QgsGrassRasterProvider::xSize() const { return mCols; }
322335
int QgsGrassRasterProvider::ySize() const { return mRows; }
323336

324337
bool QgsGrassRasterProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>& theResults )
@@ -331,10 +344,10 @@ bool QgsGrassRasterProvider::identify( const QgsPoint& thePoint, QMap<QString, Q
331344

332345
int QgsGrassRasterProvider::capabilities() const
333346
{
334-
int capability = QgsRasterDataProvider::Identify
335-
| QgsRasterDataProvider::ExactResolution
336-
| QgsRasterDataProvider::ExactMinimumMaximum
337-
| QgsRasterDataProvider::Size;
347+
int capability = QgsRasterDataProvider::Identify
348+
| QgsRasterDataProvider::ExactResolution
349+
| QgsRasterDataProvider::ExactMinimumMaximum
350+
| QgsRasterDataProvider::Size;
338351
return capability;
339352
}
340353

@@ -345,7 +358,8 @@ int QgsGrassRasterProvider::dataType( int bandNo ) const
345358

346359
int QgsGrassRasterProvider::srcDataType( int bandNo ) const
347360
{
348-
switch ( mGrassDataType ) {
361+
switch ( mGrassDataType )
362+
{
349363
case CELL_TYPE:
350364
return QgsRasterDataProvider::Int32;
351365
break;
@@ -365,10 +379,12 @@ int QgsGrassRasterProvider::bandCount() const
365379
return 1;
366380
}
367381

368-
int QgsGrassRasterProvider::colorInterpretation ( int bandNo ) const {
382+
int QgsGrassRasterProvider::colorInterpretation( int bandNo ) const
383+
{
369384
// TODO: avoid loading color table here or cache it
370-
QList<QgsColorRampShader::ColorRampItem> ct = colorTable(bandNo);
371-
if ( ct.size() > 0 ) {
385+
QList<QgsColorRampShader::ColorRampItem> ct = colorTable( bandNo );
386+
if ( ct.size() > 0 )
387+
{
372388
return QgsRasterDataProvider::PaletteIndex;
373389
}
374390
return QgsRasterDataProvider::GrayIndex;
@@ -378,27 +394,27 @@ QString QgsGrassRasterProvider::metadata()
378394
{
379395
QString myMetadata ;
380396
QStringList myList;
381-
myList.append ( "GISDBASE: " + mGisdbase );
382-
myList.append ( "LOCATION: " + mLocation );
383-
myList.append ( "MAPSET: " + mMapset );
384-
myList.append ( "MAP: " + mMapName );
397+
myList.append( "GISDBASE: " + mGisdbase );
398+
myList.append( "LOCATION: " + mLocation );
399+
myList.append( "MAPSET: " + mMapset );
400+
myList.append( "MAP: " + mMapName );
385401

386402
QHash<QString, QString>::iterator i;
387-
for (i = mInfo.begin(); i != mInfo.end(); ++i)
403+
for ( i = mInfo.begin(); i != mInfo.end(); ++i )
388404
{
389-
myList.append ( i.key() + " : " + i.value() );
405+
myList.append( i.key() + " : " + i.value() );
390406
}
391407
myMetadata += QgsRasterDataProvider::makeTableCells( myList );
392-
408+
393409

394410
return myMetadata;
395411
}
396412

397413
void QgsGrassRasterProvider::populateHistogram( int theBandNoInt,
398-
QgsRasterBandStats & theBandStats,
399-
int theBinCount,
400-
bool theIgnoreOutOfRangeFlag,
401-
bool theHistogramEstimatedFlag)
414+
QgsRasterBandStats & theBandStats,
415+
int theBinCount,
416+
bool theIgnoreOutOfRangeFlag,
417+
bool theHistogramEstimatedFlag )
402418
{
403419
// TODO: we could either implement it in QgsRasterDataProvider::populateHistogram
404420
// or use r.stats (see d.histogram)
@@ -414,8 +430,8 @@ void QgsGrassRasterProvider::populateHistogram( int theBandNoInt,
414430
theBandStats.histogramVector->push_back( 0 );
415431
}
416432
}
417-
QgsDebugMsg( ">>>>> Histogram vector now contains " +
418-
QString::number( theBandStats.histogramVector->size() ) + " elements" );
433+
QgsDebugMsg( ">>>>> Histogram vector now contains " +
434+
QString::number( theBandStats.histogramVector->size() ) + " elements" );
419435

420436
}
421437

‎src/providers/grass/qgsgrassrasterprovider.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
177177
*/
178178
int capabilities() const;
179179

180-
int dataType ( int bandNo ) const;
181-
int srcDataType ( int bandNo ) const;
180+
int dataType( int bandNo ) const;
181+
int srcDataType( int bandNo ) const;
182182

183183
int bandCount() const;
184184

185-
int colorInterpretation ( int bandNo ) const;
185+
int colorInterpretation( int bandNo ) const;
186186

187187
int xBlockSize() const;
188188
int yBlockSize() const;
@@ -195,18 +195,18 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
195195
void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );
196196

197197
double noDataValue() const;
198-
double minimumValue(int bandNo)const;
199-
double maximumValue(int bandNo)const;
198+
double minimumValue( int bandNo )const;
199+
double maximumValue( int bandNo )const;
200200

201-
QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const;
201+
QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const;
202202

203-
// void buildSupportedRasterFileFilter( QString & theFileFiltersString );
203+
// void buildSupportedRasterFileFilter( QString & theFileFiltersString );
204204

205205
/**
206206
* Get metadata in a format suitable for feeding directly
207207
* into a subset of the GUI raster properties "Metadata" tab.
208208
*/
209-
QString metadata();
209+
QString metadata();
210210

211211
// Following methods specific for WMS are not used at all in this provider and should be removed IMO from qgsdataprovider.h
212212
void addLayers( QStringList const & layers, QStringList const & styles = QStringList() ) {}
@@ -216,11 +216,11 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
216216
void setImageCrs( QString const & crs ) {}
217217

218218
void populateHistogram( int theBandNoInt,
219-
QgsRasterBandStats & theBandStats,
220-
int theBinCountInt = 256,
221-
bool theIgnoreOutOfRangeFlag = true,
222-
bool theThoroughBandScanFlag = false
223-
);
219+
QgsRasterBandStats & theBandStats,
220+
int theBinCountInt = 256,
221+
bool theIgnoreOutOfRangeFlag = true,
222+
bool theThoroughBandScanFlag = false
223+
);
224224

225225

226226
private:

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,14 +693,16 @@ void QgsWmsProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, in
693693
// TODO: optimize to avoid writing to QImage
694694
QImage* image = draw( viewExtent, pixelWidth, pixelHeight );
695695

696-
if ( ! image ) { // should not happen
696+
if ( ! image ) // should not happen
697+
{
697698
QgsDebugMsg( "image is NULL" );
698699
return;
699700
}
700-
QgsDebugMsg( QString("image height = %1 bytesPerLine = %2").arg(image->height() ) . arg ( image->bytesPerLine() ) ) ;
701+
QgsDebugMsg( QString( "image height = %1 bytesPerLine = %2" ).arg( image->height() ) . arg( image->bytesPerLine() ) ) ;
701702
int myExpectedSize = pixelWidth * pixelHeight * 4;
702703
int myImageSize = image->height() * image->bytesPerLine();
703-
if ( myExpectedSize != myImageSize ) { // should not happen
704+
if ( myExpectedSize != myImageSize ) // should not happen
705+
{
704706
QgsDebugMsg( "unexpected image size" );
705707
return;
706708
}
@@ -1009,7 +1011,7 @@ int QgsWmsProvider::srcDataType( int bandNo ) const
10091011
int QgsWmsProvider::bandCount() const
10101012
{
10111013
return 1;
1012-
}
1014+
}
10131015

10141016
void QgsWmsProvider::capabilitiesReplyProgress( qint64 bytesReceived, qint64 bytesTotal )
10151017
{

‎src/providers/wms/qgswmsprovider.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,10 @@ class QgsWmsProvider : public QgsRasterDataProvider
529529
*/
530530
int capabilities() const;
531531

532-
int dataType ( int bandNo ) const;
533-
int srcDataType ( int bandNo ) const;
532+
int dataType( int bandNo ) const;
533+
int srcDataType( int bandNo ) const;
534534
int bandCount() const;
535-
535+
536536

537537
/**
538538
* Get metadata in a format suitable for feeding directly

0 commit comments

Comments
 (0)
Please sign in to comment.