== Introduction == This version of django_gheat is an edited version of [https://github.com/robertrv/django-gheat django_gheat]. The following guide will explain how to install and use django_gheat. == Install Python == Get Python 2.6 from [http://www.python.org/download/ here], or: {{{ $ sudo apt-get install python }}} == Install MySQL == Set up a MySQL server to your liking. Make sure you get as minimal version 3.23-5.1 due to the MySQLdb support. Then create a database for django_gheat. {{{ $ sudo apt-get install mysql-server $ sudo mysqladmin password password $ echo "CREATE DATABASE project_heatmap;" | mysql -uroot -ppassword }}} == Install MySQLdb == Get the latest version from [http://sourceforge.net/projects/mysql-python/files/mysql-python/ here], make sure it's higher than 1.2.1p2 {{{ $ sudo apt-get install python-mysqldb }}} == Install Django == Get Django 1.3 from [http://www.djangoproject.com/download/1.3/tarball/ here] or check for a newer version [http://www.djangoproject.com/download/ here], then: {{{ $ tar xzvf Django-1.3.tar.gz $ cd Django-1.3 $ sudo python setup.py install }}} == Install django_gheat == Get the latest django_gheat from the [http://svn.wirelessleiden.nl/svn/projects/Heatmap/src/ repository] {{{ # cd to where you want 'django_gheat' to be located $ svn co http://svn.wirelessleiden.nl/svn/projects/Heatmap/src/django_gheat/ $ cd django_gheat/ }}} Open {{{./settings.py}}}, look for the 'DATABASES' section and edit the following lines: {{{ # If you are using MySQL with MySQLdb, don't edit this line. # If you are using a different database, replace 'mysql' with 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'ENGINE': 'django.db.backends.mysql', # The name of your database, or the path to your database file if you are using sqlite3. 'NAME': ' ', # Connection settings for your database. Not used with sqlite3 'USER': ' ', 'PASSWORD': ' ', 'HOST': ' ', 'PORT': ' ', }}} Once you've entered the correct settings, you will be able to start Django. {{{ # The following command will add some standard Django tables and the tables defined in django_gheat/gheat/models.py to the database $ ./manage.py syncdb $ ./manage.py runserver }}} Something like this should return: {{{ 0 errors found Django version 1.3, using settings 'persisted.settings' Development server is running at http://127.0.0.1:8000/ Quit the server with CONTROL-C. }}} You will now be able to browse to the location where the dev server is running. Add 'home/' to the address and a map will be displayed where heatmap tiles will be generated realtime. == Populating the database == The 'syncdb' command added the following tables to the database: [[Image(model.png, 400px, align=right)]] Generated by installing [https://github.com/django-extensions/django-extensions django_extentions] and the command: {{{./manage.py graph_models gheat | dot -Tpng -o model.png}}}. NOTE: that on this moment only the gheat_meting(lat, lng, signaal) are used for generating heatmaps, so make sure you at least put some data in those columns. You can use one of the php scripts in the db/ folder to insert data into the database. The csv_to_db.php inserts data from a csv, and the random_to_db.php inserts random points into your database. Make sure to edit the following lines: {{{ // edit with personal settings $location = ' '; $username = ' '; $password = ' '; $database = ' '; }}} == Importing .csv == There is a data import script for the .csv file format: {{{ # In theory, only the -f option is needed, but for overview's sake, please use the others aswell. # -f = location of the .csv, e.g. '/home/test.csv' # -m = name of the dataset, e.g. 'Walk in park' or 'Trip with boat' # -g = your name # -e = your email address # -a = antenna # -k = network card $ ./manage.py import_csv -f -m -g -e -a -k }}} Make sure the variables in this script match the column numbers in your file e.g.; Lat is read from the first column [0], if the lat in your file is in the 4th column, change 'lat = row[0]' to 'lat = row[3]'. Also, take note of the replace() and strip() functions. These should probably be edited aswell. == Prerender heatmap == You can prerender a heatmap with the following command: {{{ $ ./manage.py gen_tiles }}} This will prerender a heatmap with the default boundingbox specified in django_gheat/gheat/management/commands/gen_tiles.py To use a different boundingbox or colorscheme, you can customize the command: {{{ # -s = start of the boundingbox, SW corner # -e = end of the boundingbox, NE corner # -c = colorscheme located in django_gheat/gheat/etc/color-schemes/ # -b = view used for creating tiles, default should be fine $ ./manage.py gen_tiles -s 60,6 -e 66,8 -c firetrans -b serve_tile }}} == Display heatmap == To display the heatmap, you can run the webserver: {{{ $ ./manage.py runserver }}} Then browse to http://localhost:8000/website/ For now, for both the on-the-fly-render and the prerender, the heatmap images will be saved in (if windows; 'C:') '/tmp/gheat'. == Troubleshooting == If something is unclear or isn't working as it should, feel free to create a ticket.