Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions olp-cpp-sdk-core/src/geo/coordinates/GeoRectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 14 additions & 2 deletions olp-cpp-sdk-core/tests/geo/coordinates/GeoRectangleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

#include <gtest/gtest.h>

#include "../testutil/CompareGeoCoordinates.h"
#include "../testutil/CompareGeoRectangle.h"
#include <olp/core/geo/coordinates/GeoRectangle.h>
#include <olp/core/math/Math.h>
#include "../testutil/CompareGeoCoordinates.h"
#include "../testutil/CompareGeoRectangle.h"

namespace olp {
namespace geo {
Expand Down Expand Up @@ -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
{
Expand Down
Loading