diff --git a/resources/context_help/HeatmapGui-en_US b/resources/context_help/HeatmapGui-en_US
new file mode 100644
index 000000000000..cafb23476032
--- /dev/null
+++ b/resources/context_help/HeatmapGui-en_US
@@ -0,0 +1,27 @@
+
Heatmap Plugin Help
+
Heatmap Plugin creates a heatmap raster for the input point vector layer. The heatmap is generated based on the number of points in a given location. The higher the number of points, the higher will be the corresponding pixel(s) value in the raster.
+
+
The Dialog Parameters
+
+
Input Point Vector
+
The input is always a vector layer of point type. All the point vector layers that are currently loaded in the window are automatically populated in the input layer drop-down list. Click the Dropdown button and select the required layer.
+
+
Output Ratser
+
The output raster location and filename can be set by clicking the button next to the output raster textbox.
+Note:The file format is automatically added depending upon the output format selected, if not explicitly given.
+
+
Output Format
+
All the file creation supporting GDAL formats are available in the drop down list. Click and select the required output format for your file.
+Note: GeoTiff and ERDAS Imagine .img formats are recommended. Some formats makes the application crash. Kindly stick to the recommended formats until the crash issue is resolved or Use other formats if you know about its GDAL support completely.
+
+
Heatmap Point Attributes
+
Buffer Radius
+
The buffer radius specifies the number of pixels or cells around a point where the heat(influence) of the point will be felt. Smaller values give you clear distinction between points and bigger values gives you nicely merged heatmap regions. This is the spatial parameter of the heat region of a point.
+Note: The value is always a whole number.
+
Decay Ratio
+
The decay ratio defines amount of heat(influence) that should reach the outermost pixel in the Buffer Radius. It is the direct measure of the outer most value.
+Example: If Buffer Ratio is set as 0 and Radius as 10, then the centre pixel of a point will have value and the pixel away by a distance of 10 units will have the value 0, a pixel which is 5 units away will have a value of 0.5 and so on. Here distance is measure not by pixel count rather using sqrt( xOffset^2 + yOffset^2 ), so you always get a circular heat region.
+
+
Further Details
+
Contact the author through aruntheguy at gmail dot com
+
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 96f9ffd88678..3f8762fb26cd 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -37,3 +37,5 @@ IF (WITH_GLOBE)
ENDIF (WITH_GLOBE)
# headers installed in qgis_core target
+
+SUBDIRS (heatmap)
diff --git a/src/plugins/heatmap/CMakeLists.txt b/src/plugins/heatmap/CMakeLists.txt
new file mode 100644
index 000000000000..94386389f7d6
--- /dev/null
+++ b/src/plugins/heatmap/CMakeLists.txt
@@ -0,0 +1,53 @@
+
+########################################################
+# Files
+
+SET (heatmap_SRCS
+ heatmap.cpp
+ heatmapgui.cpp
+)
+
+SET (heatmap_UIS heatmapguibase.ui)
+
+SET (heatmap_MOC_HDRS
+ heatmap.h
+ heatmapgui.h
+)
+
+SET (heatmap_RCCS heatmap.qrc)
+
+########################################################
+# Build
+
+QT4_WRAP_UI (heatmap_UIS_H ${heatmap_UIS})
+
+QT4_WRAP_CPP (heatmap_MOC_SRCS ${heatmap_MOC_HDRS})
+
+QT4_ADD_RESOURCES(heatmap_RCC_SRCS ${heatmap_RCCS})
+
+ADD_LIBRARY (heatmapplugin MODULE ${heatmap_SRCS} ${heatmap_MOC_SRCS} ${heatmap_RCC_SRCS} ${heatmap_UIS_H})
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${GEOS_INCLUDE_DIR}
+ ${GDAL_INCLUDE_DIR}
+ ../../core
+ ../../core/raster
+ ../../gui
+ ../../analysis/raster
+ ..
+)
+
+TARGET_LINK_LIBRARIES(heatmapplugin
+ qgis_core
+ qgis_gui
+)
+
+
+########################################################
+# Install
+
+INSTALL(TARGETS heatmapplugin
+ RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
+ LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})
+
diff --git a/src/plugins/heatmap/README b/src/plugins/heatmap/README
new file mode 100644
index 000000000000..1c03ea3ea8c8
--- /dev/null
+++ b/src/plugins/heatmap/README
@@ -0,0 +1,97 @@
+Welcome to your automatically generated plugin!
+-------------------------------------------------------------
+
+This is just a starting point. You now need to modify the code to make it do
+something useful....read on for a more information to get yourself started.
+
+Documentation:
+-------------------------------------------------------------
+
+You really need to read the QGIS API Documentation now at:
+
+http://qgis.org/api/
+
+In particular look at the following classes:
+
+QGisInterface : http://qgis.org/api/classQgisInterface.html
+QgsMapCanvas : http://qgis.org/api/classQgsMapCanvas.html
+QgsMapTool : http://qgis.org/api/classQgsMapTool.html
+QgisPlugin : http://qgis.org/api/classQgisPlugin.html
+
+QGisInterface is an abstract base class (ABC) that specifies what publicly
+available features of QGIS are exposed to third party code and plugins. An
+instance of the QgisInterface is passed to the plugin when it loads. Please
+consult the QGIS development team if there is functionality required in the
+QGisInterface that is not available.
+
+QgsPlugin is an ABC that defines required behaviour your plugin must provide.
+See below for more details.
+
+What are all the files in my generated plugin directory for?
+-------------------------------------------------------------
+
+CMakeLists.txt
+This is the generated CMake file that builds the plugin. You should add you
+application specific dependencies and source files to this file.
+
+heatmap.h
+heatmap.cpp
+This is the class that provides the 'glue' between your custom application
+logic and the QGIS application. You will see that a number of methods are
+already implemented for you - including some examples of how to add a raster or
+vector layer to the main application map canvas. This class is a concrete
+implementation of QgisPlugin (which defines required behaviour for a plugin).
+In particular, a plugin has a number of static methods and members so that the
+QgsPluginManager and plugin loader logic can identify each plugin, create an
+appropriate menu entry for it etc. Note there is nothing stopping you creating
+multiple toolbar icons and menu entries for a single plugin. By default though
+a single menu entry and toolbar button is created and its pre-configured to
+call the run() method in this class when selected. This default implementation
+provided for you by the plugin builder is well documented, so please refer to
+the code for further advice.
+
+heatmapgui.ui
+This is a Qt designer 'ui' file. It defines the look of the default plugin
+dialog without implementing any application logic. You can modify this form to
+suite your needs or completely remove it if your plugin does not need to
+display a user form (e.g. for custom MapTools).
+
+
+heatmapgui.cpp
+heatmapgui.h
+This is the concrete class where application logic for the above mentioned
+dialog should go. The world is your oyster here really....
+
+heatmap.qrc
+This is the Qt4 resources file for your plugin. The Makefile generated for your
+plugin is all set up to compile the resource file so all you need to do is add
+your additional icons etc using the simple xml file format. Note the namespace
+used for all your resources e.g. (":/Heatmap/"). It is important to use
+this prefix for all your resources. We suggest you include any other images and
+run time data in this resurce file too.
+
+heatmap.png
+This is the icon that will be used for your plugin menu entry and toolbar icon.
+Simply replace this icon with your own icon to make your plugin disctinctive
+from the rest.
+
+README
+This file contains the documentation you are reading now!
+
+
+Getting developer help:
+-------------------------------------------------------------
+
+For Questions and Comments regarding the plugin builder template and creating
+your features in QGIS using the plugin interface please contact us via:
+
+ * the QGIS developers mailing list, or
+ * IRC (#qgis on freenode.net)
+
+QGIS is distributed under the Gnu Public License. If you create a useful plugin
+please consider contributing it back to the community.
+
+Have fun and thank you for choosing QGIS.
+
+The QGIS Team
+2007
diff --git a/src/plugins/heatmap/heatmap.cpp b/src/plugins/heatmap/heatmap.cpp
new file mode 100644
index 000000000000..124cdae20181
--- /dev/null
+++ b/src/plugins/heatmap/heatmap.cpp
@@ -0,0 +1,339 @@
+/***************************************************************************
+ heatmap.cpp
+ Creates a Heatmap raster for the input point vector
+ -------------------
+ begin : January 2012
+ copyright : [(C) Arunmozhi]
+ email : [aruntheguy at gmail dot com]
+
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+// GDAL includes
+#include "gdal_priv.h"
+#include "cpl_string.h"
+#include "cpl_conv.h"
+
+// QGIS Specific includes
+#include
+#include
+
+#include "heatmap.h"
+#include "heatmapgui.h"
+
+#include "qgsgeometry.h"
+#include "qgsvectorlayer.h"
+#include "qgsvectordataprovider.h"
+
+// Qt4 Related Includes
+#include
+#include
+#include
+#include
+#include
+
+#define NO_DATA -9999
+
+
+static const QString sName = QObject::tr( "Heatmap" );
+static const QString sDescription = QObject::tr( "Creates a Heatmap raster for the input point vector" );
+static const QString sCategory = QObject::tr( "Raster" );
+static const QString sPluginVersion = QObject::tr( "Version 0.1" );
+static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
+static const QString sPluginIcon = ":/heatmap/heatmap.png";
+
+/**
+ * Constructor for the plugin. The plugin is passed a pointer
+ * an interface object that provides access to exposed functions in QGIS.
+ * @param theQGisInterface - Pointer to the QGIS interface object
+ */
+Heatmap::Heatmap( QgisInterface * theQgisInterface ):
+ QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ),
+ mQGisIface( theQgisInterface )
+{
+}
+
+Heatmap::~Heatmap()
+{
+
+}
+
+/*
+ * Initialize the GUI interface for the plugin - this is only called once when the plugin is
+ * added to the plugin registry in the QGIS application.
+ */
+void Heatmap::initGui()
+{
+
+ // Create the action for tool
+ mQActionPointer = new QAction( QIcon( ":/heatmap/heatmap.png" ), tr( "Heatmap" ), this );
+ // Set the what's this text
+ mQActionPointer->setWhatsThis( tr( "Creats a heatmap raster for the input point vector." ) );
+ // Connect the action to the run
+ connect( mQActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );
+ // Add the icon to the toolbar
+ mQGisIface->addToolBarIcon( mQActionPointer );
+ mQGisIface->addPluginToRasterMenu( tr( "&Heatmap" ), mQActionPointer );
+
+}
+//method defined in interface
+void Heatmap::help()
+{
+ //implement me!
+}
+
+// Slot called when the menu item is triggered
+// If you created more menu items / toolbar buttons in initiGui, you should
+// create a separate handler for each action - this single run() method will
+// not be enough
+void Heatmap::run()
+{
+ HeatmapGui *myPluginGui = new HeatmapGui( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
+ myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
+
+ // Connect the createRaster signal to createRaster Slot
+ connect( myPluginGui, SIGNAL( createRaster( QgsVectorLayer*, int, float, QString, QString ) ),
+ this, SLOT( createRaster( QgsVectorLayer*, int, float, QString, QString ) ) );
+
+ myPluginGui->show();
+}
+
+// Unload the plugin by cleaning up the GUI
+void Heatmap::unload()
+{
+ // remove the GUI
+ mQGisIface->removePluginMenu( "&Heatmap", mQActionPointer );
+ mQGisIface->removeToolBarIcon( mQActionPointer );
+ delete mQActionPointer;
+}
+
+// The worker
+void Heatmap::createRaster( QgsVectorLayer* theVectorLayer, int theBuffer, float theDecay, QString theOutputFilename, QString theOutputFormat )
+{
+ // generic variables
+ int xSize, ySize;
+ double xResolution, yResolution;
+ double rasterX, rasterY;
+
+ // Getting the rasterdataset in place
+ GDALAllRegister();
+
+ GDALDataset *emptyDataset;
+ GDALDriver *myDriver;
+
+ myDriver = GetGDALDriverManager()->GetDriverByName( theOutputFormat.toUtf8() );
+ if( myDriver == NULL )
+ {
+ QMessageBox::information( 0, tr("Error in GDAL Driver!"), tr("Cannot open the driver for the format specified") );
+ return;
+ }
+
+ // bounding box info
+ QgsRectangle myBBox = theVectorLayer->extent();
+ // fixing a base width of 500 px/cells
+ xSize = 500;
+ xResolution = myBBox.width()/xSize;
+ yResolution = xResolution;
+ ySize = myBBox.height()/yResolution;
+ // add extra extend to cover the corner points' heat region
+ xSize = xSize + ( theBuffer * 2 ) + 10 ;
+ ySize = ySize + ( theBuffer * 2 ) + 10 ;
+ // Define the new lat,lon for the buffered raster area
+ rasterX = myBBox.xMinimum() - ( theBuffer + 5 ) * xResolution;
+ rasterY = myBBox.yMinimum() - ( theBuffer + 5 ) * yResolution;
+
+ double geoTransform[6] = { rasterX, xResolution, 0, rasterY, 0, yResolution };
+
+ emptyDataset = myDriver->Create( theOutputFilename.toUtf8(), xSize, ySize, 1, GDT_Float32, NULL );
+
+ emptyDataset->SetGeoTransform( geoTransform );
+
+ GDALRasterBand *poBand;
+ poBand = emptyDataset->GetRasterBand(1);
+ poBand->SetNoDataValue( NO_DATA );
+
+ float* line = ( float * ) CPLMalloc( sizeof( float ) * xSize );
+ std::fill_n( line, xSize, NO_DATA );
+ // Write the empty raster
+ for ( int i = 0; i < ySize ; i += 1 )
+ {
+ poBand->RasterIO( GF_Write, 0, 0, xSize, 1, line, xSize, 1, GDT_Float32, 0, 0 );
+ }
+
+ CPLFree( line );
+ //close the dataset
+ GDALClose( (GDALDatasetH) emptyDataset );
+
+ // open the raster in GA_Update mode
+ GDALDataset *heatmapDS;
+ heatmapDS = ( GDALDataset * ) GDALOpen( theOutputFilename.toUtf8(), GA_Update );
+ if( !heatmapDS )
+ {
+ QMessageBox::information( 0, tr("Error in Updating Raster!"), tr("Couldnot open the created raster for updation. The Heatmap was not generated.") );
+ return;
+ }
+ poBand = heatmapDS->GetRasterBand( 1 );
+ // Get the data buffer ready
+ int blockSize = 2 * theBuffer + 1; // block SIDE would have been more appropriate
+ // Open the vector features
+ QgsVectorDataProvider* myVectorProvider = theVectorLayer->dataProvider();
+ if( !myVectorProvider )
+ {
+ QMessageBox::information( 0, tr( "Error in Point Layer!"), tr("Couldnot identify the vector data provider.") );
+ return;
+ }
+ QgsAttributeList dummyList;
+ myVectorProvider->select( dummyList );
+
+ int totalFeatures = myVectorProvider->featureCount();
+ int counter = 0;
+
+ QProgressDialog p( "Creating Heatmap ... ", "Abort", 0, totalFeatures );
+ p.setWindowModality(Qt::WindowModal);
+
+ QgsFeature myFeature;
+
+ while( myVectorProvider->nextFeature( myFeature ) )
+ {
+ counter += 1;
+ p.setValue( counter );
+ if( p.wasCanceled() )
+ {
+ QMessageBox::information( 0, tr("Heatmap Generation Aborted!"), tr("QGIS will now load the partially-computed raster.") );
+ break;
+ }
+
+ QgsGeometry* myPointGeometry;
+ myPointGeometry = myFeature.geometry();
+ // convert the geometry to point
+ QgsPoint myPoint;
+ myPoint = myPointGeometry->asPoint();
+ // avoiding any empty points or out of extent points
+ if( ( myPoint.x() < rasterX ) || ( myPoint.y() < rasterY ) )
+ {
+ continue;
+ }
+ // calculate the pixel position
+ unsigned int xPosition, yPosition;
+ xPosition = (( myPoint.x() - rasterX )/ xResolution ) - theBuffer;
+ yPosition = (( myPoint.y() - rasterY )/ yResolution ) - theBuffer;
+
+ // get the data
+ float *dataBuffer = ( float * ) CPLMalloc( sizeof( float ) * blockSize * blockSize );
+ poBand->RasterIO( GF_Read, xPosition, yPosition, blockSize, blockSize, dataBuffer, blockSize, blockSize, GDT_Float32, 0, 0 );
+
+ for( int xp = 0; xp <= theBuffer; xp += 1 )
+ {
+ for( int yp = 0; yp <= theBuffer; yp += 1 )
+ {
+ float distance = sqrt( pow( xp, 2 ) + pow( yp, 2 ) );
+ float pixelValue = 1 - ( (1-theDecay) * distance / theBuffer );
+
+ // clearing anamolies along the axes
+ if( xp == 0 && yp == 0 )
+ {
+ pixelValue /= 4;
+ }
+ else if( xp == 0 || yp == 0 )
+ {
+ pixelValue /= 2;
+ }
+
+ if( distance <= theBuffer )
+ {
+ int pos[4];
+ pos[0] = ( theBuffer + xp ) * blockSize + ( theBuffer + yp );
+ pos[1] = ( theBuffer + xp ) * blockSize + ( theBuffer - yp );
+ pos[2] = ( theBuffer - xp ) * blockSize + ( theBuffer + yp );
+ pos[3] = ( theBuffer - xp ) * blockSize + ( theBuffer - yp );
+ for( int p = 0; p < 4; p += 1 )
+ {
+ if( dataBuffer[ pos[p] ] == NO_DATA )
+ {
+ dataBuffer[ pos[p] ] = 0;
+ }
+ dataBuffer[ pos[p] ] += pixelValue;
+ }
+ }
+ }
+ }
+
+ poBand->RasterIO( GF_Write, xPosition, yPosition, blockSize, blockSize, dataBuffer, blockSize, blockSize, GDT_Float32, 0, 0 );
+ CPLFree( dataBuffer );
+ }
+
+ //Finally close the dataset
+ GDALClose( (GDALDatasetH) heatmapDS );
+
+ // Open the file in QGIS window
+ mQGisIface->addRasterLayer( theOutputFilename, QFileInfo( theOutputFilename ).baseName() );
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+//
+// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
+// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
+// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
+//
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * Required extern functions needed for every plugin
+ * These functions can be called prior to creating an instance
+ * of the plugin class
+ */
+// Class factory to return a new instance of the plugin class
+QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
+{
+ return new Heatmap( theQgisInterfacePointer );
+}
+// Return the name of the plugin - note that we do not user class members as
+// the class may not yet be insantiated when this method is called.
+QGISEXTERN QString name()
+{
+ return sName;
+}
+
+// Return the description
+QGISEXTERN QString description()
+{
+ return sDescription;
+}
+
+// Return the category
+QGISEXTERN QString category()
+{
+ return sCategory;
+}
+
+// Return the type (either UI or MapLayer plugin)
+QGISEXTERN int type()
+{
+ return sPluginType;
+}
+
+// Return the version number for the plugin
+QGISEXTERN QString version()
+{
+ return sPluginVersion;
+}
+
+QGISEXTERN QString icon()
+{
+ return sPluginIcon;
+}
+
+// Delete ourself
+QGISEXTERN void unload( QgisPlugin * thePluginPointer )
+{
+ delete thePluginPointer;
+}
diff --git a/src/plugins/heatmap/heatmap.h b/src/plugins/heatmap/heatmap.h
new file mode 100644
index 000000000000..bf0707d086cd
--- /dev/null
+++ b/src/plugins/heatmap/heatmap.h
@@ -0,0 +1,105 @@
+/***************************************************************************
+ heatmap.h
+ -------------------
+ begin : Jan 21, 2004
+ copyright : (C) 2004 by Tim Sutton
+ email : tim@linfiniti.com
+
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/***************************************************************************
+ * QGIS Programming conventions:
+ *
+ * mVariableName - a class level member variable
+ * sVariableName - a static class level member variable
+ * variableName() - accessor for a class member (no 'get' in front of name)
+ * setVariableName() - mutator for a class member (prefix with 'set')
+ *
+ * Additional useful conventions:
+ *
+ * theVariableName - a method parameter (prefix with 'the')
+ * myVariableName - a locally declared variable within a method ('my' prefix)
+ *
+ * DO: Use mixed case variable names - myVariableName
+ * DON'T: separate variable names using underscores: my_variable_name (NO!)
+ *
+ * **************************************************************************/
+#ifndef Heatmap_H
+#define Heatmap_H
+
+//QT4 includes
+#include
+
+//QGIS includes
+#include "../qgisplugin.h"
+#include "qgsvectorlayer.h"
+
+//forward declarations
+class QAction;
+class QToolBar;
+
+class QgisInterface;
+
+/**
+* \class Plugin
+* \brief heatmap plugin for QGIS
+* \description generates a heatmap raster for the input point vector
+*/
+class Heatmap: public QObject, public QgisPlugin
+{
+ Q_OBJECT
+ public:
+
+ // MANDATORY PLUGIN METHODS FOLLOW
+
+ /**
+ * Constructor for a plugin. The QgisInterface pointer is passed by
+ * QGIS when it attempts to instantiate the plugin.
+ * @param theInterface Pointer to the QgisInterface object.
+ */
+ Heatmap( QgisInterface * theInterface );
+ //! Destructor
+ virtual ~Heatmap();
+
+ public slots:
+ //! init the gui
+ virtual void initGui();
+ //! Show the dialog box
+ void run();
+ //! unload the plugin
+ void unload();
+ //! show the help document
+ void help();
+ //! the worker slot to create heatmap
+ /*
+ * Signal: createRaster
+ * Params:
+ * QgsVectorLayer* -> Input point layer
+ * int -> Buffer distance
+ * float -> Decay ratio
+ * QString -> Output filename
+ * QString -> Output Format Short Name
+ */
+ void createRaster( QgsVectorLayer*, int, float, QString, QString );
+
+ private:
+
+ // MANDATORY PLUGIN PROPERTY DECLARATIONS .....
+
+ int mPluginType;
+ //! Pointer to the QGIS interface object
+ QgisInterface *mQGisIface;
+ //!pointer to the qaction for this plugin
+ QAction * mQActionPointer;
+
+};
+
+#endif //Heatmap_H
diff --git a/src/plugins/heatmap/heatmap.png b/src/plugins/heatmap/heatmap.png
new file mode 100644
index 000000000000..37cc5a36226a
Binary files /dev/null and b/src/plugins/heatmap/heatmap.png differ
diff --git a/src/plugins/heatmap/heatmap.qrc b/src/plugins/heatmap/heatmap.qrc
new file mode 100644
index 000000000000..691a64c54e25
--- /dev/null
+++ b/src/plugins/heatmap/heatmap.qrc
@@ -0,0 +1,5 @@
+
+
+ heatmap.png
+
+
diff --git a/src/plugins/heatmap/heatmap.svg b/src/plugins/heatmap/heatmap.svg
new file mode 100644
index 000000000000..1cbf82b55fdf
--- /dev/null
+++ b/src/plugins/heatmap/heatmap.svg
@@ -0,0 +1,143 @@
+
+
+
+
diff --git a/src/plugins/heatmap/heatmapgui.cpp b/src/plugins/heatmap/heatmapgui.cpp
new file mode 100644
index 000000000000..18d3d7429bfe
--- /dev/null
+++ b/src/plugins/heatmap/heatmapgui.cpp
@@ -0,0 +1,193 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Tim Sutton *
+ * tim@linfiniti.com *
+ * *
+ * This is a plugin generated from the QGIS plugin template *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+// qgis includes
+#include "qgis.h"
+#include "heatmapgui.h"
+#include "qgscontexthelp.h"
+#include "qgsmaplayer.h"
+#include "qgsmaplayerregistry.h"
+#include "qgsvectorlayer.h"
+
+// GDAL includes
+#include "gdal_priv.h"
+#include "cpl_string.h"
+#include "cpl_conv.h"
+
+//qt includes
+#include
+#include
+#include
+#include
+
+//standard includes
+
+HeatmapGui::HeatmapGui( QWidget* parent, Qt::WFlags fl )
+ : QDialog( parent, fl )
+{
+ setupUi( this );
+
+ // Adding point layers to the mInputVectorCombo
+ QMap mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
+ QMapIterator layers(mapLayers);
+
+ while( layers.hasNext() )
+ {
+ layers.next();
+ QgsVectorLayer* vl = qobject_cast(layers.value());
+ if( ( vl ) && ( vl->geometryType() == QGis::Point ) )
+ {
+ mInputVectorCombo->addItem( vl->name(), QVariant( vl->id() ) );
+ }
+ }
+
+ // Adding GDAL drivers with CREATE to the mFormatCombo
+ GDALAllRegister();
+ int nDrivers = GDALGetDriverCount();
+ for( int i = 0; i < nDrivers; i +=1 )
+ {
+ GDALDriver* nthDriver = GetGDALDriverManager()->GetDriver( i );
+ char** driverMetadata = nthDriver->GetMetadata();
+ if( CSLFetchBoolean( driverMetadata, GDAL_DCAP_CREATE, false ) )
+ {
+ // Add LongName text, shortname variant; GetDescription actually gets the shortname
+ mFormatCombo->addItem( nthDriver->GetMetadataItem( GDAL_DMD_LONGNAME ), QVariant( nthDriver->GetDescription() ) );
+ // Add the drivers and their extensions to a map for filename correction
+ mExtensionMap.insert( nthDriver->GetDescription(), nthDriver->GetMetadataItem( GDAL_DMD_EXTENSION ) );
+ }
+ }
+
+ //finally set right the ok button
+ enableOrDisableOkButton();
+}
+
+HeatmapGui::~HeatmapGui()
+{
+}
+
+void HeatmapGui::on_mButtonBox_accepted()
+{
+ // Variables to be emitted with the createRaster signal
+ QgsVectorLayer* inputLayer;
+ int bufferDistance;
+ float decayRatio;
+ QString outputFileName;
+ QString outputFormat;
+
+ QString dummyText;
+
+ // The input vector layer
+ int myLayerId = mInputVectorCombo->itemData( mInputVectorCombo->currentIndex() ).toInt();
+
+ QMap mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
+ QMapIterator layers(mapLayers);
+
+ while( layers.hasNext() )
+ {
+ layers.next();
+ QgsVectorLayer* vl = qobject_cast(layers.value());
+ if ( vl )
+ {
+ dummyText = vl->id();
+ if( dummyText.toInt() == myLayerId )
+ {
+ inputLayer = vl;
+ }
+ }
+ }
+
+ // The buffer distance
+ dummyText = mBufferLineEdit->text();
+ bufferDistance = dummyText.toInt();
+ if( bufferDistance == NULL )
+ {
+ QMessageBox::information( 0, tr("Invalid Buffer Value!"), tr("Buffer distance cannot be NULL, kindly enter a valid value.") );
+ return;
+ }
+ // The decay ratio
+ dummyText = mDecayLineEdit->text();
+ decayRatio = dummyText.toFloat();
+
+ // The output filename
+ outputFileName = mOutputRasterLineEdit->text();
+ QFileInfo myFileInfo( outputFileName );
+ if( outputFileName.isEmpty() || !myFileInfo.dir().exists() )
+ {
+ QMessageBox::information( 0, tr("Output filename is invalid!"), tr("Kindly enter a valid output file path and name.") );
+ return;
+ }
+
+ // The output format
+ outputFormat = mFormatCombo->itemData( mFormatCombo->currentIndex() ).toString();
+
+ // append the file format if the suffix is empty
+ QString suffix = myFileInfo.suffix();
+ if( suffix.isEmpty() )
+ {
+ QMap::const_iterator it = mExtensionMap.find( outputFormat );
+ if( it != mExtensionMap.end() && it.key() == outputFormat )
+ {
+ // making sure that there is really a extension value available
+ // Some drivers donot seem to have any extension at all
+ if( it.value() != NULL || it.value() != "" )
+ {
+ outputFileName.append(".");
+ outputFileName.append( it.value() );
+ }
+ }
+ }
+
+ emit createRaster( inputLayer, bufferDistance, decayRatio, outputFileName, outputFormat );
+ //and finally
+ accept();
+}
+
+void HeatmapGui::on_mButtonBox_rejected()
+{
+ reject();
+}
+
+void HeatmapGui::on_mButtonBox_helpRequested()
+{
+ QgsContextHelp::run( metaObject()->className() );
+}
+
+void HeatmapGui::on_mBrowseButton_clicked()
+{
+ QSettings s;
+ QString lastDir = s.value( "/Heatmap/lastOutputDir", "" ).toString();
+
+ QString outputFilename = QFileDialog::getSaveFileName( 0, tr( "Save Heatmap as: "), lastDir );
+ if( !outputFilename.isEmpty() )
+ {
+ mOutputRasterLineEdit->setText( outputFilename );
+ QFileInfo outputFileInfo( outputFilename );
+ QDir outputDir = outputFileInfo.absoluteDir();
+ if( outputDir.exists() )
+ {
+ s.setValue( "/Heatmap/lastOutputDir", outputFileInfo.absolutePath() );
+ }
+ }
+
+ enableOrDisableOkButton();
+}
+
+void HeatmapGui::enableOrDisableOkButton()
+{
+ bool enabled = true;
+ QString filename = mOutputRasterLineEdit->text();
+ QFileInfo theFileInfo( filename );
+ if( filename.isEmpty() || !theFileInfo.dir().exists() || ( mInputVectorCombo->count() == 0 ) )
+ {
+ enabled = false;
+ }
+ mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
+}
diff --git a/src/plugins/heatmap/heatmapgui.h b/src/plugins/heatmap/heatmapgui.h
new file mode 100644
index 000000000000..39335ef48a63
--- /dev/null
+++ b/src/plugins/heatmap/heatmapgui.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Tim Sutton *
+ * tim@linfiniti.com *
+ * *
+ * This is a plugin generated from the QGIS plugin template *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+#ifndef HeatmapGUI_H
+#define HeatmapGUI_H
+
+#include
+#include
+
+#include "qgsvectorlayer.h"
+/**
+@author Tim Sutton
+*/
+class HeatmapGui : public QDialog, private Ui::HeatmapGuiBase
+{
+ Q_OBJECT
+ public:
+ HeatmapGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
+ ~HeatmapGui();
+
+ private:
+ QMap mExtensionMap;
+ void enableOrDisableOkButton();
+
+ private slots:
+ void on_mButtonBox_accepted();
+ void on_mButtonBox_rejected();
+ void on_mButtonBox_helpRequested();
+ void on_mBrowseButton_clicked(); // Function to open the file dialog
+
+ signals:
+ /*
+ * Signal: createRaster
+ * Params:
+ * QgsVectorLayer* -> Input point layer
+ * int -> Buffer distance
+ * float -> Decay ratio
+ * QString -> Output filename
+ * QString -> Output Format Short Name
+ */
+ void createRaster( QgsVectorLayer*, int, float, QString, QString );
+
+};
+
+#endif
diff --git a/src/plugins/heatmap/heatmapguibase.ui b/src/plugins/heatmap/heatmapguibase.ui
new file mode 100644
index 000000000000..3e72ee69e0fb
--- /dev/null
+++ b/src/plugins/heatmap/heatmapguibase.ui
@@ -0,0 +1,221 @@
+
+
+ HeatmapGuiBase
+
+
+
+ 0
+ 0
+ 400
+ 260
+
+
+
+ Heatmap Plugin
+
+
+
+
+
+
+
+ 10
+ 20
+ 110
+ 21
+
+
+
+ Input Point Vector
+
+
+
+
+
+ 125
+ 20
+ 260
+ 25
+
+
+
+
+
+
+ 10
+ 65
+ 110
+ 16
+
+
+
+ Output Raster
+
+
+
+
+
+ 125
+ 60
+ 230
+ 25
+
+
+
+
+
+
+ 355
+ 60
+ 30
+ 25
+
+
+
+ Qt::ClickFocus
+
+
+ ...
+
+
+ false
+
+
+
+
+
+ 10
+ 225
+ 375
+ 30
+
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok
+
+
+
+
+
+ 10
+ 140
+ 370
+ 80
+
+
+
+ Heatmap Point Attributes
+
+
+
+
+ 10
+ 27
+ 101
+ 16
+
+
+
+ Buffer Radius
+
+
+
+
+
+ 10
+ 56
+ 101
+ 16
+
+
+
+ Decay Ratio
+
+
+
+
+
+ 110
+ 20
+ 113
+ 25
+
+
+
+ 10
+
+
+
+
+
+ 110
+ 50
+ 113
+ 25
+
+
+
+ 0.5
+
+
+
+
+
+
+ 10
+ 105
+ 110
+ 15
+
+
+
+ Output Format
+
+
+
+
+
+ 125
+ 100
+ 260
+ 25
+
+
+
+
+
+
+
+ mButtonBox
+ accepted()
+ HeatmapGuiBase
+ accept()
+
+
+ 195
+ 123
+
+
+ 199
+ 79
+
+
+
+
+ mButtonBox
+ rejected()
+ HeatmapGuiBase
+ reject()
+
+
+ 195
+ 123
+
+
+ 199
+ 79
+
+
+
+
+