Skip to content

Commit

Permalink
Fixed loading star names for Hawaiian Starlines SC (fix #2808)
Browse files Browse the repository at this point in the history
+ cosmetic fixes for logger
  • Loading branch information
alex-w committed Nov 9, 2022
1 parent 028e1f5 commit 31fd90c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 51 deletions.
24 changes: 12 additions & 12 deletions src/core/modules/NebulaMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,8 +1408,8 @@ void NebulaMgr::convertDSOCatalog(const QString &in, const QString &out, bool de
dsoIn.close();
dsoOut.flush();
dsoOut.close();
qDebug() << "Converted" << readOk << "/" << totalRecords << "DSO records";
qDebug() << "[...] Please use 'gzip -nc catalog.pack > catalog.dat' to pack the catalog.";
qDebug().noquote() << "Converted" << readOk << "/" << totalRecords << "DSO records";
qDebug().noquote() << "[...] Please use 'gzip -nc catalog.pack > catalog.dat' to pack the catalog.";
}

bool NebulaMgr::loadDSOCatalog(const QString &filename)
Expand All @@ -1418,7 +1418,7 @@ bool NebulaMgr::loadDSOCatalog(const QString &filename)
if (!in.open(QIODevice::ReadOnly))
return false;

qDebug() << "Loading DSO data ...";
qDebug().noquote() << "Loading DSO data ...";

// Let's begin use gzipped data
QDataStream ins(StelUtils::uncompress(in.readAll()));
Expand All @@ -1435,12 +1435,12 @@ bool NebulaMgr::loadDSOCatalog(const QString &filename)
version = "3.1"; // The first version of extended edition of the catalog
if (edition.isEmpty())
edition = "unknown";
qDebug() << "[...]" << QString("Stellarium DSO Catalog, version %1 (%2 edition)").arg(version, edition);
qDebug().noquote() << "[...]" << QString("Stellarium DSO Catalog, version %1 (%2 edition)").arg(version, edition);
if (StelUtils::compareVersions(version, StellariumDSOCatalogVersion)!=0)
{
++totalRecords;
qDebug() << "WARNING: Mismatch of DSO catalog version (" << version << ")! The expected version is" << StellariumDSOCatalogVersion;
qDebug() << " See section 5.5 of the User Guide and install the right version of the catalog!";
qDebug().noquote() << "WARNING: Mismatch of DSO catalog version (" << version << ")! The expected version is" << StellariumDSOCatalogVersion;
qDebug().noquote() << " See section 5.5 of the User Guide and install the right version of the catalog!";
QMessageBox::warning(Q_NULLPTR, q_("Attention!"), QString("%1. %2: %3 - %4: %5. %6").arg(q_("DSO catalog version mismatch"), q_("Found"), version, q_("Expected"), StellariumDSOCatalogVersion, q_("See Logfile for instructions.")), QMessageBox::Ok);
break;
}
Expand All @@ -1459,7 +1459,7 @@ bool NebulaMgr::loadDSOCatalog(const QString &filename)
++totalRecords;
}
in.close();
qDebug() << "Loaded" << --totalRecords << "DSO records";
qDebug().noquote() << "Loaded" << --totalRecords << "DSO records";
return true;
}

Expand All @@ -1469,7 +1469,7 @@ bool NebulaMgr::loadDSONames(const QString &filename)
QFile dsoNameFile(filename);
if (!dsoNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "DSO name data file" << QDir::toNativeSeparators(filename) << "not found.";
qWarning().noquote() << "DSO name data file" << QDir::toNativeSeparators(filename) << "not found.";
return false;
}

Expand Down Expand Up @@ -1619,11 +1619,11 @@ bool NebulaMgr::loadDSONames(const QString &filename)
nodata.append(QString("%1 %2").arg(ref.trimmed(), cdes.trimmed()));
}
dsoNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "DSO name records successfully";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "DSO name records successfully";

int err = nodata.size();
if (err>0)
qDebug() << "WARNING - No position data for" << err << "objects:" << nodata.join(", ");
qDebug().noquote() << "WARNING - No position data for" << err << "objects:" << nodata.join(", ");

return true;
}
Expand All @@ -1634,7 +1634,7 @@ bool NebulaMgr::loadDSOOutlines(const QString &filename)
QFile dsoOutlineFile(filename);
if (!dsoOutlineFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "DSO outline data file" << QDir::toNativeSeparators(filename) << "not found.";
qWarning().noquote() << "DSO outline data file" << QDir::toNativeSeparators(filename) << "not found.";
return false;
}

Expand Down Expand Up @@ -1718,7 +1718,7 @@ bool NebulaMgr::loadDSOOutlines(const QString &filename)
}
}
dsoOutlineFile.close();
qDebug() << "Loaded" << readOk << "DSO outline records successfully";
qDebug().noquote() << "Loaded" << readOk << "DSO outline records successfully";
return true;
}

Expand Down
77 changes: 39 additions & 38 deletions src/core/modules/StarMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,11 @@ int StarMgr::loadCommonNames(const QString& commonNameFile)
additionalNamesIndex.clear();
additionalNamesIndexI18n.clear();

qDebug() << "Loading star names from" << QDir::toNativeSeparators(commonNameFile);
qDebug().noquote() << "Loading star names from" << QDir::toNativeSeparators(commonNameFile);
QFile cnFile(commonNameFile);
if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(commonNameFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(commonNameFile);
return 0;
}

Expand All @@ -755,11 +755,11 @@ int StarMgr::loadCommonNames(const QString& commonNameFile)
// " 677|_("Alpheratz")"
// "113368|_("Fomalhaut")"
// Note: Stellarium doesn't support sky cultures made prior to version 0.10.6 now!
static const QRegularExpression recordRx("^\\s*(\\d+)\\s*\\|[_]*[(]\"(.*)\"[)]\\s*([\\,\\d\\s]*)\\n");
static const QRegularExpression recordRx("^\\s*(\\d+)\\s*\\|[_]*[(]\"(.*)\"[)]\\s*([\\,\\d\\s]*)");

while(!cnFile.atEnd())
{
record = QString::fromUtf8(cnFile.readLine());
record = QString::fromUtf8(cnFile.readLine()).trimmed();
lineNumber++;
if (commentRx.match(record).hasMatch())
continue;
Expand All @@ -768,8 +768,9 @@ int StarMgr::loadCommonNames(const QString& commonNameFile)
QRegularExpressionMatch recMatch=recordRx.match(record);
if (!recMatch.hasMatch())
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
<< " - record does not match record pattern";
qWarning().noquote() << "Problematic record:" << record;
continue;
}
else
Expand All @@ -779,14 +780,14 @@ int StarMgr::loadCommonNames(const QString& commonNameFile)
int hip = recMatch.captured(1).toInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
<< " - failed to convert " << recMatch.captured(1) << "to a number";
continue;
}
QString englishCommonName = recMatch.captured(2).trimmed();
if (englishCommonName.isEmpty())
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
<< " - empty name field";
continue;
}
Expand Down Expand Up @@ -832,7 +833,7 @@ int StarMgr::loadCommonNames(const QString& commonNameFile)
}
cnFile.close();

qDebug() << "Loaded" << readOk << "/" << totalRecords << "common star names";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "common star names";
return 1;
}

Expand All @@ -844,19 +845,19 @@ void StarMgr::loadSciNames(const QString& sciNameFile, const bool extraData)
{
sciExtraDesignationsMapI18n.clear();
sciExtraDesignationsIndexI18n.clear();
qDebug() << "Loading scientific star extra names from" << QDir::toNativeSeparators(sciNameFile);
qDebug().noquote() << "Loading scientific star extra names from" << QDir::toNativeSeparators(sciNameFile);
}
else
{
sciDesignationsMapI18n.clear();
sciDesignationsIndexI18n.clear();
qDebug() << "Loading scientific star names from" << QDir::toNativeSeparators(sciNameFile);
qDebug().noquote() << "Loading scientific star names from" << QDir::toNativeSeparators(sciNameFile);
}

QFile snFile(sciNameFile);
if (!snFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(sciNameFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(sciNameFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(snFile.readAll()).split('\n');
Expand All @@ -879,7 +880,7 @@ void StarMgr::loadSciNames(const QString& sciNameFile, const bool extraData)
const QStringList& fields = record.split('|');
if (fields.size()!=2)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
<< " - record does not match record pattern";
continue;
}
Expand All @@ -890,15 +891,15 @@ void StarMgr::loadSciNames(const QString& sciNameFile, const bool extraData)
int hip = fields.at(0).toInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
<< " - failed to convert " << fields.at(0) << "to a number";
continue;
}

QString sci_name = fields.at(1).trimmed();
if (sci_name.isEmpty())
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
<< " - empty name field";
continue;
}
Expand Down Expand Up @@ -933,9 +934,9 @@ void StarMgr::loadSciNames(const QString& sciNameFile, const bool extraData)
}

if (extraData)
qDebug() << "Loaded" << readOk << "/" << totalRecords << "scientific star extra names";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "scientific star extra names";
else
qDebug() << "Loaded" << readOk << "/" << totalRecords << "scientific star names";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "scientific star names";
}

// Load GCVS from file
Expand All @@ -944,11 +945,11 @@ void StarMgr::loadGcvs(const QString& GcvsFile)
varStarsMapI18n.clear();
varStarsIndexI18n.clear();

qDebug() << "Loading variable stars from" << QDir::toNativeSeparators(GcvsFile);
qDebug().noquote() << "Loading variable stars from" << QDir::toNativeSeparators(GcvsFile);
QFile vsFile(GcvsFile);
if (!vsFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(GcvsFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(GcvsFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(vsFile.readAll()).split('\n');
Expand All @@ -973,7 +974,7 @@ void StarMgr::loadGcvs(const QString& GcvsFile)
int hip = fields.at(0).toInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(GcvsFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(GcvsFile)
<< " - failed to convert " << fields.at(0) << "to a number";
continue;
}
Expand Down Expand Up @@ -1010,7 +1011,7 @@ void StarMgr::loadGcvs(const QString& GcvsFile)
++readOk;
}

qDebug() << "Loaded" << readOk << "/" << totalRecords << "variable stars";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "variable stars";
}

// Load WDS from file
Expand All @@ -1019,11 +1020,11 @@ void StarMgr::loadWds(const QString& WdsFile)
wdsStarsMapI18n.clear();
wdsStarsIndexI18n.clear();

qDebug() << "Loading double stars from" << QDir::toNativeSeparators(WdsFile);
qDebug().noquote() << "Loading double stars from" << QDir::toNativeSeparators(WdsFile);
QFile dsFile(WdsFile);
if (!dsFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(WdsFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(WdsFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(dsFile.readAll()).split('\n');
Expand Down Expand Up @@ -1069,7 +1070,7 @@ void StarMgr::loadWds(const QString& WdsFile)
++readOk;
}

qDebug() << "Loaded" << readOk << "/" << totalRecords << "double stars";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "double stars";
}

// Load cross-identification data from file
Expand All @@ -1080,11 +1081,11 @@ void StarMgr::loadCrossIdentificationData(const QString& crossIdFile)
hdStarsIndex.clear();
hrStarsIndex.clear();

qDebug() << "Loading cross-identification data from" << QDir::toNativeSeparators(crossIdFile);
qDebug().noquote() << "Loading cross-identification data from" << QDir::toNativeSeparators(crossIdFile);
QFile ciFile(crossIdFile);
if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(crossIdFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(crossIdFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()).split('\n');
Expand All @@ -1109,7 +1110,7 @@ void StarMgr::loadCrossIdentificationData(const QString& crossIdFile)
const QStringList& fields = record.split('\t');
if (fields.size()!=5)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile)
<< " - record does not match record pattern";
continue;
}
Expand All @@ -1120,7 +1121,7 @@ void StarMgr::loadCrossIdentificationData(const QString& crossIdFile)
int hip = fields.at(0).toInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile)
<< " - failed to convert " << fields.at(0) << "to a number";
continue;
}
Expand All @@ -1142,19 +1143,19 @@ void StarMgr::loadCrossIdentificationData(const QString& crossIdFile)
}
}

qDebug() << "Loaded" << readOk << "/" << totalRecords << "cross-identification data records for stars";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "cross-identification data records for stars";
}

void StarMgr::loadPlxErr(const QString& plxErrFile)
{
// TODO: This is temporary solution for display parallax errors until format of stars catalogs will not be changed!
hipParallaxErrors.clear();

qDebug() << "Loading parallax errors data from" << QDir::toNativeSeparators(plxErrFile);
qDebug().noquote() << "Loading parallax errors data from" << QDir::toNativeSeparators(plxErrFile);
QFile ciFile(plxErrFile);
if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(plxErrFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(plxErrFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()).split('\n');
Expand All @@ -1177,7 +1178,7 @@ void StarMgr::loadPlxErr(const QString& plxErrFile)
const QStringList& fields = record.split('\t');
if (fields.size()!=2)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(plxErrFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(plxErrFile)
<< " - record does not match record pattern";
continue;
}
Expand All @@ -1188,7 +1189,7 @@ void StarMgr::loadPlxErr(const QString& plxErrFile)
int hip = fields.at(0).toInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(plxErrFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(plxErrFile)
<< " - failed to convert " << fields.at(0) << "to a number";
continue;
}
Expand All @@ -1198,19 +1199,19 @@ void StarMgr::loadPlxErr(const QString& plxErrFile)
}
}

qDebug() << "Loaded" << readOk << "/" << totalRecords << "parallax error data records for stars";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "parallax error data records for stars";
}

void StarMgr::loadPMData(const QString &pmDataFile)
{
// TODO: This is temporary solution for display parallax errors until format of stars catalogs will not be changed!
hipPMData.clear();

qDebug() << "Loading proper motion data from" << QDir::toNativeSeparators(pmDataFile);
qDebug().noquote() << "Loading proper motion data from" << QDir::toNativeSeparators(pmDataFile);
QFile ciFile(pmDataFile);
if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSeparators(pmDataFile);
qWarning().noquote() << "WARNING - could not open" << QDir::toNativeSeparators(pmDataFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()).split('\n');
Expand All @@ -1233,7 +1234,7 @@ void StarMgr::loadPMData(const QString &pmDataFile)
const QStringList& fields = record.split('\t');
if (fields.size()!=3)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(pmDataFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(pmDataFile)
<< " - record does not match record pattern";
continue;
}
Expand All @@ -1244,7 +1245,7 @@ void StarMgr::loadPMData(const QString &pmDataFile)
int hip = fields.at(0).toInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(pmDataFile)
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(pmDataFile)
<< " - failed to convert " << fields.at(0) << "to a number";
continue;
}
Expand All @@ -1257,7 +1258,7 @@ void StarMgr::loadPMData(const QString &pmDataFile)
}
}

qDebug() << "Loaded" << readOk << "/" << totalRecords << "proper motion data records for stars";
qDebug().noquote() << "Loaded" << readOk << "/" << totalRecords << "proper motion data records for stars";
}

int StarMgr::getMaxSearchLevel() const
Expand Down
2 changes: 1 addition & 1 deletion src/core/modules/ZoneArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ZoneArray* ZoneArray::create(const QString& catalogFilePath, bool use_mmap)
ReadInt(*file,mag_steps) < 0)
{
dbStr += "error - file format is bad.";
qDebug() << dbStr;
qDebug().noquote() << dbStr;
return Q_NULLPTR;
}
const bool byte_swap = (magic == FILE_MAGIC_OTHER_ENDIAN);
Expand Down

0 comments on commit 31fd90c

Please sign in to comment.