38 #include <gtest/gtest.h> 63 TEST(UTMPoint, nullConstructor)
70 EXPECT_EQ(pt.
zone, 0);
71 EXPECT_EQ(pt.
band,
' ');
76 TEST(UTMPoint, flatConstructor)
89 EXPECT_EQ(pt.
zone, z);
90 EXPECT_EQ(pt.
band, b);
94 TEST(UTMPoint, hasAltitude)
108 EXPECT_EQ(pt.
zone, z);
109 EXPECT_EQ(pt.
band, b);
113 TEST(UTMPoint, copyConstructor)
128 EXPECT_EQ(pt2.
zone, z);
129 EXPECT_EQ(pt2.
band, b);
136 double lat = 30.385315;
137 double lon = -97.728524;
140 geographic_msgs::GeoPoint ll;
148 double e = 622159.34;
149 double n = 3362168.30;
152 double abs_err = 0.01;
157 EXPECT_NEAR(pt.
easting, e, abs_err);
158 EXPECT_NEAR(pt.
northing, n, abs_err);
159 EXPECT_NEAR(pt.
altitude, alt, abs_err);
160 EXPECT_EQ(pt.
zone, z);
161 EXPECT_EQ(pt.
band, b);
180 for (uint8_t b = 1; b <= 60; ++b)
227 TEST(UTMPose, pointQuaternionConstructor)
236 geometry_msgs::Quaternion q;
259 TEST(UTMPose, quaternionValidation)
269 geometry_msgs::Quaternion q;
303 TEST(UTMConvert, fromUtmToLatLongAndBack)
311 for (uint8_t
z = 1;
z <= 60; ++
z)
314 geographic_msgs::GeoPoint ll;
326 TEST(UTMConvert, fromLatLongToUtmAndBack)
333 for (
double lon = -179.5; lon < 180.0; lon += 1.0)
335 for (
double lat = -80.0; lat <= 84.0; lat += 1.0)
346 EXPECT_NEAR(pt1.latitude, pt2.latitude, 0.0000001);
347 EXPECT_NEAR(pt1.longitude, pt2.longitude, 0.0000012);
348 EXPECT_NEAR(pt1.altitude, pt2.altitude, 0.000001);
354 TEST(UTMConvert, internationalDateLine)
359 for (
double lat = -80.0; lat <= 84.0; lat += 1.0)
370 EXPECT_NEAR(pt1.latitude, pt2.latitude, 0.0000001);
371 EXPECT_NEAR(pt1.altitude, pt2.altitude, 0.000001);
373 if (pt2.longitude - pt1.longitude > 359.0)
377 pt2.longitude -= 360.0;
379 EXPECT_NEAR(pt1.longitude, pt2.longitude, 0.0000012);
387 std::ostringstream out1;
389 std::string expected(
"(0, 0, nan [0 ])");
390 EXPECT_EQ(out1.str(), expected);
393 std::ostringstream out2;
395 expected =
"(622159.338, 3362168.303, 209 [14R])";
396 EXPECT_EQ(out2.str(), expected);
403 geometry_msgs::Quaternion q;
410 std::ostringstream out;
412 std::string expected(
"(1000, 2400, 200 [14R]), ([0, 0, 0], 1)");
413 EXPECT_EQ(out.str(), expected);
417 int main(
int argc,
char **argv)
419 testing::InitGoogleTest(&argc, argv);
422 return RUN_ALL_TESTS();
char band
MGRS latitude band letter.
Universal Transverse Mercator coordinates.
int main(int argc, char **argv)
double northing
northing within grid zone [meters]
double altitude
altitude above ellipsoid [meters] or NaN
geometry_msgs::Quaternion orientation
uint8_t zone
UTM longitude zone number.
void fromMsg(const geographic_msgs::GeoPoint &from, UTMPoint &to)
TFSIMD_FORCE_INLINE const tfScalar & z() const
TEST(UTMPoint, nullConstructor)
static bool is2D(const UTMPoint &pt)
bool isValid(const UTMPoint &pt)
void check_utm_near(const geodesy::UTMPoint &pt1, const geodesy::UTMPoint &pt2, double abs_err)
double easting
easting within grid zone [meters]
void convert(const From &from, To &to)
geographic_msgs::GeoPoint toMsg(const UTMPoint &from)