4. The db.py script

The script at __/bin/db.py is used to manage the database at __/var/points.db. It's available subcommands are:

Subcommand Description
clear Remove all points from the database
count Print the number of points in the database to stdout
delete Delete the database from the filesystem
sync Update the database from the file at __/var/points.txt

For the clear, count, and sync subcommands, the database will be created if it does not exist. The default subcommand is sync.

The __/var/points.txt file is a CSV-formatted file with three fields: point id, latitude, and longitude. The point id field can be any string. If it is not unique within the points.txt file then the last point with a given point id will override any previous points with that same point id. Gheat uses the point id field to keep track of when points should be removed from the database, as well as when points are updated, in order to tell when the tile cache ought to be flushed. The latitude and longitude fields must be floats. Multiple data points may have the same latitude and longitude in order to increase the intensity of that geographic point on the heatmap.

The sync subcommand outputs a token for each point in the points.txt file:

Token Meaning
. The point was not modified since the last time it was seen
o The point was modified and has been updated
O This is a new point

The number of points deleted can be determined by using the count subcommand before and after the sync subcommand.

Gheat is copyright © 2007-2008 by Chad Whitacre and contributors, and is offered under the MIT license.