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

Added support alternative names (designations) for exoplanets #2350

Merged
merged 3 commits into from Mar 16, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/Exoplanets/CMakeLists.txt
@@ -1,6 +1,6 @@
SET(EXOPLANETS_PLUGIN_MAJOR "0")
SET(EXOPLANETS_PLUGIN_MINOR "4")
SET(EXOPLANETS_PLUGIN_PATCH "5")
SET(EXOPLANETS_PLUGIN_MINOR "5")
SET(EXOPLANETS_PLUGIN_PATCH "0")
SET(EXOPLANETS_VERSION "${EXOPLANETS_PLUGIN_MAJOR}.${EXOPLANETS_PLUGIN_MINOR}.${EXOPLANETS_PLUGIN_PATCH}")

ADD_DEFINITIONS(-DEXOPLANETS_PLUGIN_VERSION="${EXOPLANETS_VERSION}")
Expand Down
47 changes: 44 additions & 3 deletions plugins/Exoplanets/src/Exoplanet.cpp
Expand Up @@ -74,7 +74,8 @@ Exoplanet::Exoplanet(const QVariantMap& map)
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();

designation = map.value("designation").toString();
starProperName = map.value("starProperName").toString();
starProperName = map.value("starProperName").toString();
starAlterNames = map.value("starAlterName").toString();
RA = StelUtils::getDecAngle(map.value("RA").toString());
DE = StelUtils::getDecAngle(map.value("DE").toString());
StelUtils::spheToRect(RA, DE, XYZ);
Expand Down Expand Up @@ -180,6 +181,7 @@ QVariantMap Exoplanet::getMap(void) const
QVariantMap map;
map["designation"] = designation;
if (!starProperName.isEmpty()) map["starProperName"] = starProperName;
if (!starAlterNames.isEmpty()) map["starAlterName"] = starAlterNames;
map["RA"] = RA;
map["DE"] = DE;
map["distance"] = distance;
Expand Down Expand Up @@ -247,6 +249,15 @@ QString Exoplanet::getDesignation(void) const
return designation;
}

QStringList Exoplanet::getDesignations(void) const
{
QStringList designations;
designations << designation;
if (!starAlterNames.isEmpty())
designations << starAlterNames.split(", ");
return designations;
}

QStringList Exoplanet::getExoplanetsEnglishNames() const
{
return englishNames;
Expand All @@ -270,9 +281,38 @@ QString Exoplanet::getInfoString(const StelCore* core, const InfoStringGroup& fl

if (flags&Name)
{
QString systemName = getNameI18n();
QString aliases, systemName = getNameI18n();
QStringList designations = getDesignations();
designations.removeDuplicates();
int asize = designations.size();
if (asize>5) // Special case for many AKA (max - 6 items per line)
{
bool firstLine = true;
for(int i=0; i<asize; i++)
{
aliases.append(designations.at(i));
if (i<asize-1)
aliases.append(" - ");

if (i>0)
{
if ((i % 4)==0 && firstLine)
{
aliases.append("<br />");
firstLine = false;
}
if (((i-4) % 6)==0 && !firstLine && i>5 && i<(asize-1))
aliases.append("<br />");
}
}
}
else
aliases = designations.join(" - ");

if (!starProperName.isEmpty())
systemName.append(QString(" (%1)").arg(designation));
systemName.append(QString(" (%1)").arg(aliases));
else
systemName = aliases;

oss << "<h2>" << systemName << "</h2>";
}
Expand Down Expand Up @@ -509,6 +549,7 @@ QVariantMap Exoplanet::getInfoMap(const StelCore *core) const

// Tentatively add a few more strings. Details are left to the plugin author.
if (!starProperName.isEmpty()) map["starProperName"] = starProperName;
if (!starAlterNames.isEmpty()) map["starAlterName"] = starAlterNames;
map["distance"] = distance;
map["stype"] = stype;
map["smass"] = smass;
Expand Down
2 changes: 2 additions & 0 deletions plugins/Exoplanets/src/Exoplanet.hpp
Expand Up @@ -112,6 +112,7 @@ class Exoplanet : public StelObject
bool isVMagnitudeDefined() const;

QString getDesignation(void) const;
QStringList getDesignations(void) const;
QStringList getExoplanetsEnglishNames(void) const;
QStringList getExoplanetsNamesI18n(void) const;
QStringList getExoplanetsDesignations(void) const;
Expand Down Expand Up @@ -177,6 +178,7 @@ class Exoplanet : public StelObject
//! Variables for description of properties of exoplanets
QString designation; //! The designation of the host star
QString starProperName; //! The proper name of the host star
QString starAlterNames; //! The alternative names of the host star
double RA; //! J2000 right ascension of host star // ALMOST USELESS AFTER CONSTRUCTOR!
double DE; //! J2000 declination of host star // ALMOST USELESS AFTER CONSTRUCTOR! use XYZ
double distance; //! Distance to star in pc
Expand Down
15 changes: 4 additions & 11 deletions plugins/Exoplanets/src/Exoplanets.cpp
Expand Up @@ -294,19 +294,11 @@ StelObjectP Exoplanets::searchByName(const QString& englishName) const
return qSharedPointerCast<StelObject>(eps);

QStringList ppn = eps->getExoplanetsEnglishNames();
ppn << eps->getDesignations();
ppn << eps->getExoplanetsDesignations();
if (!ppn.isEmpty())
{
for (const auto& str : ppn)
{
if (str.toUpper() == englishName.toUpper())
return qSharedPointerCast<StelObject>(eps);
}
}

ppn = eps->getExoplanetsDesignations();
if (!ppn.isEmpty())
{
for (const auto& str : qAsConst(ppn))
for (const auto& str : qAsConst(ppn))
{
if (str.toUpper() == englishName.toUpper())
return qSharedPointerCast<StelObject>(eps);
Expand Down Expand Up @@ -366,6 +358,7 @@ QStringList Exoplanets::listMatchingObjects(const QString& objPrefix, int maxNbI
names.append(eps->getExoplanetsNamesI18n());
names.append(eps->getEnglishName());
names.append(eps->getExoplanetsEnglishNames());
names.append(eps->getDesignations());
}

QString fullMatch = "";
Expand Down