Skip to content

Commit 30e2f32

Browse files
committed
indentation update
1 parent 289e5a6 commit 30e2f32

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

src/core/qgsapplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QStri
7373
}
7474
void QgsApplication::init( QString customConfigPath )
7575
{
76-
if( customConfigPath.isEmpty() )
76+
if ( customConfigPath.isEmpty() )
7777
{
7878
customConfigPath = QDir::homePath() + QString( "/.qgis/" );
7979
}

src/plugins/heatmap/heatmap.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,21 @@ void Heatmap::createRaster( QgsVectorLayer* theVectorLayer, int theBuffer, float
126126

127127
GDALDataset *emptyDataset;
128128
GDALDriver *myDriver;
129-
129+
130130
myDriver = GetGDALDriverManager()->GetDriverByName( theOutputFormat.toUtf8() );
131-
if( myDriver == NULL )
131+
if ( myDriver == NULL )
132132
{
133-
QMessageBox::information( 0, tr("Error in GDAL Driver!"), tr("Cannot open the driver for the format specified") );
133+
QMessageBox::information( 0, tr( "Error in GDAL Driver!" ), tr( "Cannot open the driver for the format specified" ) );
134134
return;
135135
}
136136

137137
// bounding box info
138138
QgsRectangle myBBox = theVectorLayer->extent();
139139
// fixing a base width of 500 px/cells
140140
xSize = 500;
141-
xResolution = myBBox.width()/xSize;
141+
xResolution = myBBox.width() / xSize;
142142
yResolution = xResolution;
143-
ySize = myBBox.height()/yResolution;
143+
ySize = myBBox.height() / yResolution;
144144
// add extra extend to cover the corner points' heat region
145145
xSize = xSize + ( theBuffer * 2 ) + 10 ;
146146
ySize = ySize + ( theBuffer * 2 ) + 10 ;
@@ -155,7 +155,7 @@ void Heatmap::createRaster( QgsVectorLayer* theVectorLayer, int theBuffer, float
155155
emptyDataset->SetGeoTransform( geoTransform );
156156

157157
GDALRasterBand *poBand;
158-
poBand = emptyDataset->GetRasterBand(1);
158+
poBand = emptyDataset->GetRasterBand( 1 );
159159
poBand->SetNoDataValue( NO_DATA );
160160

161161
float* line = ( float * ) CPLMalloc( sizeof( float ) * xSize );
@@ -168,44 +168,44 @@ void Heatmap::createRaster( QgsVectorLayer* theVectorLayer, int theBuffer, float
168168

169169
CPLFree( line );
170170
//close the dataset
171-
GDALClose( (GDALDatasetH) emptyDataset );
171+
GDALClose(( GDALDatasetH ) emptyDataset );
172172

173173
// open the raster in GA_Update mode
174174
GDALDataset *heatmapDS;
175175
heatmapDS = ( GDALDataset * ) GDALOpen( theOutputFilename.toUtf8(), GA_Update );
176-
if( !heatmapDS )
176+
if ( !heatmapDS )
177177
{
178-
QMessageBox::information( 0, tr("Error in Updating Raster!"), tr("Couldnot open the created raster for updation. The Heatmap was not generated.") );
178+
QMessageBox::information( 0, tr( "Error in Updating Raster!" ), tr( "Couldnot open the created raster for updation. The Heatmap was not generated." ) );
179179
return;
180180
}
181181
poBand = heatmapDS->GetRasterBand( 1 );
182182
// Get the data buffer ready
183183
int blockSize = 2 * theBuffer + 1; // block SIDE would have been more appropriate
184184
// Open the vector features
185185
QgsVectorDataProvider* myVectorProvider = theVectorLayer->dataProvider();
186-
if( !myVectorProvider )
186+
if ( !myVectorProvider )
187187
{
188-
QMessageBox::information( 0, tr( "Error in Point Layer!"), tr("Couldnot identify the vector data provider.") );
188+
QMessageBox::information( 0, tr( "Error in Point Layer!" ), tr( "Couldnot identify the vector data provider." ) );
189189
return;
190190
}
191191
QgsAttributeList dummyList;
192192
myVectorProvider->select( dummyList );
193-
193+
194194
int totalFeatures = myVectorProvider->featureCount();
195195
int counter = 0;
196196

197197
QProgressDialog p( "Creating Heatmap ... ", "Abort", 0, totalFeatures );
198-
p.setWindowModality(Qt::WindowModal);
198+
p.setWindowModality( Qt::WindowModal );
199199

200200
QgsFeature myFeature;
201201

202-
while( myVectorProvider->nextFeature( myFeature ) )
202+
while ( myVectorProvider->nextFeature( myFeature ) )
203203
{
204204
counter += 1;
205205
p.setValue( counter );
206-
if( p.wasCanceled() )
206+
if ( p.wasCanceled() )
207207
{
208-
QMessageBox::information( 0, tr("Heatmap Generation Aborted!"), tr("QGIS will now load the partially-computed raster.") );
208+
QMessageBox::information( 0, tr( "Heatmap Generation Aborted!" ), tr( "QGIS will now load the partially-computed raster." ) );
209209
break;
210210
}
211211

@@ -215,46 +215,46 @@ void Heatmap::createRaster( QgsVectorLayer* theVectorLayer, int theBuffer, float
215215
QgsPoint myPoint;
216216
myPoint = myPointGeometry->asPoint();
217217
// avoiding any empty points or out of extent points
218-
if( ( myPoint.x() < rasterX ) || ( myPoint.y() < rasterY ) )
218+
if (( myPoint.x() < rasterX ) || ( myPoint.y() < rasterY ) )
219219
{
220220
continue;
221221
}
222-
// calculate the pixel position
222+
// calculate the pixel position
223223
unsigned int xPosition, yPosition;
224-
xPosition = (( myPoint.x() - rasterX )/ xResolution ) - theBuffer;
225-
yPosition = (( myPoint.y() - rasterY )/ yResolution ) - theBuffer;
224+
xPosition = (( myPoint.x() - rasterX ) / xResolution ) - theBuffer;
225+
yPosition = (( myPoint.y() - rasterY ) / yResolution ) - theBuffer;
226226

227227
// get the data
228228
float *dataBuffer = ( float * ) CPLMalloc( sizeof( float ) * blockSize * blockSize );
229229
poBand->RasterIO( GF_Read, xPosition, yPosition, blockSize, blockSize, dataBuffer, blockSize, blockSize, GDT_Float32, 0, 0 );
230230

231-
for( int xp = 0; xp <= theBuffer; xp += 1 )
231+
for ( int xp = 0; xp <= theBuffer; xp += 1 )
232232
{
233-
for( int yp = 0; yp <= theBuffer; yp += 1 )
233+
for ( int yp = 0; yp <= theBuffer; yp += 1 )
234234
{
235235
float distance = sqrt( pow( xp, 2 ) + pow( yp, 2 ) );
236-
float pixelValue = 1 - ( (1-theDecay) * distance / theBuffer );
236+
float pixelValue = 1 - (( 1 - theDecay ) * distance / theBuffer );
237237

238238
// clearing anamolies along the axes
239-
if( xp == 0 && yp == 0 )
239+
if ( xp == 0 && yp == 0 )
240240
{
241241
pixelValue /= 4;
242242
}
243-
else if( xp == 0 || yp == 0 )
243+
else if ( xp == 0 || yp == 0 )
244244
{
245245
pixelValue /= 2;
246246
}
247247

248-
if( distance <= theBuffer )
248+
if ( distance <= theBuffer )
249249
{
250250
int pos[4];
251251
pos[0] = ( theBuffer + xp ) * blockSize + ( theBuffer + yp );
252252
pos[1] = ( theBuffer + xp ) * blockSize + ( theBuffer - yp );
253253
pos[2] = ( theBuffer - xp ) * blockSize + ( theBuffer + yp );
254254
pos[3] = ( theBuffer - xp ) * blockSize + ( theBuffer - yp );
255-
for( int p = 0; p < 4; p += 1 )
255+
for ( int p = 0; p < 4; p += 1 )
256256
{
257-
if( dataBuffer[ pos[p] ] == NO_DATA )
257+
if ( dataBuffer[ pos[p] ] == NO_DATA )
258258
{
259259
dataBuffer[ pos[p] ] = 0;
260260
}
@@ -269,7 +269,7 @@ void Heatmap::createRaster( QgsVectorLayer* theVectorLayer, int theBuffer, float
269269
}
270270

271271
//Finally close the dataset
272-
GDALClose( (GDALDatasetH) heatmapDS );
272+
GDALClose(( GDALDatasetH ) heatmapDS );
273273

274274
// Open the file in QGIS window
275275
mQGisIface->addRasterLayer( theOutputFilename, QFileInfo( theOutputFilename ).baseName() );

src/plugins/heatmap/heatmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Heatmap: public QObject, public QgisPlugin
8181
//! the worker slot to create heatmap
8282
/*
8383
* Signal: createRaster
84-
* Params:
84+
* Params:
8585
* QgsVectorLayer* -> Input point layer
8686
* int -> Buffer distance
8787
* float -> Decay ratio

src/plugins/heatmap/heatmapgui.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
3737

3838
// Adding point layers to the mInputVectorCombo
3939
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
40-
QMapIterator<QString, QgsMapLayer*> layers(mapLayers);
40+
QMapIterator<QString, QgsMapLayer*> layers( mapLayers );
4141

42-
while( layers.hasNext() )
42+
while ( layers.hasNext() )
4343
{
4444
layers.next();
45-
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>(layers.value());
46-
if( ( vl ) && ( vl->geometryType() == QGis::Point ) )
45+
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( layers.value() );
46+
if (( vl ) && ( vl->geometryType() == QGis::Point ) )
4747
{
4848
mInputVectorCombo->addItem( vl->name(), QVariant( vl->id() ) );
4949
}
@@ -54,11 +54,11 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
5454
int myIndex = -1;
5555
GDALAllRegister();
5656
int nDrivers = GDALGetDriverCount();
57-
for( int i = 0; i < nDrivers; i +=1 )
57+
for ( int i = 0; i < nDrivers; i += 1 )
5858
{
5959
GDALDriver* nthDriver = GetGDALDriverManager()->GetDriver( i );
6060
char** driverMetadata = nthDriver->GetMetadata();
61-
if( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
61+
if ( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
6262
{
6363
++myIndex;
6464
QString myLongName = nthDriver->GetMetadataItem( GDAL_DMD_LONGNAME );
@@ -72,7 +72,7 @@ HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
7272
}
7373
}
7474
}
75-
mFormatCombo->setCurrentIndex(myTiffIndex);
75+
mFormatCombo->setCurrentIndex( myTiffIndex );
7676

7777
//finally set right the ok button
7878
enableOrDisableOkButton();
@@ -97,16 +97,16 @@ void HeatmapGui::on_mButtonBox_accepted()
9797
int myLayerId = mInputVectorCombo->itemData( mInputVectorCombo->currentIndex() ).toInt();
9898

9999
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
100-
QMapIterator<QString, QgsMapLayer*> layers(mapLayers);
101-
102-
while( layers.hasNext() )
100+
QMapIterator<QString, QgsMapLayer*> layers( mapLayers );
101+
102+
while ( layers.hasNext() )
103103
{
104104
layers.next();
105-
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>(layers.value());
105+
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( layers.value() );
106106
if ( vl )
107107
{
108108
dummyText = vl->id();
109-
if( dummyText.toInt() == myLayerId )
109+
if ( dummyText.toInt() == myLayerId )
110110
{
111111
inputLayer = vl;
112112
}
@@ -116,9 +116,9 @@ void HeatmapGui::on_mButtonBox_accepted()
116116
// The buffer distance
117117
dummyText = mBufferLineEdit->text();
118118
bufferDistance = dummyText.toInt();
119-
if( bufferDistance == NULL )
119+
if ( bufferDistance == NULL )
120120
{
121-
QMessageBox::information( 0, tr("Invalid Buffer Value!"), tr("Buffer distance cannot be NULL, kindly enter a valid value.") );
121+
QMessageBox::information( 0, tr( "Invalid Buffer Value!" ), tr( "Buffer distance cannot be NULL, kindly enter a valid value." ) );
122122
return;
123123
}
124124
// The decay ratio
@@ -128,9 +128,9 @@ void HeatmapGui::on_mButtonBox_accepted()
128128
// The output filename
129129
outputFileName = mOutputRasterLineEdit->text();
130130
QFileInfo myFileInfo( outputFileName );
131-
if( outputFileName.isEmpty() || !myFileInfo.dir().exists() )
131+
if ( outputFileName.isEmpty() || !myFileInfo.dir().exists() )
132132
{
133-
QMessageBox::information( 0, tr("Output filename is invalid!"), tr("Kindly enter a valid output file path and name.") );
133+
QMessageBox::information( 0, tr( "Output filename is invalid!" ), tr( "Kindly enter a valid output file path and name." ) );
134134
return;
135135
}
136136

@@ -139,16 +139,16 @@ void HeatmapGui::on_mButtonBox_accepted()
139139

140140
// append the file format if the suffix is empty
141141
QString suffix = myFileInfo.suffix();
142-
if( suffix.isEmpty() )
142+
if ( suffix.isEmpty() )
143143
{
144144
QMap<QString, QString>::const_iterator it = mExtensionMap.find( outputFormat );
145-
if( it != mExtensionMap.end() && it.key() == outputFormat )
145+
if ( it != mExtensionMap.end() && it.key() == outputFormat )
146146
{
147147
// making sure that there is really a extension value available
148148
// Some drivers donot seem to have any extension at all
149-
if( it.value() != NULL || it.value() != "" )
149+
if ( it.value() != NULL || it.value() != "" )
150150
{
151-
outputFileName.append(".");
151+
outputFileName.append( "." );
152152
outputFileName.append( it.value() );
153153
}
154154
}
@@ -174,13 +174,13 @@ void HeatmapGui::on_mBrowseButton_clicked()
174174
QSettings s;
175175
QString lastDir = s.value( "/Heatmap/lastOutputDir", "" ).toString();
176176

177-
QString outputFilename = QFileDialog::getSaveFileName( 0, tr( "Save Heatmap as: "), lastDir );
178-
if( !outputFilename.isEmpty() )
177+
QString outputFilename = QFileDialog::getSaveFileName( 0, tr( "Save Heatmap as: " ), lastDir );
178+
if ( !outputFilename.isEmpty() )
179179
{
180180
mOutputRasterLineEdit->setText( outputFilename );
181181
QFileInfo outputFileInfo( outputFilename );
182182
QDir outputDir = outputFileInfo.absoluteDir();
183-
if( outputDir.exists() )
183+
if ( outputDir.exists() )
184184
{
185185
s.setValue( "/Heatmap/lastOutputDir", outputFileInfo.absolutePath() );
186186
}
@@ -199,7 +199,7 @@ void HeatmapGui::enableOrDisableOkButton()
199199
bool enabled = true;
200200
QString filename = mOutputRasterLineEdit->text();
201201
QFileInfo theFileInfo( filename );
202-
if( filename.isEmpty() || !theFileInfo.dir().exists() || ( mInputVectorCombo->count() == 0 ) )
202+
if ( filename.isEmpty() || !theFileInfo.dir().exists() || ( mInputVectorCombo->count() == 0 ) )
203203
{
204204
enabled = false;
205205
}

src/plugins/heatmap/heatmapgui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
4040
signals:
4141
/*
4242
* Signal: createRaster
43-
* Params:
43+
* Params:
4444
* QgsVectorLayer* -> Input point layer
4545
* int -> Buffer distance
4646
* float -> Decay ratio

0 commit comments

Comments
 (0)