Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/web/www/routino/router.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 569 - (show annotations) (download) (as text)
Wed Dec 29 09:50:50 2010 UTC (14 years, 3 months ago) by amb
File MIME type: text/x-perl
File size: 7210 byte(s)
Added the uncontrolled (not auto-generated) files from routino-1.1.

1 #
2 # Routino generic router Perl script
3 #
4 # Part of the Routino routing software.
5 #
6 # This file Copyright 2008,2009 Andrew M. Bishop
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
17 #
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
21
22 # Use the directory paths script
23 require "paths.pl";
24
25 # Use the perl Time::HiRes module
26 use Time::HiRes qw(gettimeofday tv_interval);
27
28 $t0 = [gettimeofday];
29
30 # Filename prefix
31
32 # EDIT THIS if the database files were created with the --prefix option.
33 $data_prefix="";
34
35 # Parameters for the router generated using "--help-profile-pl")
36
37 # Transport types
38 @router_transports=('foot', 'bicycle', 'horse', 'motorbike', 'motorcar', 'goods', 'hgv', 'psv');
39
40 # Highway types
41 @router_highways=('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'unclassified', 'residential', 'service', 'track', 'path', 'bridleway', 'cycleway', 'footway');
42
43 # Restriction types
44 @router_restrictions=('oneway', 'weight', 'height', 'width', 'length');
45
46 # Allowed highways
47 %router_profile_highway=(
48 motorway => { foot => 0, bicycle => 0, horse => 0, motorbike => 100, motorcar => 100, goods => 100, hgv => 100, psv => 100},
49 trunk => { foot => 40, bicycle => 30, horse => 25, motorbike => 100, motorcar => 100, goods => 100, hgv => 100, psv => 100},
50 primary => { foot => 50, bicycle => 70, horse => 50, motorbike => 90, motorcar => 90, goods => 90, hgv => 90, psv => 90},
51 secondary => { foot => 60, bicycle => 80, horse => 50, motorbike => 80, motorcar => 80, goods => 80, hgv => 80, psv => 80},
52 tertiary => { foot => 70, bicycle => 90, horse => 75, motorbike => 70, motorcar => 70, goods => 70, hgv => 70, psv => 70},
53 unclassified => { foot => 80, bicycle => 90, horse => 75, motorbike => 60, motorcar => 60, goods => 60, hgv => 60, psv => 60},
54 residential => { foot => 90, bicycle => 90, horse => 75, motorbike => 50, motorcar => 50, goods => 50, hgv => 50, psv => 50},
55 service => { foot => 90, bicycle => 90, horse => 75, motorbike => 80, motorcar => 80, goods => 80, hgv => 80, psv => 80},
56 track => { foot => 95, bicycle => 90, horse => 100, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
57 path => { foot => 100, bicycle => 90, horse => 100, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
58 bridleway => { foot => 100, bicycle => 90, horse => 100, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
59 cycleway => { foot => 95, bicycle => 100, horse => 90, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
60 footway => { foot => 100, bicycle => 90, horse => 90, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0}
61 );
62
63 # Speed limits
64 %router_profile_speed=(
65 motorway => { foot => 0, bicycle => 0, horse => 0, motorbike => 112, motorcar => 112, goods => 96, hgv => 89, psv => 89},
66 trunk => { foot => 4, bicycle => 0, horse => 0, motorbike => 96, motorcar => 96, goods => 96, hgv => 80, psv => 80},
67 primary => { foot => 4, bicycle => 20, horse => 8, motorbike => 96, motorcar => 96, goods => 96, hgv => 80, psv => 80},
68 secondary => { foot => 4, bicycle => 20, horse => 8, motorbike => 88, motorcar => 88, goods => 88, hgv => 80, psv => 80},
69 tertiary => { foot => 4, bicycle => 20, horse => 8, motorbike => 80, motorcar => 80, goods => 80, hgv => 80, psv => 80},
70 unclassified => { foot => 4, bicycle => 20, horse => 8, motorbike => 64, motorcar => 64, goods => 64, hgv => 64, psv => 64},
71 residential => { foot => 4, bicycle => 20, horse => 8, motorbike => 48, motorcar => 48, goods => 48, hgv => 48, psv => 48},
72 service => { foot => 4, bicycle => 20, horse => 8, motorbike => 32, motorcar => 32, goods => 32, hgv => 32, psv => 32},
73 track => { foot => 4, bicycle => 20, horse => 8, motorbike => 16, motorcar => 16, goods => 16, hgv => 16, psv => 16},
74 path => { foot => 4, bicycle => 20, horse => 8, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
75 bridleway => { foot => 4, bicycle => 20, horse => 8, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
76 cycleway => { foot => 4, bicycle => 20, horse => 8, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0},
77 footway => { foot => 4, bicycle => 20, horse => 8, motorbike => 0, motorcar => 0, goods => 0, hgv => 0, psv => 0}
78 );
79
80 # Restrictions
81 %router_profile_restrictions=(
82 oneway => { foot => 0, bicycle => 1, horse => 1, motorbike => 1, motorcar => 1, goods => 1, hgv => 1, psv => 1},
83 weight => { foot => 0.0, bicycle => 0.0, horse => 0.0, motorbike => 0.0, motorcar => 0.0, goods => 5.0, hgv => 10.0, psv => 15.0},
84 height => { foot => 0.0, bicycle => 0.0, horse => 0.0, motorbike => 0.0, motorcar => 0.0, goods => 2.5, hgv => 3.0, psv => 3.0},
85 width => { foot => 0.0, bicycle => 0.0, horse => 0.0, motorbike => 0.0, motorcar => 0.0, goods => 2.0, hgv => 2.5, psv => 2.5},
86 length => { foot => 0.0, bicycle => 0.0, horse => 0.0, motorbike => 0.0, motorcar => 0.0, goods => 5.0, hgv => 6.0, psv => 6.0}
87 );
88
89 # Run the router
90
91 sub RunRouter
92 {
93 ($optimise,%params)=@_;
94
95 # Combine all of the parameters together
96
97 $params="--$optimise";
98
99 foreach $key (keys %params)
100 {
101 $params.=" --$key=$params{$key}";
102 }
103
104 # Change directory
105
106 mkdir $results_dir,0755 if(! -d $results_dir);
107 chdir $results_dir;
108
109 # Create a unique output directory
110
111 chomp($uuid=`echo '$params' $$ | md5sum | cut -f1 '-d '`);
112
113 mkdir $uuid,0755;
114 chdir $uuid;
115
116 # Run the router
117
118 $params.=" --dir=$data_dir" if($data_dir);
119 $params.=" --prefix=$data_prefix" if($data_prefix);
120 $params.=" --quiet";
121
122 $message=`$bin_dir/router $params 2>&1`;
123
124 (undef,undef,$cuser,$csystem) = times;
125 $time=sprintf "time: %.3f CPU / %.3f elapsed",$cuser+$csystem,tv_interval($t0);
126
127 if(-f "$optimise.txt")
128 {
129 $result=`tail -1 $optimise.txt`;
130 @result=split(/\t/,$result);
131 $result = $result[4]." , ".$result[5];
132 }
133
134 # Return the results
135
136 return($uuid,$time,$result,$message);
137 }
138
139 1;