From 4771d190737f371d9799d1c7fbea576650b5b88c Mon Sep 17 00:00:00 2001 From: Tom Pittenger Date: Mon, 24 Aug 2015 14:52:27 -0700 Subject: [PATCH] AP_Math: added locations_are_same(loc1,loc2) helper returns true if lat and lng are the same, ignores alt and options --- libraries/AP_Math/AP_Math.h | 5 +++++ libraries/AP_Math/location.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/libraries/AP_Math/AP_Math.h b/libraries/AP_Math/AP_Math.h index 40d671160f..c4df5834bb 100644 --- a/libraries/AP_Math/AP_Math.h +++ b/libraries/AP_Math/AP_Math.h @@ -150,6 +150,11 @@ float wrap_180_cd_float(float angle); */ float wrap_PI(float angle_in_radians); +/* + * check if lat and lng match. Ignore altitude and options + */ +bool locations_are_same(const struct Location &loc1, const struct Location &loc2); + /* print a int32_t lat/long in decimal degrees */ diff --git a/libraries/AP_Math/location.cpp b/libraries/AP_Math/location.cpp index 5d7c81af80..eaac6d6114 100644 --- a/libraries/AP_Math/location.cpp +++ b/libraries/AP_Math/location.cpp @@ -222,6 +222,13 @@ float wrap_PI(float angle_in_radians) return angle_in_radians; } +/* + return true if lat and lng match. Ignores altitude and options + */ +bool locations_are_same(const struct Location &loc1, const struct Location &loc2) { + return (loc1.lat == loc2.lat) && (loc1.lng == loc2.lng); +} + /* print a int32_t lat/long in decimal degrees */