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

Exclude outdated solar system objects #1880

Merged
merged 11 commits into from
Sep 23, 2021
12 changes: 11 additions & 1 deletion src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4274,7 +4274,7 @@ void Planet::drawOrbit(const StelCore* core)
if (hidden || (pType==isObserver)) return;
if (orbitPtr && pType>=isArtificial)
{
if (!static_cast<KeplerOrbit*>(orbitPtr)->objectDateValid(lastJDE))
if (!hasValidData())
return;
}

Expand Down Expand Up @@ -4328,6 +4328,16 @@ void Planet::drawOrbit(const StelCore* core)
sPainter.setLineWidth(1);
}

bool Planet::hasValidData()
{
if (pType<isObserver)
return true;
else if (orbitPtr && pType>=isArtificial)
return static_cast<KeplerOrbit*>(orbitPtr)->objectDateValid(lastJDE);
else
return false;
}

void Planet::update(int deltaTime)
{
hintFader.update(deltaTime);
Expand Down
1 change: 1 addition & 0 deletions src/core/modules/Planet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class Planet : public StelObject
virtual double getAngularSize(const StelCore* core) const Q_DECL_OVERRIDE;
virtual bool hasAtmosphere(void) {return atmosphere;}
virtual bool hasHalo(void) {return halo;}
bool hasValidData();
alex-w marked this conversation as resolved.
Show resolved Hide resolved
float getAxisRotation(void) { return axisRotation;} //! return axisRotation last computed in computeTransMatrix().

///////////////////////////////////////////////////////////////////////////
Expand Down
20 changes: 20 additions & 0 deletions src/gui/AstroCalcDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,9 @@ void AstroCalcDialog::currentCelestialPositions()
break;
}

if (!planet->hasValidData())
passByType = false;

if (passByType && planet != core->getCurrentPlanet() && planet->getVMagnitudeWithExtinction(core) <= mag && planet->isAboveRealHorizon(core))
{
pos = planet->getJ2000EquatorialPos(core);
Expand Down Expand Up @@ -1717,6 +1720,10 @@ void AstroCalcDialog::generateEphemeris()
double JD = firstJD + i * currentStep;
core->setJD(JD);
core->update(0); // force update to get new coordinates

if (!obj->hasValidData())
continue;

if (useHorizontalCoords)
{
pos = obj->getAltAzPosAuto(core);
Expand Down Expand Up @@ -4473,6 +4480,19 @@ QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP& object1, Stel
QMap<double, double> separations;
QPair<double, double> extremum;

if (object2->getType()=="Planet")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do you also see the inefficiency?
For a simple date validity test you set the whole program state twice.

Please do the following: extend
bool Planet::hasValidPositionalData(const double jde)
{
if (pType<isObserver)
return true;
else if (orbitPtr && pType>=isArtificial)
return static_cast<KeplerOrbit*>(orbitPtr)->objectDateValid(jde);
else
return false;
}

And then you can simply test here:

if ( (!planet->hasValidPositionalData(stopJD)) || (!planet->hasValidPositionalData(startJD)) )
return separations; // empty result.

And probably this is not even what we need here? Imagine some object with orbit_good=100 (days)

You make an ephemeris for 250 days which enclose the orbit's validity range. The object would be excluded with the current solution! Maybe add a test for (startJD+stopJD)/2? Or sample every 50 days between startJD and stopJD? Or is there a limit or typical value for (stopJD-startJD)? If this is always something like 10 days, you could exclude the object if both dates are invalid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added JDE as parameter to reduce number of calls, but for second proposal I think it should be postponed to the future releases, because this subsystem should be refactored after pencil and paper works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. The inefficiency is solved.
The next question is just what this function should do. Is this logic correct? Whenever at least one limit of the search interval is outside the validity range for the planet, the planet is discarded. I see a danger of another error. If you need to merge this now, leave a FIXME with this question for later, and maybe somebody reports an error. Else please don't merge, and let's solve this with better tests for the overlapping cases. (We may need to add some really simple date validity queries to the Planet.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the QWarning() logging, or some other warning mechanism. the QWarning() is not much asked, and will help if a user opens an issue; the log will explain what happened.

thank you!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next question is just what this function should do. Is this logic correct?

Yes, but I'll change it as first iteration of excluding the data.

{
PlanetP planet = qSharedPointerCast<Planet>(object2);
core->setJD(stopJD);
core->update(0);
if (!planet->hasValidData())
return separations;
core->setJD(startJD);
core->update(0);
if (!planet->hasValidData())
return separations;
}

QStringList objects;
objects.clear();
objects.append(object1->getEnglishName());
Expand Down