HikingBikingMaps/PathRendering

From OpenStreetMap Wiki
Jump to: navigation, search

This page gives technical details for implementing the path rendering described at HikingBikingMaps.

Pregarten.png

This image shows, how some of the possible tagging variations of paths are rendered. In the valley going south from the middle of the top of the image, you can see a path tagged as foot=designated and bicycle=yes, but without a surface tag (dashed blue-salmon). In the city center of Pregarten, slightly to the south-east of the image center, you can see renderings of paths with surface=paved, foot=designated, and bicycle=designated. The blue dotted cycleway across the bridge in the south-west is a traditional highway=cycleway.

No layer definition has to be changed or added to implement this. But the following is a tricky combination of additions to and replacements of styles. These rules should be inserted directly before the rule with <Filter>[highway] = 'footway' and not ([tunnel]='yes' or [tunnel]='true')</Filter> in the extremely long style <Style name="minor-roads-fill">:

    <Rule>
        <Filter>[highway]='path' and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">#000</CssParameter>
            <CssParameter name="stroke-width">0.5</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">0.5</CssParameter>
        </LineSymbolizer>
    </Rule>
    <Rule>
        <Filter>[highway]='path' and ([bicycle]='designated') and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">blue</CssParameter>
            <CssParameter name="stroke-width">1.0</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
        </LineSymbolizer>
    </Rule>
    <Rule>
        <Filter>[highway]='path' and ([foot]='designated') and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">salmon</CssParameter>
            <CssParameter name="stroke-width">1.0</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
        </LineSymbolizer>
    </Rule>
    <Rule>
        <Filter>[highway]='path' and ([bicycle]='yes') and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">blue</CssParameter>
            <CssParameter name="stroke-width">1.0</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
            <CssParameter name="stroke-dasharray">0.0,5.5,4.0,0.5</CssParameter>
        </LineSymbolizer>
    </Rule>
    <Rule>
        <Filter>[highway]='path' and ([foot]='yes') and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">salmon</CssParameter>
            <CssParameter name="stroke-width">1.0</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
            <CssParameter name="stroke-dasharray">5,5</CssParameter>
        </LineSymbolizer>
    </Rule>
    <Rule>
        <Filter>[highway]='path' and ([foot]='designated' and [bicycle]='designated') and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">blue</CssParameter>
            <CssParameter name="stroke-width">1.0</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
            <CssParameter name="stroke-dasharray">0.0,5.5,4.0,0.5</CssParameter>
        </LineSymbolizer>
    </Rule>
    <Rule>
        <Filter>([horse]='designated' or [horse]='yes') and not ([tunnel]='yes' or [tunnel]='true') and not [surface]='paved'</Filter>
        <MaxScaleDenominator>100000</MaxScaleDenominator>
        <LineSymbolizer>
            <CssParameter name="stroke">green</CssParameter>
            <CssParameter name="stroke-width">1.0</CssParameter>
            <CssParameter name="stroke-linejoin">round</CssParameter>
            <CssParameter name="stroke-linecap">round</CssParameter>
            <CssParameter name="stroke-opacity">1</CssParameter>
            <CssParameter name="stroke-dasharray">0,3.3,3.3,6.6</CssParameter>
        </LineSymbolizer>
    </Rule>

The following block belongs just after the rule <Filter>[highway] = 'cycleway' and not ([tunnel]='yes' or [tunnel]='true')</Filter> in the same style (it overwrites every second salmon dot):

    <Rule>
      <Filter>[highway]='path' and [surface]='paved' and (([foot]='designated' or [foot]='yes') and ([bicycle]='designated' or [bicycle]='yes')) and not ([tunnel]='yes' or [tunnel]='true')</Filter>
      <MaxScaleDenominator>100000</MaxScaleDenominator>
      <LineSymbolizer>
        <CssParameter name="stroke">blue</CssParameter>
        <CssParameter name="stroke-width">1.5</CssParameter>
        <CssParameter name="stroke-dasharray">0,4,1,3</CssParameter>
        <CssParameter name="stroke-linejoin">round</CssParameter>
        <CssParameter name="stroke-linecap">round</CssParameter>
      </LineSymbolizer>
    </Rule>

Finally, two Filter elements have to be replaced. The first replaces <Filter>[highway] = 'footway' and not ([tunnel]='yes' or [tunnel]='true')</Filter>:

      <Filter>([highway] = 'footway' or ([highway]='path' and ([foot]='designated' or [foot]='yes') and [surface]='paved')) and not ([tunnel]='yes' or [tunnel]='true')</Filter>

and the second replaces <Filter>[highway] = 'cycleway' and not ([tunnel]='yes' or [tunnel]='true')</Filter>:

      <Filter>([highway] = 'cycleway' or ([highway]='path' and ([bicycle]='designated' or [bicycle]='yes') and [surface]='paved' and [foot]<>'designated' and [foot]<>'yes')) and not ([tunnel]='yes' or [tunnel]='true')</Filter>