<?php
$zoom = $_GET["zoom"];
$tileX = $_GET["x"];
$tileY = $_GET["y"];
header ('Content-type: image/png');
$tileImage = "tilesdir/".$zoom."/x".$tileX."_y".$tileY.".png";
$showTileInfo = false;
if($showTileInfo){
include "gm.php";
}
if( file_exists($tileImage) ) {
$im = imagecreatefrompng($tileImage);
if($showTileInfo) writeTileInfo($im, $zoom, $tileX, $tileY);
imagepng($im);
imagedestroy($im);
}
else {
$im = @imagecreatetruecolor(256, 256);
if($im) {
imagesavealpha($im, true);
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);
if($showTileInfo) writeTileInfo($im, $zoom, $tileX, $tileY);
imagepng($im);
imagedestroy($im);
}
}
function writeTileInfo($im, $zoom, $tileX, $tileY) {
$value = Google_Tile_Factors( $zoom );
$tile = Google_Tile_Calc( $value, $tileY, $tileX ) ;
$text_color = imagecolorallocate($im, 233, 14, 91);
$strArr = array(
"X=".$tileX . ", Y=".$tileY.", ZOOM=".$zoom,
"latN: ".$tile["LATN"],
"lngW: ".$tile["LNGW"],
"latS: ".$tile["LATS"],
"lngE: ".$tile["LNGE"],
"pixN: ".$tile["PYN"],
"pixW: ".$tile["PXW"],
"pixS: ".$tile["PYS"],
"pixE: ".$tile["PXE"]
);
$y = 5;
foreach($strArr as $str) {
imagestring($im, 2, 5, $y, $str , $text_color);
$y = $y+15;
}
imagerectangle($im, 0, 0, 255, 255, $text_color);
}
?>