<?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-2015, 2018, 2019, 2020, 2021, 2022, 2023 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>
      <if k="barrier" v="block"     > <unset/> </if>
      <if k="barrier" v="chicane"   > <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>
      <if k="barrier" v="toll_booth"> <unset/> </if>

      <!-- Barrier types -->

      <if k="barrier" v="wall">  <set v="no_access"/> </if>
      <if k="barrier" v="fence"> <set v="no_access"/> </if>
      <if k="barrier" v="hedge"> <set v="no_access"/> </if>

      <if k="barrier" v="no_access">
        <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"/>

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

      <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="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="chain">       <set v="not_wheeled"/> </if>
      <if k="barrier" v="log">         <set v="not_wheeled"/> </if>
      <if k="barrier" v="tree">        <set v="not_wheeled"/> </if>
      <if k="barrier" v="fallen_tree"> <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="cycle_barrier">
        <output k="bicycle" v="no"/>
        <set v="no_motorised"/>
      </if>

      <if k="barrier" v="motorcycle_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="post">        <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>


      <!-- Normalisation of access tag keys -->

      <ifnot k="foot"      > <if k="access:foot"      > <set k="foot"      /> </if> </ifnot>
      <ifnot k="horse"     > <if k="access:horse"     > <set k="horse"     /> </if> </ifnot>
      <ifnot k="wheelchair"> <if k="access:wheelchair"> <set k="wheelchair"/> </if> </ifnot>
      <ifnot k="bicycle"   > <if k="access:bicycle"   > <set k="bicycle"   /> </if> </ifnot>
      <ifnot k="moped"     > <if k="access:moped"     > <set k="moped"     /> </if> </ifnot>
      <ifnot k="motorcycle"> <if k="access:motorcycle"> <set k="motorcycle"/> </if> </ifnot>
      <ifnot k="motorcar"  > <if k="access:motorcar"  > <set k="motorcar"  /> </if> </ifnot>
      <ifnot k="goods"     > <if k="access:goods"     > <set k="goods"     /> </if> </ifnot>
      <ifnot k="hgv"       > <if k="access:hgv"       > <set k="hgv"       /> </if> </ifnot>
      <ifnot k="psv"       > <if k="access:psv"       > <set k="psv"       /> </if> </ifnot>

      <!-- Normalisation of access tag values -->

      <if v="designated"  > <set v="yes"/> </if>
      <if v="permissive"  > <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="destination" > <set v="no"/> </if>
      <if v="permit"      > <set v="no"/> </if>
      <if v="customer"    > <set v="no"/> </if>
      <if v="customers"   > <set v="no"/> </if>
      <if v="delivery"    > <set v="no"/> </if>
      <if v="residents"   > <set v="no"/> </if>
      <if v="private"     > <set v="no"/> </if>

      <if v="unsuitable"  > <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"/>

          <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>

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

        </ifnot>

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

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

    <!-- 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. -->

    <ifnot k="highway">

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

      <if k="public_transport" v="platform">
        <set k="highway" v="platform"/>
      </if>

      <if k="railway" v="platform">
        <set k="highway" v="platform"/>
      </if>

    </ifnot>

    <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="platform">
        <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"/>

        <!-- Heuristics for ferries - only a common vehicle type within its category -->

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

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

        <if k="motorcycle" v="yes">
          <output k="moped" v="yes"/>
        </if>

        <if k="motorcar" v="yes">
          <output k="moped" v="yes"/>
          <output k="motorcycle" v="yes"/>
        </if>

        <if k="goods" v="yes">
          <output k="moped" v="yes"/>
          <output k="motorcycle" v="yes"/>
          <output k="motorcar" v="yes"/>
        </if>

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

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

        <!-- Heuristics for ferries - tag groups instead of individual vehicle types -->

        <if k="access" v="yes">
          <output k="foot" v="yes"/>
          <output k="horse" v="yes"/>
          <output k="wheelchair" v="yes"/>
          <set k="vehicle" v="yes"/>
        </if>

        <if k="vehicle" v="yes">
          <output k="bicycle" v="yes"/>
          <set k="motor_vehicle" v="yes"/>
        </if>

        <if k="motor_vehicle" 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"/>
        </if>

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

      <!-- Unrecognised highway type -->

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

      <!-- Normalisation of access tag keys -->

      <ifnot k="foot"      > <if k="access:foot"      > <set k="foot"      /> </if> </ifnot>
      <ifnot k="horse"     > <if k="access:horse"     > <set k="horse"     /> </if> </ifnot>
      <ifnot k="wheelchair"> <if k="access:wheelchair"> <set k="wheelchair"/> </if> </ifnot>
      <ifnot k="bicycle"   > <if k="access:bicycle"   > <set k="bicycle"   /> </if> </ifnot>
      <ifnot k="moped"     > <if k="access:moped"     > <set k="moped"     /> </if> </ifnot>
      <ifnot k="motorcycle"> <if k="access:motorcycle"> <set k="motorcycle"/> </if> </ifnot>
      <ifnot k="motorcar"  > <if k="access:motorcar"  > <set k="motorcar"  /> </if> </ifnot>
      <ifnot k="goods"     > <if k="access:goods"     > <set k="goods"     /> </if> </ifnot>
      <ifnot k="hgv"       > <if k="access:hgv"       > <set k="hgv"       /> </if> </ifnot>
      <ifnot k="psv"       > <if k="access:psv"       > <set k="psv"       /> </if> </ifnot>

      <!-- Normalisation of access tag values -->

      <if v="designated"  > <set v="yes"/> </if>
      <if v="permissive"  > <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="destination" > <set v="no"/> </if>
      <if v="permit"      > <set v="no"/> </if>
      <if v="customer"    > <set v="no"/> </if>
      <if v="customers"   > <set v="no"/> </if>
      <if v="delivery"    > <set v="no"/> </if>
      <if v="residents"   > <set v="no"/> </if>
      <if v="private"     > <set v="no"/> </if>

      <if v="unsuitable"  > <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="bus">
            <set v="psv" />
          </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" -->

      <!-- 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_highway">
          <set v="byway_open_to_all_traffic"/>
        </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 2020-11-15 -->

        <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 k="footway" v="crossing"> <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 2020-11-15 -->

        <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 k="sidewalk" v="separate"> <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 2020-11-15 -->

        <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_lane"> <output k="bicycle" v="yes"/> </if>
        <if k="cycleway" v="opposite">    <output k="bicycle" v="yes"/> </if>
        <if k="cycleway" v="crossing">    <output k="bicycle" v="yes"/> </if>
        <if k="cycleway" v="yes">         <output k="bicycle" v="yes"/> </if>

        <if k="cycleway" v="opposite_lane">
          <output k="bicycle" v="yes"/>
          <output k="cyclebothways" v="yes"/>
        </if>

        <if k="cycleway" v="opposite_track">
          <output k="bicycle" v="yes"/>
          <output k="cyclebothways" v="yes"/>
        </if>

        <if k="cycleway" v="opposite">
          <output k="bicycle" v="yes"/>
          <output k="cyclebothways" v="yes"/>
        </if>
      </if>

      <if k="oneway:bicycle" v="no">
        <output k="bicycle" v="yes"/>
        <output k="cyclebothways" v="yes"/>
      </if>

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

      <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>

      <!-- Normalisation of property tags -->

      <if k="surface">

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

        <if k="surface" v="paved">                 <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="asphalt">               <set k="paved" v="yes"/> <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="paving_stones">         <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="unhewn_cobblestone">    <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="metal">                 <set k="paved" v="yes"/> <unset k="surface"/> </if>
        <if k="surface" v="wood">                  <set k="paved" v="yes"/> <unset k="surface"/> </if>

        <if k="surface" v="unpaved">               <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="compacted">             <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="gravel">                <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="pebblestone">           <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="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="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="mud">                   <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="woodchips">             <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="snow">                  <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="ice">                   <set k="paved" v="no"/>  <unset k="surface"/> </if>
        <if k="surface" v="salt">                  <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="metaled">      <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="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>
      <ifnot k="ref" > <if k="prow_ref" > <output k="ref"/> </if> </ifnot>

      <!-- Output the area tag -->

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

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

    <!-- Special case for motor vehicles -->

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

      <output k="bridge"        v="no"/>
      <output k="tunnel"        v="no"/>
      <output k="footroute"     v="no"/>
      <output k="bicycleroute"  v="no"/>
      <output k="cyclebothways" v="no"/>
    </if>

  </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>

    <!-- Special case for motor vehicles -->

    <if>
      <output k="footroute"    v="no"/>
      <output k="bicycleroute" v="no"/>
    </if>

  </relation>

</routino-tagging>
