Esempio n. 1
0
         }
     }
     // 如果原始檔案是特殊格式,則將檔名當作參數帶入
     // twmap_294_2677_7_5_0.gpx 則讀出
     if (preg_match("/^(\\d+)x(\\d+)-(\\d+)x(\\d+)-v\\d([p]?)\$/", $pa['filename'], $testnam)) {
         //$testnam = explode("_", $pa['filename']);
         //if ($testnam[0] == 'twmap') {
         $inp['startx'] = $testnam[1] / 1000;
         $inp['starty'] = $testnam[2] / 1000;
         $inp['shiftx'] = $testnam[3];
         $inp['shifty'] = $testnam[4];
         $inp['ph'] = $testnam[5] == 'p' ? 1 : 0;
         //	error_out(print_r($inp,true));
     } else {
         // 輸入的是 gpx , 讀出邊界範圍, 本 svg 不做為轉檔之用, 因為尚未得到圖檔大小
         $svg = new gpxsvg(array("gpx" => $tmp_gpx, "width" => 1024, "fit_a4" => 1, "show_label_trk" => isset($inp['trk_label']) ? 1 : 0, "show_label_wpt" => $inp['wpt_label']));
         $ret = $svg->process();
         msglog("svg get_bound processed");
         if ($ret === false) {
             @unlink($tmp_gpx);
             error_out("讀取 gpx 失敗" . print_r($svg->_err, true));
         }
         $inp['startx'] = $svg->bound_twd67['tl'][0] / 1000;
         $inp['starty'] = $svg->bound_twd67['tl'][1] / 1000;
         $inp['shiftx'] = ($svg->bound_twd67['br'][0] - $svg->bound_twd67['tl'][0]) / 1000;
         $inp['shifty'] = ($svg->bound_twd67['tl'][1] - $svg->bound_twd67['br'][1]) / 1000;
         $inp['ph'] = $svg->bound_twd67['ph'];
         unset($svg);
     }
 } else {
     $msgarr = array(1 => "The uploaded file exceeds the upload_max_filesize directive in php.ini", 2 => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form", 3 => "The uploaded file was only partially uploaded", 4 => "No file was uploaded", 6 => "Missing a temporary folder", 7 => 'Failed to write file to disk.', 8 => 'A PHP extension stopped the file upload.');
Esempio n. 2
0
function gpx2svg($param, $outsvg)
{
    $svg = new gpxsvg($param);
    $ret = $svg->process();
    if ($ret === false) {
        return array(false, $svg->_err);
    }
    ob_start();
    $svg->output();
    $ret = file_put_contents($outsvg, ob_get_contents());
    ob_end_clean();
    if ($ret === false) {
        return array(false, "unable to write to {$outsvg}");
    }
    return array(true, "{$outsvg} created");
}
Esempio n. 3
0
        file_put_contents($tmp_gdb, $data);
        $cmd = sprintf("/usr/bin/gpsbabel -i gdb -o gpx -f %s -F %s", $tmp_gdb, $tmp_gpx);
        exec($cmd, $out, $ret);
        if ($ret != 0) {
            @unlink($tmp_gdb);
            ajaxerr("4:unsupported format?[gdb fail to convert to gpx]");
        }
    } else {
        file_put_contents($tmp_gpx, $data);
    }
} catch (Exception $e) {
    error_log("keepon add: unable to download");
    ajaxerr("3:unable to download gpx");
}
// 1.1 把參數抓出來
$svg = new gpxsvg(array("gpx" => $tmp_gpx, "width" => 1024, "fit_a4" => 1, "show_label_trk" => 0, "show_label_wpt" => 2));
$ret = $svg->process();
// msglog("svg get_bound processed");
if ($ret === false) {
    @unlink($tmp_gpx);
    ajaxerr("4:unsupported format?");
}
$TODO['startx'] = $svg->bound_twd67['tl'][0] / 1000;
$TODO['starty'] = $svg->bound_twd67['tl'][1] / 1000;
$TODO['shiftx'] = ($svg->bound_twd67['br'][0] - $svg->bound_twd67['tl'][0]) / 1000;
$TODO['shifty'] = ($svg->bound_twd67['tl'][1] - $svg->bound_twd67['br'][1]) / 1000;
$TODO['ph'] = $svg->bound_twd67['ph'];
// 2. 加入 queue
/*
require_once("../lib/memq.inc.php");