Version 15 (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 ./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:
Generated by installing 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 .netxml
There is a data import script for the .netxml file format:
# 'cd' to project root # In theory, only the -f option is needed, but for overview's sake, please use the others aswell. # -f = location of the .netxml, e.g. '/home/test.netxml' # -m = name of the dataset, e.g. 'Walk in park' or 'Trip with boat' # -g = your name # -e = your email address $ ./manage.py dataimport -f <file location> -m <dataset name> -g <username> -e <email>
When importing .netxml, be sure your file has atleast the following parent/child xml elements:
<wireless-network> <SSID> <encryption> </encryption> <essid cloaked=""> </essid> </SSID> <BSSID> </BSSID> <gps-info> <min-lat> </min-lat> <min-lon> </min-lon> </gps-info> </wireless-network>
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
Display heatmap
To display the heatmap, you can run the webserver:
$ cd samples/persisted $ ./manage.py runserver
Then browse to http://localhost:8000/home/
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.
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