Skip to content

Commit

Permalink
Change float to double for calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 13, 2013
1 parent 04d9165 commit ec01afb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/plugins/heatmap/heatmap.cpp
Expand Up @@ -334,7 +334,7 @@ int Heatmap::bufferSize( double radius, double cellsize )
return buffer;
}

float Heatmap::calculateKernelValue( float distance, int bandwidth, int kernelShape )
double Heatmap::calculateKernelValue( double distance, int bandwidth, int kernelShape )
{
switch (kernelShape) {
case HeatmapGui::Triangular:
Expand All @@ -350,23 +350,23 @@ float Heatmap::calculateKernelValue( float distance, int bandwidth, int kernelSh

}

float Heatmap::uniformKernel( float distance, int bandwidth )
double Heatmap::uniformKernel( double distance, int bandwidth )
{
// Normalizing constant. Calculated by polar double integrating the kernel function
// with radius of 0 to bandwidth and equating area to 1.
float k = 2. / (M_PI * (float)bandwidth);
double k = 2. / (M_PI * (double)bandwidth);

// Derived from Wand and Jones (1995), p. 175
return k * ( 0.5 / (float)bandwidth);
return k * ( 0.5 / (double)bandwidth);
}

float Heatmap::quarticKernel( float distance, int bandwidth )
double Heatmap::quarticKernel( double distance, int bandwidth )
{
// Normalizing constant
float k = 16. / (5. * M_PI * pow((float)bandwidth, 2));
double k = 16. / (5. * M_PI * pow((double)bandwidth, 2));

// Derived from Wand and Jones (1995), p. 175
return k * (15. / 16. ) * pow( 1. - pow( distance / (float)bandwidth, 2), 2);
return k * (15. / 16. ) * pow( 1. - pow( distance / (double)bandwidth, 2), 2);
}

// Unload the plugin by cleaning up the GUI
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/heatmap/heatmap.h
Expand Up @@ -86,11 +86,11 @@ class Heatmap: public QObject, public QgisPlugin
//! Worker to calculate buffer size in pixels
int bufferSize( double radius, double cellsize );
//! Calculate the value given to a point width a given distance for a specified kernel shape
float calculateKernelValue( float distance, int bandwidth, int kernelShape );
double calculateKernelValue( double distance, int bandwidth, int kernelShape );
//! Uniform kernel function
float uniformKernel( float distance, int bandwidth );
double uniformKernel( double distance, int bandwidth );
//! Quartic kernel function
float quarticKernel( float distance, int bandwidth );
double quarticKernel( double distance, int bandwidth );


// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
Expand Down

0 comments on commit ec01afb

Please sign in to comment.