Version 6 (modified by 14 years ago) ( diff ) | ,
---|
Introduction
This version of django_gheat is an edited version of django_gheat. The following guide will explain how to install and use django_gheat.
Install Python
Get Python 2.6 from 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 here, make sure it's higher than 1.2.1p2
$ sudo apt-get install python-mysqldb
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' to project root # 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 # if using sample page, first 'cd samples/persisted', will get fixed soon $ ./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, `naam` varchar(64) NOT NULL, `email` varchar(64) NOT NULL ) ; CREATE TABLE `gheat_apparatuur` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `antenne` varchar(64) NOT NULL, `kaart` varchar(64) NOT NULL ) ; CREATE TABLE `gheat_meetrondje` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `datum` datetime NOT NULL, `naam` varchar(60) NOT NULL, `gebruiker_id` integer NOT NULL, `apparatuur_id` integer NOT NULL ) ; ALTER TABLE `gheat_meetrondje` ADD CONSTRAINT `apparatuur_id_refs_id_5e2d317` FOREIGN KEY (`apparatuur_id`) REFERENCES `gheat_apparatuur` (`id`); ALTER TABLE `gheat_meetrondje` ADD CONSTRAINT `gebruiker_id_refs_id_3b558609` FOREIGN KEY (`gebruiker_id`) REFERENCES `gheat_gebruiker` (`id`); CREATE TABLE `gheat_meting` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `meetrondje_id` integer NOT NULL, `accespoint_id` integer NOT NULL, `lat` double precision NOT NULL, `lng` double precision NOT NULL, `signaal` integer NOT NULL ) ; ALTER TABLE `gheat_meting` ADD CONSTRAINT `accespoint_id_refs_id_49f1ad5c` FOREIGN KEY (`accespoint_id`) REFERENCES `gheat_accespoint` (`id`); ALTER TABLE `gheat_meting` ADD CONSTRAINT `meetrondje_id_refs_id_6c4042fe` FOREIGN KEY (`meetrondje_id`) REFERENCES `gheat_meetrondje` (`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' to project root $ ./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
Troubleshooting
If something is unclear or isn't working as it should, feel free to create a ticket.
Attachments (1)
-
model.png
(24.3 KB
) - added by 14 years ago.
./manage.py graph_models gheat | dot -Tpng -o model.png
Download all attachments as: .zip