Skip to content

Commit 04d9165

Browse files
committedMar 13, 2013
Merge heatmap_fixes branch
2 parents 032c5f5 + 239479a commit 04d9165

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed
 

‎src/plugins/heatmap/heatmap.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ void Heatmap::run()
110110
QgsRectangle myBBox = d.bbox();
111111
int columns = d.columns();
112112
int rows = d.rows();
113-
float cellsize = d.cellSizeX(); // or d.cellSizeY(); both have the same value
114-
float myDecay = d.decayRatio();
113+
double cellsize = d.cellSizeX(); // or d.cellSizeY(); both have the same value
114+
double myDecay = d.decayRatio();
115115
int kernelShape = d.kernelShape();
116-
116+
117117
// Start working on the input vector
118118
QgsVectorLayer* inputLayer = d.inputVectorLayer();
119119

@@ -168,8 +168,8 @@ void Heatmap::run()
168168
int wField = 0;
169169

170170
// Handle different radius options
171-
float radius;
172-
float radiusToMapUnits = 1;
171+
double radius;
172+
double radiusToMapUnits = 1;
173173
int myBuffer;
174174
if ( d.variableRadius() )
175175
{
@@ -230,7 +230,7 @@ void Heatmap::run()
230230
// If radius is variable then fetch it and calculate new pixel buffer size
231231
if ( d.variableRadius() )
232232
{
233-
radius = myFeature.attribute( rField ).toFloat() * radiusToMapUnits;
233+
radius = myFeature.attribute( rField ).toDouble() * radiusToMapUnits;
234234
myBuffer = bufferSize( radius, cellsize );
235235
}
236236

@@ -245,25 +245,25 @@ void Heatmap::run()
245245
poBand->RasterIO( GF_Read, xPosition, yPosition, blockSize, blockSize,
246246
dataBuffer, blockSize, blockSize, GDT_Float32, 0, 0 );
247247

248-
float weight = 1.0;
248+
double weight = 1.0;
249249
if ( d.weighted() )
250250
{
251-
weight = myFeature.attribute( wField ).toFloat();
251+
weight = myFeature.attribute( wField ).toDouble();
252252
}
253253

254254
for ( int xp = 0; xp <= myBuffer; xp++ )
255255
{
256256
for ( int yp = 0; yp <= myBuffer; yp++ )
257257
{
258-
float distance = sqrt( pow( xp, 2.0 ) + pow( yp, 2.0 ) );
258+
double distance = sqrt( pow( xp, 2.0 ) + pow( yp, 2.0 ) );
259259

260260
// is pixel outside search bandwidth of feature?
261261
if ( distance > myBuffer )
262262
{
263263
continue;
264264
}
265265

266-
float pixelValue = weight * calculateKernelValue( distance, myBuffer, kernelShape );
266+
double pixelValue = weight * calculateKernelValue( distance, myBuffer, kernelShape );
267267

268268
// clearing anamolies along the axes
269269
if ( xp == 0 && yp == 0 )
@@ -308,8 +308,8 @@ void Heatmap::run()
308308
* Local functions
309309
*
310310
*/
311-
312-
float Heatmap::mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCrs )
311+
312+
double Heatmap::mapUnitsOf( double meters, QgsCoordinateReferenceSystem layerCrs )
313313
{
314314
// Worker to transform metres input to mapunits
315315
QgsDistanceArea da;
@@ -322,7 +322,7 @@ float Heatmap::mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCrs )
322322
return meters / da.measureLine( QgsPoint( 0.0, 0.0 ), QgsPoint( 0.0, 1.0 ) );
323323
}
324324

325-
int Heatmap::bufferSize( float radius, float cellsize )
325+
int Heatmap::bufferSize( double radius, double cellsize )
326326
{
327327
// Calculate the buffer size in pixels
328328

‎src/plugins/heatmap/heatmap.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ class Heatmap: public QObject, public QgisPlugin
8282

8383
private:
8484
//! Worker to convert meters to map units
85-
float mapUnitsOf( float meters, QgsCoordinateReferenceSystem crs );
85+
double mapUnitsOf( double meters, QgsCoordinateReferenceSystem layerCrs );
8686
//! Worker to calculate buffer size in pixels
87-
int bufferSize( float radius, float cellsize );
87+
int bufferSize( double radius, double cellsize );
8888
//! Calculate the value given to a point width a given distance for a specified kernel shape
8989
float calculateKernelValue( float distance, int bandwidth, int kernelShape );
9090
//! Uniform kernel function

‎src/plugins/heatmap/heatmapgui.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void HeatmapGui::on_columnLineEdit_editingFinished()
170170

171171
void HeatmapGui::on_cellXLineEdit_editingFinished()
172172
{
173-
mXcellsize = cellXLineEdit->text().toFloat();
173+
mXcellsize = cellXLineEdit->text().toDouble();
174174
mYcellsize = mXcellsize;
175175
mRows = mBBox.height() / mYcellsize + 1;
176176
mColumns = mBBox.width() / mXcellsize + 1;
@@ -180,7 +180,7 @@ void HeatmapGui::on_cellXLineEdit_editingFinished()
180180

181181
void HeatmapGui::on_cellYLineEdit_editingFinished()
182182
{
183-
mYcellsize = cellYLineEdit->text().toFloat();
183+
mYcellsize = cellYLineEdit->text().toDouble();
184184
mXcellsize = mYcellsize;
185185
mRows = mBBox.height() / mYcellsize + 1;
186186
mColumns = mBBox.width() / mXcellsize + 1;
@@ -281,10 +281,10 @@ void HeatmapGui::updateBBox()
281281
mBBox = inputLayer->extent();
282282
QgsCoordinateReferenceSystem layerCrs = inputLayer->crs();
283283

284-
float radiusInMapUnits = 0.0;
284+
double radiusInMapUnits = 0.0;
285285
if ( useRadius->isChecked() )
286286
{
287-
float maxInField = inputLayer->maximumValue( radiusFieldCombo->itemData( radiusFieldCombo->currentIndex() ).toInt() ).toFloat();
287+
double maxInField = inputLayer->maximumValue( radiusFieldCombo->itemData( radiusFieldCombo->currentIndex() ).toInt() ).toDouble();
288288

289289
if ( radiusFieldUnitCombo->currentIndex() == HeatmapGui::Meters )
290290
{
@@ -297,7 +297,7 @@ void HeatmapGui::updateBBox()
297297
}
298298
else
299299
{
300-
float radiusValue = mBufferLineEdit->text().toFloat();
300+
double radiusValue = mBufferLineEdit->text().toDouble();
301301
if ( mRadiusUnitCombo->currentIndex() == HeatmapGui::Meters )
302302
{
303303
radiusInMapUnits = mapUnitsOf( radiusValue, layerCrs );
@@ -325,7 +325,7 @@ void HeatmapGui::updateBBox()
325325
}
326326
}
327327

328-
float HeatmapGui::mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCrs )
328+
double HeatmapGui::mapUnitsOf( double meters, QgsCoordinateReferenceSystem layerCrs )
329329
{
330330
// converter function to transform metres input to mapunits
331331
// so that bounding box can be updated
@@ -356,9 +356,9 @@ bool HeatmapGui::variableRadius()
356356
return useRadius->isChecked();
357357
}
358358

359-
float HeatmapGui::radius()
359+
double HeatmapGui::radius()
360360
{
361-
float radius = mBufferLineEdit->text().toFloat();
361+
double radius = mBufferLineEdit->text().toDouble();
362362
if ( mRadiusUnitCombo->currentIndex() == HeatmapGui::Meters )
363363
{
364364
radius = mapUnitsOf( radius, inputVectorLayer()->crs() );
@@ -380,9 +380,9 @@ int HeatmapGui::kernelShape()
380380
return kernelShapeCombo->currentIndex();
381381
}
382382

383-
float HeatmapGui::decayRatio()
383+
double HeatmapGui::decayRatio()
384384
{
385-
return mDecayLineEdit->text().toFloat();
385+
return mDecayLineEdit->text().toDouble();
386386
}
387387

388388
int HeatmapGui::radiusField()

‎src/plugins/heatmap/heatmapgui.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
5050
bool variableRadius();
5151

5252
/** Returns the fixed radius value */
53-
float radius();
53+
double radius();
5454

5555
/** Return the radius Unit (meters/map units) */
5656
int radiusUnit();
@@ -59,7 +59,7 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
5959
int kernelShape();
6060

6161
/** Return the decay ratio */
62-
float decayRatio();
62+
double decayRatio();
6363

6464
/** Return the attribute field for variable radius */
6565
int radiusField();
@@ -83,10 +83,10 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
8383
int columns() { return mColumns; }
8484

8585
/** Returns the cell size X value */
86-
float cellSizeX() { return mXcellsize; }
86+
double cellSizeX() { return mXcellsize; }
8787

8888
/** Returns the cell size Y valuue */
89-
float cellSizeY() { return mYcellsize; }
89+
double cellSizeY() { return mYcellsize; }
9090

9191
/** Return the BBox */
9292
QgsRectangle bbox() { return mBBox; }
@@ -96,7 +96,7 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
9696

9797
// bbox of layer for lineedit changes
9898
QgsRectangle mBBox;
99-
float mXcellsize, mYcellsize;
99+
double mXcellsize, mYcellsize;
100100
int mRows, mColumns;
101101

102102
/** Function to check wether all constrains are satisfied and enable the OK button */
@@ -112,7 +112,7 @@ class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
112112
void updateSize();
113113

114114
/** Convert Maters value to the corresponding map units based on Layer projection */
115-
float mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCrs );
115+
double mapUnitsOf( double meters, QgsCoordinateReferenceSystem layerCrs );
116116

117117
private slots:
118118
void on_mButtonBox_accepted();

0 commit comments

Comments
 (0)
Please sign in to comment.