void CatalogDB::GetAllObjects(const QString &catalog, QList< SkyObject* > &sky_list, QList < QPair <int, QString> > &object_names, CatalogComponent *catalog_ptr) { sky_list.clear(); QString selected_catalog = QString::number(FindCatalog(catalog)); skydb_.open(); QSqlQuery get_query(skydb_); get_query.prepare("SELECT Epoch, Type, RA, Dec, Magnitude, Prefix, " "IDNumber, LongName, MajorAxis, MinorAxis, " "PositionAngle, Flux FROM ObjectDesignation JOIN DSO " "JOIN Catalog WHERE Catalog.id = :catID AND " "ObjectDesignation.id_Catalog = Catalog.id AND " "ObjectDesignation.UID_DSO = DSO.UID"); get_query.bindValue("catID", selected_catalog); // kWarning() << get_query.lastQuery(); // kWarning() << get_query.lastError(); // kWarning() << FindCatalog(catalog); if (!get_query.exec()) { kWarning() << get_query.lastQuery(); kWarning() << get_query.lastError(); } while (get_query.next()) { int cat_epoch = get_query.value(0).toInt(); unsigned char iType = get_query.value(1).toInt(); dms RA(get_query.value(2).toDouble()); dms Dec(get_query.value(3).toDouble()); float mag = get_query.value(4).toFloat(); QString catPrefix = get_query.value(5).toString(); int id_number_in_catalog = get_query.value(6).toInt(); QString lname = get_query.value(7).toString(); float a = get_query.value(8).toFloat(); float b = get_query.value(9).toFloat(); float PA = get_query.value(10).toFloat(); float flux = get_query.value(11).toFloat(); QString name = catPrefix + ' ' + QString::number(id_number_in_catalog); SkyPoint t; t.set(RA, Dec); if (cat_epoch == 1950) { // Assume B1950 epoch t.B1950ToJ2000(); // t.ra() and t.dec() are now J2000.0 // coordinates } else if (cat_epoch == 2000) { // Do nothing { } } else { // FIXME: What should we do? // FIXME: This warning will be printed for each line in the // catalog rather than once for the entire catalog kWarning() << "Unknown epoch while dealing with custom " "catalog. Will ignore the epoch and assume" " J2000.0"; } RA = t.ra(); Dec = t.dec(); if (iType == 0) { // Add a star StarObject *o = new StarObject(RA, Dec, mag, lname); sky_list.append(o); } else { // Add a deep-sky object DeepSkyObject *o = new DeepSkyObject(iType, RA, Dec, mag, name, QString(), lname, catPrefix, a, b, -PA); o->setFlux(flux); o->setCustomCatalog(catalog_ptr); sky_list.append(o); // Add name to the list of object names if (!name.isEmpty()) { object_names.append(qMakePair<int,QString>(iType, name)); } } if (!lname.isEmpty() && lname != name) { object_names.append(qMakePair<int,QString>(iType, lname)); } } get_query.clear(); skydb_.close(); }