38 #include <gtest/gtest.h> 64 TEST(UTMPoint, nullConstructor)
71 EXPECT_EQ(pt.
zone, 0);
72 EXPECT_EQ(pt.
band,
' ');
77 TEST(UTMPoint, flatConstructor)
90 EXPECT_EQ(pt.
zone, z);
91 EXPECT_EQ(pt.
band, b);
95 TEST(UTMPoint, hasAltitude)
109 EXPECT_EQ(pt.
zone, z);
110 EXPECT_EQ(pt.
band, b);
114 TEST(UTMPoint, copyConstructor)
129 EXPECT_EQ(pt2.
zone, z);
130 EXPECT_EQ(pt2.
band, b);
137 double lat = 30.385315;
138 double lon = -97.728524;
141 geographic_msgs::GeoPoint ll;
149 double e = 622159.34;
150 double n = 3362168.30;
153 double abs_err = 0.01;
158 EXPECT_NEAR(pt.
easting, e, abs_err);
159 EXPECT_NEAR(pt.
northing, n, abs_err);
160 EXPECT_NEAR(pt.
altitude, alt, abs_err);
161 EXPECT_EQ(pt.
zone, z);
162 EXPECT_EQ(pt.
band, b);
181 for (uint8_t b = 1; b <= 60; ++b)
228 TEST(UTMPose, pointQuaternionConstructor)
237 geometry_msgs::Quaternion q;
260 TEST(UTMPose, quaternionValidation)
270 geometry_msgs::Quaternion q;
304 TEST(UTMConvert, fromUtmPoseToLatLongAndBack)
312 for (uint8_t
z = 1;
z <= 60; ++
z)
314 for (
unsigned int heading = 0; heading < 360; heading++)
318 geographic_msgs::GeoPose ll;
332 TEST(UTMConvert, fromUtmToLatLongAndBack)
340 for (uint8_t
z = 1;
z <= 60; ++
z)
343 geographic_msgs::GeoPoint ll;
355 TEST(UTMConvert, fromLatLongToUtmAndBack)
362 for (
double lon = -179.5; lon < 180.0; lon += 1.0)
364 for (
double lat = -80.0; lat <= 84.0; lat += 1.0)
375 EXPECT_NEAR(pt1.latitude, pt2.latitude, 0.0000001);
376 EXPECT_NEAR(pt1.longitude, pt2.longitude, 0.0000012);
377 EXPECT_NEAR(pt1.altitude, pt2.altitude, 0.000001);
383 TEST(UTMConvert, internationalDateLine)
388 for (
double lat = -80.0; lat <= 84.0; lat += 1.0)
399 EXPECT_NEAR(pt1.latitude, pt2.latitude, 0.0000001);
400 EXPECT_NEAR(pt1.altitude, pt2.altitude, 0.000001);
402 if (pt2.longitude - pt1.longitude > 359.0)
406 pt2.longitude -= 360.0;
408 EXPECT_NEAR(pt1.longitude, pt2.longitude, 0.0000012);
416 std::ostringstream out1;
418 std::string expected(
"(0, 0, nan [0 ])");
419 EXPECT_EQ(out1.str(), expected);
422 std::ostringstream out2;
424 expected =
"(622159.338, 3362168.303, 209 [14R])";
425 EXPECT_EQ(out2.str(), expected);
432 geometry_msgs::Quaternion q;
439 std::ostringstream out;
441 std::string expected(
"(1000, 2400, 200 [14R]), ([0, 0, 0], 1)");
442 EXPECT_EQ(out.str(), expected);
448 geographic_msgs::GeoPoint zone2, zone3;
449 zone2.latitude=24.02;
460 double distance = std::sqrt(diffx*diffx + diffy*diffy);
466 double distance2 = std::sqrt(diffx*diffx + diffy*diffy);
467 ROS_INFO(
"Prev Distance %f, Actual Distance %f", distance, distance2);
468 EXPECT_LT(distance2, distance);
472 int main(
int argc,
char **argv)
474 testing::InitGoogleTest(&argc, argv);
477 return RUN_ALL_TESTS();
char band
MGRS latitude band letter.
Universal Transverse Mercator coordinates.
static double getYaw(const Quaternion &bt_q)
void fromMsg(const geographic_msgs::GeoPoint &from, UTMPoint &to, const bool &force_zone=false, const char &band='A', const uint8_t &zone=0)
int main(int argc, char **argv)
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
double northing
northing within grid zone [meters]
double altitude
altitude above ellipsoid [meters] or NaN
static bool sameGridZone(const UTMPoint &pt1, const UTMPoint &pt2)
geometry_msgs::Quaternion orientation
uint8_t zone
UTM longitude zone number.
static double from_degrees(double degrees)
TFSIMD_FORCE_INLINE const tfScalar & z() const
TEST(UTMPoint, nullConstructor)
static bool is2D(const UTMPoint &pt)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)
bool isValid(const UTMPoint &pt)
TFSIMD_FORCE_INLINE tfScalar distance2(const Vector3 &v) const
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)