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=koha" , "dpavlin" , "" , { AutoCommit => 1 } ) ;
12 my $point = param('POINT') ;
13 my $zoom = param('ZOOM') ;
27 my $maxpix = 15 ; # Maximum pixels between click and point
32 print qq{Content-type: text/xml\r\n\r\n};
33 print qq{<?xml version="1.0" encoding="UTF-8"?>\n} ;
38 print qq!<info error="No point passed..."/>\n! ;
44 if ( $point =~ /(.*),(.*)/ )
49 $value = &Google_Tile_Factors($zoom) ; # Calculate Tile Factors
51 ($latpix,$lngpix) = &Google_Coord_to_Pix( $value, $lat, $lng ) ; # Convert coordinate to pixel location
53 $x = "select city,country,count,point,point'($lat,$lng)' <-> point as distance from geo_count order by distance limit 1" ;
55 if ( my ($city,$country,$count,$volpnt,$i) = $dbh->selectrow_array($x) ) # Got one
57 $volpnt =~ /\((.*),(.*)\)/ ;
61 ($vlatpix,$vlngpix) = &Google_Coord_to_Pix( $value, $vlat, $vlng ) ; # Convert coordinate to pixel location
63 if ( sqrt(($vlatpix - $latpix)**2 + ($vlngpix - $lngpix)**2) > $maxpix )
65 # Click not within maxpix of point...
66 print qq!<info error="No publisher is within range of your click, please try again."/>\n! ;
67 } else # Good point found
70 my $sth = $dbh->prepare(qq{
72 author, title, bi.biblionumber
74 join geo_biblioitems bi on bi.city = c.city_koha
75 join biblio b on b.biblionumber = bi.biblionumber
76 where c.city = ? and country = ?
80 $sth->execute( $city, $country );
82 my $descript = "<b>$city</b> <em>$country</em> $count items\n<ol>";
84 while ( my $row = $sth->fetchrow_hashref ) {
85 $descript .= sprintf qq|<li><a target="koha" href="http://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=%d">%s</a> %s\n|,
86 $row->{biblionumber}, $row->{title}, $row->{author}
90 $descript .= "\n</ol>\n";
92 print qq!<info error="" name="${city}_${country}" lat="$vlat" lng="$vlng">\n! ;
93 print qq! <description><\![CDATA[$descript]]></description>\n! ;
99 print qq!<info error="No valid point ($point) passed. Should be: (lat,lng) format."/>\n! ;