[OSM-talk] simplifying mapnik layout definition

Rob rob at coolbegin.com
Tue May 27 22:03:46 BST 2008


2008/5/27 Tom Hughes <tom at compton.nu>:
> Martijn van Oosterhout wrote:
>> On Tue, May 27, 2008 at 7:29 PM, Robert (Jamie) Munro <rjmunro at arjam.net> wrote:
>>> Here's some working code that simplifies the file:
>>> sed "s/(\[bridge] = 'yes' or \[bridge]='true')/isBridge/g" osm.xml
>>>
>>> And the reverse:
>>> sed "s/isBridge/([bridge] = 'yes' or [bridge]='true')/g"
>>
>> I'm thinking of teaching osm2pgsql and Mapnik about booleans at some
>> point so that all the comparisons against yes/no/1/0/on/off/etc all
>> get done during import. For this to work Mapnik needs to be able to
>> handle comparing different types, I sent a patch to Jon to do this so
>> hopefully at some point we can simplify at least that portion...
>
> I've already taught mapnik about booleans - if you have a postgresql
> boolean column called 'bridge' then you can use '[bridge]' or 'not
> [bridge]' as filters.
>

cool would be class based renderstyle implementation
and integrate the scaledominators in a simpler way..
and have the casings into the same class definition, with some kind of
rendering level

<Class name="Road">
 <Class name="RoadTop" Level="100" width='8' color='#a37b48'>
      <LineSymbolizer>
        <CssParameter name="stroke">[color]</CssParameter>
        <CssParameter name="stroke-width">[width]</CssParameter>
        <CssParameter name="stroke-linejoin">round</CssParameter>
        <CssParameter name="stroke-linecap">round</CssParameter>
      </LineSymbolizer>
 </Class>
 <Class name="RoadCasing" Level="0" width='6' color='#a37b48'>
      <LineSymbolizer>
        <CssParameter name="stroke">[color]</CssParameter>
        <CssParameter name="stroke-width">[width+2]</CssParameter>
        <CssParameter name="stroke-linejoin">round</CssParameter>
        <CssParameter name="stroke-linecap">round</CssParameter>
      </LineSymbolizer>
 </Class>
</Class>

and then a primary and secondary road could look like:

<Style name="minor-roads">
   <Rule class="Road">
      <Filter>([highway] = 'primary' or [highway] = 'primary_link')
and not [tunnel]='yes'</Filter>
      <RenderStyle MaxScale='150000' MinScale='75000' width='8' class="Road"/>
      <RenderStyle MaxScale='75000' MinScale='5000' width='10' class="Road"/>
    </Rule>
 <Rule>
      <Filter>([highway] = 'secondary' or [highway] =
'secondary_link') and not ([tunnel]='yes' or [tunnel]='true')</Filter>
      <RenderStyle MaxScale='150000' MinScale='75000' width='8'
color='red' class="Road"/>
      <!-- let's make a dash line -->
      <RenderStyle MaxScale='75000' MinScale='5000' width='10'
color='red' class="Road">
       <Class name="RoadTop">
         <LineSymbolizer>
             <CssParameter name="stroke-dasharray">4,2</CssParameter>
          <LineSymbolizer>
        </Class>
      </RenderStyle>
    </Rule>
</Style>

we can override the width and color variables in the RenderStyle
i know this sample is not complete in anyway, but i hope the point is
clear ;) shoot on it




More information about the talk mailing list