Skip to content

Commit e1148c0

Browse files
committed
Add UTM unit tests
1 parent 79384e9 commit e1148c0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

libs/topography/src/conversions_unittest.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,33 @@ TEST(TopographyConversion, geodeticToENU_WGS84)
7070
EXPECT_NEAR(P.y, 0, 0.1e-3);
7171
EXPECT_NEAR(P.z, A_height, 0.1e-3);
7272
}
73+
74+
TEST(TopographyConversion, geodeticToUTM_WGS84)
75+
{
76+
mrpt::topography::TGeodeticCoords gps_point;
77+
gps_point.lon = -2.404508;
78+
gps_point.lat = 36.829293;
79+
gps_point.height = 0;
80+
81+
mrpt::topography::TUTMCoords utm;
82+
int utm_zone = 0;
83+
char lat_band = 0;
84+
85+
mrpt::topography::geodeticToUTM(gps_point, utm, utm_zone, lat_band);
86+
87+
EXPECT_EQ(utm_zone, 30);
88+
EXPECT_EQ(lat_band, 'S');
89+
EXPECT_NEAR(utm.x, 553103.02, 0.05);
90+
EXPECT_NEAR(utm.y, 4076100.98, 0.05);
91+
}
92+
93+
TEST(TopographyConversion, UTMToGeodetic_WGS84)
94+
{
95+
const mrpt::topography::TUTMCoords utm = {553103.020, 4076100.969, 0.0};
96+
97+
mrpt::topography::TGeodeticCoords gc;
98+
mrpt::topography::UTMToGeodetic(utm, 30, 'N', gc);
99+
100+
EXPECT_NEAR(gc.lat, 36.829293, 1e-6);
101+
EXPECT_NEAR(gc.lon, -2.404508, 1e-6);
102+
}

0 commit comments

Comments
 (0)