Database-driven Generation of SVG-Maps with the Apache Cocoon 2 Framework

Peter Schaer

Department of Geography

University of Berne

Hallerstrasse 12, CH-3012 Berne

Phone: +41316318863; Fax: +41316318511

The department of geography at the university of Berne (Switzerland) initiated in the year 2000 a project to create a thematic atlas about the urban region of the swiss capital. It will visualize the economic, political and social structure of the bern region (consisting of 89 communities). This atlas will probably be published as a book, as a cd-rom and in the internet. My task in this project is it to find an appropriate method for generating the maps for the atlas.

SVG seemed to be the ideal format for this job. Previous work (e.g. those presented at SVGOpen 2002 in Zurich) showed that SVG is ideally suited for building svg-maps of any kind. Because the atlas will contain quite a lot of maps (50 - 100) a manual generation of these maps is too time-consuming and i had to find an automated method of map generation. I heard of mapmaking with PHP and also with PERL, but because the Apache Cocoon Framework is completely based on XML-workflow, I decided to use it in this project to develop a mapserver.

The data of the thematic atlas consists mainly of swiss census data and some special data ascertained by other students working on the same project. I chose MySQL as the Database-Management-System in this application because it is easy to setup and use and because there is no need to use GIS-enabled Database-Management-Systems like Oracle Spatial or PostgreSQL. The data was filled into the tables very easily and quickly using CSV-import.

The user creates the maps by accessing the webpages of the mapserver. There he can configure the mapdata to be visualized, the map symbols, the map size and several other parameters. The map generation process is controlled by XML Server Pages (XSP) and the ESQL-Logicsheet. Those two cocoon-modules create the SQL-queries and put the results of the queries into a valid XML-stream, which will be transported to the XSL-transformer. The connection to MySQL is controlled by a JDBC-driver. This transformer uses an XSL-processor (by default: xalan) to transform the XML-stream into a SVG-stream using a XSL-stylesheet. The resulting SVG-stream is then being transported back to the user.

To provide maps for three different medias I had to develop different XSL-stylesheets. There is a stylesheet for internet- and CD-ROM-maps (enabling user-interaction) and a stylesheet for maps of the printed atlas (no user-interaction). Those maps for the printed atlas can be imported into an appropriate software (e.g. Corel Draw, Adobe Illustrator and others) to integrate them in the printed atlas.

The Apache Cocoon Framework is an ideal tool for building dynamic SVG-maps for different output-medias, because it is completely based on Open Source-Technology and on XML-workflow. And SVG is not only suited for creating interactive webmaps but also for designing conventional printed maps.