2 # Deliver click values to volcano.htm...
3 # Author. John D. Coryat 02/2010...
4 # Copyright 2010 USNaviguide LLC. All rights reserved...
6 use CGI qw/:standard *table/;
9 use USNaviguide_Google_Tiles ;
11 my $dbh = DBI->connect ( "dbi:Pg:dbname=volcano" , "" , "" , { AutoCommit => 1 } ) ;
12 my $point = param('POINT') ;
13 my $zoom = param('ZOOM') ;
27 my $maxpix = 15 ; # Maximum pixels between click and point
33 print header('text/xml');
34 print qq{<?xml version="1.0" encoding="UTF-8"?>\n} ;
39 print qq!<info error="No point passed..."/>\n! ;
45 if ( $point =~ /(.*),(.*)/ )
50 $value = &Google_Tile_Factors($zoom) ; # Calculate Tile Factors
52 ($latpix,$lngpix) = &Google_Coord_to_Pix( $value, $lat, $lng ) ; # Convert coordinate to pixel location
54 $x = "select name,descript,volpnt,point'($lat,$lng)' <-> volpnt as distance from gvp_world order by distance limit 1" ;
56 if ( ($name,$descript,$volpnt,$i) = $dbh->selectrow_array($x) ) # Got one
58 $volpnt =~ /\((.*),(.*)\)/ ;
62 ($vlatpix,$vlngpix) = &Google_Coord_to_Pix( $value, $vlat, $vlng ) ; # Convert coordinate to pixel location
64 if ( sqrt(($vlatpix - $latpix)**2 + ($vlngpix - $lngpix)**2) > $maxpix )
66 # Click not within maxpix of point...
67 print qq!<info error="No volcano is within range of your click, please try again."/>\n! ;
68 } else # Good point found
70 print qq!<info error = "" name = "$name" lat="$vlat" lng="$vlng">\n! ;
71 print qq! <description><\![CDATA[$descript]]></description>\n! ;
77 print qq!<info error="No valid point ($point) passed. Should be: (lat,lng) format."/>\n! ;