comparison tools/makegmaps.php @ 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
comparison
equal deleted inserted replaced
278:2233bdad4ab5 279:0374836ed73a
681 { 681 {
682 if (!$drawn) 682 if (!$drawn)
683 { 683 {
684 if ($zoom < 9) 684 if ($zoom < 9)
685 { 685 {
686 $im = @imagecreate($tileDim, $tileDim); 686 $im = imagecreate($tileDim, $tileDim);
687 if ($im === false || get_resource_type($im) != "gd")
688 die("\nCould not create GD image resource open dim=".$tileDim.
689 " for zoom=".$zoom.", continent=".$continent."\n");
690
687 $sea = imagecolorallocate($im, 51, 51, 170); 691 $sea = imagecolorallocate($im, 51, 51, 170);
688 imagefilledrectangle($im, 0, 0, $tileDim, $tileDim, $sea); 692 imagefilledrectangle($im, 0, 0, $tileDim, $tileDim, $sea);
689 } 693 }
690 else 694 else
691 { 695 {
692 $inFilename = $cfg["pathTileData"].$zoom."/sea.png"; 696 $inFilename = $cfg["pathTileData"].$zoom."/sea.png";
693 $im = @imagecreatefrompng($inFilename); 697 $im = imagecreatefrompng($inFilename);
694 if ($im === false) 698 if ($im === false)
695 die("\nCould not open '".$inFilename."'.\n"); 699 die("\nCould not open '".$inFilename."'.\n");
700
701 if (get_resource_type($im) != "gd")
702 die("Not an GD image resource ".$im." in '".$inFilename."'\n");
696 } 703 }
697 } 704 }
698 705
699 $dx = $tileDim; 706 $dx = $tileDim;
700 $dy = $tileDim; 707 $dy = $tileDim;
764 $my = ceil(($worldMap["h"] * $scale) / $tileDim); 771 $my = ceil(($worldMap["h"] * $scale) / $tileDim);
765 $mw = ceil( $worldMap["w"] * $scale); 772 $mw = ceil( $worldMap["w"] * $scale);
766 $mh = ceil( $worldMap["h"] * $scale); 773 $mh = ceil( $worldMap["h"] * $scale);
767 774
768 $mapMtime = -1; 775 $mapMtime = -1;
769 foreach ($continentList as $continent => $data) 776 foreach ($continentList as $continent => &$data)
770 if ($data[4] && $data[7]) 777 if ($data[4] && $data[7])
771 { 778 {
772 $mapFile = $cfg["pathImageCache"].$continent."_".$zoom2.".png"; 779 $mapFile = $cfg["pathImageCache"].$continent."_".$zoom2.".png";
773 $mapData[$continent] = @imagecreatefrompng($mapFile); 780 $mapData[$continent] = imagecreatefrompng($mapFile);
781 if ($mapData[$continent] === FALSE ||
782 get_resource_type($mapData[$continent]) != "gd")
783 die("Not an GD image resource ".$mapData[$continent]." in '".$mapFile."'\n");
784
774 $tmp = filemtime($mapFile); 785 $tmp = filemtime($mapFile);
775 if ($tmp > $mapMtime) 786 if ($tmp > $mapMtime)
776 $mapMtime = $tmp; 787 $mapMtime = $tmp;
777 } 788 }
778 789