@@ -258,6 +258,59 @@ TEST(MsgsTest, ConvertMathSphericalCoordinatesToMsgs)
258258 EXPECT_DOUBLE_EQ (2.2 , math.LongitudeReference ().Degree ());
259259 EXPECT_DOUBLE_EQ (3.3 , math.ElevationReference ());
260260 EXPECT_DOUBLE_EQ (0.4 , math.HeadingOffset ().Degree ());
261+
262+ // For Moon's surface.
263+ auto msgMoon = msgs::Convert (
264+ math::SphericalCoordinates (
265+ math::SphericalCoordinates::SurfaceType::MOON_SCS,
266+ GZ_DTOR (1.1 ), GZ_DTOR (2.2 ), 3.3 , GZ_DTOR (0.4 )));
267+
268+ EXPECT_EQ (msgs::SphericalCoordinates::MOON_SCS,
269+ msgMoon.surface_model ());
270+ EXPECT_DOUBLE_EQ (1.1 , msgMoon.latitude_deg ());
271+ EXPECT_DOUBLE_EQ (2.2 , msgMoon.longitude_deg ());
272+ EXPECT_DOUBLE_EQ (3.3 , msgMoon.elevation ());
273+ EXPECT_DOUBLE_EQ (0.4 , msgMoon.heading_deg ());
274+
275+ auto mathMoon = msgs::Convert (msgMoon);
276+
277+ EXPECT_EQ (math::SphericalCoordinates::MOON_SCS,
278+ mathMoon.Surface ());
279+ EXPECT_DOUBLE_EQ (1.1 , mathMoon.LatitudeReference ().Degree ());
280+ EXPECT_DOUBLE_EQ (2.2 , mathMoon.LongitudeReference ().Degree ());
281+ EXPECT_DOUBLE_EQ (3.3 , mathMoon.ElevationReference ());
282+ EXPECT_DOUBLE_EQ (0.4 , mathMoon.HeadingOffset ().Degree ());
283+
284+ // For custom surfaces.
285+ auto sc = math::SphericalCoordinates (
286+ math::SphericalCoordinates::CUSTOM_SURFACE,
287+ 12000 , 10000 );
288+ sc.SetLatitudeReference (GZ_DTOR (1.1 ));
289+ sc.SetLongitudeReference (GZ_DTOR (2.2 ));
290+ sc.SetElevationReference (3.3 );
291+ sc.SetHeadingOffset (GZ_DTOR (0.4 ));
292+
293+ auto msgCustom = msgs::Convert (sc);
294+
295+ EXPECT_EQ (msgs::SphericalCoordinates::CUSTOM_SURFACE,
296+ msgCustom.surface_model ());
297+ EXPECT_DOUBLE_EQ (1.1 , msgCustom.latitude_deg ());
298+ EXPECT_DOUBLE_EQ (2.2 , msgCustom.longitude_deg ());
299+ EXPECT_DOUBLE_EQ (3.3 , msgCustom.elevation ());
300+ EXPECT_DOUBLE_EQ (0.4 , msgCustom.heading_deg ());
301+ EXPECT_DOUBLE_EQ (12000 , msgCustom.surface_axis_equatorial ());
302+ EXPECT_DOUBLE_EQ (10000 , msgCustom.surface_axis_polar ());
303+
304+ auto mathCustom = msgs::Convert (msgCustom);
305+
306+ EXPECT_EQ (math::SphericalCoordinates::CUSTOM_SURFACE,
307+ mathCustom.Surface ());
308+ EXPECT_DOUBLE_EQ (1.1 , mathCustom.LatitudeReference ().Degree ());
309+ EXPECT_DOUBLE_EQ (2.2 , mathCustom.LongitudeReference ().Degree ());
310+ EXPECT_DOUBLE_EQ (3.3 , mathCustom.ElevationReference ());
311+ EXPECT_DOUBLE_EQ (0.4 , mathCustom.HeadingOffset ().Degree ());
312+ EXPECT_DOUBLE_EQ (12000 , mathCustom.SurfaceAxisEquatorial ());
313+ EXPECT_DOUBLE_EQ (10000 , mathCustom.SurfaceAxisPolar ());
261314}
262315
263316// ///////////////////////////////////////////////
@@ -488,6 +541,40 @@ TEST(MsgsTest, SetSphericalCoordinates)
488541 EXPECT_DOUBLE_EQ (2.2 , msg.longitude_deg ());
489542 EXPECT_DOUBLE_EQ (3.3 , msg.elevation ());
490543 EXPECT_DOUBLE_EQ (0.4 , msg.heading_deg ());
544+
545+ // For Moon's surface.
546+ msgs::SphericalCoordinates msgMoon;
547+ msgs::Set (&msgMoon, math::SphericalCoordinates (
548+ math::SphericalCoordinates::SurfaceType::MOON_SCS,
549+ GZ_DTOR (1.2 ), GZ_DTOR (2.3 ), 3.4 , GZ_DTOR (0.5 )));
550+
551+ EXPECT_EQ (msgs::SphericalCoordinates::MOON_SCS,
552+ msgMoon.surface_model ());
553+ EXPECT_DOUBLE_EQ (1.2 , msgMoon.latitude_deg ());
554+ EXPECT_DOUBLE_EQ (2.3 , msgMoon.longitude_deg ());
555+ EXPECT_DOUBLE_EQ (3.4 , msgMoon.elevation ());
556+ EXPECT_DOUBLE_EQ (0.5 , msgMoon.heading_deg ());
557+
558+ // For a custom surface.
559+ msgs::SphericalCoordinates msgCustom;
560+ auto sc = math::SphericalCoordinates (
561+ math::SphericalCoordinates::CUSTOM_SURFACE,
562+ 12000 , 10000 );
563+ sc.SetLatitudeReference (GZ_DTOR (1.9 ));
564+ sc.SetLongitudeReference (GZ_DTOR (2.8 ));
565+ sc.SetElevationReference (3.7 );
566+ sc.SetHeadingOffset (GZ_DTOR (0.6 ));
567+
568+ msgs::Set (&msgCustom, sc);
569+
570+ EXPECT_EQ (msgs::SphericalCoordinates::CUSTOM_SURFACE,
571+ msgCustom.surface_model ());
572+ EXPECT_DOUBLE_EQ (1.9 , msgCustom.latitude_deg ());
573+ EXPECT_DOUBLE_EQ (2.8 , msgCustom.longitude_deg ());
574+ EXPECT_DOUBLE_EQ (3.7 , msgCustom.elevation ());
575+ EXPECT_DOUBLE_EQ (0.6 , msgCustom.heading_deg ());
576+ EXPECT_DOUBLE_EQ (12000 , msgCustom.surface_axis_equatorial ());
577+ EXPECT_DOUBLE_EQ (10000 , msgCustom.surface_axis_polar ());
491578}
492579
493580// ///////////////////////////////////////////////
0 commit comments