Skip to content

Commit 851977e

Browse files
authored
fix: harmonize depracation warnings (#562)
* fix: harmonize depracation warnings * fix: add disable delcarations
1 parent f5760a0 commit 851977e

File tree

11 files changed

+58
-16
lines changed

11 files changed

+58
-16
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ OPTION (BUILD_SCRIPT "Build script" OFF)
2727
OPTION (BUILD_WITH_CXX_17 "Build with C++ 17 support." OFF)
2828
OPTION (BUILD_WITH_BOOST_STACKTRACE "Build with Boost Stacktrace instead of stacktrace basic" ON)
2929
OPTION (BUILD_WITH_BOOST_STATIC "Build with Boost Static lib" ON)
30+
OPTION (BUILD_WITHOUT_DEPRECATED_DECLARATION_WARNINGS "Build without deprecated declaration warnings" OFF)
3031

3132
## Setup
3233

@@ -167,6 +168,14 @@ IF (BUILD_WITH_DEBUG_SYMBOLS)
167168

168169
ENDIF ()
169170

171+
### Warnings
172+
173+
IF (BUILD_WITHOUT_DEPRECATED_DECLARATION_WARNINGS)
174+
175+
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
176+
177+
ENDIF ()
178+
170179
### Debugging Options
171180

172181
SET (CMAKE_VERBOSE_MAKEFILE 0) # Use 1 for debugging, 0 for release

bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Flight/Profile.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Flight_Profile(pybind11::module& aMo
5555

5656
.value("GeocentricNadir", Profile::TargetType::GeocentricNadir, "Geocentric nadir")
5757
.value("GeodeticNadir", Profile::TargetType::GeodeticNadir, "Geodetic nadir")
58-
.value("Trajectory", Profile::TargetType::Trajectory, "Trajectory") // Deprecated in favor of TargetPosition
58+
.value("Trajectory", Profile::TargetType::Trajectory, "Deprecated - Use TargetPosition instead.")
5959
.value("TargetPosition", Profile::TargetType::TargetPosition, "Target position")
6060
.value("TargetVelocity", Profile::TargetType::TargetVelocity, "Target velocity")
6161
.value(
@@ -114,7 +114,14 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Flight_Profile(pybind11::module& aMo
114114
)
115115

116116
.def(
117-
init<const Trajectory&, const Profile::Axis&, const bool&&>(),
117+
init(
118+
+[](const Trajectory& trajectory, const Profile::Axis& axis, const bool& antiDirection
119+
) -> Profile::TrajectoryTarget
120+
{
121+
PyErr_WarnEx(PyExc_DeprecationWarning, "Use TrajectoryTarget.target_position(...) instead.", 1);
122+
return Profile::TrajectoryTarget(trajectory, axis, antiDirection);
123+
}
124+
),
118125
R"doc(
119126
Constructor.
120127

bindings/python/src/OpenSpaceToolkitAstrodynamicsPy/Trajectory.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory(pybind11::module& aModule
2727
using ostk::physics::unit::Derived;
2828

2929
using ostk::astrodynamics::Trajectory;
30+
using ostk::astrodynamics::trajectory::Orbit;
3031
using ostk::astrodynamics::trajectory::State;
3132

3233
class_<Trajectory, Shared<Trajectory>>(
@@ -152,9 +153,18 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory(pybind11::module& aModule
152153
)
153154
.def_static(
154155
"ground_strip",
155-
overload_cast<const LLA&, const LLA&, const Derived&, const Instant&, const Celestial&, const Duration&>(
156-
&Trajectory::GroundStrip
157-
),
156+
+[](const LLA& aStartLLA,
157+
const LLA& anEndLLA,
158+
const Derived& aGroundSpeed,
159+
const Instant& aStartInstant,
160+
const Celestial& aCelestial,
161+
const Duration& aStepSize) -> Trajectory
162+
{
163+
PyErr_WarnEx(
164+
PyExc_DeprecationWarning, "Use Trajectory(model=TargetScan.from_ground_speed(...)) instead.", 1
165+
);
166+
return Trajectory::GroundStrip(aStartLLA, anEndLLA, aGroundSpeed, aStartInstant, aCelestial, aStepSize);
167+
},
158168
R"doc(
159169
Create a `Trajectory` object representing a ground strip.
160170
Computes the duration as the geodetic distance / ground speed.
@@ -181,7 +191,14 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory(pybind11::module& aModule
181191
)
182192
.def_static(
183193
"ground_strip",
184-
overload_cast<const LLA&, const LLA&, const Array<Instant>&, const Celestial&>(&Trajectory::GroundStrip),
194+
+[](const LLA& aStartLLA,
195+
const LLA& anEndLLA,
196+
const Array<Instant>& anInstantArray,
197+
const Celestial& aCelestial) -> Trajectory
198+
{
199+
PyErr_WarnEx(PyExc_DeprecationWarning, "Use Trajectory(model=TargetScan(...)) instead.", 1);
200+
return Trajectory::GroundStrip(aStartLLA, anEndLLA, anInstantArray, aCelestial);
201+
},
185202
R"doc(
186203
Create a `Trajectory` object representing a ground strip.
187204
This method computes the duration as the geodetic distance / ground speed.
@@ -203,7 +220,11 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory(pybind11::module& aModule
203220
)
204221
.def_static(
205222
"ground_strip_geodetic_nadir",
206-
&Trajectory::GroundStripGeodeticNadir,
223+
+[](const Orbit& anOrbit, const Array<Instant>& anInstantArray, const Celestial& aCelestial) -> Trajectory
224+
{
225+
PyErr_WarnEx(PyExc_DeprecationWarning, "Use Trajectory(model=Nadir(...)) instead.", 1);
226+
return Trajectory::GroundStripGeodeticNadir(anOrbit, anInstantArray, aCelestial);
227+
},
207228
R"doc(
208229
Create a `Trajectory` object representing a ground strip that follows the geodetic nadir of the provided orbit.
209230
@@ -213,7 +234,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory(pybind11::module& aModule
213234
celestial_object (Celestial): The celestial object. Defaults to Earth.WGS84().
214235
215236
Returns:
216-
Trajectory: The `Trajectory` object representing the ground strip.
237+
Trajectory: The `Trajectory` object representing the ground strip.
217238
)doc",
218239
arg("orbit"),
219240
arg("instants"),

bindings/python/test/flight/test_profile.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ def profile(request) -> Profile:
9797
@pytest.fixture(
9898
params=[
9999
Profile.Target(Profile.TargetType.GeocentricNadir, Profile.Axis.X),
100+
Profile.TrajectoryTarget(
101+
Trajectory.position(Position.meters((0.0, 0.0, 0.0), Frame.ITRF())),
102+
Profile.Axis.X,
103+
),
100104
Profile.TrajectoryTarget.target_position(
101105
Trajectory.position(Position.meters((0.0, 0.0, 0.0), Frame.ITRF())),
102106
Profile.Axis.X,

include/OpenSpaceToolkit/Astrodynamics/Flight/Profile.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Profile
9292
{
9393
GeocentricNadir, /// Negative of the position vector of the satellite in the ECI frame
9494
GeodeticNadir, /// Negative of the geodetic normal of the satellite in the ECI frame
95-
Trajectory, /// Points towards the provided trajectory, eg. Ground Station in ECEF
95+
Trajectory, /// DEPRECATED: Use TargetPosition instead.
9696
TargetPosition, /// Points towards the provided target position
9797
TargetVelocity, /// Points along the provided target's velocity vector
9898
TargetSlidingGroundVelocity, /// Points along the provided target's ground velocity vector (aka the scan
@@ -128,10 +128,11 @@ class Profile
128128
public:
129129
/// @brief Constructs a TrajectoryTarget object.
130130
///
131+
/// @deprecated Use TrajectoryTarget::TargetPosition(...) instead.
131132
/// @param aTrajectory The trajectory to point towards.
132133
/// @param anAxis The axis of the target.
133134
/// @param isAntiDirection Whether the target is in the anti-direction.
134-
[[deprecated("Use TrajectoryTarget::TargetPosition instead.")]]
135+
[[deprecated("Use TrajectoryTarget::TargetPosition(...) instead.")]]
135136
TrajectoryTarget(
136137
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection = false
137138
);

include/OpenSpaceToolkit/Astrodynamics/Flight/Profile/Model/Tabulated.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class Tabulated : public virtual Model
5656
/// @brief Constructor
5757
///
5858
/// @param aStateArray An array of states
59-
/// @deprecated Use the constructor with Interpolator::Type instead
60-
[[deprecated("Use the constructor with Interpolator::Type instead")]]
59+
/// @deprecated Use the constructor with Interpolator::Type instead.
60+
[[deprecated("Use the constructor with Interpolator::Type instead.")]]
6161
Tabulated(const Array<State>& aStateArray);
6262

6363
/// @brief Constructor

include/OpenSpaceToolkit/Astrodynamics/Trajectory.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class Trajectory
195195
/// duration);
196196
/// @endcode
197197
///
198-
/// @deprecated Use Trajectory::TargetScan instead.
198+
/// @deprecated Use Trajectory(TargetScan::FromGroundSpeed(...)) instead.
199199
/// @param aStartLLA A start LLA
200200
/// @param anEndLLA An end LLA
201201
/// @param aGroundSpeed A ground speed
@@ -225,7 +225,7 @@ class Trajectory
225225
/// Trajectory trajectory = Trajectory::GroundStrip(startLLA, endLLA, instants, earth);
226226
/// @endcode
227227
///
228-
/// @deprecated Use Trajectory::TargetScan instead.
228+
/// @deprecated Use Trajectory(TargetScan(...)) instead.
229229
/// @param aStartLLA A start LLA
230230
/// @param anEndLLA An end LLA
231231
/// @param anInstantArray An array of instants

src/OpenSpaceToolkit/Astrodynamics/Flight/Profile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Profile::TrajectoryTarget::TrajectoryTarget(
9090
if (aType == TargetType::Trajectory)
9191
{
9292
throw ostk::core::error::RuntimeError(
93-
"TrajectoryTarget::Trajectory is deprecated. Use TrajectoryTarget::TargetPosition instead."
93+
"TargetType::Trajectory is deprecated. Use TargetType::TargetPosition instead."
9494
);
9595
}
9696

src/OpenSpaceToolkit/Astrodynamics/Trajectory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Trajectory Trajectory::GroundStripGeodeticNadir(
252252
[[maybe_unused]] const Celestial& aCelestial
253253
)
254254
{
255-
[[deprecated("Use Trajectory::GeodeticNadirGroundTrack instead.")]] return Trajectory(Nadir(anOrbit));
255+
return Trajectory(Nadir(anOrbit));
256256
}
257257

258258
Trajectory::Trajectory()

0 commit comments

Comments
 (0)