[OSM-dev] Rendering Route Relations with Mapnik

Jon Burgess jburgess777 at gmail.com
Sun Jul 17 01:18:17 BST 2011


On Sat, 2011-07-16 at 19:38 +0100, Graham Jones wrote:
> I would like to render some route relations with mapnik (e.g.
> route="hiking" relations that link multiple ways), using a 'standard'
> postgresql database created by osm2pgsql if possible.
> 
> 
> I see that osm2pgsql using the "default" default.style file creates a
> 'route' column in planet_osm_line, but I am not sure if this is
> created from route relations, or just ways tagged with 'route'?

The ways referenced by the route=hiking relation should be present in
the line table if you've used the default osm2pgsql style, e.g.

gis=> select osm_id,count(*),route from planet_osm_line  where osm_id < 0 and route='hiking' group by osm_id,route;
 osm_id  | count | route  
---------+-------+--------
  -68615 |     9 | hiking
 -140533 |     8 | hiking
(2 rows)

The output above is from a database containing the Geofabrik
essex.osm.bz2 extract. The osm_id column corresponds to the negative of
the relation ID, the original hiking route relations for this data are:

http://www.openstreetmap.org/browse/relation/68615
http://www.openstreetmap.org/browse/relation/140533

> There is another table planet_osm_rels, which looks like it might be
> the thing I need, but I am not sure how to write the SQL to extract
> the geometries of all of the ways in the relation for rendering.
> Arrays within tables look daunting...
> 
It should be possible to render these relations by creating a Mapnik
rule with a filter set to: [route]='hiking' applied to a datasource
reading from planet_osm_line. The standard OSM mapnik osm.xml renders
[route]='ferry' and this should be simple to change to [route]='hiking'.

  Jon






More information about the dev mailing list