StarMgr.cpp   StarMgr.cpp 
skipping to change at line 67 skipping to change at line 67
#include <QCryptographicHash> #include <QCryptographicHash>
#include <errno.h> #include <errno.h>
static QStringList spectral_array; static QStringList spectral_array;
static QStringList component_array; static QStringList component_array;
// This number must be incremented each time the content or file format of the stars catalogs change // This number must be incremented each time the content or file format of the stars catalogs change
// It can also be incremented when the defaultStarsConfig.json file change. // It can also be incremented when the defaultStarsConfig.json file change.
// It should always matchs the version field of the defaultStarsConfig.json file // It should always matchs the version field of the defaultStarsConfig.json file
static const int StarCatalogFormatVersion = 8; static const int StarCatalogFormatVersion = 9;
// Initialise statics // Initialise statics
bool StarMgr::flagSciNames = true; bool StarMgr::flagSciNames = true;
QHash<int,QString> StarMgr::commonNamesMap; QHash<int,QString> StarMgr::commonNamesMap;
QHash<int,QString> StarMgr::commonNamesMapI18n; QHash<int,QString> StarMgr::commonNamesMapI18n;
QHash<int,QString> StarMgr::additionalNamesMap;
QHash<int,QString> StarMgr::additionalNamesMapI18n;
QMap<QString,int> StarMgr::commonNamesIndexI18n; QMap<QString,int> StarMgr::commonNamesIndexI18n;
QMap<QString,int> StarMgr::commonNamesIndex; QMap<QString,int> StarMgr::commonNamesIndex;
QMap<QString,int> StarMgr::additionalNamesIndex;
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; QHash<int, int> StarMgr::saoStarsMap;
QMap<int, int> StarMgr::saoStarsIndex; QMap<int, int> StarMgr::saoStarsIndex;
QHash<int, int> StarMgr::hdStarsMap; 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;
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())
{ {
QString s = QString::fromUtf8(f.readLine()); QString s = QString::fromUtf8(f.readLine());
skipping to change at line 179 skipping to change at line 186
ConstellationMgr* cmgr=GETSTELMODULE(ConstellationMgr); ConstellationMgr* cmgr=GETSTELMODULE(ConstellationMgr);
if (cmgr->getConstellationDisplayStyle() == ConstellationMgr::conste llationsNative) if (cmgr->getConstellationDisplayStyle() == ConstellationMgr::conste llationsNative)
return getCommonEnglishName(hip); return getCommonEnglishName(hip);
QHash<int,QString>::const_iterator it(commonNamesMapI18n.find(hip)); QHash<int,QString>::const_iterator it(commonNamesMapI18n.find(hip));
if (it!=commonNamesMapI18n.end()) if (it!=commonNamesMapI18n.end())
return it.value(); return it.value();
return QString(); return QString();
} }
QString StarMgr::getAdditionalNames(int hip)
{
QHash<int,QString>::const_iterator it(additionalNamesMapI18n.find(hi
p));
if (it!=additionalNamesMapI18n.end())
return it.value();
return QString();
}
QString StarMgr::getAdditionalEnglishNames(int hip)
{
QHash<int,QString>::const_iterator it(additionalNamesMap.find(hip));
if (it!=additionalNamesMap.end())
return it.value();
return QString();
}
QString StarMgr::getCommonEnglishName(int hip) QString StarMgr::getCommonEnglishName(int hip)
{ {
QHash<int,QString>::const_iterator it(commonNamesMap.find(hip)); QHash<int,QString>::const_iterator it(commonNamesMap.find(hip));
if (it!=commonNamesMap.end()) if (it!=commonNamesMap.end())
return it.value(); return it.value();
return QString(); return QString();
} }
QString StarMgr::getSciName(int hip) QString StarMgr::getSciName(int hip)
{ {
skipping to change at line 219 skipping to change at line 242
QHash<int,int>::const_iterator it2(hdStarsMap.find(hip)); QHash<int,int>::const_iterator it2(hdStarsMap.find(hip));
if (it2!=hdStarsMap.end()) if (it2!=hdStarsMap.end())
{ {
if (designations.isEmpty()) if (designations.isEmpty())
designations = QString("HD %1").arg(it2.value()); designations = QString("HD %1").arg(it2.value());
else else
designations += QString(" - HD %1").arg(it2.value()) ; designations += QString(" - HD %1").arg(it2.value()) ;
} }
QHash<int,int>::const_iterator it3(hrStarsMap.find(hip));
if (it3!=hrStarsMap.end())
{
if (designations.isEmpty())
designations = QString("HR %1").arg(it3.value());
else
designations += QString(" - HR %1").arg(it3.value())
;
}
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);
return QString(); return QString();
} }
skipping to change at line 598 skipping to change at line 630
{ {
QString tmpFic = StelFileMgr::findFile("stars/default/" + ca t_hip_cids_file_name); QString tmpFic = StelFileMgr::findFile("stars/default/" + ca t_hip_cids_file_name);
if (tmpFic.isEmpty()) if (tmpFic.isEmpty())
qWarning() << "ERROR while loading data from " << QD ir::toNativeSeparators(("stars/default/" + cat_hip_cids_file_name)); qWarning() << "ERROR while loading data from " << QD ir::toNativeSeparators(("stars/default/" + cat_hip_cids_file_name));
else else
component_array = initStringListFromFile(tmpFic); component_array = initStringListFromFile(tmpFic);
} }
lastMaxSearchLevel = maxGeodesicGridLevel; lastMaxSearchLevel = maxGeodesicGridLevel;
qDebug() << "Finished loading star catalogue data, max_geodesic_leve l: " << maxGeodesicGridLevel; qDebug() << "Finished loading star catalogue data, max_geodesic_leve l: " << maxGeodesicGridLevel;
hipparcosStars.clear();
for (int hip=0; hip<=NR_OF_HIP; hip++)
{
const Star1 *const s = hipIndex[hip].s;
if (s)
{
const SpecialZoneArray<Star1> *const a = hipIndex[hi
p].a;
const SpecialZoneData<Star1> *const z = hipIndex[hip
].z;
hipparcosStars.push_back(s->createStelObject(a,z));
}
}
} }
// Load common names from file // Load common names from file
int StarMgr::loadCommonNames(const QString& commonNameFile) int StarMgr::loadCommonNames(const QString& commonNameFile)
{ {
commonNamesMap.clear(); commonNamesMap.clear();
commonNamesMapI18n.clear(); commonNamesMapI18n.clear();
additionalNamesMap.clear();
additionalNamesMapI18n.clear();
commonNamesIndexI18n.clear(); commonNamesIndexI18n.clear();
commonNamesIndex.clear(); commonNamesIndex.clear();
additionalNamesIndex.clear();
additionalNamesIndexI18n.clear();
qDebug() << "Loading star names from" << QDir::toNativeSeparators(co mmonNameFile); qDebug() << "Loading star names from" << QDir::toNativeSeparators(co mmonNameFile);
QFile cnFile(commonNameFile); QFile cnFile(commonNameFile);
if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!cnFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(commonNameFile); qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(commonNameFile);
return 0; return 0;
} }
int readOk=0; int readOk=0;
skipping to change at line 628 skipping to change at line 676
int lineNumber=0; int lineNumber=0;
QString record; QString record;
// Allow empty and comment lines where first char (after optional bl anks) is # // Allow empty and comment lines where first char (after optional bl anks) is #
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
// record structure is delimited with a | character. We will // record structure is delimited with a | character. We will
// use a QRegExp to extract the fields. with whitespace padding perm itted // use a QRegExp to extract the fields. with whitespace padding perm itted
// (i.e. it will be stripped automatically) Example record strings: // (i.e. it will be stripped automatically) Example record strings:
// " 677|_("Alpheratz")" // " 677|_("Alpheratz")"
// "113368|_("Fomalhaut")" // "113368|_("Fomalhaut")"
// Note: Stellarium doesn't support sky cultures made prior version 0.10.6 now! // Note: Stellarium doesn't support sky cultures made prior version 0.10.6 now!
QRegExp recordRx("^\\s*(\\d+)\\s*\\|_[(]\"(.*)\"[)]\\s*\\n"); QRegExp recordRx("^\\s*(\\d+)\\s*\\|_[(]\"(.*)\"[)]\\s*([\\,\\d\\s]* )\\n");
while(!cnFile.atEnd()) while(!cnFile.atEnd())
{ {
record = QString::fromUtf8(cnFile.readLine()); record = QString::fromUtf8(cnFile.readLine());
lineNumber++; lineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
totalRecords++; totalRecords++;
if (!recordRx.exactMatch(record)) if (!recordRx.exactMatch(record))
skipping to change at line 663 skipping to change at line 711
continue; continue;
} }
QString englishCommonName = recordRx.capturedTexts() .at(2).trimmed(); QString englishCommonName = recordRx.capturedTexts() .at(2).trimmed();
if (englishCommonName.isEmpty()) if (englishCommonName.isEmpty())
{ {
qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile) qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(commonNameFile)
<< " - empty name field"; << " - empty name field";
continue; continue;
} }
const QString commonNameI18n = englishCommonName; const QString englishNameCap = englishCommonName.toU
QString commonNameI18n_cap = commonNameI18n.toUpper( pper();
); if (commonNamesMap.find(hip)!=commonNamesMap.end())
{
if (additionalNamesMap.find(hip)!=additional
NamesMap.end())
{
QString sname = additionalNamesMap[h
ip].append(" - " + englishCommonName);
QString snamecap = sname.toUpper();
additionalNamesMap[hip] = sname;
additionalNamesMapI18n[hip] = sname;
additionalNamesIndex.remove(englishN
ameCap);
additionalNamesIndexI18n.remove(engl
ishNameCap);
additionalNamesIndex[snamecap] = hip
;
additionalNamesIndexI18n[snamecap] =
hip;
}
else
{
additionalNamesMap[hip] = englishCom
monName;
additionalNamesMapI18n[hip] = englis
hCommonName;
additionalNamesIndex[englishNameCap]
= hip;
additionalNamesIndexI18n[englishName
Cap] = hip;
}
}
else
{
commonNamesMap[hip] = englishCommonName;
commonNamesMapI18n[hip] = englishCommonName;
commonNamesIndexI18n[englishNameCap] = hip;
commonNamesIndex[englishNameCap] = hip;
}
QString reference = recordRx.capturedTexts().at(3).t
rimmed();
if (!reference.isEmpty())
{
if (referenceMap.find(hip)!=referenceMap.end
())
referenceMap[hip] = referenceMap[hip
].append("," + reference);
else
referenceMap[hip] = reference;
}
commonNamesMap[hip] = englishCommonName;
commonNamesMapI18n[hip] = commonNameI18n;
commonNamesIndexI18n[commonNameI18n_cap] = hip;
commonNamesIndex[englishCommonName.toUpper()] = hip;
readOk++; readOk++;
} }
} }
cnFile.close(); cnFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "common sta r names"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "common sta r names";
return 1; return 1;
} }
// Load scientific names from file // Load scientific names from file
skipping to change at line 706 skipping to change at line 786
int readOk=0; int readOk=0;
int totalRecords=0; int totalRecords=0;
int lineNumber=0; int lineNumber=0;
// record structure is delimited with a | character. Example record strings: // record structure is delimited with a | character. Example record strings:
// " 10819|c_And" // " 10819|c_And"
// "113726|1_And" // "113726|1_And"
foreach(const QString& record, allRecords) foreach(const QString& record, allRecords)
{ {
++lineNumber; ++lineNumber;
if (record.isEmpty()) // skip comments and empty lines
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue; continue;
++totalRecords; ++totalRecords;
const QStringList& fields = record.split('|'); const QStringList& fields = record.split('|');
if (fields.size()!=2) if (fields.size()!=2)
{ {
qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(sciNameFile) qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(sciNameFile)
<< " - record does not match record patte rn"; << " - record does not match record patte rn";
continue; continue;
} }
skipping to change at line 780 skipping to change at line 861
vsFile.close(); vsFile.close();
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. // record structure is delimited with a tab character.
foreach(const QString& record, allRecords) foreach(const QString& record, allRecords)
{ {
++lineNumber; ++lineNumber;
if (record.isEmpty()) // skip comments and empty lines
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue; continue;
++totalRecords; ++totalRecords;
const QStringList& fields = record.split('\t'); const QStringList& fields = record.split('\t');
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" << lin eNumber << "in" << QDir::toNativeSeparators(GcvsFile) qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(GcvsFile)
skipping to change at line 854 skipping to change at line 936
dsFile.close(); dsFile.close();
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. // record structure is delimited with a tab character.
foreach(const QString& record, allRecords) foreach(const QString& record, allRecords)
{ {
++lineNumber; ++lineNumber;
if (record.isEmpty()) // skip comments and empty lines
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue; continue;
++totalRecords; ++totalRecords;
const QStringList& fields = record.split('\t'); const QStringList& fields = record.split('\t');
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" << lin eNumber << "in" << QDir::toNativeSeparators(WdsFile) qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(WdsFile)
skipping to change at line 895 skipping to change at line 978
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(); saoStarsMap.clear();
saoStarsIndex.clear(); saoStarsIndex.clear();
hdStarsMap.clear(); hdStarsMap.clear();
hdStarsIndex.clear(); hdStarsIndex.clear();
hrStarsMap.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();
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;
if (record.isEmpty()) // skip comments and empty lines
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()!=3) if (fields.size()!=4)
{ {
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); unsigned int sao = fields.at(1).toUInt(&ok);
unsigned int hd = fields.at(2).toUInt(&ok); unsigned int hd = fields.at(2).toUInt(&ok);
unsigned int hr = fields.at(3).toUInt(&ok);
if (sao>0) if (sao>0)
{ {
saoStarsMap[hip] = sao; saoStarsMap[hip] = sao;
saoStarsIndex[sao] = hip; saoStarsIndex[sao] = hip;
} }
if (hd>0) if (hd>0)
{ {
hdStarsMap[hip] = hd; hdStarsMap[hip] = hd;
hdStarsIndex[hd] = 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
{ {
int rval = -1; int rval = -1;
skipping to change at line 1135 skipping to change at line 1228
return result; return result;
} }
//! Update i18 names from english names according to passed translator. //! Update i18 names from english names according to passed translator.
//! The translation is done using gettext with translated strings defined i n translations.h //! The translation is done using gettext with translated strings defined i n translations.h
void StarMgr::updateI18n() void StarMgr::updateI18n()
{ {
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
commonNamesMapI18n.clear(); commonNamesMapI18n.clear();
commonNamesIndexI18n.clear(); commonNamesIndexI18n.clear();
additionalNamesMapI18n.clear();
additionalNamesIndexI18n.clear();
for (QHash<int,QString>::ConstIterator it(commonNamesMap.constBegin( ));it!=commonNamesMap.constEnd();it++) for (QHash<int,QString>::ConstIterator it(commonNamesMap.constBegin( ));it!=commonNamesMap.constEnd();it++)
{ {
const int i = it.key(); const int i = it.key();
const QString t(trans.qtranslate(it.value())); const QString t(trans.qtranslate(it.value()));
commonNamesMapI18n[i] = t; commonNamesMapI18n[i] = t;
commonNamesIndexI18n[t.toUpper()] = i; commonNamesIndexI18n[t.toUpper()] = i;
} }
for (QHash<int,QString>::ConstIterator ita(additionalNamesMap.constB
egin());ita!=additionalNamesMap.constEnd();ita++)
{
const int i = ita.key();
QStringList a = ita.value().split(" - ");
QStringList tn;
foreach(const QString &str, a)
{
tn << trans.qtranslate(str);
}
const QString r = tn.join(" - ");
additionalNamesMapI18n[i] = r;
additionalNamesIndexI18n[r.toUpper()] = i;
}
} }
// Search the star by HP number // Search the star by HP number
StelObjectP StarMgr::searchHP(int hp) const StelObjectP StarMgr::searchHP(int hp) const
{ {
if (0 < hp && hp <= NR_OF_HIP) if (0 < hp && hp <= NR_OF_HIP)
{ {
const Star1 *const s = hipIndex[hp].s; const Star1 *const s = hipIndex[hp].s;
if (s) if (s)
{ {
skipping to change at line 1193 skipping to change at line 1301
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.captu redTexts().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
QRegExp rx4("^\\s*(HR)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx4.exactMatch(objw))
{
QMap<int,int>::const_iterator hr(hrStarsIndex.find(rx4.captu
redTexts().at(2).toInt()));
if (hr!=hrStarsIndex.end())
{
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
QMap<QString, int>::iterator ita;
for (ita = additionalNamesIndexI18n.begin(); ita != additionalNamesI
ndexI18n.end(); ++ita)
{
if (ita.key().contains(objw, Qt::CaseInsensitive))
return searchHP(ita.value());
}
// Search by sci name // Search by sci name
QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ; QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ;
if (it2!=sciNamesIndexI18n.end()) if (it2!=sciNamesIndexI18n.end())
{ {
return searchHP(it2.value()); return searchHP(it2.value());
} }
// Search by additional sci name // Search by additional sci name
QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n. find(objw); QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n. find(objw);
if (it3!=sciAdditionalNamesIndexI18n.end()) if (it3!=sciAdditionalNamesIndexI18n.end())
skipping to change at line 1264 skipping to change at line 1391
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.captu redTexts().at(2).toInt()));
if (hd!=hdStarsIndex.end()) if (hd!=hdStarsIndex.end())
{ {
return searchHP(hd.value()); return searchHP(hd.value());
} }
} }
// Search by I18n common name // Search by HR number if it's an HR formated number
QRegExp rx4("^\\s*(HR)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx4.exactMatch(objw))
{
QMap<int,int>::const_iterator hr(hrStarsIndex.find(rx4.captu
redTexts().at(2).toInt()));
if (hr!=hrStarsIndex.end())
{
return searchHP(hr.value());
}
}
// 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
QMap<QString, int>::iterator ita;
for (ita = additionalNamesIndex.begin(); ita != additionalNamesIndex
.end(); ++ita)
{
if (ita.key().contains(objw, Qt::CaseInsensitive))
return searchHP(ita.value());
}
// Search by sci name // Search by sci name
QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ; QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ;
if (it2!=sciNamesIndexI18n.end()) if (it2!=sciNamesIndexI18n.end())
{ {
return searchHP(it2.value()); return searchHP(it2.value());
} }
// Search by additional sci name // Search by additional sci name
QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n. find(objw); QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n. find(objw);
if (it3!=sciAdditionalNamesIndexI18n.end()) if (it3!=sciAdditionalNamesIndexI18n.end())
skipping to change at line 1300 skipping to change at line 1446
{ {
QStringList result; QStringList result;
if (maxNbItem <= 0) if (maxNbItem <= 0)
{ {
return result; return result;
} }
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
QMap<QString, int> cNamesIdx = inEnglish ? commonNamesIndex : common NamesIndexI18n; QMap<QString, int> cNamesIdx = inEnglish ? commonNamesIndex : common NamesIndexI18n;
QMap<QString, int> aNamesIdx = inEnglish ? additionalNamesIndex : ad ditionalNamesIndexI18n;
// Search for common names // Search for common names
if (useStartOfWords) if (useStartOfWords)
{ {
for (QMap<QString,int>::const_iterator it(cNamesIdx.lowerBou nd(objw)); it!=cNamesIdx.end(); ++it) for (QMap<QString,int>::const_iterator it(cNamesIdx.lowerBou nd(objw)); it!=cNamesIdx.end(); ++it)
{ {
if (it.key().startsWith(objw)) if (it.key().startsWith(objw))
{ {
if (maxNbItem<=0) if (maxNbItem<=0)
break; break;
result.append(inEnglish ? getCommonEnglishNa me(it.value()) : getCommonName(it.value())); result.append(inEnglish ? getCommonEnglishNa me(it.value()) : getCommonName(it.value()));
--maxNbItem; --maxNbItem;
} }
else else
break; break;
} }
for (QMap<QString,int>::const_iterator ita(aNamesIdx.lowerBo
und(objw)); ita!=aNamesIdx.end(); ++ita)
{
if (ita.key().startsWith(objw))
{
if (maxNbItem<=0)
break;
QStringList names = (inEnglish ? getAddition
alEnglishNames(ita.value()) : getAdditionalNames(ita.value())).split(" - ")
;
foreach (QString name, names)
{
if (name.contains(objw, Qt::CaseInse
nsitive))
{
result.append(name);
--maxNbItem;
}
}
}
else
break;
}
} }
else else
{ {
QMapIterator<QString, int> i(cNamesIdx); QMapIterator<QString, int> i(cNamesIdx);
while (i.hasNext()) while (i.hasNext())
{ {
i.next(); i.next();
if (i.key().contains(objw)) if (i.key().contains(objw))
{ {
if (maxNbItem<=0) if (maxNbItem<=0)
break; break;
result.append(inEnglish ? getCommonEnglishNa me(i.value()) : getCommonName(i.value())); result.append(inEnglish ? getCommonEnglishNa me(i.value()) : getCommonName(i.value()));
--maxNbItem; --maxNbItem;
} }
} }
QMapIterator<QString, int> j(aNamesIdx);
while (j.hasNext())
{
j.next();
if (j.key().contains(objw))
{
if (maxNbItem<=0)
break;
QStringList names = (inEnglish ? getAddition
alEnglishNames(j.value()) : getAdditionalNames(j.value())).split(" - ");
foreach (QString name, names)
{
if (name.contains(objw, Qt::CaseInse
nsitive))
{
result.append(name);
--maxNbItem;
}
}
}
}
} }
// Search for sci names // Search for sci names
QString bayerPattern = objw; QString bayerPattern = objw;
QRegExp bayerRegEx(bayerPattern); QRegExp bayerRegEx(bayerPattern);
// if the first character is a Greek letter, check if there's an ind ex // if the first character is a Greek letter, check if there's an ind ex
// after it, such as "alpha1 Cen". // after it, such as "alpha1 Cen".
if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 ) if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 )
bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?")); bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?"));
skipping to change at line 1438 skipping to change at line 1625
{ {
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
QRegExp hrRx("^(HR)\\s*(\\d+)\\s*$");
hrRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hrRx.exactMatch(objw))
{
bool ok;
int hrNum = hrRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator hr(hrStarsIndex.find(hrNum));
if (hr!=hrStarsIndex.end())
{
StelObjectP s = searchHP(hr.value());
if (s && maxNbItem>0)
{
result << QString("HR%1").arg(hrNum);
maxNbItem--;
}
}
}
// Add exact WDS catalogue numbers // Add exact WDS catalogue numbers
QRegExp wdsRx("^(WDS)\\s*(\\S+)\\s*$"); QRegExp wdsRx("^(WDS)\\s*(\\S+)\\s*$");
wdsRx.setCaseSensitivity(Qt::CaseInsensitive); wdsRx.setCaseSensitivity(Qt::CaseInsensitive);
if (wdsRx.exactMatch(objw)) if (wdsRx.exactMatch(objw))
{ {
for (QMap<QString,int>::const_iterator wds(wdsStarsIndexI18n .lowerBound(objw)); wds!=wdsStarsIndexI18n.end(); ++wds) for (QMap<QString,int>::const_iterator wds(wdsStarsIndexI18n .lowerBound(objw)); wds!=wdsStarsIndexI18n.end(); ++wds)
{ {
if (wds.key().startsWith(objw)) if (wds.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
 End of changes. 30 change blocks. 
15 lines changed or deleted 253 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/