Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/web/www/routino/router.cgi
Parent Directory
|
Revision Log
Revision 675 -
(show annotations)
(download)
Fri Apr 22 13:59:27 2011 UTC (13 years, 10 months ago) by amb
File size: 2856 byte(s)
Fri Apr 22 13:59:27 2011 UTC (13 years, 10 months ago) by amb
File size: 2856 byte(s)
Add in the option to specify an initial heading.
1 | #!/usr/bin/perl |
2 | # |
3 | # Routino interactive router CGI |
4 | # |
5 | # Part of the Routino routing software. |
6 | # |
7 | # This file Copyright 2008-2011 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 | "heading" => "[-0-9.]+", |
41 | "transport" => "[a-z]+", |
42 | "highway-[a-z]+" => "[0-9.]+", |
43 | "speed-[a-z]+" => "[0-9.]+", |
44 | "property-[a-z]+" => "[0-9.]+", |
45 | "oneway" => "(1|0|true|false|on|off)", |
46 | "turns" => "(1|0|true|false|on|off)", |
47 | "weight" => "[0-9.]+", |
48 | "height" => "[0-9.]+", |
49 | "width" => "[0-9.]+", |
50 | "length" => "[0-9.]+", |
51 | "length" => "[0-9.]+", |
52 | |
53 | "language" => "[-a-zA-Z]+", |
54 | "type" => "(shortest|quickest)", |
55 | "format" => "(html|gpx-route|gpx-track|text|text-all)" |
56 | ); |
57 | |
58 | # Validate the CGI parameters, ignore invalid ones |
59 | |
60 | foreach $key (@rawparams) |
61 | { |
62 | foreach $test (keys (%legalparams)) |
63 | { |
64 | if($key =~ m%^$test$%) |
65 | { |
66 | $value=$query->param($key); |
67 | |
68 | if($value =~ m%^$legalparams{$test}$%) |
69 | { |
70 | $cgiparams{$key}=$value; |
71 | last; |
72 | } |
73 | } |
74 | } |
75 | } |
76 | |
77 | # Get the important parameters |
78 | |
79 | $type=$cgiparams{type}; |
80 | delete $cgiparams{type}; |
81 | |
82 | $format=$cgiparams{format}; |
83 | delete $cgiparams{format}; |
84 | |
85 | # Fill in the default parameters |
86 | |
87 | %fullparams=FillInDefaults(%cgiparams); |
88 | |
89 | # Run the router |
90 | |
91 | ($router_uuid,$router_time,$router_result,$router_message)=RunRouter($type,%fullparams); |
92 | |
93 | # Return the output |
94 | |
95 | if($format) |
96 | { |
97 | ReturnOutput($router_uuid,$type,$format); |
98 | } |
99 | else |
100 | { |
101 | print header('text/plain'); |
102 | |
103 | print "$router_uuid\n"; |
104 | print "$router_time\n"; |
105 | print "$router_result\n"; |
106 | print "$router_message\n"; |
107 | } |
Properties
Name | Value |
---|---|
svn:executable | * |