Routino SVN Repository Browser

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

ViewVC logotype

Annotation of /trunk/web/www/routino/router.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 569 - (hide annotations) (download)
Wed Dec 29 09:50:50 2010 UTC (14 years, 2 months ago) by amb
File size: 3150 byte(s)
Added the uncontrolled (not auto-generated) files from routino-1.1.

1 amb 569 #!/usr/bin/perl
2     #
3     # Routino interactive router CGI
4     #
5     # Part of the Routino routing software.
6     #
7     # This file Copyright 2008,2009 Andrew M. Bishop
8     #
9     # This program is free software: you can redistribute it and/or modify
10     # it under the terms of the GNU Affero General Public License as published by
11     # the Free Software Foundation, either version 3 of the License, or
12     # (at your option) any later version.
13     #
14     # This program is distributed in the hope that it will be useful,
15     # but WITHOUT ANY WARRANTY; without even the implied warranty of
16     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     # GNU Affero General Public License for more details.
18     #
19     # You should have received a copy of the GNU Affero General Public License
20     # along with this program. If not, see <http://www.gnu.org/licenses/>.
21     #
22    
23     # Use the generic router script
24     require "router.pl";
25    
26     # Use the perl CGI module
27     use CGI ':cgi';
28    
29     # Create the query and get the parameters
30    
31     $query=new CGI;
32    
33     @rawparams=$query->param;
34    
35     # Legal CGI parameters with regexp validity check
36    
37     %legalparams=(
38     "lon[1-9]" => "[-0-9.]+",
39     "lat[1-9]" => "[-0-9.]+",
40     "transport" => "[a-z]+",
41     "highway-[a-z]+" => "[0-9.]+",
42     "speed-[a-z]+" => "[0-9.]+",
43     "oneway" => "(1|0|true|false|on|off)",
44     "weight" => "[0-9.]+",
45     "height" => "[0-9.]+",
46     "width" => "[0-9.]+",
47     "length" => "[0-9.]+",
48     "length" => "[0-9.]+",
49     "type" => "(shortest|quickest)"
50     );
51    
52     # Validate the CGI parameters, ignore invalid ones
53    
54     foreach $key (@rawparams)
55     {
56     foreach $test (keys (%legalparams))
57     {
58     if($key =~ m%^$test$%)
59     {
60     $value=$query->param($key);
61    
62     if($value =~ m%^$legalparams{$test}$%)
63     {
64     $cgiparams{$key}=$value;
65     last;
66     }
67     }
68     }
69     }
70    
71     # Get the important parameters
72    
73     $type=$cgiparams{type};
74     delete $cgiparams{type};
75    
76     # Fill in the default parameters using the ones in router.pl (don't use compiled in defaults)
77    
78     $cgiparams{transport}='motorcar' if(!defined $cgiparams{transport});
79    
80     $transport=$cgiparams{transport};
81    
82     foreach $highway (@router_highways)
83     {
84     $key="highway-$highway";
85     $value=$router_profile_highway{$highway}->{$transport};
86     $cgiparams{$key}=$value if(!defined $cgiparams{$key});
87    
88     $key="speed-$highway";
89     $value=$router_profile_speed{$highway}->{$transport};
90     $cgiparams{$key}=$value if(!defined $cgiparams{$key});
91     }
92    
93     $cgiparams{oneway} =~ s/(true|on)/1/;
94     $cgiparams{oneway} =~ s/(false|off)/0/;
95    
96     foreach $restriction (@router_restrictions)
97     {
98     $key="$restriction";
99     $value=$router_profile_restrictions{$restriction}->{$transport};
100     $cgiparams{$key}=$value if(!defined $cgiparams{$key});
101     }
102    
103     # Run the router
104    
105     ($router_uuid,$router_time,$router_result,$router_message)=&RunRouter($type,%cgiparams);
106    
107     # Return the output
108    
109     print header('text/plain');
110    
111     print "$router_uuid\n";
112     print "$router_time\n";
113     print "$router_result\n";
114     print "$router_message\n";

Properties

Name Value
svn:executable *