[Talk-us] Highway Shield Rendering

Phil! Gold phil_g at pobox.com
Wed Apr 4 17:02:59 BST 2012


* Josh Doe <josh at joshdoe.com> [2012-04-04 08:55 -0400]:
> Is this something that could be used in a Carto stylesheet, or does it
> use special syntax only supported by XML?

I'm not sure, because I don't really know Carto.  Most of the magic comes
from two places: first, there are PostgreSQL functions that take a way ID
and return a string that gives the path to the shield for that way;
second, there's the path expression syntax added to Mapnik2 that lets you
use database fields in image filenames.  If you can represent both of
those in Carto, you don't need to touch an XML stylesheet.

Just for reference, here's a relevant extract from the XML we're using:

    <Style name="roads-text-ref">
        <Rule>
            <Filter>[highway] = 'motorway' and [route_shield] <> ''</Filter>
            &maxscale_zoom13;
            &minscale_zoom18;
            <ShieldSymbolizer file="&shields;/[route_shield].png" minimum-distance="30" no-text="true" placement="line" spacing="640" fontset-name="book-fonts" size="10" fill="white">null</ShieldSymbolizer>
        </Rule>
        <!-- ... -->
    </Style>
    <Layer name="roads-text-ref" status="on" srs="&osm2pgsql_projection;">
        <StyleName>roads-text-ref</StyleName>
        <Datasource>
            <Parameter name="table">
                (SELECT way, highway, aeroway, ref, char_length(ref) as length,
                        CASE WHEN bridge IN ('yes','true','1') THEN 'yes'::text
                             ELSE bridge END AS bridge,
                        route_shield(osm_id) route_shield
                   FROM &prefix;_line
                   WHERE (highway IS NOT NULL OR aeroway IS NOT NULL)
                     AND ((ref IS NOT NULL AND char_length(ref) BETWEEN 1 AND 8) OR
                          route_refs(osm_id) IS NOT NULL)
                ) AS roads
            </Parameter>
            &datasource-settings;
        </Datasource>
    </Layer>

> I know it's not really relevant to this thread, but since you have a
> separate stylesheet from the standard OSM one, maybe you could reduce
> the prominence of standard highway labels on residential/unclassified
> highways:
> http://elrond.aperiodic.net/shields/?zoom=15&lat=38.78332&lon=-77.30564&layers=B0
> https://trac.openstreetmap.org/ticket/4183

Ooof.  I'm trying to limit the stylesheet changes to just what's needed to
put our shields on properly, but I can probably tweak the font settings on
those a little.  They do kind of need it.

-- 
...computer contrarian of the first order... / http://aperiodic.net/phil/
PGP: 026A27F2  print: D200 5BDB FC4B B24A 9248  9F7A 4322 2D22 026A 27F2
--- --
Like the ski resort full of girls hunting for husbands and husbands
hunting for girls, the situation is not as symmetrical as it might seem.
                       -- Alan MacKay
---- --- --



More information about the Talk-us mailing list