One thousand billions of... maps (with SVG and Cocoon)


Table of Contents


1. Goal
2. Interface
3. Base maps
4. Mixing data and maps
5. How Cocoon help us
6. Future

We present here an application of SVG to the on-line production of maps for the analysis of results of elections. We use Cocoon -from the Apache foundation- to facilitate this production. The used method is easily generalizable for different data source.

1. Goal

We wanted to supply a Web site ( http://shadok.enst.fr:8080/election/) which allows every guest to produce his own spatial analysis of the results of the presidential elections 2002 in France. For each of 36000 French administrative divisions (municipalities), we have the percentage of blank or invalid vote, the percentage of voters, the percentage of abstentions, the percentage obtained by every candidate. We authorize all the combinations of these results to produce a map. Furthermore, the proposed method can be easily modified to process other data.

samplemap.jpg

The most difficult part of the process is to get the data.

We've developed a set of tools, using Perl, wget and lynx. So, our crawling and cleaning of the datas is nerly automatic. The only step in our process which is not easily generalizable is the initial production of the data in our XML format. However, the necessary converters are rather simple to produce.

2. Interface

The interface is a simple form which allows: to choose a geographic zone, to decide how to combine the results of the candidates; for each one, we decide either to ignore the results, or to count them positively, or to count them negatively; for example, if we count Mamere positively and Lepage negatively, we are going to highlight the balance between these two candidates.

presidform.jpg

The form is generated from an XML document which list the possible choices and a custom template for the this atlas. It could be an hand-made form, because it is a very simple form.

3. Base maps

Every base map is an SVG file and mainly consists of a path by municipality. A sample of SVG code for a municipality is:

<path id="C04006-1" fill="rgb(0,0,0)" onmouseover="zin('C04006')" onmouseout="zou('C04006')" d="M414 299 L418 289L427 293L429 298... L414 299z"/>

The 'id' field allows to do the link

Original base maps were described in PostScript, and have been converted in SVG. Base maps were once prepared for every geographic zone. A possible evolution consists in putting the coordinates of the municipalities in a geographic database and to build the map on demand according to a request in the database.

4. Mixing data and maps

Then we compute the final data (sum or difference of percentages) associated to every municipality. We sort the municipalities according to this data. Thus, we get a quick way to rank them into N (N=3 to 7) equal classes (same number of municipalities). For every class, we get the minimum and maximum value, each class being refered by a color. Cold colors are used for the negative values, warm colors for the positive values; color poorly saturated near zero, colours darker and\or more saturated far from zero. Then, we make an XSLT transformation to give the good value to the 'fill' field in the path associated with each municipality.

5. How Cocoon help us

Cocoon parse the calling URL to choose some processing to do to generate a document as the URL response.

Cocoon allows us quite easily:

For our maps, we have the following chain of processing:

Every stage produces an XML representation, which moves from step to step by SAX events. So, an XML file is not really created for each step. A file is created only if it could be used in the cache.

The XSLT transformations are compiled once during their first use.

Cocoon allows to benefit from a powerful caching mechanism. Cocoon allows us to internationalize easily our maps generation by using a list of all textual messages shown on a map contained in an XML file for each supported language.

6. Future

Afterward, we have planed to:

XHTML rendition made possible by SchemaSoft's Document Interpreter™ technology.