From 612ca82a06f8fe8a9597dcdd5b0cd08d0a707d9d Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Sat, 10 Dec 2022 20:01:16 +0100 Subject: [PATCH] Fix formatting --- include/util/cheap_ruler.hpp | 60 ++++++++++++++--------------- src/util/coordinate_calculation.cpp | 4 +- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/include/util/cheap_ruler.hpp b/include/util/cheap_ruler.hpp index b17c53dc6..67df8d6f2 100644 --- a/include/util/cheap_ruler.hpp +++ b/include/util/cheap_ruler.hpp @@ -7,41 +7,41 @@ #include #include -namespace mapbox { +namespace mapbox +{ -namespace geometry { - template - struct point - { - using coordinate_type = T; +namespace geometry +{ +template struct point +{ + using coordinate_type = T; - constexpr point() - : x(), y() - {} - constexpr point(T x_, T y_) - : x(x_), y(y_) - {} + constexpr point() : x(), y() {} + constexpr point(T x_, T y_) : x(x_), y(y_) {} - T x; - T y; - }; -} + T x; + T y; +}; +} // namespace geometry -namespace cheap_ruler { +namespace cheap_ruler +{ -using point = geometry::point; +using point = geometry::point; -class CheapRuler { +class CheapRuler +{ // Values that define WGS84 ellipsoid model of the Earth - static constexpr double RE = 6378.137; // equatorial radius + static constexpr double RE = 6378.137; // equatorial radius static constexpr double FE = 1.0 / 298.257223563; // flattening static constexpr double E2 = FE * (2 - FE); static constexpr double RAD = M_PI / 180.0; -public: - explicit CheapRuler(double latitude) { + public: + explicit CheapRuler(double latitude) + { // Curvature formulas from https://en.wikipedia.org/wiki/Earth_radius#Meridional double mul = RAD * RE * 1000; double coslat = std::cos(latitude * RAD); @@ -53,7 +53,8 @@ public: ky = mul * w * w2 * (1 - E2); // based on meridonal radius of curvature } - double squareDistance(point a, point b) const { + double squareDistance(point a, point b) const + { auto dx = longDiff(a.x, b.x) * kx; auto dy = (a.y - b.y) * ky; return dx * dx + dy * dy; @@ -62,26 +63,23 @@ public: // // Given two points of the form [x = longitude, y = latitude], returns the distance. // - double distance(point a, point b) const { - return std::sqrt(squareDistance(a, b)); - } + double distance(point a, point b) const { return std::sqrt(squareDistance(a, b)); } // // Returns the bearing between two points in angles. // - double bearing(point a, point b) const { + double bearing(point a, point b) const + { auto dx = longDiff(b.x, a.x) * kx; auto dy = (b.y - a.y) * ky; return std::atan2(dx, dy) / RAD; } -private: + private: double ky; double kx; - static double longDiff(double a, double b) { - return std::remainder(a - b, 360); - } + static double longDiff(double a, double b) { return std::remainder(a - b, 360); } }; } // namespace cheap_ruler diff --git a/src/util/coordinate_calculation.cpp b/src/util/coordinate_calculation.cpp index f62ec7be2..1e3edc3c4 100644 --- a/src/util/coordinate_calculation.cpp +++ b/src/util/coordinate_calculation.cpp @@ -30,8 +30,8 @@ class CheapRulerContainer { for (int n = 0; n < number_of_rulers; n++) { - cheap_ruler_cache[n] = mapbox::cheap_ruler::CheapRuler( - step * (n + 0.5) / COORDINATE_PRECISION); + cheap_ruler_cache[n] = + mapbox::cheap_ruler::CheapRuler(step * (n + 0.5) / COORDINATE_PRECISION); } };