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/visualiser.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1520 - (show annotations) (download)
Sat Mar 8 19:36:35 2014 UTC (11 years, 1 month ago) by amb
File size: 4005 byte(s)
Update all Perl scripts to "use strict".

1 #!/usr/bin/perl
2 #
3 # Routino data visualiser CGI
4 #
5 # Part of the Routino routing software.
6 #
7 # This file Copyright 2008-2014 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 strict;
24
25 # Use the directory paths script
26 require "paths.pl";
27
28 # Use the perl CGI module
29 use CGI ':cgi';
30
31
32 # Create the query and get the parameters
33
34 my $query=new CGI;
35
36 my @rawparams=$query->param;
37
38 # Legal CGI parameters with regexp validity check
39
40 my %legalparams=(
41 "latmin" => "[-0-9.]+",
42 "latmax" => "[-0-9.]+",
43 "lonmin" => "[-0-9.]+",
44 "lonmax" => "[-0-9.]+",
45 "data" => "(junctions|super|oneway|highway-.*|transport-.*|barrier-.*|turns|speed|weight|height|width|length|property-.*|errorlogs)",
46 "dump" => "(node|segment|turn-relation|errorlog)[0-9]+"
47 );
48
49 # Validate the CGI parameters, ignore invalid ones
50
51 my %cgiparams=();
52
53 foreach my $key (@rawparams)
54 {
55 foreach my $test (keys (%legalparams))
56 {
57 if($key =~ m%^$test$%)
58 {
59 my $value=$query->param($key);
60
61 if($value =~ m%^$legalparams{$test}$%)
62 {
63 $cgiparams{$key}=$value;
64 last;
65 }
66 }
67 }
68 }
69
70 # Data or dump?
71
72 my $params="";
73
74 my $data=$cgiparams{"data"};
75 my $dump=$cgiparams{"dump"};
76
77 if(!defined $data && !defined $dump)
78 {
79 print header(-status => '500 Invalid CGI parameters');
80 exit;
81 }
82
83 if(defined $data)
84 {
85 # Parameters to limit range selected
86
87 my %limits=(
88 "junctions" => 0.2,
89 "super" => 0.2,
90 "oneway" => 0.2,
91 "highway" => 0.2,
92 "transport" => 0.2,
93 "barrier" => 0.3,
94 "turns" => 0.3,
95 "speed" => 0.3,
96 "weight" => 0.3,
97 "height" => 0.3,
98 "width" => 0.3,
99 "length" => 0.3,
100 "property" => 0.3,
101 "errorlogs" => 0.5
102 );
103
104 # Check the parameters
105
106 my $latmin=$cgiparams{"latmin"};
107 my $latmax=$cgiparams{"latmax"};
108 my $lonmin=$cgiparams{"lonmin"};
109 my $lonmax=$cgiparams{"lonmax"};
110
111 if($latmin eq "" || $latmax eq "" || $lonmin eq "" || $lonmax eq "" || $data eq "")
112 {
113 print header(-status => '500 Invalid CGI parameters');
114 exit;
115 }
116
117 my $subdata=$data;
118 $subdata="highway" if($data =~ m%highway-%);
119 $subdata="transport" if($data =~ m%transport-%);
120 $subdata="barrier" if($data =~ m%barrier-%);
121 $subdata="property" if($data =~ m%property-%);
122
123 if(($latmax-$latmin)>$limits{$subdata} || ($lonmax-$lonmin)>$limits{$subdata})
124 {
125 print header(-status => '500 Selected area too large');
126 exit;
127 }
128
129 # Print the output
130
131 print header('text/plain');
132
133 print "$latmin $lonmin $latmax $lonmax\n";
134
135 # Set the parameters
136
137 $params.=" --visualiser --data=$data";
138 $params.=" --latmin=$latmin --latmax=$latmax --lonmin=$lonmin --lonmax=$lonmax";
139 }
140 else
141 {
142 # Print the output
143
144 print header('text/plain');
145
146 # Set the parameters
147
148 $params.=" --dump-visualiser --data=$dump";
149 }
150
151 # Run the filedumper
152
153 $params.=" --dir=$main::data_dir" if($main::data_dir);
154 $params.=" --prefix=$main::data_prefix" if($main::data_prefix);
155
156 system "$main::bin_dir/$main::filedumper_exe $params 2>&1";

Properties

Name Value
svn:executable *