コード例 #1
0
ファイル: Header.php プロジェクト: marando/jplephem
 /**
  * Parses the constant values from GROUP 1040 and 1041
  *
  * @param FileReader $file
  */
 protected function parseGroup1040and1041(FileReader $file)
 {
     $coeffNames = [];
     $coeffValues = [];
     // Seek to start of GROUP 1040, and store the total number of constants
     $file->seek(14);
     $count = (int) trim($file->current());
     // Parse each constant header
     $i = 0;
     while ($i < $count) {
         $file->next();
         foreach ($file->splitCurrent(' ') as $coeff) {
             $coeffNames[] = $coeff;
             $i++;
         }
     }
     // Seek to the begining of GROUP 1041
     $file->seek(18 + ceil($count / 10));
     // Parse each constant value
     $i = 0;
     while ($i < $count) {
         $file->next();
         foreach ($file->splitCurrent(' ') as $value) {
             $coeffValues[] = static::evalNumber($value);
             $i++;
         }
     }
     // Create a new constant instance and store each of the coefficients
     $this->const = new Constant();
     for ($i = 0; $i < count($coeffNames); $i++) {
         $this->const->{$coeffNames[$i]} = $coeffValues[$i];
     }
 }