diff options
-rw-r--r-- | include/mbgl/util/geo.hpp | 16 | ||||
-rw-r--r-- | test/map/transform.cpp | 3 |
2 files changed, 13 insertions, 6 deletions
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp index 0f6a049962..99b5743877 100644 --- a/include/mbgl/util/geo.hpp +++ b/include/mbgl/util/geo.hpp @@ -19,7 +19,7 @@ public: LatLng(double lat = 0, double lon = 0) : latitude(lat), longitude(lon) {} - operator bool() const { + explicit operator bool() const { return !(std::isnan(latitude) || std::isnan(longitude)); } @@ -29,6 +29,14 @@ public: PrecisionPoint project() const; }; +inline bool operator==(const LatLng& a, const LatLng& b) { + return a.latitude == b.latitude && a.longitude == b.longitude; +} + +inline bool operator!=(const LatLng& a, const LatLng& b) { + return !(a == b); +} + class ProjectedMeters { public: double northing = 0; @@ -37,7 +45,7 @@ public: ProjectedMeters(double n = 0, double e = 0) : northing(n), easting(e) {} - operator bool() const { + explicit operator bool() const { return !(std::isnan(northing) || std::isnan(easting)); } }; @@ -133,7 +141,7 @@ public: MetersBounds(const ProjectedMeters& sw_, const ProjectedMeters& ne_) : sw(sw_), ne(ne_) {} - operator bool() const { + explicit operator bool() const { return sw && ne; } }; @@ -159,7 +167,7 @@ public: EdgeInsets(const double t, const double l, const double b, const double r) : top(t), left(l), bottom(b), right(r) {} - operator bool() const { + explicit operator bool() const { return top || left || bottom || right; } diff --git a/test/map/transform.cpp b/test/map/transform.cpp index 8325e60ebf..3eb1c1bee1 100644 --- a/test/map/transform.cpp +++ b/test/map/transform.cpp @@ -198,7 +198,6 @@ TEST(Transform, Anchor) { ASSERT_NEAR(M_PI_4, transform.getAngle(), 0.000001); ASSERT_NE(anchorLatLng, transform.getLatLng()); - ASSERT_DOUBLE_EQ(anchorLatLng, transform.getState().pointToLatLng(anchorPoint)); } TEST(Transform, Padding) { @@ -224,7 +223,7 @@ TEST(Transform, Padding) { EdgeInsets padding; padding.top = 1000.0 / 2.0; ASSERT_GT(padding.top, 0); - ASSERT_TRUE(padding); + ASSERT_TRUE(bool(padding)); const LatLng shiftedCenter = transform.getLatLng(padding); ASSERT_NE(trueCenter.latitude, shiftedCenter.latitude); |