changeset 144:e92a0df189b6 gmap2

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 09 Mar 2014 16:21:59 +0200
parents 83e5dc431e61
children 36d253c09da3
files overlay.php
diffstat 1 files changed, 33 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/overlay.php	Sun Mar 09 16:09:57 2014 +0200
+++ b/overlay.php	Sun Mar 09 16:21:59 2014 +0200
@@ -1,13 +1,22 @@
 <?php
 $cachepath = "cache/";
-$fontfile = "./tools/lucon.ttf";
 $tilesize = 256;
 
+$patchfont = "./tools/lucon.ttf";
+$patchsize = array();
+$patchsize[ 8] = 7;
+$patchsize[16] = 13;
+$patchsize[32] = 26;
+
+$labelfont = "./tools/lucon.ttf";
+$labelsize = array();
+$labelsize[ 4] = 7;
+$labelsize[ 8] = 8;
+$labelsize[16] = 9;
+$labelsize[32] = 12;
+
+
 $vzoom = isset($_GET["zoom"]) ? intval($_GET["zoom"]) : 0;
-//if ($vzoom < 2) $vzoom = 0;
-//else
-//if ($vzoom > 10) $vzoom = 10;
-
 $zoom = pow(2, $vzoom - 5);
 $xc = isset($_GET["x"]) ? intval($_GET["x"]) : 0;
 $yc = isset($_GET["y"]) ? intval($_GET["y"]) : 0;
@@ -33,17 +42,6 @@
 
 imagefilledrectangle($im, 0,0, $tilesize,$tilesize, $c_trans);
 
-$fontsize = array();
-$fontsize[ 8] = 7;
-$fontsize[16] = 13;
-$fontsize[32] = 26;
-
-$labelsize = array();
-$labelsize[ 4] = 7;
-$labelsize[ 8] = 8;
-$labelsize[16] = 9;
-$labelsize[32] = 12;
-
 
 function chkcoords($xoffs, $yoffs)
 {
@@ -66,15 +64,18 @@
   $yoffs = $data[1] * $zoom;
   $char  = $data[2];
   
-  if (chkcoords($xoffs, $yoffs))
+  if ($zoom >= 8 && chkcoords($xoffs, $yoffs))
   {
-    if ($zoom >= 8)
-    {
-      imagefilledrectangle($im,$xoffs-$xorig,$yoffs-$yorig,$xoffs-$xorig+$zoom-1,$yoffs-$yorig+$zoom-1,$c_black);
-      imagettftext($im,$fontsize[$zoom],0,$xoffs-$xorig+$fontsize[$zoom]/4,$yoffs-$yorig+$fontsize[$zoom], $c_white, $fontfile, $char);
-      //imagechar($im,$fontsize[$zoom],$xoffs-$xorig,$yoffs-$yorig,$char,$c_white);
-      $flag = TRUE;
-    }
+    $px = $xoffs - $xorig;
+    $py = $yoffs - $yorig;
+
+    imagefilledrectangle($im, $px, $py, $px+$zoom-1, $py+$zoom-1, $c_black);
+    imagettftext($im, $patchsize[$zoom], 0,
+      $px+$patchsize[$zoom]/4,
+      $py+$patchsize[$zoom], $c_white, $patchfont, $char);
+
+    //imagechar($im,$patchsize[$zoom],$px,$py,$char,$c_white);
+    $flag = TRUE;
   }
 }
 fclose($file);
@@ -87,12 +88,15 @@
   $yoffs = $data[1] * $zoom;
   $char  = $data[2];
 
-  if (chkcoords($xoffs, $yoffs) && $zoom >= 4)
+  if ($zoom >= 4 && chkcoords($xoffs, $yoffs))
   {
-    $box = imagettfbbox($labelsize[$zoom], 0, $fontfile, $char);
-    imagefilledrectangle($im,$xoffs-$xorig+$box[6],$yoffs-$yorig+$box[7]+5,$xoffs-$xorig+$box[2],$yoffs-$yorig+$box[3]+5,$c_alpha);      
-    imagettftext($im,$labelsize[$zoom],0,$xoffs-$xorig,$yoffs-$yorig+5, $c_white, $fontfile, $char);
-    //imagestring($im,1,$xoffs-$xorig,$yoffs-$yorig,$char,$c_white);      
+    $px = $xoffs - $xorig;
+    $py = $yoffs - $yorig;
+
+    $box = imagettfbbox($labelsize[$zoom], 0, $labelfont, $char);
+    imagefilledrectangle($im,$px+$box[6],$py+$box[7]+5,$px+$box[2],$py+$box[3]+5,$c_alpha);
+    imagettftext($im,$labelsize[$zoom],0,$px,$py+5, $c_white, $labelfont, $char);
+    //imagestring($im,1,$px,$py,$char,$c_white);
     $flag = TRUE;
   }
 }