Ejemplo n.º 1
0
function stb_loaddata($stbindex, &$x, &$y, &$f, $arrayfile)
{
    $i = 0;
    // try to get sorted array it from file
    if (arrayfile($arrayfile, $array, "GET") === FALSE) {
        // actually load
        if (!($fp = fopen($file, "r"))) {
            echo "cannot open {$file}!\n";
            return FALSE;
        }
        while ($line = fgets($fp, 128)) {
            //list ($x[$i],$y[$i],$f[$i])=split(" ",$line,3);
            list($array[$i]['x'], $array[$i]['y'], $array[$i]['f']) = split(" ", trim($line), 3);
            $i++;
            // echo "$i =" . $x[$i-1][0] . "$line";
        }
        fclose($fp);
        $B = new mdasort();
        $B->aData = $array;
        $B->aSortKeys = array(array('x', 'ASC'), array('y', 'DESC'));
        $B->sort();
        echo "get it from {$file}\n";
        if (arrayfile($arrayfile, $array, "DUMP") === FALSE) {
            echo "{$arrayfile} write failed\n";
        }
    }
    for ($j = 0; $j < count($array); $j++) {
        $x[$j] = $array[$j]['x'];
        $y[$j] = $array[$j]['y'];
        $f[$j] = $array[$j]['f'];
    }
    return TRUE;
}
Ejemplo n.º 2
0
 function load_index()
 {
     // return FALSE when error
     $i = 0;
     // try to get sorted array it from file
     if (arrayfile($this->arrayfile, $array, "GET") === FALSE) {
         // actually load
         if (!($fp = fopen($this->stbindex, "r"))) {
             $this->err[] = "cannot open stbindex!\n";
             return FALSE;
         }
         while ($line = fgets($fp, 128)) {
             list($array[$i]['x'], $array[$i]['y'], $array[$i]['f']) = preg_split("/\\s+/", trim($line), 3);
             $i++;
             // echo "$i =" . $this->x[$i-1][0] . "$line";
         }
         fclose($fp);
         $B = new mdasort();
         $B->aData = $array;
         $B->aSortKeys = array(array('x', 'ASC'), array('y', 'DESC'));
         $B->sort();
         // echo "get it from $file\n";
         if (arrayfile($this->arrayfile, $array, "DUMP") === FALSE) {
             $this->err[] = "{$arrayfile} write failed\n";
             return FALSE;
         }
     }
     for ($j = 0; $j < count($array); $j++) {
         $this->x[$j] = $array[$j]['x'];
         $this->y[$j] = $array[$j]['y'];
         $this->f[$j] = $array[$j]['f'];
     }
     $this->doLog("index loaded..");
     return TRUE;
 }