Geographic Displays

From WormBaseWiki
Jump to navigationJump to search

The following two pages contain geographic map displays based on Google Maps.

1) Paper page includes a small geographic map displaying locations of the authors of the paper:

$WORMBASE/cgi-perl/misc/paper: CGI script that contains the code segment
$WORMBASE/cgi-perl/misc/geo_map_by_paper: CGI script that generates the display
$WORMBASE/html/geo_map/templates/: Template Toolkit templates for geo_map_by_paper

2) Large geographic map displaying locations of all Wormbase people:

$WORMBASE/cgi-perl/misc/wb_people: Stand-alone CGI script
$WORMBASE/cgi-perl/lib/WormBase/ Wormbase-specific subclass of HTML::GMap
$WORMBASE/html/geo_map/_tmp/: Temp directory
$WORMBASE/html/geo_map/*.png: Images
$WORMBASE/html/geo_map/prototype.v1-5-0.js: prototype.js
(Keep symlink _tmp/prototype.js -> ../prototype.v1-5-0.js)

The following CPAN modules are required for the wb_people page (GD::Icons is installed automatically when HTML::GMap is installed). Please refer to CPAN documentation for further information on these modules.

HTML::GMap -
GD::Icons  -

The Wormbase geographic map displays depend on a database named "geo_map".

The code base for creating a new geo_map database:

Code base: $WORMBASE/util/import_export/geo_map/

Steps for updating the geo_map database:

For each build of the database, use an empty directory. A number of intermediary files are generated during the build. The data is loaded into MySQL and then processed. The final step is to make a mysqldump of the database to use in production.

1) Dump paper, author and person data:

Command-line: perl

This script generates 3 files:

 data_dump.papers  : Paper objects
 data_dump.authors : Author objects
 data_dump.people  : Person objects

2) Extract addresses from Author and Person objects, make a non-redundant list. These addresses will be mapped to latitude/longitude pairs (geocoded).

Command-line: cat data_dump.persons data_dump.authors | cut -d'|' -f3 | sort -u > all_addresses.txt
(see; name the file all_addresses.txt)

3) Geocode the non-redundant address list (all_addresses.txt):

Command-line: perl all_addresses.txt

This creates:

 all_addresses.txt.cache  : Address cache, used internally.
 all_addresses.txt.failed : List of addresses that could not be geocoded.
 all_addresses.txt.log    : Log file.
 all_addresses.txt.ok     : List of addresses that were successfully geocoded.


  • From this step, only "all_addresses.txt.ok" will are used in the subsequent steps.
  • If this step is interrupted at any point, you can restart it. To restart it:
Remove all_addresses.txt.failed, all_addresses.txt.log, all_addresses.txt.ok
(Leave all_addresses.txt.cache).
Re-run "perl".

4) Create a mysql script that loads and processes the data:

perl <dir> > <file.mysql>; Absolute path to the processing directory

5) Source the file.mysql against the mysql database:

mysql> drop database geo_map;
mysql> create database;
mysql> use geo_map;
mysql> source path_to_file/file.mysql;

6) Process the database using the script. This script populates the wb_by_person2 table.

7) Make a mysqldump of this database and load it to any other server the application will run on.

Currently: Dev Site - brie3, Live site -

Installation notes:

  • The CGI script and the temp files need to expire immediately. The following blocks in the httpd.conf are included for this purpose. These blovks must come *after* the Location /db block.
# wb_people CGI script and dynamic images expire immediately
<LocationMatch "/db/misc/wb_people">
   ExpiresActive On
   ExpiresDefault "access plus 0 seconds"
<LocationMatch "/geo_map/_tmp/">
   ExpiresActive On
   ExpiresDefault "access plus 0 seconds"
  • See $WORMBASE/util/import_export/geo_map/archive for previously loaded data.
  • In order to track versions, create date-stamped databases and symlink from "geo_map". See mysql server on brie3 or
e.g. geo_map -> geo_map_2007_12_17
  • Google Maps keys for different servers are located in brie3:/usr/local/wormbase/util/import_export/geo_map/google_maps_keys.txt (not in cvs).
  • Database access information is in (search for "Google Maps API related").