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
33 print qq{Content-type: text/xml\r\n\r\n};
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 city,count,point,point'($lat,$lng)' <-> point as distance from geo_count 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 publisher is within range of your click, please try again."/>\n! ;
68 } else # Good point found
71 my $sth = $dbh->prepare(qq{
73 author, title, bi.biblionumber
75 join geo_biblioitems bi on bi.city = c.city_koha
76 join biblio b on b.biblionumber = bi.biblionumber
81 $sth->execute( $name );
83 $descript = "<b>$name</b> $descript items\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 = "$name" 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! ;