From 3097cef82813b07fc66fd890655b06ae63dbf77f Mon Sep 17 00:00:00 2001 From: Vissarion Fisikopoulos Date: Thu, 30 Jan 2025 15:51:19 +0200 Subject: [PATCH] test: Add tests for equal points on antimeridian --- test/algorithms/equals/equals_on_spheroid.cpp | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/algorithms/equals/equals_on_spheroid.cpp b/test/algorithms/equals/equals_on_spheroid.cpp index ce87e0e9b..f0c35e684 100644 --- a/test/algorithms/equals/equals_on_spheroid.cpp +++ b/test/algorithms/equals/equals_on_spheroid.cpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit test -// Copyright (c) 2015, Oracle and/or its affiliates. +// Copyright (c) 2015-2025, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -176,6 +177,33 @@ BOOST_AUTO_TEST_CASE( equals_point_point_se ) >::apply("se"); } +template +std::string to_string_with_precision(const T value, const int precision = 15) +{ + std::ostringstream out; + out << std::fixed << std::setprecision(precision) << value; + return out.str(); +} + +void test_pp_rad(double half_pi) +{ + using cs_radian = bg::cs::spherical_equatorial; + using P = bgm::point; + + test_geometry("ser_pp_half_pi", + "POINT(" + to_string_with_precision(-half_pi) + " 0)", + "POINT(" + to_string_with_precision(half_pi) + " 0)", true); +} + +BOOST_AUTO_TEST_CASE( equals_point_point_radian ) +{ + test_pp_rad(bg::math::d2r() * 180); + // half pi value with less accuracy + test_pp_rad(-3.14159265358979); + // convert from degrees to radians with constant from epsg 4326 (WGS84) + test_pp_rad(0.017453292519943278 * 180); +} + BOOST_AUTO_TEST_CASE( equals_point_point_with_height_se ) { typedef bg::cs::spherical_equatorial cs_type;