<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#
# Routino generic router Perl script
#
# Part of the Routino routing software.
#
# This file Copyright 2008,2009 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
#

# Use the directory paths script
require "paths.pl";

# Use the perl Time::HiRes module
use Time::HiRes qw(gettimeofday tv_interval);

$t0 = [gettimeofday];

# Filename prefix

# EDIT THIS if the database files were created with the --prefix option.
$data_prefix="";

# Parameters for the router generated using "--help-profile-pl")

################################################################################

# Transport types
@router_transports=('foot', 'horse', 'wheelchair', 'bicycle', 'moped', 'motorbike', 'motorcar', 'goods', 'hgv', 'psv');

# Highway types
@router_highways=('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'unclassified', 'residential', 'service', 'track', 'cycleway', 'path', 'steps');

# Property types
@router_properties=('paved', 'multilane', 'bridge', 'tunnel');

# Restriction types
@router_restrictions=('oneway', 'weight', 'height', 'width', 'length');

# Allowed highways
%router_profile_highway=(
      motorway =&gt; { foot =&gt;   0,  horse =&gt;   0,  wheelchair =&gt;   0,  bicycle =&gt;   0,  moped =&gt;   0,  motorbike =&gt; 100,  motorcar =&gt; 100,  goods =&gt; 100,  hgv =&gt; 100,  psv =&gt; 100},
         trunk =&gt; { foot =&gt;  40,  horse =&gt;  25,  wheelchair =&gt;  40,  bicycle =&gt;  30,  moped =&gt;  90,  motorbike =&gt; 100,  motorcar =&gt; 100,  goods =&gt; 100,  hgv =&gt; 100,  psv =&gt; 100},
       primary =&gt; { foot =&gt;  50,  horse =&gt;  50,  wheelchair =&gt;  50,  bicycle =&gt;  70,  moped =&gt; 100,  motorbike =&gt;  90,  motorcar =&gt;  90,  goods =&gt;  90,  hgv =&gt;  90,  psv =&gt;  90},
     secondary =&gt; { foot =&gt;  60,  horse =&gt;  50,  wheelchair =&gt;  60,  bicycle =&gt;  80,  moped =&gt;  90,  motorbike =&gt;  80,  motorcar =&gt;  80,  goods =&gt;  80,  hgv =&gt;  80,  psv =&gt;  80},
      tertiary =&gt; { foot =&gt;  70,  horse =&gt;  75,  wheelchair =&gt;  70,  bicycle =&gt;  90,  moped =&gt;  80,  motorbike =&gt;  70,  motorcar =&gt;  70,  goods =&gt;  70,  hgv =&gt;  70,  psv =&gt;  70},
  unclassified =&gt; { foot =&gt;  80,  horse =&gt;  75,  wheelchair =&gt;  80,  bicycle =&gt;  90,  moped =&gt;  70,  motorbike =&gt;  60,  motorcar =&gt;  60,  goods =&gt;  60,  hgv =&gt;  60,  psv =&gt;  60},
   residential =&gt; { foot =&gt;  90,  horse =&gt;  75,  wheelchair =&gt;  90,  bicycle =&gt;  90,  moped =&gt;  60,  motorbike =&gt;  50,  motorcar =&gt;  50,  goods =&gt;  50,  hgv =&gt;  50,  psv =&gt;  50},
       service =&gt; { foot =&gt;  90,  horse =&gt;  75,  wheelchair =&gt;  90,  bicycle =&gt;  90,  moped =&gt;  80,  motorbike =&gt;  80,  motorcar =&gt;  80,  goods =&gt;  80,  hgv =&gt;  80,  psv =&gt;  80},
         track =&gt; { foot =&gt;  95,  horse =&gt; 100,  wheelchair =&gt;  95,  bicycle =&gt;  90,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0},
      cycleway =&gt; { foot =&gt;  95,  horse =&gt;  90,  wheelchair =&gt;  95,  bicycle =&gt; 100,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0},
          path =&gt; { foot =&gt; 100,  horse =&gt; 100,  wheelchair =&gt; 100,  bicycle =&gt;  90,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0},
         steps =&gt; { foot =&gt;  80,  horse =&gt;   0,  wheelchair =&gt;   0,  bicycle =&gt;   0,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0}
   );

# Speed limits
%router_profile_speed=(
      motorway =&gt; { foot =&gt;   0,  horse =&gt;   0,  wheelchair =&gt;   0,  bicycle =&gt;   0,  moped =&gt;  48,  motorbike =&gt; 112,  motorcar =&gt; 112,  goods =&gt;  96,  hgv =&gt;  89,  psv =&gt;  89},
         trunk =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  48,  motorbike =&gt;  96,  motorcar =&gt;  96,  goods =&gt;  96,  hgv =&gt;  80,  psv =&gt;  80},
       primary =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  48,  motorbike =&gt;  96,  motorcar =&gt;  96,  goods =&gt;  96,  hgv =&gt;  80,  psv =&gt;  80},
     secondary =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  48,  motorbike =&gt;  88,  motorcar =&gt;  88,  goods =&gt;  88,  hgv =&gt;  80,  psv =&gt;  80},
      tertiary =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  48,  motorbike =&gt;  80,  motorcar =&gt;  80,  goods =&gt;  80,  hgv =&gt;  80,  psv =&gt;  80},
  unclassified =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  48,  motorbike =&gt;  64,  motorcar =&gt;  64,  goods =&gt;  64,  hgv =&gt;  64,  psv =&gt;  64},
   residential =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  48,  motorbike =&gt;  48,  motorcar =&gt;  48,  goods =&gt;  48,  hgv =&gt;  48,  psv =&gt;  48},
       service =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  32,  motorbike =&gt;  32,  motorcar =&gt;  32,  goods =&gt;  32,  hgv =&gt;  32,  psv =&gt;  32},
         track =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;  16,  motorbike =&gt;  16,  motorcar =&gt;  16,  goods =&gt;  16,  hgv =&gt;  16,  psv =&gt;  16},
      cycleway =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0},
          path =&gt; { foot =&gt;   4,  horse =&gt;   8,  wheelchair =&gt;   4,  bicycle =&gt;  20,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0},
         steps =&gt; { foot =&gt;   4,  horse =&gt;   0,  wheelchair =&gt;   4,  bicycle =&gt;   0,  moped =&gt;   0,  motorbike =&gt;   0,  motorcar =&gt;   0,  goods =&gt;   0,  hgv =&gt;   0,  psv =&gt;   0}
   );

# Highway properties
%router_profile_property=(
         paved =&gt; { foot =&gt;  50,  horse =&gt;  20,  wheelchair =&gt;  90,  bicycle =&gt;  50,  moped =&gt; 100,  motorbike =&gt; 100,  motorcar =&gt; 100,  goods =&gt; 100,  hgv =&gt; 100,  psv =&gt; 100},
     multilane =&gt; { foot =&gt;  25,  horse =&gt;  25,  wheelchair =&gt;  25,  bicycle =&gt;  25,  moped =&gt;  25,  motorbike =&gt;  75,  motorcar =&gt;  75,  goods =&gt;  75,  hgv =&gt;  75,  psv =&gt;  75},
        bridge =&gt; { foot =&gt;  50,  horse =&gt;  50,  wheelchair =&gt;  50,  bicycle =&gt;  50,  moped =&gt;  50,  motorbike =&gt;  50,  motorcar =&gt;  50,  goods =&gt;  50,  hgv =&gt;  50,  psv =&gt;  50},
        tunnel =&gt; { foot =&gt;  50,  horse =&gt;  50,  wheelchair =&gt;  50,  bicycle =&gt;  50,  moped =&gt;  50,  motorbike =&gt;  50,  motorcar =&gt;  50,  goods =&gt;  50,  hgv =&gt;  50,  psv =&gt;  50}
   );

# Restrictions
%router_profile_restrictions=(
        oneway =&gt; { foot =&gt;    0,  horse =&gt;    1,  wheelchair =&gt;    0,  bicycle =&gt;    1,  moped =&gt;    1,  motorbike =&gt;    1,  motorcar =&gt;    1,  goods =&gt;    1,  hgv =&gt;    1,  psv =&gt;    1},
        weight =&gt; { foot =&gt;  0.0,  horse =&gt;  0.0,  wheelchair =&gt;  0.0,  bicycle =&gt;  0.0,  moped =&gt;  0.0,  motorbike =&gt;  0.0,  motorcar =&gt;  0.0,  goods =&gt;  5.0,  hgv =&gt; 10.0,  psv =&gt; 15.0},
        height =&gt; { foot =&gt;  0.0,  horse =&gt;  0.0,  wheelchair =&gt;  0.0,  bicycle =&gt;  0.0,  moped =&gt;  0.0,  motorbike =&gt;  0.0,  motorcar =&gt;  0.0,  goods =&gt;  2.5,  hgv =&gt;  3.0,  psv =&gt;  3.0},
         width =&gt; { foot =&gt;  0.0,  horse =&gt;  0.0,  wheelchair =&gt;  0.0,  bicycle =&gt;  0.0,  moped =&gt;  0.0,  motorbike =&gt;  0.0,  motorcar =&gt;  0.0,  goods =&gt;  2.0,  hgv =&gt;  2.5,  psv =&gt;  2.5},
        length =&gt; { foot =&gt;  0.0,  horse =&gt;  0.0,  wheelchair =&gt;  0.0,  bicycle =&gt;  0.0,  moped =&gt;  0.0,  motorbike =&gt;  0.0,  motorcar =&gt;  0.0,  goods =&gt;  5.0,  hgv =&gt;  6.0,  psv =&gt;  6.0}
   );

################################################################################


# Run the router

sub RunRouter
  {
   ($optimise,%params)=@_;

   # Combine all of the parameters together

   $params="--$optimise";

   foreach $key (keys %params)
     {
      $params.=" --$key=$params{$key}";
     }

   # Change directory

   mkdir $results_dir,0755 if(! -d $results_dir);
   chdir $results_dir;

   # Create a unique output directory

   chomp($uuid=`echo '$params' $$ | md5sum | cut -f1 '-d '`);

   mkdir $uuid;
   chmod 0775, $uuid;
   chdir $uuid;

   # Run the router

   $params.=" --dir=$data_dir" if($data_dir);
   $params.=" --prefix=$data_prefix" if($data_prefix);
   $params.=" --quiet";

   $message=`$bin_dir/router $params 2&gt;&amp;1`;

   (undef,undef,$cuser,$csystem) = times;
   $time=sprintf "time: %.3f CPU / %.3f elapsed",$cuser+$csystem,tv_interval($t0);

   if(-f "$optimise.txt")
     {
      $result=`tail -1 $optimise.txt`;
      @result=split(/\t/,$result);
      $result = $result[4]." , ".$result[5];
     }

   # Return the results

   return($uuid,$time,$result,$message);
  }

1;
</pre></body></html>