changeset 279:0374836ed73a gmap2

Various fixes in the image data handling.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Apr 2015 21:57:15 +0300
parents 2233bdad4ab5
children 632e61498905
files tools/makegmaps.php
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tools/makegmaps.php	Thu Apr 16 21:04:35 2015 +0300
+++ b/tools/makegmaps.php	Thu Apr 16 21:57:15 2015 +0300
@@ -683,16 +683,23 @@
       {
         if ($zoom < 9)
         {
-          $im = @imagecreate($tileDim, $tileDim);
+          $im = imagecreate($tileDim, $tileDim);
+          if ($im === false || get_resource_type($im) != "gd")
+            die("\nCould not create GD image resource open dim=".$tileDim.
+            " for zoom=".$zoom.", continent=".$continent."\n");
+
           $sea = imagecolorallocate($im, 51, 51, 170);
           imagefilledrectangle($im, 0, 0, $tileDim, $tileDim, $sea);
         }
         else
         {
           $inFilename = $cfg["pathTileData"].$zoom."/sea.png";
-          $im = @imagecreatefrompng($inFilename);
+          $im = imagecreatefrompng($inFilename);
           if ($im === false)
             die("\nCould not open '".$inFilename."'.\n");
+
+          if (get_resource_type($im) != "gd")
+            die("Not an GD image resource ".$im." in '".$inFilename."'\n");
         }
       }
 
@@ -766,11 +773,15 @@
   $mh = ceil( $worldMap["h"] * $scale);
 
   $mapMtime = -1;
-  foreach ($continentList as $continent => $data)
+  foreach ($continentList as $continent => &$data)
   if ($data[4] && $data[7])
   {
     $mapFile = $cfg["pathImageCache"].$continent."_".$zoom2.".png";
-    $mapData[$continent] = @imagecreatefrompng($mapFile);
+    $mapData[$continent] = imagecreatefrompng($mapFile);
+    if ($mapData[$continent] === FALSE ||
+      get_resource_type($mapData[$continent]) != "gd")
+      die("Not an GD image resource ".$mapData[$continent]." in '".$mapFile."'\n");
+
     $tmp = filemtime($mapFile);
     if ($tmp > $mapMtime)
       $mapMtime = $tmp;