Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Gaia ID in other functionalities #4064

Merged
merged 8 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/core/modules/Asterism.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,86 +52,94 @@
asterism = Q_NULLPTR;
}

bool Asterism::read(const QString& record, StarMgr *starMgr)
{
abbreviation.clear();
numberOfSegments = 0;
typeOfAsterism = 1;
flagAsterism = true;

QString buf(record);
QTextStream istr(&buf, QIODevice::ReadOnly);
// We allow mixed-case abbreviations now that they can be displayed on screen. We then need toUpper() in comparisons.
istr >> abbreviation >> typeOfAsterism >> numberOfSegments;
if (istr.status()!=QTextStream::Ok)
return false;

StelCore *core = StelApp::getInstance().getCore();
asterism = new StelObjectP[numberOfSegments*2];
for (unsigned int i=0;i<numberOfSegments*2;++i)
{
switch (typeOfAsterism)
{
case 0: // Ray helpers
case 1: // A big asterism with lines by HIP stars
{
unsigned int HP = 0;
int64_t HP = 0;
istr >> HP;
if(HP == 0)
{
return false;
}
asterism[i]=starMgr->searchHP(static_cast<int>(HP));
if (HP <= 120416)
henrysky marked this conversation as resolved.
Show resolved Hide resolved
{
asterism[i]=starMgr->searchHP(static_cast<int>(HP));
}
else
{
asterism[i]=starMgr->searchGaia(HP);
}

if (!asterism[i])
{
qWarning() << "Error in asterism" << abbreviation << "- can't find star HIP" << HP;
return false;
}
break;
}
case 2: // A small asterism with lines by J2000.0 coordinates
{
double RA, DE;
Vec3d coords;

istr >> RA >> DE;
StelUtils::spheToRect(RA*M_PI/12., DE*M_PI/180., coords);
QList<StelObjectP> stars = starMgr->searchAround(coords, 0.1, core);
StelObjectP s = Q_NULLPTR;
double d = 10.;
for (const auto& p : stars)
{
double a = coords.angle(p->getJ2000EquatorialPos(core));
if (a<d)
{
d = a;
s = p;
}
}
asterism[i] = s;
if (!asterism[i])
{
qWarning() << "Error in asterism" << abbreviation << "- can't find star with coordinates" << RA << "/" << DE;
return false;
}
break;
}
}
}

if (typeOfAsterism>0)
{
XYZname.set(0.,0.,0.);
for(unsigned int j=0;j<numberOfSegments*2;++j)
XYZname+= asterism[j]->getJ2000EquatorialPos(core);
XYZname.normalize();
}
else
flagAsterism = false;

return true;
}

Check notice on line 142 in src/core/modules/Asterism.cpp

View check run for this annotation

codefactor.io / CodeFactor

src/core/modules/Asterism.cpp#L55-L142

Complex Method
void Asterism::drawOptim(StelPainter& sPainter, const StelCore* core, const SphericalCap& viewportHalfspace) const
{
if (flagAsterism)
Expand Down
66 changes: 34 additions & 32 deletions src/core/modules/Star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,48 @@ QString Star1::getNameI18n(void) const

QString Star1::getScreenNameI18n(void) const
{
QStringList starNames;
int64_t star_id;
if (getHip())
star_id = static_cast<int64_t>(getHip());
else
star_id = getGaia();
if (!StarMgr::getDesignationUsage())
starNames << StarMgr::getCommonName(star_id);
if (StarMgr::getFlagSciNames()) // The scientific designations can be used for western sky cultures only
{
QStringList starNames;
if (!StarMgr::getDesignationUsage())
starNames << StarMgr::getCommonName(getHip());
if (StarMgr::getFlagSciNames()) // The scientific designations can be used for western sky cultures only
{
starNames << StarMgr::getSciName(getHip()).split(" - ");
if (StarMgr::getFlagDblStarsDesignation()) // append the traditional designations of double stars
starNames << StarMgr::getSciExtraName(getHip()).split(" - ");
if (StarMgr::getFlagVarStarsDesignation()) // append the designations of variable stars (from GCVS)
starNames << StarMgr::getGcvsName(getHip());
if (StarMgr::getFlagHIPDesignation()) // append the HIP numbers of stars
starNames << QString("HIP %1").arg(getHip());
}
starNames.removeAll(QString(""));
if (starNames.count()>0)
return starNames.first();
else
return QString();
starNames << StarMgr::getSciName(star_id).split(" - ");
if (StarMgr::getFlagDblStarsDesignation()) // append the traditional designations of double stars
starNames << StarMgr::getSciExtraName(star_id).split(" - ");
if (StarMgr::getFlagVarStarsDesignation()) // append the designations of variable stars (from GCVS)
starNames << StarMgr::getGcvsName(star_id);
if (StarMgr::getFlagHIPDesignation()) // append the HIP numbers of stars
starNames << QString("HIP %1").arg(star_id);
}
return QString();
starNames.removeAll(QString(""));
if (starNames.count()>0)
return starNames.first();
else
return QString();
}

QString Star1::getDesignation() const
{
QStringList starNames;
int64_t star_id;
if (getHip())
{
QStringList starNames;
starNames << StarMgr::getSciName(getHip()).split(" - ");
starNames << StarMgr::getSciExtraName(getHip()).split(" - ");
starNames << StarMgr::getGcvsName(getHip());
starNames << QString("HIP %1").arg(getHip());
starNames.removeAll(QString(""));
if (starNames.count()>0)
return starNames.first();
else
return QString();
}
return QString();
star_id = static_cast<int64_t>(getHip());
else
star_id = getGaia();
starNames << StarMgr::getSciName(star_id).split(" - ");
starNames << StarMgr::getSciExtraName(star_id).split(" - ");
starNames << StarMgr::getGcvsName(star_id);
starNames << QString("HIP %1").arg(star_id);
starNames.removeAll(QString(""));
if (starNames.count()>0)
return starNames.first();
else
return QString();
}

int Star1::hasComponentID(void) const
Expand Down
8 changes: 4 additions & 4 deletions src/core/modules/StarMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ QMap<QString,int> StarMgr::commonNamesIndexI18n;
QMap<QString,int> StarMgr::commonNamesIndex;
QMap<QString,int> StarMgr::additionalNamesIndex;
QMap<QString,int> StarMgr::additionalNamesIndexI18n;
QHash<int,QString> StarMgr::sciDesignationsMapI18n;
QHash<int64_t,QString> StarMgr::sciDesignationsMapI18n;
QMap<QString,int> StarMgr::sciDesignationsIndexI18n;
QHash<int,QString> StarMgr::sciExtraDesignationsMapI18n;
QMap<QString,int> StarMgr::sciExtraDesignationsIndexI18n;
Expand Down Expand Up @@ -222,10 +222,10 @@ QString StarMgr::getCommonEnglishName(int hip)
}


QString StarMgr::getSciName(int hip)
QString StarMgr::getSciName(int64_t hip)
{
auto it = sciDesignationsMapI18n.find(hip);
if (it!=sciDesignationsMapI18n.end())
if (it != sciDesignationsMapI18n.end())
return it.value();
return QString();
}
Expand Down Expand Up @@ -892,7 +892,7 @@ void StarMgr::loadSciNames(const QString& sciNameFile, const bool extraData)
{
// The record is the right format. Extract the fields
bool ok;
int hip = fields.at(0).toInt(&ok);
int64_t hip = fields.at(0).toLongLong(&ok);
if (!ok)
{
qWarning().noquote() << "WARNING - parse error at line" << lineNumber << "in" << QDir::toNativeSeparators(sciNameFile)
Expand Down
8 changes: 4 additions & 4 deletions src/core/modules/StarMgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ public slots:
static QString getCommonName(int hip);
henrysky marked this conversation as resolved.
Show resolved Hide resolved

//! Get the (translated) scientific name for a star with a specified
//! Hipparcos catalogue number.
//! @param hip The Hipparcos number of star
//! Hipparcos or Gaia catalogue number.
//! @param hip The Hipparcos/Gaia number of star
//! @return translated scientific name of star
static QString getSciName(int hip);
static QString getSciName(int64_t hip);

//! Get the (translated) scientific extra name for a star with a specified
//! Hipparcos catalogue number.
Expand Down Expand Up @@ -505,7 +505,7 @@ private slots:
static QMap<QString, int> additionalNamesIndex;
static QMap<QString, int> additionalNamesIndexI18n;

static QHash<int, QString> sciDesignationsMapI18n;
static QHash<int64_t, QString> sciDesignationsMapI18n;
static QMap<QString, int> sciDesignationsIndexI18n;
henrysky marked this conversation as resolved.
Show resolved Hide resolved
static QHash<int, QString> sciExtraDesignationsMapI18n;
static QMap<QString, int> sciExtraDesignationsIndexI18n;
Expand Down
142 changes: 70 additions & 72 deletions src/core/modules/StarWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
StelUtils::rectToSphe(&az_app,&alt_app,getAltAzPosApparent(core));
Q_UNUSED(az_app)

int64_t star_id;
if (s->getHip())
star_id = static_cast<int64_t>(s->getHip());
else
star_id = s->getGaia();

const QString varType = StarMgr::getGcvsVariabilityType(s->getHip());
const QString objType = StarMgr::convertToOjectTypes(s->getObjType());
const int wdsObs = StarMgr::getWdsLastObservation(s->getHip());
Expand All @@ -160,26 +166,27 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
const double vEpoch = StarMgr::getGcvsEpoch(s->getHip());
const double vPeriod = StarMgr::getGcvsPeriod(s->getHip());
const int vMm = StarMgr::getGcvsMM(s->getHip());

if ((flags&Name) || (flags&CatalogNumber))
oss << "<h2>";

const QString commonNameI18 = StarMgr::getCommonName(s->getHip());
const QString additionalNameI18 = StarMgr::getAdditionalNames(s->getHip());
const QString sciName = StarMgr::getSciName(star_id);
const QString sciExtraName = StarMgr::getSciExtraName(s->getHip());
const QString varSciName = StarMgr::getGcvsName(s->getHip());
const QString wdsSciName = StarMgr::getWdsName(s->getHip());
QStringList designations;
if (!sciName.isEmpty())
designations.append(sciName);
if (!sciExtraName.isEmpty())
designations.append(sciExtraName);
if (!varSciName.isEmpty() && !sciName.contains(varSciName, Qt::CaseInsensitive))
designations.append(varSciName);

QString hip, hipq;
if (s->getHip())
{
if ((flags&Name) || (flags&CatalogNumber))
oss << "<h2>";

const QString commonNameI18 = StarMgr::getCommonName(s->getHip());
const QString additionalNameI18 = StarMgr::getAdditionalNames(s->getHip());
const QString sciName = StarMgr::getSciName(s->getHip());
const QString sciExtraName = StarMgr::getSciExtraName(s->getHip());
const QString varSciName = StarMgr::getGcvsName(s->getHip());
const QString wdsSciName = StarMgr::getWdsName(s->getHip());
QStringList designations;
if (!sciName.isEmpty())
designations.append(sciName);
if (!sciExtraName.isEmpty())
designations.append(sciExtraName);
if (!varSciName.isEmpty() && !sciName.contains(varSciName, Qt::CaseInsensitive))
designations.append(varSciName);

QString hip, hipq;
if (s->hasComponentID())
{
hip = QString("HIP %1 %2").arg(s->getHip()).arg(StarMgr::convertToComponentIds(s->getComponentIds()));
Expand All @@ -190,76 +197,67 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
hip = QString("HIP %1").arg(s->getHip());
hipq = QString("%1").arg(s->getHip());
}

designations.append(hip);
}

const QString crossIndexData = StarMgr::getCrossIdentificationDesignations(hipq);
if (!crossIndexData.isEmpty())
designations.append(crossIndexData);
const QString crossIndexData = StarMgr::getCrossIdentificationDesignations(hipq);
if (!crossIndexData.isEmpty())
designations.append(crossIndexData);

if (s->getGaia())
designations.append(QString("Gaia DR3 %1").arg(s->getGaia()));
if (s->getGaia())
designations.append(QString("Gaia DR3 %1").arg(s->getGaia()));

if (!wdsSciName.isEmpty() && !sciName.contains(wdsSciName, Qt::CaseInsensitive))
designations.append(wdsSciName);
if (!wdsSciName.isEmpty() && !sciName.contains(wdsSciName, Qt::CaseInsensitive))
designations.append(wdsSciName);

QString designationsList = designations.join(" - ");
designations.clear();
designations = designationsList.split(" - ");
designations.removeDuplicates();
int asize = designations.size();
if (asize>6) // Special case for many designations (max - 7 items per line); NOTE: Should we add size to the config data for skyculture?
QString designationsList = designations.join(" - ");
designations.clear();
designations = designationsList.split(" - ");
designations.removeDuplicates();
int asize = designations.size();
if (asize>6) // Special case for many designations (max - 7 items per line); NOTE: Should we add size to the config data for skyculture?
{
designationsList = "";
for(int i=0; i<asize; i++)
{
designationsList = "";
for(int i=0; i<asize; i++)
{
designationsList.append(designations.at(i));
if (i<asize-1)
designationsList.append(" - ");
designationsList.append(designations.at(i));
if (i<asize-1)
designationsList.append(" - ");

if (i>0 && (i % 6)==0 && i<(asize-1))
designationsList.append("<br />");
}
if (i>0 && (i % 6)==0 && i<(asize-1))
designationsList.append("<br />");
}
else
designationsList = designations.join(" - ");
}
else
designationsList = designations.join(" - ");

if (flags&Name)
{
QString commonNames;
if (!commonNameI18.isEmpty())
commonNames = commonNameI18;

if (flags&Name)
if (!additionalNameI18.isEmpty() && StarMgr::getFlagAdditionalNames())
{
QString commonNames;
if (!commonNameI18.isEmpty())
commonNames = commonNameI18;
QStringList additionalNames = additionalNameI18.split(" - ");
additionalNames.removeDuplicates();

if (!additionalNameI18.isEmpty() && StarMgr::getFlagAdditionalNames())
{
QStringList additionalNames = additionalNameI18.split(" - ");
additionalNames.removeDuplicates();
commonNames.append(QString(" (%1)").arg(additionalNames.join(" - ")));
}

commonNames.append(QString(" (%1)").arg(additionalNames.join(" - ")));
}
if (!commonNames.isEmpty())
oss << StelUtils::wrapText(commonNames, 80);

if (!commonNames.isEmpty())
oss << StelUtils::wrapText(commonNames, 80);
if (!commonNameI18.isEmpty() && !designationsList.isEmpty() && flags&CatalogNumber)
oss << "<br />";
}

if (!commonNameI18.isEmpty() && !designationsList.isEmpty() && flags&CatalogNumber)
oss << "<br />";
}
if (flags&CatalogNumber)
oss << designationsList;

if (flags&CatalogNumber)
oss << designationsList;
if ((flags&Name) || (flags&CatalogNumber))
oss << "</h2>";

if ((flags&Name) || (flags&CatalogNumber))
oss << "</h2>";
}
if (s->getGaia() && !s->getHip()) {
if ((flags&Name) || (flags&CatalogNumber))
oss << "<h2>";
QString gaia_id;
gaia_id = QString("Gaia DR3 %1").arg(s->getGaia());
oss << gaia_id;
if ((flags&Name) || (flags&CatalogNumber))
oss << "</h2>";
}
if (flags&Name)
{
QStringList extraNames=getExtraInfoStrings(Name);
Expand Down
1 change: 1 addition & 0 deletions stars/hip_gaia3/name.fab
Original file line number Diff line number Diff line change
Expand Up @@ -4940,3 +4940,4 @@
103511|33_Vul
105411|34_Vul
105966|35_Vul
5350358584482202880|η Car
Loading