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') ;
15 my $maxpix = 15 ; # Maximum pixels between click and point
17 print qq{Content-type: text/xml\r\n\r\n};
18 print qq{<?xml version="1.0" encoding="UTF-8"?>\n} ;
23 print qq!<info error="No point passed..."/>\n! ;
29 if ( $point =~ /(.*),(.*)/ )
34 my $value = &Google_Tile_Factors($zoom) ; # Calculate Tile Factors
36 my ($latpix,$lngpix) = &Google_Coord_to_Pix( $value, $lat, $lng ) ; # Convert coordinate to pixel location
44 ,point'($lat,$lng)' <-> point as distance
50 if ( my ($city,$country,$count,$volpnt,$i) = $dbh->selectrow_array($sql) ) # Got one
52 $volpnt =~ /\((.*),(.*)\)/ ;
56 my ($vlatpix,$vlngpix) = &Google_Coord_to_Pix( $value, $vlat, $vlng ) ; # Convert coordinate to pixel location
58 if ( sqrt(($vlatpix - $latpix)**2 + ($vlngpix - $lngpix)**2) > $maxpix )
60 # Click not within maxpix of point...
61 print qq!<info error="No publisher is within range of your click, please try again."/>\n! ;
62 } else # Good point found
65 my $sth = $dbh->prepare(qq{
67 author, title, max(bi.biblionumber), count(title)
69 join geo_biblioitems bi on bi.city = c.city_koha
70 join biblio b on b.biblionumber = bi.biblionumber
71 where c.city = ? and country = ?
72 group by author, title
73 order by min(timestamp)
76 $sth->execute( $city, $country );
78 my $rows = $sth->rows;
79 $rows = "more than $rows" if $rows == 100;
81 $books = 'book' if $rows == 1;
83 my $descript = "<b>$city</b> <em>$country</em> <small>$rows $books</small>\n<ol>";
85 while ( my $row = $sth->fetchrow_hashref ) {
86 $descript .= sprintf qq|<li><a target="koha" href="http://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=%d">%s</a> %s\n|,
87 $row->{biblionumber}, $row->{title}, $row->{author}
91 $descript .= "\n</ol>\n";
93 print qq!<info error="" name="${city}_${country}" lat="$vlat" lng="$vlng">\n! ;
94 print qq! <description><\![CDATA[$descript]]></description>\n! ;
100 print qq!<info error="No valid point ($point) passed. Should be: (lat,lng) format."/>\n! ;