wiki:django_gheat

Version 1 (modified by dennisw, 14 years ago) ( diff )

--

Introduction

This version of django_gheat is an edited version of django_gheat.

Install Python

Get Python 2.6 from here, or:

$ sudo apt-get install python2.6

Install MySQL

Set up a MySQL server to your liking. Make sure you get version 3.23-5.1 due to the MySQLdb support. Then create a database for django_gheat.

Install MySQLdb

Get the latest version from here, make sure it's higher than 1.2.1p2

$ sudo apt-get install mysql-server

Install Django

Get Django 1.3 from here or check for a newer version 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 repository

Open /samples/persisted/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.

$ cd django_gheat/samples/persisted

# The following command will add some standard Django tables and the tables defined in django_gheat/gheat/models.py to the database
$ python manage.py syncdb

$ python 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:

BEGIN;
CREATE TABLE `gheat_accespoint` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `mac` varchar(17) NOT NULL,
    `ssid` varchar(64) NOT NULL,
    `encryptie` bool NOT NULL
)
;
CREATE TABLE `gheat_gebruiker` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `gebruiker` varchar(64) NOT NULL,
    `apparatuur` varchar(64) NOT NULL
)
;
CREATE TABLE `gheat_meting` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `accespoint_id` integer NOT NULL,
    `gebruiker_id` integer NOT NULL,
    `lat` double precision NOT NULL,
    `lng` double precision NOT NULL,
    `signaal` integer NOT NULL,
    `datum` datetime NOT NULL
)
;
ALTER TABLE `gheat_meting` ADD CONSTRAINT `gebruiker_id_refs_id_56605efc` FOREIGN KEY (`gebruiker_id`) REFERENCES `gheat_gebruiker` (`id`);
ALTER TABLE `gheat_meting` ADD CONSTRAINT `accespoint_id_refs_id_49f1ad5c` FOREIGN KEY (`accespoint_id`) REFERENCES `gheat_accespoint` (`id`);
COMMIT;

Note that on this moment only the gheat_meting(lat, lng, signaal) are used for generating heatmaps, so make sure you atleast put some data in those columns.

Prerender heatmap

You can prerender a heatmap with the following command:

$ cd django_gheat/samples/persisted
$ python 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

$ python manage.py gen_tiles -s 60,6 -e 66,8 -c firetrans -b serve_tile

Troubleshooting

If something is unclear or isn't working as it should, feel free to create a ticket.

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.