hard-code local path
[google-map-tiles.git] / tiles / tileserver.pl
1 #!/usr/bin/perl
2 # Serve Map Tiles...
3 # Author. John D. Coryat 08/2007...
4
5 use CGI qw/:standard *table/ ;
6 use strict ;
7
8 my $zoom        = param('Z') ;                          # Zoom
9 my $py          = param('Y') ;                          # Y Tile Name
10 my $px          = param('X') ;                          # X Tile Name
11 my $path        = $ENV{'DOCUMENT_ROOT'} . "/ws-2010-08/tiles" ;
12 $path = '/srv/google-map-markers-with-tile-layer/tiles';
13 my $i           = 0 ;
14 my $size        = 0 ;
15 my $x           = '' ;
16 my $file        = '' ;
17
18 if ( !defined($zoom) or !$zoom )                        # Has to be a zoom
19 {
20  exit ;
21 }
22
23 # v_9_6.png
24
25 $file   = "$path/$zoom/v_$px" . "_$py" . ".png" ;
26
27 print STDERR "$file\n" ;
28
29 $size   = ( -s $file ) ;
30
31 if ( !$size )                                           # not found
32 {
33  $file  = $path . "/notiles.png" ;
34  $size  = ( -s $file ) ;
35 }
36
37 if ( $size and open ( PNG, $file ) )
38 {
39  read ( PNG, $x, $size ) ;
40  close( PNG ) ;
41  print header(-type=> 'image/png', -expires=> '+1d', -Pragma=> 'no-cache') ;
42
43  print $x ;
44
45
46 # END
47