[OSM-dev] Rendering rivers in real width

Komяpa me at komzpa.net
Sat Feb 11 10:49:34 GMT 2012


> So, talking about Mapnik2, ist there a way fo a data-driven control
> of stroke-width in LineSymbolizer.

no. But you can always use SQL as ultimate scripting language for
mapnik, writing something like:


select
   ST_Buffer(way,
        coalesce((CASE WHEN (tags->'width') ~
E'^[[:digit:]]+([.][[:digit:]]+)?$' THEN CAST ((tags->'width') AS
FLOAT)
                       ELSE NULL END),
                      10)) as way
from planet_osm_line l
where waterway in
('river','canal','derelict_canal','stream','drain','ditch','wadi'))
and
          not exists (select way from planet_osm_polygon p where
                              p.waterway = l.waterway and
ST_Contains(l.way, p.way) and p.name = l.name)

Never tested the above query, there are things to enhance, e.g. a line
covered by more than one bounding polygon and the fact that linear
rivers should be covered by riverbank, not river polygon, but hope
that gives you a starting point at least. Of course you should use
polygonsymbolizer for this.

P.S. Please don't use 900913 as srid wherever, it's deprecated and
should be replaced with EPSG:3857


-- 
Darafei "Komяpa" Praliaskouski
OSM BY Team - http://openstreetmap.by/
xmpp:me at komzpa.net mailto:me at komzpa.net



More information about the dev mailing list