Clickable Maps from LocDB and free data sources

Goals
The MediaWiki imagemap extension allows wiki contributors to define clickable maps. This could be a great feature for helping readers to navigate through our geographical hierarchy. The crucial point is to define the polygons that tell the map which part of its area should be sensitive to which link. Creating these polygons manually is awsome. Since our geograpgical hierarchy is permanently actualyzised, also the polygons for all clickable maps have to be kept up to date. Fortunaly, it should be possible to let all this work do the machine.

Algorithm
Locations with geographical coordinates that have no sublocations are called atomic. We can divide the earth's surface into so called Voronoi facets around atomic locations. Each facet has one atomic location as center. Voronoi facets do not do not overlap each other and they cover the whole surface of the earth.

Calculating Voronoi facets on a sphere might be hard, but dividing a plane into Voronoi facets is a standard task with well elaborated algorithms. "qhull" is a free command line tool for doing this task. So, we first make a global Mercator projection of all atomic locations into a plane. In order to reflect the endlesness of the sphere, the map is repeated periodically in longitudinal direction. Then we apply the voronoi algorithm and cut out the area between -180° and 180°. The Voronoi polygons are stored in a DB table.

Once we have the facets for atomic locations, we easily can calculate the polygons for all other locations by simply unifying all polygons of their sublocations.

In order to find a suitable map cropping, we need to know the area that needs to be displayed on the map for each location. This is not the same as its Voronoi facets since the latter ones may reach far into the ocean. The needed mapping area is better described by the so called convex hull of all the location's sublocations. The convex hull is defined as the smallest convex polygon that includes all points that belong to a location. Calculating the convex hull in a plane is simple, but we are on a sphere. This time, the Mercator projection is not applicable. We better use a Lambert Azimutal projection since it only has one singularity, i.e. the point opposite the projection center. The projection ceter should also be the center of the convex hull. I don't know if there is a more elegant way, but an iterative procedure always leads to good results. We store the convex hull and the projetion center for each location in the DB.

The maps are made by "mapnik". The below demos are just made from testing data from the mapnik tutorial. The real maps should be made from OSM, of course.

Demos
The projection, cropping, and underlaying polygons of this maps have been made automatically without any human help. All needed data have been retrieved from our location database. The border lines are from sample data from the mapnik tutorial.

Germany
The extension of the map is obviously too large. This has been caused by the inappropriate radius=600km entry for Germany in the locDB. We see that the sensitive areas for de:Schleswig-Holstein and de:Niedersachsen go far into the Northsea. This is because the next neighbours of locations next to the coast are far away. The area in between is divided into the neighbouring Voronoi facets. The borders to The Netherlands, Belgium, Luxembourg, Switzerland and Austria are quite well fit, while there are some inaccuracies along the borders to the Czech Republic, Poland and specially Denmark. The more locations we have in an area, the more exact the results.

Central Europe
The polygon for Slovakia is quite bad. There are not enough locations for satisfying results.

Europe
The difference of the used Lambert azimutal projection and the Mercator projection used by Google maps and OSM are significant. Svalbard, for example, appears in its correct size. The Lambert azimutal projection preserves the area.

At the time of map rendering, Sweden has had a radius of 2000 km in our locDB. This is the reason for the far northern extent of the map. The Azores are part of Portugal in our locDB. That's why the map reaches far towards west.

We don't have any locations in Greenland. If there were any, Northern Europe would not extend so far towards west. Also, note the remarkalbe extend of Southern Europe towards the northern Atlantic. The next neigbours of the Azores are far away and the Azores belong to Southern Europe. At the other hand, Southern Europe seperates well against North-Africa, Turkey, Central Europe, Western Europe and acceptable against Eastern Europe.

Note the tiny regions "Eifel" and "Verdichtungsraum Aachen-Heerlen" (did you find them?). This is very particular for our geographical hierarchy, and for sure not found elsewhere.