summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/util/geo.hpp28
-rw-r--r--include/mbgl/util/projection.hpp29
-rw-r--r--test/util/geo.test.cpp15
-rw-r--r--test/util/projection.test.cpp16
4 files changed, 43 insertions, 45 deletions
diff --git a/include/mbgl/util/geo.hpp b/include/mbgl/util/geo.hpp
index 5f5f8bb33b..6d725b102b 100644
--- a/include/mbgl/util/geo.hpp
+++ b/include/mbgl/util/geo.hpp
@@ -79,34 +79,6 @@ public:
}
};
-class ProjectedMeters {
-private:
- double _northing; // Distance measured northwards.
- double _easting; // Distance measured eastwards.
-
-public:
- ProjectedMeters(double n_ = 0, double e_ = 0)
- : _northing(n_), _easting(e_) {
- if (std::isnan(_northing)) {
- throw std::domain_error("northing must not be NaN");
- }
- if (std::isnan(_easting)) {
- throw std::domain_error("easting must not be NaN");
- }
- }
-
- double northing() const { return _northing; }
- double easting() const { return _easting; }
-
- friend bool operator==(const ProjectedMeters& a, const ProjectedMeters& b) {
- return a._northing == b._northing && a._easting == b._easting;
- }
-
- friend bool operator!=(const ProjectedMeters& a, const ProjectedMeters& b) {
- return !(a == b);
- }
-};
-
class LatLngBounds {
public:
// Return a bounds covering the entire (unwrapped) world.
diff --git a/include/mbgl/util/projection.hpp b/include/mbgl/util/projection.hpp
index ed34261b18..3cc1146513 100644
--- a/include/mbgl/util/projection.hpp
+++ b/include/mbgl/util/projection.hpp
@@ -5,9 +5,36 @@
#include <mbgl/util/geometry.hpp>
#include <mbgl/math/clamp.hpp>
-
namespace mbgl {
+class ProjectedMeters {
+private:
+ double _northing; // Distance measured northwards.
+ double _easting; // Distance measured eastwards.
+
+public:
+ ProjectedMeters(double n_ = 0, double e_ = 0)
+ : _northing(n_), _easting(e_) {
+ if (std::isnan(_northing)) {
+ throw std::domain_error("northing must not be NaN");
+ }
+ if (std::isnan(_easting)) {
+ throw std::domain_error("easting must not be NaN");
+ }
+ }
+
+ double northing() const { return _northing; }
+ double easting() const { return _easting; }
+
+ friend bool operator==(const ProjectedMeters& a, const ProjectedMeters& b) {
+ return a._northing == b._northing && a._easting == b._easting;
+ }
+
+ friend bool operator!=(const ProjectedMeters& a, const ProjectedMeters& b) {
+ return !(a == b);
+ }
+};
+
// Spherical Mercator projection
// http://docs.openlayers.org/library/spherical_mercator.html
class Projection {
diff --git a/test/util/geo.test.cpp b/test/util/geo.test.cpp
index 3dfa8e1cca..d0d01b6f88 100644
--- a/test/util/geo.test.cpp
+++ b/test/util/geo.test.cpp
@@ -33,21 +33,6 @@ TEST(LatLng, InvalidLatLng) {
}
}
-TEST(ProjectedMeters, InvalidProjectedMeters) {
- try {
- ProjectedMeters { NAN };
- ASSERT_TRUE(false) << "should throw";
- } catch (const std::domain_error& error) {
- ASSERT_EQ(std::string(error.what()), "northing must not be NaN");
- }
- try {
- ProjectedMeters { 0, NAN };
- ASSERT_TRUE(false) << "should throw";
- } catch (const std::domain_error& error) {
- ASSERT_EQ(std::string(error.what()), "easting must not be NaN");
- }
-}
-
TEST(EdgeInsets, InvalidEdgeInsets) {
try {
EdgeInsets { NAN };
diff --git a/test/util/projection.test.cpp b/test/util/projection.test.cpp
index 9f27fe3d14..a489320dde 100644
--- a/test/util/projection.test.cpp
+++ b/test/util/projection.test.cpp
@@ -1,7 +1,6 @@
#include <mbgl/test/util.hpp>
#include <mbgl/util/constants.hpp>
-#include <mbgl/util/geo.hpp>
#include <mbgl/util/projection.hpp>
#include <limits>
@@ -61,3 +60,18 @@ TEST(Projection, ProjectedMeters) {
EXPECT_EQ(latLng.latitude(), util::LATITUDE_MAX);
EXPECT_EQ(latLng.longitude(), util::LONGITUDE_MAX);
}
+
+TEST(Projection, InvalidProjectedMeters) {
+ try {
+ ProjectedMeters { NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "northing must not be NaN");
+ }
+ try {
+ ProjectedMeters { 0, NAN };
+ ASSERT_TRUE(false) << "should throw";
+ } catch (const std::domain_error& error) {
+ ASSERT_EQ(std::string(error.what()), "easting must not be NaN");
+ }
+}