StarMgr.cpp   StarMgr.cpp 
skipping to change at line 87 skipping to change at line 87
QMap<QString,int> StarMgr::additionalNamesIndex; QMap<QString,int> StarMgr::additionalNamesIndex;
QMap<QString,int> StarMgr::additionalNamesIndexI18n; QMap<QString,int> StarMgr::additionalNamesIndexI18n;
QHash<int,QString> StarMgr::sciNamesMapI18n; QHash<int,QString> StarMgr::sciNamesMapI18n;
QMap<QString,int> StarMgr::sciNamesIndexI18n; QMap<QString,int> StarMgr::sciNamesIndexI18n;
QHash<int,QString> StarMgr::sciAdditionalNamesMapI18n; QHash<int,QString> StarMgr::sciAdditionalNamesMapI18n;
QMap<QString,int> StarMgr::sciAdditionalNamesIndexI18n; QMap<QString,int> StarMgr::sciAdditionalNamesIndexI18n;
QHash<int, varstar> StarMgr::varStarsMapI18n; QHash<int, varstar> StarMgr::varStarsMapI18n;
QMap<QString, int> StarMgr::varStarsIndexI18n; QMap<QString, int> StarMgr::varStarsIndexI18n;
QHash<int, wds> StarMgr::wdsStarsMapI18n; QHash<int, wds> StarMgr::wdsStarsMapI18n;
QMap<QString, int> StarMgr::wdsStarsIndexI18n; QMap<QString, int> StarMgr::wdsStarsIndexI18n;
QHash<int, int> StarMgr::saoStarsMap; QMap<QString, crossid> StarMgr::crossIdMap;
QMap<int, int> StarMgr::saoStarsIndex; QMap<int, int> StarMgr::saoStarsIndex;
QHash<int, int> StarMgr::hdStarsMap;
QMap<int, int> StarMgr::hdStarsIndex; QMap<int, int> StarMgr::hdStarsIndex;
QHash<int, int> StarMgr::hrStarsMap;
QMap<int, int> StarMgr::hrStarsIndex; QMap<int, int> StarMgr::hrStarsIndex;
QHash<int, QString> StarMgr::referenceMap; QHash<int, QString> StarMgr::referenceMap;
QStringList initStringListFromFile(const QString& file_name) QStringList initStringListFromFile(const QString& file_name)
{ {
QStringList list; QStringList list;
QFile f(file_name); QFile f(file_name);
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) if (f.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
while (!f.atEnd()) while (!f.atEnd())
skipping to change at line 226 skipping to change at line 224
} }
QString StarMgr::getSciAdditionalName(int hip) QString StarMgr::getSciAdditionalName(int hip)
{ {
QHash<int,QString>::const_iterator it(sciAdditionalNamesMapI18n.find (hip)); QHash<int,QString>::const_iterator it(sciAdditionalNamesMapI18n.find (hip));
if (it!=sciAdditionalNamesMapI18n.end()) if (it!=sciAdditionalNamesMapI18n.end())
return it.value(); return it.value();
return QString(); return QString();
} }
QString StarMgr::getCrossIdentificationDesignations(int hip) QString StarMgr::getCrossIdentificationDesignations(QString hip)
{ {
QString designations; QString designations;
QHash<int,int>::const_iterator it(saoStarsMap.find(hip)); QMap<QString, crossid>::const_iterator cr(crossIdMap.find(hip));
if (it!=saoStarsMap.end()) if (cr==crossIdMap.end() && hip.right(1).toUInt()==0)
designations = QString("SAO %1").arg(it.value()); cr = crossIdMap.find(hip.left(hip.size()-1));
QHash<int,int>::const_iterator it2(hdStarsMap.find(hip)); if (cr!=crossIdMap.end())
if (it2!=hdStarsMap.end())
{ {
if (designations.isEmpty()) crossid crossIdData = cr.value();
designations = QString("HD %1").arg(it2.value()); if (crossIdData.sao>0)
else designations = QString("SAO %1").arg(crossIdData.sao
designations += QString(" - HD %1").arg(it2.value()) );
;
}
QHash<int,int>::const_iterator it3(hrStarsMap.find(hip)); if (crossIdData.hd>0)
if (it3!=hrStarsMap.end()) {
{ if (designations.isEmpty())
if (designations.isEmpty()) designations = QString("HD %1").arg(crossIdD
designations = QString("HR %1").arg(it3.value()); ata.hd);
else else
designations += QString(" - HR %1").arg(it3.value()) designations += QString(" - HD %1").arg(cros
; sIdData.hd);
}
if (crossIdData.hr>0)
{
if (designations.isEmpty())
designations = QString("HR %1").arg(crossIdD
ata.hr);
else
designations += QString(" - HR %1").arg(cros
sIdData.hr);
}
} }
return designations; return designations;
} }
QString StarMgr::getWdsName(int hip) QString StarMgr::getWdsName(int hip)
{ {
QHash<int,wds>::const_iterator it(wdsStarsMapI18n.find(hip)); QHash<int,wds>::const_iterator it(wdsStarsMapI18n.find(hip));
if (it!=wdsStarsMapI18n.end()) if (it!=wdsStarsMapI18n.end())
return QString("WDS J%1").arg(it.value().designation); return QString("WDS J%1").arg(it.value().designation);
skipping to change at line 1003 skipping to change at line 1006
wdsStarsIndexI18n[QString("WDS J%1").arg(doubleStar.designat ion.toUpper())] = hip; wdsStarsIndexI18n[QString("WDS J%1").arg(doubleStar.designat ion.toUpper())] = hip;
++readOk; ++readOk;
} }
qDebug() << "Loaded" << readOk << "/" << totalRecords << "double sta rs"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "double sta rs";
} }
// Load cross-identification data from file // Load cross-identification data from file
void StarMgr::loadCrossIdentificationData(const QString& crossIdFile) void StarMgr::loadCrossIdentificationData(const QString& crossIdFile)
{ {
saoStarsMap.clear(); crossIdMap.clear();
saoStarsIndex.clear(); saoStarsIndex.clear();
hdStarsMap.clear();
hdStarsIndex.clear(); hdStarsIndex.clear();
hrStarsMap.clear();
hrStarsIndex.clear(); hrStarsIndex.clear();
qDebug() << "Loading cross-identification data from" << QDir::toNati veSeparators(crossIdFile); qDebug() << "Loading cross-identification data from" << QDir::toNati veSeparators(crossIdFile);
QFile ciFile(crossIdFile); QFile ciFile(crossIdFile);
if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(crossIdFile); qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(crossIdFile);
return; return;
} }
const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()). split('\n'); const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()). split('\n');
ciFile.close(); ciFile.close();
crossid crossIdData;
int readOk=0; int readOk=0;
int totalRecords=0; int totalRecords=0;
int lineNumber=0; int lineNumber=0;
// record structure is delimited with a 'tab' character. Example rec ord strings: // record structure is delimited with a 'tab' character. Example rec ord strings:
// "1 128522 224700" // "1 128522 224700"
// "2 165988 224690" // "2 165988 224690"
foreach(const QString& record, allRecords) foreach(const QString& record, allRecords)
{ {
++lineNumber; ++lineNumber;
// skip comments and empty lines // skip comments and empty lines
if (record.startsWith("//") || record.startsWith("#") || rec ord.isEmpty()) if (record.startsWith("//") || record.startsWith("#") || rec ord.isEmpty())
continue; continue;
++totalRecords; ++totalRecords;
const QStringList& fields = record.split('\t'); const QStringList& fields = record.split('\t');
if (fields.size()!=4) if (fields.size()!=5)
{ {
qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(crossIdFile) qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(crossIdFile)
<< " - record does not match record patte rn"; << " - record does not match record patte rn";
continue; continue;
} }
else else
{ {
// The record is the right format. Extract the fiel ds // The record is the right format. Extract the fiel ds
bool ok; bool ok;
unsigned int hip = fields.at(0).toUInt(&ok); unsigned int hip = fields.at(0).toUInt(&ok);
if (!ok) if (!ok)
{ {
qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile) qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile)
<< " - failed to convert " << fie lds.at(0) << "to a number"; << " - failed to convert " << fie lds.at(0) << "to a number";
continue; continue;
} }
unsigned int sao = fields.at(1).toUInt(&ok); QString hipstar = QString("%1%2").arg(hip).arg(field
unsigned int hd = fields.at(2).toUInt(&ok); s.at(1).trimmed());
unsigned int hr = fields.at(3).toUInt(&ok); crossIdData.sao = fields.at(2).toUInt(&ok);
crossIdData.hd = fields.at(3).toUInt(&ok);
if (sao>0) crossIdData.hr = fields.at(4).toUInt(&ok);
{
saoStarsMap[hip] = sao; crossIdMap[hipstar] = crossIdData;
saoStarsIndex[sao] = hip; if (crossIdData.sao>0)
} saoStarsIndex[crossIdData.sao] = hip;
if (crossIdData.hd>0)
if (hd>0) hdStarsIndex[crossIdData.hd] = hip;
{ if (crossIdData.hr>0)
hdStarsMap[hip] = hd; hrStarsIndex[crossIdData.hr] = hip;
hdStarsIndex[hd] = hip;
}
if (hr>0)
{
hrStarsMap[hip] = hr;
hrStarsIndex[hr] = hip;
}
++readOk; ++readOk;
} }
} }
qDebug() << "Loaded" << readOk << "/" << totalRecords << "cross-iden tification data records for stars"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "cross-iden tification data records for stars";
} }
int StarMgr::getMaxSearchLevel() const int StarMgr::getMaxSearchLevel() const
{ {
skipping to change at line 1313 skipping to change at line 1307
QRegExp rx("^\\s*(HIP|HP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx("^\\s*(HIP|HP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx.exactMatch(objw)) if (rx.exactMatch(objw))
{ {
return searchHP(rx.capturedTexts().at(2).toInt()); return searchHP(rx.capturedTexts().at(2).toInt());
} }
// Search by SAO number if it's an SAO formated number // Search by SAO number if it's an SAO formated number
QRegExp rx2("^\\s*(SAO)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx2("^\\s*(SAO)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx2.exactMatch(objw)) if (rx2.exactMatch(objw))
{ {
QMap<int,int>::const_iterator sao(saoStarsIndex.find(rx2.cap turedTexts().at(2).toInt())); QMap<int, int>::const_iterator sao(saoStarsIndex.find(rx2.ca pturedTexts().at(2).toInt()));
if (sao!=saoStarsIndex.end()) if (sao!=saoStarsIndex.end())
{
return searchHP(sao.value()); return searchHP(sao.value());
}
} }
// Search by HD number if it's an HD formated number // Search by HD number if it's an HD formated number
QRegExp rx3("^\\s*(HD)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx3("^\\s*(HD)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx3.exactMatch(objw)) if (rx3.exactMatch(objw))
{ {
QMap<int,int>::const_iterator hd(hdStarsIndex.find(rx3.captu redTexts().at(2).toInt())); QMap<int, int>::const_iterator hd(hdStarsIndex.find(rx3.capt uredTexts().at(2).toInt()));
if (hd!=hdStarsIndex.end()) if (hd!=hdStarsIndex.end())
{
return searchHP(hd.value()); return searchHP(hd.value());
}
} }
// Search by HR number if it's an HR formated number // Search by HR number if it's an HR formated number
QRegExp rx4("^\\s*(HR)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx4("^\\s*(HR)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx4.exactMatch(objw)) if (rx4.exactMatch(objw))
{ {
QMap<int,int>::const_iterator hr(hrStarsIndex.find(rx4.captu redTexts().at(2).toInt())); QMap<int, int>::const_iterator hr(hrStarsIndex.find(rx4.capt uredTexts().at(2).toInt()));
if (hr!=hrStarsIndex.end()) if (hr!=hrStarsIndex.end())
{
return searchHP(hr.value()); return searchHP(hr.value());
}
} }
// Search by I18n common name // Search by I18n common name
QMap<QString,int>::const_iterator it(commonNamesIndexI18n.find(objw) ); QMap<QString,int>::const_iterator it(commonNamesIndexI18n.find(objw) );
if (it!=commonNamesIndexI18n.end()) if (it!=commonNamesIndexI18n.end())
{ {
return searchHP(it.value()); return searchHP(it.value());
} }
// Search by I18n additional common names // Search by I18n additional common names
skipping to change at line 1402 skipping to change at line 1390
QRegExp rx("^\\s*(HP|HIP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx("^\\s*(HP|HIP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx.exactMatch(objw)) if (rx.exactMatch(objw))
{ {
return searchHP(rx.capturedTexts().at(2).toInt()); return searchHP(rx.capturedTexts().at(2).toInt());
} }
// Search by SAO number if it's an SAO formated number // Search by SAO number if it's an SAO formated number
QRegExp rx2("^\\s*(SAO)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx2("^\\s*(SAO)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx2.exactMatch(objw)) if (rx2.exactMatch(objw))
{ {
QMap<int,int>::const_iterator sao(saoStarsIndex.find(rx2.cap turedTexts().at(2).toInt())); QMap<int, int>::const_iterator sao(saoStarsIndex.find(rx2.ca pturedTexts().at(2).toInt()));
if (sao!=saoStarsIndex.end()) if (sao!=saoStarsIndex.end())
{
return searchHP(sao.value()); return searchHP(sao.value());
}
} }
// Search by HD number if it's an HD formated number // Search by HD number if it's an HD formated number
QRegExp rx3("^\\s*(HD)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx3("^\\s*(HD)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx3.exactMatch(objw)) if (rx3.exactMatch(objw))
{ {
QMap<int,int>::const_iterator hd(hdStarsIndex.find(rx3.captu redTexts().at(2).toInt())); QMap<int, int>::const_iterator hd(hdStarsIndex.find(rx3.capt uredTexts().at(2).toInt()));
if (hd!=hdStarsIndex.end()) if (hd!=hdStarsIndex.end())
{
return searchHP(hd.value()); return searchHP(hd.value());
}
} }
// Search by HR number if it's an HR formated number // Search by HR number if it's an HR formated number
QRegExp rx4("^\\s*(HR)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx4("^\\s*(HR)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx4.exactMatch(objw)) if (rx4.exactMatch(objw))
{ {
QMap<int,int>::const_iterator hr(hrStarsIndex.find(rx4.captu redTexts().at(2).toInt())); QMap<int, int>::const_iterator hr(hrStarsIndex.find(rx4.capt uredTexts().at(2).toInt()));
if (hr!=hrStarsIndex.end()) if (hr!=hrStarsIndex.end())
{
return searchHP(hr.value()); return searchHP(hr.value());
}
} }
// Search by English common name // Search by English common name
QMap<QString,int>::const_iterator it(commonNamesIndex.find(objw)); QMap<QString,int>::const_iterator it(commonNamesIndex.find(objw));
if (it!=commonNamesIndex.end()) if (it!=commonNamesIndex.end())
{ {
return searchHP(it.value()); return searchHP(it.value());
} }
// Search by English additional common names // Search by English additional common names
skipping to change at line 1626 skipping to change at line 1608
} }
} }
// Add exact SAO catalogue numbers // Add exact SAO catalogue numbers
QRegExp saoRx("^(SAO)\\s*(\\d+)\\s*$"); QRegExp saoRx("^(SAO)\\s*(\\d+)\\s*$");
saoRx.setCaseSensitivity(Qt::CaseInsensitive); saoRx.setCaseSensitivity(Qt::CaseInsensitive);
if (saoRx.exactMatch(objw)) if (saoRx.exactMatch(objw))
{ {
bool ok; bool ok;
int saoNum = saoRx.capturedTexts().at(2).toInt(&ok); int saoNum = saoRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator sao(saoStarsIndex.find(saoNum) ); QMap<int, int>::const_iterator sao(saoStarsIndex.find(saoNum ));
if (sao!=saoStarsIndex.end()) if (sao!=saoStarsIndex.end())
{ {
StelObjectP s = searchHP(sao.value()); StelObjectP s = searchHP(sao.value());
if (s && maxNbItem>0) if (s && maxNbItem>0)
{ {
result << QString("SAO%1").arg(saoNum); result << QString("SAO%1").arg(saoNum);
maxNbItem--; maxNbItem--;
} }
} }
} }
// Add exact HD catalogue numbers // Add exact HD catalogue numbers
QRegExp hdRx("^(HD)\\s*(\\d+)\\s*$"); QRegExp hdRx("^(HD)\\s*(\\d+)\\s*$");
hdRx.setCaseSensitivity(Qt::CaseInsensitive); hdRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hdRx.exactMatch(objw)) if (hdRx.exactMatch(objw))
{ {
bool ok; bool ok;
int hdNum = hdRx.capturedTexts().at(2).toInt(&ok); int hdNum = hdRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator hd(hdStarsIndex.find(hdNum)); QMap<int, int>::const_iterator hd(hdStarsIndex.find(hdNum));
if (hd!=hdStarsIndex.end()) if (hd!=hdStarsIndex.end())
{ {
StelObjectP s = searchHP(hd.value()); StelObjectP s = searchHP(hd.value());
if (s && maxNbItem>0) if (s && maxNbItem>0)
{ {
result << QString("HD%1").arg(hdNum); result << QString("HD%1").arg(hdNum);
maxNbItem--; maxNbItem--;
} }
} }
} }
// Add exact HR catalogue numbers // Add exact HR catalogue numbers
QRegExp hrRx("^(HR)\\s*(\\d+)\\s*$"); QRegExp hrRx("^(HR)\\s*(\\d+)\\s*$");
hrRx.setCaseSensitivity(Qt::CaseInsensitive); hrRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hrRx.exactMatch(objw)) if (hrRx.exactMatch(objw))
{ {
bool ok; bool ok;
int hrNum = hrRx.capturedTexts().at(2).toInt(&ok); int hrNum = hrRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator hr(hrStarsIndex.find(hrNum)); QMap<int, int>::const_iterator hr(hrStarsIndex.find(hrNum));
if (hr!=hrStarsIndex.end()) if (hr!=hrStarsIndex.end())
{ {
StelObjectP s = searchHP(hr.value()); StelObjectP s = searchHP(hr.value());
if (s && maxNbItem>0) if (s && maxNbItem>0)
{ {
result << QString("HR%1").arg(hrNum); result << QString("HR%1").arg(hrNum);
maxNbItem--; maxNbItem--;
} }
} }
} }
 End of changes. 35 change blocks. 
69 lines changed or deleted 55 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/