Utilities Manual

Pygeoclients is a simple Python module with a collection of command-line utilities to import, geocode and show a map of addresses. It was intented to to plot business clients on a map.

Polyglot - pygeoclients.polyglot

The “polyglot” utility is used to import addresses from other databases to a Pygeoclient’s format, this destination format can be any database, so you can for exemplo import from an Oracle database and store in a Oracle database or in a MySQL database, or even on a SQLite3 database.

Examples

The polyglot utility have the follow syntax:

# python -m pygeoclients.polyglot --help

Polyglot v.0.1
By Christian S. Perone

Usage: polyglot.py [options]

Options:
  -h, --help            show this help message and exit
  -s SOURCEDB, --source=SOURCEDB
                        The source database connection (ex.
                        'sqlite:///db.db').
  -d DESTDB, --dest=DESTDB
                        The destination database (default is
                        'sqlite:///db.db').
  -f FROM, --from=FROM  The table and field source (ex. clients.address).
  -a, --append          Append data to the destination database (default).
  -r, --reset           Clear the destination database before import data.

Suppose you have a database of clients on a MySQL database, this database is called “dbclients”, and the table which contains the client’s addresses is “client” and the field with the addresses is “address”. So what you can do to let Polyglot automatically import these data into a Pygeoclient’s database format is something like this:

python -m pygeoclients.polyglot -s mysql://root@localhost/dbclients -d sqlite:///db.db -f client.address

What this command will do is to import all records in the field “address” from the table “client” to the SQLite3 “db.db” (it can be any other database) format Pygeoclient’s database. This data will be used later by the Geocoding utility, which will convert the addresses to geo locations (lat/lng).

If you don’t know how to create the database strings, see the “Creating database connections” on the introduction.

Geocoding - pygeoclients.geocoding

The “geocoding” utility is used to geocode (convert addresses to geo locations) the addresses imported by polyglot from a database.

Examples

The geocoding utility have the follow syntax:

# python -m pygeoclients.geocoding --help

Geocoding Service v.0.1
By Christian S. Perone

Usage: geocoding.py [options]

Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Database to read (default is 'sqlite:///db.db').
  -i INTERVAL, --interval=INTERVAL
                        Interval (in seconds) between calls of Google service
                        (default is '2.0' seconds).
  -r, --reprocess       Force the processing of all records.

After you have imported the addresses with Polyglot, you must geocode them using the Geocoding utility, which uses the Google geocoding service to convert addresses into geo locations and store it on the database. A simple example can be this:

python -m pygeoclients.geocoding -f sqlite:///db.db

This command will connect call the Google geocoding services for every address in the database.

Geoserver - pygeoclients.geoserver

The “geoserver” utility is used to start a server to provide geo locations data to visualization applications like Google Maps and Google Earth. To use Geoserver, you must first import data with Polyglot and Geocoding them with Geocoding utility.

Examples

The geoserver utility have the follow syntax:

# python -m pygeoclients.geoserver --help


Geoserver v.0.1
By Christian S. Perone

Usage: geoserver.py [options]

Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Database to read (default is 'sqlite:///db.db').
  --host=HOST, --host=HOST
                        Host to start server (default is 'localhost').
  -p PORT, --port=PORT  Port to listen (default is '6666').
  -m, --map             Use the Google Maps server mode (the default).
  -e, --earth           Use the Google Earth server mode.

A simple call of the server for Google Earth client can be something like this:

python -m pygeoclients.geoserver -f sqlite:///db.db -p 6666 -e

This command will listen on the port 6666 for Google Earth requests, now what you must do is to create a “Network Link” in Google Earth pointing to “http://localhost:6666“.

DB Utility - pygeoclients.db

The “db” is a simple command-line utility to visualize database of imported addresses, delete records, add new records and etc.

Examples

The db utility have the follow syntax:

# python -m pygeoclients.db --help

Geocoding Database v.0.1
By Christian S. Perone

Usage: db.py [options]

Options:
  -h, --help            show this help message and exit
  -f FILENAME, --file=FILENAME
                        Database to read (default is 'sqlite:///db.db').
  -s, --show            Show all records in database.
  -a ADDRESS, --add=ADDRESS
                        Add a new address record.
  -d ADDRESS, --delete=ADDRESS
                        Delete a address record, it will find for %ADDRESS%.
  -r, --reset           Reset all records in the database, drop and recreate
                        all tables.

To add new address you can call it like this:

python -m pygeoclients.db --add "St. Peter Avenue, 666, New York"