Пример #1
0
 bool Application::loadCameraCalibration(fs::path const &ccPath)
 {
     {
         std::ifstream ccFile(ccPath.string());
         if(!ccFile.is_open())
             return false;
         
         cv::CameraCalibration &ccal = m_CameraCalibration;
         {
             base::IArchive ccArchive(ccFile);
             ccArchive & ccal;
         }
         
     }
     
     return true;
 }
Пример #2
0
bool CatalogDB::AddCatalogContents(const QString& fname) {
  QDir::setCurrent(QDir::homePath());  // for files with relative path
  QString filename = fname;
  // If the filename begins with "~", replace the "~" with the user's home
  // directory (otherwise, the file will not successfully open)
  if (filename.at(0) == '~')
      filename = QDir::homePath() + filename.mid(1, filename.length());

  QFile ccFile(filename);

  if (ccFile.open(QIODevice::ReadOnly)) {
      QStringList columns;  // list of data column descriptors in the header
      QString catalog_name;
      char delimiter;

      QTextStream stream(&ccFile);
      // TODO(spacetime) : Decide appropriate number of lines to be read
      QStringList lines;
      for (int times = 10; times >= 0 && !stream.atEnd(); --times)
        lines.append(stream.readLine());
      /*WAS
        * = stream.readAll().split('\n', QString::SkipEmptyParts);
        * Memory Hog!
        */

      if (lines.size() < 1 ||
          !ParseCatalogInfoToDB(lines, columns, catalog_name, delimiter)) {
          kWarning() << "Issue in catalog file header: " << filename;
          ccFile.close();
          return false;
      }
      ccFile.close();
      // The entry in the Catalog table is now ready!

      /*
        * Now 'Columns' should be a StringList of the Header contents
        * Hence, we 1) Convert the Columns to a KSParser compatible format
        *           2) Use KSParser to read stuff and store in DB
        */

      // Part 1) Conversion to KSParser compatible format
      QList< QPair<QString, KSParser::DataTypes> > sequence =
                                          buildParserSequence(columns);

      // Part 2) Read file and store into DB
      KSParser catalog_text_parser(filename, '#', sequence, delimiter);

      QHash<QString, QVariant> row_content;
      while (catalog_text_parser.HasNextRow()) {
        row_content = catalog_text_parser.ReadNextRow();

        CatalogEntryData catalog_entry;

        dms read_ra(row_content["RA"].toString(), false);
        dms read_dec(row_content["Dc"].toString(), true);
        kDebug()<<row_content["Nm"].toString();
        catalog_entry.catalog_name = catalog_name;
        catalog_entry.ID = row_content["ID"].toInt();
        catalog_entry.long_name = row_content["Nm"].toString();
        catalog_entry.ra = read_ra.Degrees();
        catalog_entry.dec = read_dec.Degrees();
        catalog_entry.type = row_content["Tp"].toInt();
        catalog_entry.magnitude = row_content["Mg"].toFloat();
        catalog_entry.position_angle = row_content["PA"].toFloat();
        catalog_entry.major_axis = row_content["Mj"].toFloat();
        catalog_entry.minor_axis = row_content["Mn"].toFloat();
        catalog_entry.flux = row_content["Flux"].toFloat();

        AddEntry(catalog_entry);
      }
  }
  return true;
}