3 # Routino interactive router CGI
5 # Part of the Routino routing software.
7 # This file Copyright 2008-2010 Andrew M. Bishop
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.
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.
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/>.
23 # Use the generic router script
26 # Use the perl CGI module
29 # Create the query and get the parameters
33 @rawparams=$query->param;
35 # Legal CGI parameters with regexp validity check
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 "property-[a-z]+" => "[0-9.]+",
44 "oneway" => "(1|0|true|false|on|off)",
45 "weight" => "[0-9.]+",
46 "height" => "[0-9.]+",
48 "length" => "[0-9.]+",
49 "length" => "[0-9.]+",
51 "language" => "[-a-zA-Z]+",
52 "type" => "(shortest|quickest)",
53 "format" => "(html|gpx-route|gpx-track|text|text-all)"
56 # Validate the CGI parameters, ignore invalid ones
58 foreach $key (@rawparams)
60 foreach $test (keys (%legalparams))
62 if($key =~ m%^$test$%)
64 $value=$query->param($key);
66 if($value =~ m%^$legalparams{$test}$%)
68 $cgiparams{$key}=$value;
75 # Get the important parameters
77 $type=$cgiparams{type};
78 delete $cgiparams{type};
80 $format=$cgiparams{format};
81 delete $cgiparams{format};
83 # Fill in the default parameters
85 %fullparams=FillInDefaults(%cgiparams);
89 ($router_uuid,$router_time,$router_result,$router_message)=RunRouter($type,%fullparams);
95 ReturnOutput($router_uuid,$type,$format);
99 print header('text/plain');
101 print "$router_uuid\n";
102 print "$router_time\n";
103 print "$router_result\n";
104 print "$router_message\n";