From db3f7c71380fefe60466583a0f24ba514003d75f Mon Sep 17 00:00:00 2001 From: Mykola Malik Date: Thu, 6 Nov 2025 12:58:51 +0100 Subject: [PATCH] Add GeoRectangle operators ==, != implementation These operators were declared, but not implemented Relates-To: MINOR Signed-off-by: Mykola Malik --- .../src/geo/coordinates/GeoRectangle.cpp | 8 ++++++++ .../tests/geo/coordinates/GeoRectangleTest.cpp | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/olp-cpp-sdk-core/src/geo/coordinates/GeoRectangle.cpp b/olp-cpp-sdk-core/src/geo/coordinates/GeoRectangle.cpp index 08b52297d..a92ffe330 100644 --- a/olp-cpp-sdk-core/src/geo/coordinates/GeoRectangle.cpp +++ b/olp-cpp-sdk-core/src/geo/coordinates/GeoRectangle.cpp @@ -120,6 +120,14 @@ bool GeoRectangle::Overlaps(const GeoRectangle& rectangle) const { return !(west >= rectangle_east || rectangle_west >= east); } +bool GeoRectangle::operator==(const GeoRectangle& other) const { + return south_west_ == other.south_west_ && north_east_ == other.north_east_; +} + +bool GeoRectangle::operator!=(const GeoRectangle& other) const { + return !(*this == other); +} + GeoRectangle GeoRectangle::BooleanUnion(const GeoRectangle& other) const { if (IsEmpty()) { return other; diff --git a/olp-cpp-sdk-core/tests/geo/coordinates/GeoRectangleTest.cpp b/olp-cpp-sdk-core/tests/geo/coordinates/GeoRectangleTest.cpp index 37b7d1be6..5e2435e34 100644 --- a/olp-cpp-sdk-core/tests/geo/coordinates/GeoRectangleTest.cpp +++ b/olp-cpp-sdk-core/tests/geo/coordinates/GeoRectangleTest.cpp @@ -19,10 +19,10 @@ #include -#include "../testutil/CompareGeoCoordinates.h" -#include "../testutil/CompareGeoRectangle.h" #include #include +#include "../testutil/CompareGeoCoordinates.h" +#include "../testutil/CompareGeoRectangle.h" namespace olp { namespace geo { @@ -87,6 +87,18 @@ TEST(GeoRectangleTest, Containment) { GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(0.05, 0.15)))); } +TEST(GeoRectangleTest, OperatorEqual) { + EXPECT_EQ(GeoRectangle(GeoCoordinates(1, 2), GeoCoordinates(10, 20)), + GeoRectangle(GeoCoordinates(1, 2), GeoCoordinates(10, 20))); +} + +TEST(GeoRectangleTest, OperatorNotEqual) { + EXPECT_NE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)), + GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 2))); + EXPECT_NE(GeoRectangle(GeoCoordinates(0, 0), GeoCoordinates(1, 1)), + GeoRectangle(GeoCoordinates(1, 0), GeoCoordinates(1, 1))); +} + TEST(GeoRectangleTest, BooleanUnion) { // Non-connected {