#! /usr/bin/perl -w use CGI; use CGI::Carp qw(fatalsToBrowser); use Encode qw(encode decode); use strict; # =========================================== # Section 1: # Read POIs from database WITHOUT taking map # section into consideration # =========================================== sub Selection_FreeX { my ($country, $times) = @_; if (open(IN, '<', "freex.dat")) { while (){ print $_; } close(IN); } else { print "Error: ", $!, "\n"; } } # =========================================== # Section 2: # Read POIs from database taking map section # into consideration # =========================================== sub Selection_FreeX_in_BBOX { my ($bbox, $country, $times) = @_; my ($minlon, $minlat, $maxlon, $maxlat, $proj) = split(",", $bbox); if (open(IN, '<', "freex.dat")) { while (){ my ($comm, $lon, $lat, $id) = split(";", $_); if ($lon > $minlon && $lon < $maxlon && $lat > $minlat && $lat < $maxlat) { print $comm, ";", $lon, ";", $lat, ";", $id, "\n"; } } close(IN); } else { print "Error: ", $!, "\n"; } } # =========================================== # Section 3: # Use the CGI module to evaluate the # parameters sent by the HTTP POST method # =========================================== print "Content-Type: text/html\n\n"; my $cgi = new CGI; if ($cgi->param('country') ne "" && $cgi->param('magazine') ne "") { Selection_FreeX($cgi->param('country'), $cgi->param('magazine')); } elsif ($cgi->param('country') ne "" && $cgi->param('magazine') ne "" && $cgi->param('bbox') ne "") { Selection_FreeX_in_BBOX($cgi->param('bbox'), $cgi->param('country'), $cgi->param('magazine')); }