< Previous

W-12: Web-based Routing: An Introduction to pgRouting with OpenLayers

"Routenplaner" (driving direction planner) is the number one search pattern in Germany of the year 2006 according to Google (source: Google Zeitgeist). Google Maps is one of the most popular internet services of the last year. Albeit the problem of freely available road network data it is possible to create your own .Google Maps. like routing application only using Open Source tools: namely with pgRouting and OpenLayers.

PgDijkstra, a PostgreSQL module was first written by Sylvain Pasche from Camptocamp. It was then extended by Orkney (Japan) and renamed pgRouting, an extension of PostgreSQL and PostGIS which is part of the PostLBS project. This workshop provides an insight into pgRouting and demonstrates how to build a simple routing application using pgRouting together with OpenLayers.

After a short introduction of the actual state of pgRouting development and its features, you will learn how to prepare the road network data for pgRouting. To be able to search the shortest-path between two points the road network data requires a specified cost-based structure.

To give a practical example of how to perform shortest-path searches with pgRouting the workshop will show how to implement basic routing functionality on the top of OpenLayers web mapping framework. Using OpenLayers makes it possible to create a "Google Maps" like web mapping application in a short time. We will be able to set a start and end point, and run the shortest-path search between these points. The result of that spatial query will be loaded into OpenLayers as a WMS layer.

As a participant of this workshop you will learn how to build the routing network data and how to create the basic OpenLayers map with base layer(s) and the routing layer. Then it will be demonstrated how to perform the routing request and how to retrieve the result using PHP (php/Mapscript) and a MapServer mapfile (WMS).

Because compiling of pgRouting is not part of this workshop, an already installed pgRouting environment and sample data will be provided.

User Level

Intermediate. An understanding of SQL, Javascript, HTML, and MapServer is helpful.


Daniel Kastl has worked for a traffic engineering company in Germany using proprietary GIS software (ArcView) and traffic management tools (PTV). Since 2005 he has been employed at Orkney, Inc. (Japan). There he works as developer for customized open source web mapping applications, using UMN MapServer, PostgreSQL/PostGIS and other open source GIS related projects. pgRouting is an open source project maintained by Orkney.

Sylvain Pasche, senior developper at Camptocamp SA, is the first author of the PgDijkstra PostgreSQL module.

Claude Philipona is co-founder of Camptocamp SA and professor at the University of Applied Sciences Western Switzerland (HES-SO)