<?xml version="1.0" encoding="UTF-8" ?>

<!-- ============================================================
     An XML format file containing Routino tagging rules

     Part of the Routino routing software.
     ============================================================
     This file Copyright 2010-2013 Andrew M. Bishop

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU Affero General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.
     ============================================================ -->

<routino-tagging xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:noNamespaceSchemaLocation="http://www.routino.org/xml/routino-tagging.xsd">

  <!-- - - - - - - - - - - Node rules - - - - - - - - - - -->

  <node>

    <!-- Note: The default is that all transport types are allowed past a barrier;
               access must be specified to disallow each transport type. -->

    <if k="barrier">

      <!-- Not useful barrier types (too generic) -->

      <if k="barrier" v="gate"     > <unset/> </if>
      <if k="barrier" v="lift_gate"> <unset/> </if>

      <!-- Not useful barrier types (generic entrances through barrier ways) -->

      <if k="barrier" v="entrance"  > <unset/> </if>
      <if k="barrier" v="sally_port"> <unset/> </if>

      <!-- Barrier types -->

      <if k="barrier" v="kissing_gate">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="footgate">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="stile">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="v_stile">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="turnstile">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="squeeze">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="squeeze_stile">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="cycle_barrier">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="bicycle_barrier">
        <set v="foot_only"/>
      </if>

      <if k="barrier" v="foot_only">
        <output k="horse"      v="no"/>
        <output k="wheelchair" v="no"/>
        <output k="bicycle"    v="no"/>
        <output k="moped"      v="no"/>
        <output k="motorcycle" v="no"/>
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <unset k="barrier"/>
      </if>

      <if k="barrier" v="horse_stile">
        <set v="not_wheeled"/>
      </if>

      <if k="barrier" v="horse_jump">
        <set v="not_wheeled"/>
      </if>

      <if k="barrier" v="step_over">
        <set v="not_wheeled"/>
      </if>

      <if k="barrier" v="not_wheeled">
        <output k="wheelchair" v="no"/>
        <output k="bicycle"    v="no"/>
        <output k="moped"      v="no"/>
        <output k="motorcycle" v="no"/>
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <unset k="barrier"/>
      </if>

      <if k="barrier" v="horse_barrier">
        <set v="no_horse"/>
      </if>

      <if k="barrier" v="cattle_grid">
        <set v="no_horse"/>
      </if>

      <if k="barrier" v="no_horse">
        <output k="horse"      v="no"/>

        <unset k="barrier"/>
      </if>

      <if k="barrier" v="motorcyle_barrier">
        <set v="no_motorised"/>
      </if>

      <if k="barrier" v="no_motorised">
        <output k="moped"      v="no"/>
        <output k="motorcycle" v="no"/>
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <unset k="barrier"/>
      </if>

      <if k="barrier" v="bollard">
        <set v="not_2plus_wheels"/>
      </if>

      <if k="barrier" v="car_barrier">
        <set v="not_2plus_wheels"/>
      </if>

      <if k="barrier" v="car_trap">
        <set v="not_2plus_wheels"/>
      </if>

      <if k="barrier" v="not_2plus_wheels">
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <unset k="barrier"/>
      </if>

      <if k="barrier">
        <logerror message="ignoring it"/>
      </if>

    </if> <!-- k="barrier" -->

    <!-- Normalisation of access tags -->

    <if v="designated"  > <set v="yes"/> </if>
    <if v="permissive"  > <set v="yes"/> </if>
    <if v="destination" > <set v="yes"/> </if>
    <if v="true"        > <set v="yes"/> </if>
    <if v="public"      > <set v="yes"/> </if>
    <if v="official"    > <set v="yes"/> </if>
                           
    <if v="unsuitable"  > <set v="no"/> </if>
    <if v="private"     > <set v="no"/> </if>
    <if v="limited"     > <set v="no"/> </if>
    <if v="restricted"  > <set v="no"/> </if>
    <if v="agricultural"> <set v="no"/> </if>
    <if v="forestry"    > <set v="no"/> </if>

    <!-- Generic access permissions for all transport types (to override defaults) -->

    <if k="access">

      <ifnot k="access" v="yes">
        <output k="foot"       v="no"/>
        <output k="horse"      v="no"/>
        <output k="wheelchair" v="no"/>
        <output k="bicycle"    v="no"/>
        <output k="moped"      v="no"/>
        <output k="motorcycle" v="no"/>
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <ifnot k="access" v="no">
          <logerror k="access" message="using 'no'"/>
        </ifnot>
      </ifnot>

    </if> <!-- k="access" -->

    <!-- Generic access permissions for classes of transport types -->

    <if k="vehicle">

      <ifnot k="vehicle" v="yes">
        <output k="bicycle"    v="no"/>
        <output k="moped"      v="no"/>
        <output k="motorcycle" v="no"/>
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <ifnot k="vehicle" v="no">
          <logerror k="vehicle" message="using 'no'"/>
        </ifnot>
      </ifnot>

    </if> <!-- k="vehicle" -->

    <if k="motor_vehicle">

      <ifnot k="motor_vehicle" v="yes">
        <output k="moped"      v="no"/>
        <output k="motorcycle" v="no"/>
        <output k="motorcar"   v="no"/>
        <output k="goods"      v="no"/>
        <output k="hgv"        v="no"/>
        <output k="psv"        v="no"/>

        <ifnot k="motor_vehicle" v="no">
          <logerror k="motor_vehicle" message="using 'no'"/>
        </ifnot>
      </ifnot>

    </if> <!-- k="motor_vehicle" -->

    <!-- Specific access rules (to override the generic ones) -->

    <if k="foot"      > <output/> </if>
    <if k="horse"     > <output/> </if>
    <if k="wheelchair"> <output/> </if>
    <if k="bicycle"   > <output/> </if>
    <if k="moped"     > <output/> </if>
    <if k="motorcycle"> <output/> </if>
    <if k="motorcar"  > <output/> </if>
    <if k="goods"     > <output/> </if>
    <if k="hgv"       > <output/> </if>
    <if k="psv"       > <output/> </if>

    <!-- Mini-roundabouts  -->

    <if k="highway" v="mini_roundabout">
      <output k="roundabout" v="yes"/>
    </if>

    <if k="junction" v="roundabout">
      <output k="roundabout" v="yes"/>
    </if>

  </node>

  <!-- - - - - - - - - - - Way rules - - - - - - - - - - -->

  <way>

    <!-- Note: The default is that no transport type is allowed on any highway;
               access must be specified to allow each transport type. -->

    <if k="route" v="ferry">
      <set k="highway" v="ferry"/>
    </if>

    <if k="highway">

      <!-- Not useful highway types (future highways) -->

      <if k="highway" v="construction"> <unset/> </if>
      <if k="highway" v="planned"     > <unset/> </if>
      <if k="highway" v="proposed"    > <unset/> </if>

      <!-- Not useful highway types (previous highways) -->

      <if k="highway" v="no"          > <unset/> </if>
      <if k="highway" v="abandoned"   > <unset/> </if>
      <if k="highway" v="disused"     > <unset/> </if>

      <!-- Not useful highway types (limited use highways) -->

      <if k="highway" v="raceway"     > <unset/> </if>

      <!-- Highway types (includes default access and default properties) -->

      <if k="highway" v="motorway_link">
        <set v="motorway"/>
      </if>

      <if k="highway" v="motorway">
        <output k="highway"/>

        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>
        <output k="multilane"  v="yes"/>
        <output k="oneway"     v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="trunk_link">
        <set v="trunk"/>
      </if>

      <if k="highway" v="trunk">
        <output k="highway"/>

        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="primary_link">
        <set v="primary"/>
      </if>

      <if k="highway" v="primary">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="wheelchair" v="no"/>
        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="secondary_link">
        <set v="secondary"/>
      </if>

      <if k="highway" v="secondary">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="wheelchair" v="yes"/>
        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="tertiary_link">
        <set v="tertiary"/>
      </if>

      <if k="highway" v="tertiary">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="wheelchair" v="yes"/>
        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="minor">
        <set k="highway" v="unclassified"/>
      </if>

      <if k="highway" v="road">
        <set k="highway" v="unclassified"/>
      </if>

      <if k="highway" v="unclassified">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="wheelchair" v="yes"/>
        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="living_street">
        <set k="highway" v="residential"/>
      </if>

      <if k="highway" v="residential">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="wheelchair" v="yes"/>
        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="access">
        <set k="highway" v="service"/>
      </if>

      <if k="highway" v="services">
        <set k="highway" v="service"/>
      </if>

      <if k="highway" v="rest_area">
        <set k="highway" v="service"/>
      </if>

      <if k="highway" v="layby">
        <set k="highway" v="service"/>
      </if>

      <if k="highway" v="service">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="wheelchair" v="yes"/>
        <output k="bicycle"    v="yes"/>
        <output k="moped"      v="yes"/>
        <output k="motorcycle" v="yes"/>
        <output k="motorcar"   v="yes"/>
        <output k="goods"      v="yes"/>
        <output k="hgv"        v="yes"/>
        <output k="psv"        v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="byway">
        <set k="highway" v="track"/>
      </if>

      <if k="highway" v="unsurfaced">
        <set k="highway" v="track"/>
      </if>

      <if k="highway" v="unpaved">
        <set k="highway" v="track"/>
      </if>

      <if k="highway" v="track">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="horse"      v="yes"/>
        <output k="bicycle"    v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="tracktype" v="grade1">
        <output k="paved"      v="yes"/>
      </if>

      <if k="highway" v="cycleway">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="wheelchair" v="yes"/>
        <output k="bicycle"    v="yes"/>

        <output k="paved"      v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="footway">
        <set k="highway" v="path"/>
      </if>

      <if k="highway" v="bridleway">
        <set k="highway" v="path"/>

        <output k="horse"      v="yes"/>
        <output k="bicycle"    v="yes"/>
      </if>

      <if k="highway" v="pedestrian">
        <set k="highway" v="path"/>

        <output k="paved"      v="yes"/>
      </if>

      <if k="highway" v="walkway">
        <set k="highway"  v="path"/>

        <output k="paved"      v="yes"/>
      </if>

      <if k="highway" v="trail">
        <set k="highway"  v="path"/>

        <output k="paved"      v="no"/>
      </if>

      <if k="highway" v="path">
        <output k="highway"/>

        <output k="foot"       v="yes"/>
        <output k="wheelchair" v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="steps">
        <output k="highway"/>

        <output k="foot"       v="yes"/>

        <unset k="highway"/>
      </if>

      <if k="highway" v="ferry">
        <output k="highway"/>

        <unset k="highway"/>
      </if>

      <!-- Unrecognised highway type -->

      <if k="highway">
        <logerror message="ignoring it"/>
      </if>

      <!-- Normalisation of access tags -->

      <if v="designated"  > <set v="yes"/> </if>
      <if v="permissive"  > <set v="yes"/> </if>
      <if v="destination" > <set v="yes"/> </if>
      <if v="true"        > <set v="yes"/> </if>
      <if v="public"      > <set v="yes"/> </if>
      <if v="customers"   > <set v="yes"/> </if>
      <if v="customer"    > <set v="yes"/> </if>
      <if v="official"    > <set v="yes"/> </if>
                           
      <if v="unsuitable"  > <set v="no"/> </if>
      <if v="private"     > <set v="no"/> </if>
      <if v="limited"     > <set v="no"/> </if>
      <if v="restricted"  > <set v="no"/> </if>
      <if v="agricultural"> <set v="no"/> </if>
      <if v="forestry"    > <set v="no"/> </if>

      <!-- Generic access restrictions for all transport types (to subtract from highway specific defaults) -->

      <if k="access">

        <ifnot k="access" v="yes">
          <output k="foot"       v="no"/>
          <output k="horse"      v="no"/>
          <output k="wheelchair" v="no"/>
          <output k="bicycle"    v="no"/>
          <output k="moped"      v="no"/>
          <output k="motorcycle" v="no"/>
          <output k="motorcar"   v="no"/>
          <output k="goods"      v="no"/>
          <output k="hgv"        v="no"/>
          <output k="psv"        v="no"/>

          <if k="access" v="foot">
            <set k="foot" v="yes"/>
            <logerror k="access" message="using 'access' = 'no' ; 'foot' = 'yes'"/>
            <set k="access" v="no"/>
          </if>

          <if k="access" v="wheelchair">
            <set k="wheelchair" v="yes"/>
            <logerror k="access" message="using 'access' = 'no' ; 'wheelchair' = 'yes'"/>
            <set k="access" v="no"/>
          </if>

          <if k="access" v="motor_vehicle">
            <set k="motor_vehicle" v="yes"/>
            <logerror k="access" message="using 'access' = 'no' ; 'motor_vehicle' = 'yes'"/>
            <set k="access" v="no"/>
          </if>

          <if k="access" v="hgv">
            <set k="hgv" v="yes"/>
            <logerror k="access" message="using 'access' = 'no' ; 'hgv' = 'yes'"/>
            <set k="access" v="no"/>
          </if>

          <if k="access" v="psv">
            <set k="psv" v="yes"/>
            <logerror k="access" message="using 'access' = 'no' ; 'psv' = 'yes'"/>
            <set k="access" v="no"/>
          </if>

          <ifnot k="access" v="no">
            <logerror k="access" message="using 'no'"/>
          </ifnot>
        </ifnot>

      </if> <!-- k="access" -->

      <!-- Access restrictions for classes of transport types (to subtract from highway specific defaults) -->

      <if k="vehicle">

        <ifnot k="vehicle" v="yes">
          <output k="bicycle"    v="no"/>
          <output k="moped"      v="no"/>
          <output k="motorcycle" v="no"/>
          <output k="motorcar"   v="no"/>
          <output k="goods"      v="no"/>
          <output k="hgv"        v="no"/>
          <output k="psv"        v="no"/>

          <ifnot k="vehicle" v="no">
            <logerror k="vehicle" message="using 'no'"/>
          </ifnot>
        </ifnot>

      </if> <!-- k="vehicle" -->

      <if k="motor_vehicle">

        <ifnot k="motor_vehicle" v="yes">
          <output k="moped"      v="no"/>
          <output k="motorcycle" v="no"/>
          <output k="motorcar"   v="no"/>
          <output k="goods"      v="no"/>
          <output k="hgv"        v="no"/>
          <output k="psv"        v="no"/>

          <ifnot k="motor_vehicle" v="no">
            <logerror k="motor_vehicle" message="using 'no'"/>
          </ifnot>
        </ifnot>

      </if> <!-- k="motor_vehicle" -->

      <!-- Other access permissions (to add to highway specific defaults with generic restrictions) -->

      <if k="designation">

        <if k="designation" v="restricted_byway">
          <output k="foot"       v="yes"/>
          <output k="horse"      v="yes"/>
          <output k="wheelchair" v="yes"/>
          <output k="bicycle"    v="yes"/>

          <unset k="designation"/>
        </if>

        <if k="designation" v="public_byway">
          <set v="byway_open_to_all_traffic"/>
        </if>

        <if k="designation" v="byway">
          <set v="byway_open_to_all_traffic"/>
        </if>

        <if k="designation" v="byway_open_to_all_traffic">
          <output k="foot"       v="yes"/>
          <output k="horse"      v="yes"/>
          <output k="wheelchair" v="yes"/>
          <output k="bicycle"    v="yes"/>
          <output k="moped"      v="yes"/>
          <output k="motorcycle" v="yes"/>
          <output k="motorcar"   v="yes"/>

          <unset k="designation"/>
        </if>

        <if k="designation" v="permissive_bridleway">
          <set v="bridleway"/>
        </if>

        <if k="designation" v="public_bridleway">
          <set v="bridleway"/>
        </if>

        <if k="designation" v="bridleway">
          <output k="foot"       v="yes"/>
          <output k="horse"      v="yes"/>
          <output k="wheelchair" v="yes"/>
          <output k="bicycle"    v="yes"/>

          <unset k="designation"/>
        </if>

        <if k="designation" v="public_cycleway">
          <output k="foot"       v="yes"/>
          <output k="wheelchair" v="yes"/>
          <output k="bicycle"    v="yes"/>

          <unset k="designation"/>
        </if>

        <if k="designation" v="permissive_footpath">
          <set v="footpath"/>
        </if>

        <if k="designation" v="public_footpath">
          <set v="footpath"/>
        </if>

        <if k="designation" v="footpath">
          <output k="foot"       v="yes"/>
          <output k="wheelchair" v="yes"/>

          <unset k="designation"/>
        </if>

        <if k="designation">
          <logerror message="ignoring it"/>
        </if>

      </if> <!-- k="designation" -->

      <!-- Derived access rules (to override the generic ones) -->

      <if k="motorroad" v="yes">
        <output k="foot"       v="no"/>
        <output k="horse"      v="no"/>
        <output k="wheelchair" v="no"/>
        <output k="bicycle"    v="no"/>
        <output k="moped"      v="no"/>
      </if>

      <if k="footway">

        <!-- Tags from http://taginfo.openstreetmap.org/keys/footway#values on 2013-02-09 -->

        <if k="footway" v="sidewalk"> <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="footway" v="both">     <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="footway" v="left">     <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="footway" v="right">    <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="footway" v="yes">      <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
      </if>

      <if k="sidewalk">

        <!-- Tags from http://taginfo.openstreetmap.org/keys/sidewalk#values on 2013-02-09 -->

        <if k="sidewalk" v="both">    <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="sidewalk" v="left">    <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="sidewalk" v="right">   <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
        <if k="sidewalk" v="yes">     <output k="foot" v="yes"/> <output k="wheelchair" v="yes"/> </if>
      </if>

      <if k="cycleway">

        <!-- Tags from http://taginfo.openstreetmap.org/keys/cycleway#values on 2013-02-09 -->

        <if k="cycleway" v="lane">   <output k="bicycle" v="yes"/> </if>
        <if k="cycleway" v="track">  <output k="bicycle" v="yes"/> </if>
        <if k="cycleway" v="shared"> <output k="bicycle" v="yes"/> </if>
        <if k="cycleway" v="yes">    <output k="bicycle" v="yes"/> </if>
      </if>

      <!-- Specific access rules (to override the generic ones) -->

      <if k="foot"      > <output/> </if>
      <if k="horse"     > <output/> </if>
      <if k="wheelchair"> <output/> </if>
      <if k="bicycle"   > <output/> </if>
      <if k="moped"     > <output/> </if>
      <if k="motorcycle"> <output/> </if>
      <if k="motorcar"  > <output/> </if>
      <if k="goods"     > <output/> </if>
      <if k="hgv"       > <output/> </if>
      <if k="psv"       > <output/> </if>

      <!-- Normalisation of property tags -->

      <if k="surface">

        <!-- Tags from http://wiki.openstreetmap.org/wiki/Key:surface on 2012-11-21 -->

        <if k="surface" v="asphalt">               <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="cobblestone">           <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="cobblestone:flattened"> <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="compacted">             <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="concrete">              <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="concrete:lanes">        <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="concrete:plates">       <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="dirt">                  <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="earth">                 <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="fine_gravel">           <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="grass">                 <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="grass_paver">           <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="gravel">                <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="ground">                <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="metal">                 <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="mud">                   <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="paved">                 <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="paving_stones">         <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="paving_stones:20">      <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="paving_stones:30">      <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="pebblestone">           <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="sand">                  <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="unpaved">               <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="wood">                  <set k="paved" v="no"/>  <unset k="surface"/> </if>

        <!-- Other tags -->

        <if k="surface" v="sealed">       <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="cement">       <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="tarmac">       <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="tar_and_chip"> <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="metalled">     <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="bricks">       <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="brick">        <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="brick_weave">  <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="setts">        <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="sett">         <set k="paved" v="yes"/> <unset k="surface"/> </if>

        <if k="surface" v="unsealed">     <set k="paved" v="no"/> <unset k="surface"/> </if>
        <if k="surface" v="soil">         <set k="paved" v="no"/> <unset k="surface"/> </if>
        <if k="surface" v="stones">       <set k="paved" v="no"/> <unset k="surface"/> </if>
        <if k="surface" v="stone">        <set k="paved" v="no"/> <unset k="surface"/> </if>
        <if k="surface" v="pebbles">      <set k="paved" v="no"/> <unset k="surface"/> </if>
        <if k="surface" v="hardcore">     <set k="paved" v="no"/> <unset k="surface"/> </if>
        <if k="surface" v="bark">         <set k="paved" v="no"/> <unset k="surface"/> </if>

        <if k="surface">
          <logerror message="ignoring it"/>
        </if>

      </if> <!-- k="surface" -->

      <if k="bridge">
        <ifnot k="bridge" v="no">
          <set k="bridge" v="yes"/>
        </ifnot>
      </if>

      <if k="tunnel">
        <ifnot k="tunnel" v="no">
          <set k="tunnel" v="yes"/>
        </ifnot>
      </if>

      <if k="junction" v="roundabout">
        <output k="oneway"     v="yes"/>
        <output k="roundabout" v="yes"/>
      </if>

      <!-- Specific property rules (to override the default ones) -->

      <if k="paved"> <output/> </if>

      <if k="lanes"> <output/> </if>

      <if k="bridge"> <output/> </if>

      <if k="tunnel"> <output/> </if>

      <!-- Output the restriction tags -->

      <if k="oneway"> <output/> </if>

      <if k="maxspeed"> <output/> </if>

      <if k="maxweight"> <output/> </if>
      <if k="maxheight"> <output/> </if>
      <if k="maxwidth" > <output/> </if>
      <if k="maxlength"> <output/> </if>

      <!-- Output the name and reference tags -->

      <if k="name"> <output/> </if>
      <if k="ref" > <output/> </if>

      <!-- Output the area tag -->

      <if k="area"> <output/> </if>

    </if> <!-- k="highway" -->

  </way>

  <!-- - - - - - - - - - - Relation rules - - - - - - - - - - -->

  <relation>

    <if k="type">
      <output/>
    </if>

    <!-- Copy route relations -->

    <if k="route">

      <if k="route" v="foot">
        <output k="footroute" v="yes"/>
      </if>

      <if k="route" v="walking">
        <output k="footroute" v="yes"/>
      </if>

      <if k="route" v="hiking">
        <output k="footroute" v="yes"/>
      </if>

      <if k="route" v="foot;bicycle">
        <output k="footroute"    v="yes"/>
        <output k="bicycleroute" v="yes"/>
      </if>

      <if k="route" v="bicycle;foot">
        <output k="footroute"    v="yes"/>
        <output k="bicycleroute" v="yes"/>
      </if>

      <if k="route" v="bicycle">
        <output k="bicycleroute" v="yes"/>
      </if>

    </if> <!-- k="route" -->

    <!-- Pass through turn relations -->

    <if k="restriction">
      <output/>
    </if>

    <if k="except">

      <if k="except" v="bus"> <set v="psv"/> </if>

      <if k="except">
        <output/>
      </if>

    </if>

  </relation>

</routino-tagging>
