Skip to content

Commit 7539f89

Browse files
authored
Alignment: deprecate old Transform* shims, migrate all in-tree callers to *JD (#2388)
* Alignment: add TransformCelestialToTelescopeJD / TransformTelescopeToCelestialJD Add new *JD variants to MathPlugin and all built-in plugins (BasicMathPlugin, NearestMathPlugin, SPKMathPlugin, DummyMathPlugin) that accept an absolute Julian Date instead of reading the system clock internally. The old TransformCelestialToTelescope / TransformTelescopeToCelestial methods become thin shims (resolving ln_get_julian_from_sys() + JulianOffset) to preserve binary ABI compatibility with external DSO plugins. MathPluginManagement gains matching *JD dispatch methods; its old methods are also reduced to shims. Test suite migrated from the joff = fixedJD - ln_get_julian_from_sys() hack to direct *JD calls with a static constexpr fixedJD, making all tests deterministic and clock-independent. * Alignment: fix JD fallback offset, add override, remove dead code Fix MathPlugin default TransformCelestialToTelescopeJD/TransformTelescopeToCelestialJD fallback to pass JulianDate - ln_get_julian_from_sys() as the offset, so legacy external plugins that add ln_get_julian_from_sys() internally recover the correct absolute JD. Add override keyword to *JD method declarations in BasicMathPlugin, NearestMathPlugin, and DummyMathPlugin for consistency with SPKMathPlugin and compiler-enforced signature checking. Remove dead pTransformCelestialToTelescope and pTransformTelescopeToCelestial function pointer members from MathPluginManagement (dispatch now goes through direct virtual calls on pLoadedMathPlugin). Remove stale commented-out ln_get_julian_from_sys() lines from BasicMathPlugin.cpp and the trivial JDD alias variables from NearestMathPlugin.cpp. Add two regression tests (LegacyPlugin_JD_Fallback_*) that verify the fallback offset computation is correct for legacy external plugins. * Alignment: deprecate old Transform* shims, migrate all in-tree callers to *JD Mark MathPluginManagement::TransformCelestialToTelescope and TransformTelescopeToCelestial [[deprecated]] so callers get compiler warnings. Thread an explicit JD parameter through AlignmentSubsystemForDrivers (default = ln_get_julian_from_sys() for source compatibility), and update all in-tree driver and example call sites to use TransformCelestialToTelescopeJD / TransformTelescopeToCelestialJD directly. skywatcherAPIMount non-zero offset sites (JulianOffset axis, bracket tracking) now compute the absolute JD explicitly before calling *JD instead of passing a relative offset. The JDnow variable is hoisted before the if/else so both branches share the same sample. External math plugins are unaffected: MathPlugin.h pure virtuals are intentionally left un-deprecated.
1 parent b99c7ea commit 7539f89

21 files changed

Lines changed: 381 additions & 168 deletions

drivers/telescope/astrotrac.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ bool AstroTrac::ReadScopeStatus()
682682
m_MountInternalCoordinates.declination = de;
683683
TDV = TelescopeDirectionVectorFromEquatorialCoordinates(m_MountInternalCoordinates);
684684

685-
if (TransformTelescopeToCelestial(TDV, skyRA, skyDE))
685+
if (TransformTelescopeToCelestialJD(TDV, skyRA, skyDE, ln_get_julian_from_sys()))
686686
{
687687
// double lst = get_local_sidereal_time(LocationNP[LOCATION_LONGITUDE].getValue());
688688
// double dHA = rangeHA(lst - skyRA);
@@ -710,7 +710,7 @@ bool AstroTrac::ReadScopeStatus()
710710
bool AstroTrac::getTelescopeFromSkyCoordinates(double ra, double de, INDI::IEquatorialCoordinates &telescopeCoordinates)
711711
{
712712
TelescopeDirectionVector TDV;
713-
if (TransformCelestialToTelescope(ra, de, 0.0, TDV))
713+
if (TransformCelestialToTelescopeJD(ra, de, ln_get_julian_from_sys(), TDV))
714714
{
715715
EquatorialCoordinatesFromTelescopeDirectionVector(TDV, telescopeCoordinates);
716716
LOGF_DEBUG("TransformCelestialToTelescope: RA=%lf DE=%lf, TDV (x :%lf, y: %lf, z: %lf), local hour RA %lf DEC %lf",

drivers/telescope/dsc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ INDI::IEquatorialCoordinates DSC::TelescopeEquatorialToSky()
468468
eq.declination = encoderEquatorialCoordinates.declination;
469469
TDV = TelescopeDirectionVectorFromLocalHourAngleDeclination(eq);
470470

471-
if (!TransformTelescopeToCelestial(TDV, RightAscension, Declination))
471+
if (!TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
472472
{
473473
RightAscension = encoderEquatorialCoordinates.rightascension;
474474
Declination = encoderEquatorialCoordinates.declination;
@@ -493,7 +493,7 @@ INDI::IEquatorialCoordinates DSC::TelescopeHorizontalToSky()
493493
TelescopeDirectionVector TDV = TelescopeDirectionVectorFromAltitudeAzimuth(encoderHorizontalCoordinates);
494494
double RightAscension, Declination;
495495

496-
if (!TransformTelescopeToCelestial(TDV, RightAscension, Declination))
496+
if (!TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
497497
{
498498
INDI::IEquatorialCoordinates EquatorialCoordinates {0, 0};
499499
TelescopeDirectionVector RotatedTDV(TDV);

drivers/telescope/skywatcherAPIMount.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ bool SkywatcherAPIMount::Goto(double ra, double dec)
537537
// Transform Celestial to Telescope coordinates.
538538
// We have no good way to estimate how long will the mount takes to reach target (with deceleration,
539539
// and not just speed). So we will use iterative GOTO once the first GOTO is complete.
540-
if (TransformCelestialToTelescope(ra, dec, 0.0, TDV))
540+
if (TransformCelestialToTelescopeJD(ra, dec, ln_get_julian_from_sys(), TDV))
541541
{
542542
INDI::IEquatorialCoordinates EquatorialCoordinates { 0, 0 };
543543
AltitudeAzimuthFromTelescopeDirectionVector(TDV, AltAz);
@@ -909,7 +909,7 @@ bool SkywatcherAPIMount::getCurrentRADE(INDI::IHorizontalCoordinates altaz, INDI
909909
DEBUGF(INDI::AlignmentSubsystem::DBG_ALIGNMENT, "TDV x %lf y %lf z %lf", TDV.x, TDV.y, TDV.z);
910910

911911
double RightAscension, Declination;
912-
if (!TransformTelescopeToCelestial(TDV, RightAscension, Declination))
912+
if (!TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
913913
{
914914
TelescopeDirectionVector RotatedTDV(TDV);
915915
switch (GetApproximateMountAlignment())
@@ -981,7 +981,7 @@ bool SkywatcherAPIMount::Sync(double ra, double dec)
981981
INDI::IHorizontalCoordinates AltAz { 0, 0 };
982982
TelescopeDirectionVector TDV;
983983

984-
if (TransformCelestialToTelescope(ra, dec, 0.0, TDV))
984+
if (TransformCelestialToTelescopeJD(ra, dec, ln_get_julian_from_sys(), TDV))
985985
{
986986
AltitudeAzimuthFromTelescopeDirectionVector(TDV, AltAz);
987987
double OrigAlt = AltAz.altitude;
@@ -1345,10 +1345,11 @@ void SkywatcherAPIMount::ConvertGuideCorrection(double delta_ra, double delta_de
13451345
TelescopeDirectionVector OldTDV;
13461346
TelescopeDirectionVector NewTDV;
13471347

1348-
TransformCelestialToTelescope(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination, 0.0, OldTDV);
1348+
TransformCelestialToTelescopeJD(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1349+
ln_get_julian_from_sys(), OldTDV);
13491350
AltitudeAzimuthFromTelescopeDirectionVector(OldTDV, OldAltAz);
1350-
TransformCelestialToTelescope(m_SkyTrackingTarget.rightascension + delta_ra,
1351-
m_SkyTrackingTarget.declination + delta_dec, 0.0, NewTDV);
1351+
TransformCelestialToTelescopeJD(m_SkyTrackingTarget.rightascension + delta_ra,
1352+
m_SkyTrackingTarget.declination + delta_dec, ln_get_julian_from_sys(), NewTDV);
13521353
AltitudeAzimuthFromTelescopeDirectionVector(NewTDV, NewAltAz);
13531354
delta_alt = NewAltAz.altitude - OldAltAz.altitude;
13541355
delta_az = NewAltAz.azimuth - OldAltAz.azimuth;
@@ -1674,7 +1675,7 @@ bool SkywatcherAPIMount::trackUsingPID()
16741675
auto de = m_SkyTrackingTarget.declination + AxisOffsetNP[DEOffset].getValue();
16751676
auto JDOffset = AxisOffsetNP[JulianOffset].getValue() / 86400.0;
16761677

1677-
if (TransformCelestialToTelescope(ra, de, JDOffset, TDV))
1678+
if (TransformCelestialToTelescopeJD(ra, de, ln_get_julian_from_sys() + JDOffset, TDV))
16781679
{
16791680
DEBUGF(INDI::AlignmentSubsystem::DBG_ALIGNMENT, "TDV x %lf y %lf z %lf", TDV.x, TDV.y, TDV.z);
16801681
AltitudeAzimuthFromTelescopeDirectionVector(TDV, AltAz);
@@ -1871,23 +1872,23 @@ bool SkywatcherAPIMount::trackUsingPredictiveRates()
18711872
}
18721873

18731874
// Start by transforming tracking target celestial coordinates to telescope coordinates.
1874-
if (TransformCelestialToTelescope(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1875-
0, TDV))
1875+
double JDnow {ln_get_julian_from_sys()};
1876+
if (TransformCelestialToTelescopeJD(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1877+
JDnow, TDV))
18761878
{
18771879
// If mount is Alt-Az then that's all we need to do
18781880
AltitudeAzimuthFromTelescopeDirectionVector(TDV, targetMountAxisCoordinates);
1879-
TransformCelestialToTelescope(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1880-
JDoffset, futureTDV);
1881+
TransformCelestialToTelescopeJD(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1882+
JDnow + JDoffset, futureTDV);
18811883
AltitudeAzimuthFromTelescopeDirectionVector(futureTDV, futureMountAxisCoordinates);
1882-
TransformCelestialToTelescope(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1883-
-JDoffset, pastTDV);
1884+
TransformCelestialToTelescopeJD(m_SkyTrackingTarget.rightascension, m_SkyTrackingTarget.declination,
1885+
JDnow - JDoffset, pastTDV);
18841886
AltitudeAzimuthFromTelescopeDirectionVector(pastTDV, pastMountAxisCoordinates);
18851887

18861888
}
18871889
// If transformation failed.
18881890
else
18891891
{
1890-
double JDnow {ln_get_julian_from_sys()};
18911892
INDI::IEquatorialCoordinates EquatorialCoordinates { 0, 0 };
18921893
EquatorialCoordinates.rightascension = m_SkyTrackingTarget.rightascension;
18931894
EquatorialCoordinates.declination = m_SkyTrackingTarget.declination;

drivers/telescope/telescope_simulator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ void ScopeSim::updateCurrentCoordsFromAxes()
317317
INDI::IEquatorialCoordinates raCoords{ encoderRA, instDec.Degrees() };
318318
TelescopeDirectionVector tdv =
319319
TelescopeDirectionVectorFromEquatorialCoordinates(raCoords);
320-
corrected = TransformTelescopeToCelestial(tdv, corrRA, corrDec);
320+
corrected = TransformTelescopeToCelestialJD(tdv, corrRA, corrDec, ln_get_julian_from_sys());
321321
}
322322
if (corrected)
323323
{
@@ -571,7 +571,7 @@ bool ScopeSim::Goto(double r, double d)
571571
if (GetAlignmentDatabase().size() >= 1)
572572
{
573573
TelescopeDirectionVector tdv;
574-
if (TransformCelestialToTelescope(r, d, 0.0, tdv))
574+
if (TransformCelestialToTelescopeJD(r, d, ln_get_julian_from_sys(), tdv))
575575
{
576576
// The TDV now encodes encoder RA (time-stable), so decode with
577577
// EquatorialCoordinatesFromTelescopeDirectionVector — no LST conversion needed.

drivers/telescope/temmadriver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ bool TemmaMount::ReadScopeStatus()
419419

420420
aligned = true;
421421

422-
if (!TransformTelescopeToCelestial(TDV, alignedRA, alignedDEC))
422+
if (!TransformTelescopeToCelestialJD(TDV, alignedRA, alignedDEC, ln_get_julian_from_sys()))
423423
{
424424
aligned = false;
425425
DEBUGF(INDI::AlignmentSubsystem::DBG_ALIGNMENT,
@@ -938,7 +938,7 @@ INDI::IEquatorialCoordinates TemmaMount::TelescopeToSky(double ra, double dec)
938938
eq.dec = dec;
939939
TDV = TelescopeDirectionVectorFromLocalHourAngleDeclination(eq);
940940

941-
if (TransformTelescopeToCelestial(TDV, RightAscension, Declination))
941+
if (TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
942942
{
943943
// if we get here, the conversion was successful
944944
//LOG_DEBUG"new values %6.4f %6.4f %6.4f %6.4f Deltas %3.0lf %3.0lf\n",ra,dec,RightAscension,Declination,(ra-RightAscension)*60,(dec-Declination)*60);
@@ -977,7 +977,7 @@ INDI::IEquatorialCoordinates TemmaMount::SkyToTelescope(double ra, double dec)
977977
// if the alignment system has been turned off
978978
// this transformation will fail, and we fall thru
979979
// to using raw co-ordinates from the mount
980-
if (TransformCelestialToTelescope(ra, dec, 0.0, TDV))
980+
if (TransformCelestialToTelescopeJD(ra, dec, ln_get_julian_from_sys(), TDV))
981981
{
982982
/* Initial attempt, using RA/DEC co-ordinates talking to alignment system
983983
EquatorialCoordinatesFromTelescopeDirectionVector(TDV,eq);

examples/tutorial_seven/simple_telescope_simulator.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool ScopeSim::Goto(double ra, double dec)
102102
TelescopeDirectionVector TDV;
103103
INDI::IHorizontalCoordinates AltAz { 0, 0 };
104104

105-
if (TransformCelestialToTelescope(ra, dec, 0.0, TDV))
105+
if (TransformCelestialToTelescopeJD(ra, dec, ln_get_julian_from_sys(), TDV))
106106
{
107107
// The alignment subsystem has successfully transformed my coordinate
108108
AltitudeAzimuthFromTelescopeDirectionVector(TDV, AltAz);
@@ -287,7 +287,7 @@ bool ScopeSim::ReadScopeStatus()
287287
INDI::IHorizontalCoordinates AltAz { CurrentEncoderMicrostepsRA / MICROSTEPS_PER_DEGREE, CurrentEncoderMicrostepsDEC / MICROSTEPS_PER_DEGREE };
288288
TelescopeDirectionVector TDV = TelescopeDirectionVectorFromAltitudeAzimuth(AltAz);
289289
double RightAscension, Declination;
290-
if (!TransformTelescopeToCelestial(TDV, RightAscension, Declination))
290+
if (!TransformTelescopeToCelestialJD(TDV, RightAscension, Declination, ln_get_julian_from_sys()))
291291
{
292292
if (TraceThisTick)
293293
DEBUG(DBG_SIMULATOR, "ReadScopeStatus - TransformTelescopeToCelestial failed");
@@ -613,8 +613,9 @@ void ScopeSim::TimerHit()
613613
TelescopeDirectionVector TDV;
614614
INDI::IHorizontalCoordinates AltAz { 0, 0 };
615615

616-
if (TransformCelestialToTelescope(CurrentTrackingTarget.rightascension, CurrentTrackingTarget.declination, JulianOffset,
617-
TDV))
616+
if (TransformCelestialToTelescopeJD(CurrentTrackingTarget.rightascension,
617+
CurrentTrackingTarget.declination,
618+
ln_get_julian_from_sys() + JulianOffset, TDV))
618619
AltitudeAzimuthFromTelescopeDirectionVector(TDV, AltAz);
619620
else
620621
{

libs/alignment/AlignmentSubsystemForDrivers.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void AlignmentSubsystemForDrivers::SaveAlignmentConfigProperties(FILE *fp)
6565
// Helper methods
6666

6767
bool AlignmentSubsystemForDrivers::AddAlignmentEntryEquatorial(double actualRA, double actualDec, double mountRA,
68-
double mountDec)
68+
double mountDec, double JD)
6969
{
7070
IGeographicCoordinates location;
7171
if (!GetDatabaseReferencePosition(location))
@@ -77,7 +77,7 @@ bool AlignmentSubsystemForDrivers::AddAlignmentEntryEquatorial(double actualRA,
7777
AlignmentDatabaseEntry NewEntry;
7878
TelescopeDirectionVector TDV = TelescopeDirectionVectorFromEquatorialCoordinates(RaDec);
7979

80-
NewEntry.ObservationJulianDate = ln_get_julian_from_sys();
80+
NewEntry.ObservationJulianDate = JD;
8181
NewEntry.RightAscension = actualRA;
8282
NewEntry.Declination = actualDec;
8383
NewEntry.TelescopeDirection = TDV;
@@ -98,7 +98,7 @@ bool AlignmentSubsystemForDrivers::AddAlignmentEntryEquatorial(double actualRA,
9898
}
9999

100100
bool AlignmentSubsystemForDrivers::SkyToTelescopeEquatorial(double actualRA, double actualDec, double &mountRA,
101-
double &mountDec)
101+
double &mountDec, double JD)
102102
{
103103
INDI::IEquatorialCoordinates eq{0, 0};
104104
TelescopeDirectionVector TDV;
@@ -115,7 +115,7 @@ bool AlignmentSubsystemForDrivers::SkyToTelescopeEquatorial(double actualRA, dou
115115

116116
if (GetAlignmentDatabase().size() >= 1)
117117
{
118-
if (TransformCelestialToTelescope(actualRA, actualDec, 0.0, TDV))
118+
if (TransformCelestialToTelescopeJD(actualRA, actualDec, JD, TDV))
119119
{
120120
EquatorialCoordinatesFromTelescopeDirectionVector(TDV, eq);
121121
// and now we have to convert from lha back to RA
@@ -129,7 +129,7 @@ bool AlignmentSubsystemForDrivers::SkyToTelescopeEquatorial(double actualRA, dou
129129
}
130130

131131
bool AlignmentSubsystemForDrivers::TelescopeEquatorialToSky(double mountRA, double mountDec, double &actualRA,
132-
double &actualDec)
132+
double &actualDec, double JD)
133133
{
134134
INDI::IEquatorialCoordinates eq{0, 0};
135135
IGeographicCoordinates location;
@@ -150,14 +150,14 @@ bool AlignmentSubsystemForDrivers::TelescopeEquatorialToSky(double mountRA, doub
150150
eq.declination = mountDec;
151151

152152
TDV = TelescopeDirectionVectorFromEquatorialCoordinates(eq);
153-
return TransformTelescopeToCelestial(TDV, actualRA, actualDec);
153+
return TransformTelescopeToCelestialJD(TDV, actualRA, actualDec, JD);
154154
}
155155

156156
return false;
157157
}
158158

159159
bool AlignmentSubsystemForDrivers::AddAlignmentEntryAltAz(double actualRA, double actualDec, double mountAlt,
160-
double mountAz)
160+
double mountAz, double JD)
161161
{
162162
IGeographicCoordinates location;
163163
if (!GetDatabaseReferencePosition(location))
@@ -169,7 +169,7 @@ bool AlignmentSubsystemForDrivers::AddAlignmentEntryAltAz(double actualRA, doubl
169169
AlignmentDatabaseEntry NewEntry;
170170
TelescopeDirectionVector TDV = TelescopeDirectionVectorFromAltitudeAzimuth(AltAz);
171171

172-
NewEntry.ObservationJulianDate = ln_get_julian_from_sys();
172+
NewEntry.ObservationJulianDate = JD;
173173
NewEntry.RightAscension = actualRA;
174174
NewEntry.Declination = actualDec;
175175
NewEntry.TelescopeDirection = TDV;
@@ -189,7 +189,8 @@ bool AlignmentSubsystemForDrivers::AddAlignmentEntryAltAz(double actualRA, doubl
189189
return false;
190190
}
191191

192-
bool AlignmentSubsystemForDrivers::SkyToTelescopeAltAz(double actualRA, double actualDec, double &mountAlt, double &mountAz)
192+
bool AlignmentSubsystemForDrivers::SkyToTelescopeAltAz(double actualRA, double actualDec, double &mountAlt,
193+
double &mountAz, double JD)
193194
{
194195
INDI::IHorizontalCoordinates altAz{0, 0};
195196
TelescopeDirectionVector TDV;
@@ -202,7 +203,7 @@ bool AlignmentSubsystemForDrivers::SkyToTelescopeAltAz(double actualRA, double a
202203

203204
if (GetAlignmentDatabase().size() >= 1)
204205
{
205-
if (TransformCelestialToTelescope(actualRA, actualDec, 0.0, TDV))
206+
if (TransformCelestialToTelescopeJD(actualRA, actualDec, JD, TDV))
206207
{
207208
AltitudeAzimuthFromTelescopeDirectionVector(TDV, altAz);
208209
mountAz = range360(altAz.azimuth);
@@ -214,7 +215,8 @@ bool AlignmentSubsystemForDrivers::SkyToTelescopeAltAz(double actualRA, double a
214215
return false;
215216
}
216217

217-
bool AlignmentSubsystemForDrivers::TelescopeAltAzToSky(double mountAlt, double mountAz, double &actualRa, double &actualDec)
218+
bool AlignmentSubsystemForDrivers::TelescopeAltAzToSky(double mountAlt, double mountAz, double &actualRa,
219+
double &actualDec, double JD)
218220
{
219221
INDI::IHorizontalCoordinates altaz{0, 0};
220222
IGeographicCoordinates location;
@@ -230,7 +232,7 @@ bool AlignmentSubsystemForDrivers::TelescopeAltAzToSky(double mountAlt, double m
230232
altaz.azimuth = range360(mountAz);
231233
altaz.altitude = range360(mountAlt);
232234
TDV = TelescopeDirectionVectorFromAltitudeAzimuth(altaz);
233-
return TransformTelescopeToCelestial(TDV, actualRa, actualDec);
235+
return TransformTelescopeToCelestialJD(TDV, actualRa, actualDec, JD);
234236
}
235237

236238
return false;

0 commit comments

Comments
 (0)