From 1417e6cf41d27c594d2bdc92f87746d2383a1b1d Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Tue, 8 Sep 2026 13:54:40 +0200 Subject: Some cleanups --- server/src/geo/wgs84.cppm | 51 ++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) (limited to 'server/src/geo/wgs84.cppm') diff --git a/server/src/geo/wgs84.cppm b/server/src/geo/wgs84.cppm index d574d39..b53a963 100644 --- a/server/src/geo/wgs84.cppm +++ b/server/src/geo/wgs84.cppm @@ -13,25 +13,20 @@ using point = bgeo::model::point; // TODO: guarantee that linestring provides non-static member // auto reserve(std::size_t) -> void // Perhaps better yet: guarantee that the backing container is a std::vector. -using linestring = bgeo::model::linestring; +using linestring = + bgeo::model::linestring; using box = bgeo::model::box; using stype = bgeo::srs::spheroid; using vincenty_strategy = bgeo::strategy::distance::vincenty; -auto from_lat_lon(double lat, double lon) -> point +inline auto from_lat_lon(double lat, double lon) -> point { return point{lon, lat}; } -auto lat(point p) -> double -{ - return bgeo::get<1>(p); -} +inline auto lat(point p) -> double { return bgeo::get<1>(p); } -auto lon(point p) -> double -{ - return bgeo::get<0>(p); -} +inline auto lon(point p) -> double { return bgeo::get<0>(p); } // Point p with latitude in [-90, 90] and longitude in [-180, 180) auto normalize(point p) -> point @@ -44,7 +39,7 @@ auto normalize(point p) -> point auto p_lat = nonneg_mod360(lat(p)) - 90.0; if (90.0 < p_lat) { - assert(p_lat < 270.0); // by nonneg_mod360 + assert(p_lat < 270.0); // by nonneg_mod360 p_lon += 180.0; p_lat -= 180.0; } @@ -53,7 +48,7 @@ auto normalize(point p) -> point return from_lat_lon(p_lat, p_lon); } -auto is_normalized(point p) -> bool +inline auto is_normalized(point p) -> bool { return -90 <= lat(p) && lat(p) <= 90 && -180 <= lon(p) && lon(p) < 180; } @@ -63,32 +58,22 @@ class normalized_point point p_; public: - normalized_point(point p) - : p_{is_normalized(p) ? p : normalize(p)} - {} + inline normalized_point(point p) : p_{is_normalized(p) ? p : normalize(p)} {} - normalized_point() - : p_{} - {} + inline normalized_point() : p_{} {} - auto lat() const -> double - { - return bgeo::get<1>(p_); - } + inline auto lat() const -> double { return bgeo::get<1>(p_); } - auto lon() const -> double - { - return bgeo::get<0>(p_); - } + inline auto lon() const -> double { return bgeo::get<0>(p_); } - auto lat(double lat) -> void + inline auto lat(double lat) -> void { if (lat < -90 || lat > 90) throw std::range_error{"latitude out of range"}; bgeo::set<1>(p_, lat); } - auto lon(double lon) -> void + inline auto lon(double lon) -> void { if (lon < -180 || lon > 180) throw std::range_error{"longitude out of range"}; @@ -101,15 +86,9 @@ class normalized_linestring std::vector ls_; public: - auto empty() const -> bool - { - return ls_.empty(); - } + inline auto empty() const -> bool { return ls_.empty(); } - auto push_back(normalized_point p) -> void - { - ls_.push_back(p); - } + inline auto push_back(normalized_point p) -> void { ls_.push_back(p); } }; } // namespace routemon::geo::wgs84 -- cgit v1.3