示例#1
0
function warn($x, $y)
{
    global $tilepath;
    global $debug;
    // 2 force regen
    list($ret, $img, $cached) = img_from_tiles($tilepath, $x, $y, 1, 1, 16, 0, $debug, "/dev/shm", "/mnt/twmapcache/cache", 2);
    if ($ret === true) {
        //@unlink($img);
        if ($cached == "cached") {
            return;
        }
        echo "{$x} {$y} ok\n";
    } else {
        echo "{$x} {$y} skip\n";
    }
}
示例#2
0
 function createpng($tag = 0, $gray = 0, $fuzzy = 0, $x = 1, $y = 1, $debug_flag = 0, $borders = array())
 {
     global $tmppath;
     global $tilecachepath;
     $v3img = dirname(__FILE__) . "/../imgs/v3image2.png";
     if ($this->createfromim == 1) {
         // just load image from im or filename
         $cim = $this->im;
     } else {
         // load from STB files
         $pscount = 1;
         $pstotal = $this->shiftx * $this->shifty;
         $this->doLog("check tiles...");
         for ($j = $this->starty; $j > $this->starty - $this->shifty; $j--) {
             for ($i = $this->startx; $i < $this->startx + $this->shiftx; $i++) {
                 //error_log("call $i $j");
                 list($status, $fname) = img_from_tiles($this->stbdir, $i * 1000, $j * 1000, 1, 1, $this->zoom, $this->ph, $debug_flag, $tmppath, $tilecachepath);
                 // 產生 progress
                 $this->doLog("{$pscount} /  {$pstotal}");
                 $this->doLog(sprintf("ps%%+%d", 20 * $pscount / $pstotal));
                 $pscount++;
                 if ($status === FALSE) {
                     error_log("error {$fname}");
                     $this->err[] = $fname;
                     return FALSE;
                 }
                 $fn[] = $fname;
             }
         }
         //print_r($fn);
         // 合併
         $this->doLog("merge tiles...");
         $outi = $outimage = tempnam($tmppath, "MTILES");
         $montage_bin = "montage";
         $cmd = sprintf("{$montage_bin} %s -mode Concatenate -tile %dx%d miff:-| composite -gravity northeast %s - miff:-| convert - -resize %dx%d\\! png:%s", implode(" ", $fn), $this->shiftx, $this->shifty, $v3img, $this->shiftx * 315, $this->shifty * 315, $outi);
         if ($debug_flag) {
             $this->doLog($cmd);
         }
         exec($cmd);
         $cim = imagecreatefrompng($outi);
         exec("rm " . implode(" ", $fn) . " {$outi}");
         //	$cim=cropimage($im,$this->movX,$this->movY,
         //		$this->shiftx * 315 + $fuzzy,
         //		$this->shifty * 315 + $fuzzy );
     }
     if ($tag == 1) {
         // echo "tag it ...\n";
         $this->doLog("tagimage ...");
         $cim = tagimage($cim, $this->startx, $this->starty, $fuzzy);
     } else {
         if ($tag == 2) {
             if ($this->outsizex == 0 || $this->outsizey == 0) {
                 $this->err[] = "Please call setoutsize() first\n";
                 return FALSE;
             }
             if ($this->createfromim == 0 && ($this->shiftx < $this->outsizex || $this->shifty < $this->outsizey)) {
                 // echo "resizing image...\n";
                 $dst = imageCreate($this->outsizex * 315 + $fuzzy, $this->outsizey * 315 + $fuzzy);
                 $bgcolor = imagecolorallocate($dst, 255, 255, 255);
                 imagefill($dst, 0, 0, $bgcolor);
                 imageCopy($dst, $cim, 0, 0, 0, 0, imageSX($cim), imageSY($cim));
                 $cim = $dst;
             }
             // refer to X,Y, I
             // debug: echo "addtagbprder2 cim $x $y $d $this->startx, $this->starty, 4x6, $this->shiftx, $this->shifty $fuzzy \n";
             $this->doLog("add borders ...");
             $cim = addtagborder2($cim, $x, $y, $debug_flag, $this->startx, $this->starty, array("x" => $this->outsizex, "y" => $this->outsizey), $this->shiftx, $this->shifty, $fuzzy);
             if (!($x == 1 && $y == 1)) {
                 // echo "add boder to cut or paste...\n";
                 $cim = addborder2($cim, $x, $y, $debug_flag, $borders);
             }
         }
     }
     if ($gray >= 1) {
         // $cim = grayscale($cim);
         //grayscale2($cim);
         $this->doLog("grayscale image ...");
         $cim = im_grayscale($cim);
     }
     return $cim;
 }