Skip to content

Commit 3b8cbc2

Browse files
committedMar 12, 2013
Convert radius to a float, not an integer. Fixes heatmaps created with a radius < 1.
1 parent 7942be9 commit 3b8cbc2

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed
 

‎src/plugins/heatmap/heatmap.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void Heatmap::run()
172172
rField = d.radiusField();
173173
myAttrList.append( rField );
174174
QgsDebugMsg( QString( "Radius Field index received: %1" ).arg( rField ) );
175-
175+
176176
// If not using map units, then calculate a conversion factor to convert the radii to map units
177177
if ( d.radiusUnit() == HeatmapGui::Meters )
178178
{
@@ -184,13 +184,13 @@ void Heatmap::run()
184184
radius = d.radius(); // radius returned by d.radius() is already in map units
185185
myBuffer = bufferSize( radius, cellsize );
186186
}
187-
187+
188188
if ( d.weighted() )
189189
{
190190
wField = d.weightField();
191191
myAttrList.append( wField );
192192
}
193-
193+
194194
// This might have attributes or mightnot have attibutes at all
195195
// based on the variableRadius() and weighted()
196196
QgsFeatureIterator fit = inputLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( myAttrList ) );
@@ -222,14 +222,14 @@ void Heatmap::run()
222222
{
223223
continue;
224224
}
225-
225+
226226
// If radius is variable then fetch it and calculate new pixel buffer size
227227
if ( d.variableRadius() )
228228
{
229229
radius = myFeature.attribute( rField ).toFloat() * radiusToMapUnits;
230230
myBuffer = bufferSize( radius, cellsize );
231231
}
232-
232+
233233
int blockSize = 2 * myBuffer + 1; //Block SIDE would be more appropriate
234234
// calculate the pixel position
235235
unsigned int xPosition, yPosition;
@@ -252,13 +252,13 @@ void Heatmap::run()
252252
for ( int yp = 0; yp <= myBuffer; yp++ )
253253
{
254254
float distance = sqrt( pow( xp, 2.0 ) + pow( yp, 2.0 ) );
255-
255+
256256
// is pixel outside search bandwidth of feature?
257257
if ( distance > myBuffer )
258258
{
259259
continue;
260260
}
261-
261+
262262
float pixelValue = weight * ( 1 - (( 1 - myDecay ) * distance / myBuffer ) );
263263

264264
// clearing anamolies along the axes
@@ -304,7 +304,7 @@ void Heatmap::run()
304304
* Local functions
305305
*
306306
*/
307-
307+
308308
float Heatmap::mapUnitsOf( float meters, QgsCoordinateReferenceSystem layerCrs )
309309
{
310310
// Worker to transform metres input to mapunits
@@ -328,8 +328,8 @@ int Heatmap::bufferSize( float radius, float cellsize )
328328
++buffer;
329329
}
330330
return buffer;
331-
}
332-
331+
}
332+
333333

334334
// Unload the plugin by cleaning up the GUI
335335
void Heatmap::unload()

‎src/plugins/heatmap/heatmapgui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool HeatmapGui::variableRadius()
358358

359359
float HeatmapGui::radius()
360360
{
361-
float radius = mBufferLineEdit->text().toInt();
361+
float radius = mBufferLineEdit->text().toFloat();
362362
if ( mRadiusUnitCombo->currentIndex() == HeatmapGui::Meters )
363363
{
364364
radius = mapUnitsOf( radius, inputVectorLayer()->crs() );

0 commit comments

Comments
 (0)
Please sign in to comment.