diff --git a/test/algorithms/buffer/buffer_gc.cpp b/test/algorithms/buffer/buffer_gc.cpp index 7a3924ff9..2fb888d66 100644 --- a/test/algorithms/buffer/buffer_gc.cpp +++ b/test/algorithms/buffer/buffer_gc.cpp @@ -37,7 +37,7 @@ void test_gc() bg::strategy::buffer::join_round join; bg::strategy::buffer::end_round end; bg::strategy::buffer::point_circle circle; - + mpo_t result_mpo; bg::buffer(gc, result_mpo, distance, side, join, end, circle); diff --git a/test/algorithms/buffer/buffer_geo_spheroid.cpp b/test/algorithms/buffer/buffer_geo_spheroid.cpp index 7ee3cffe9..d7a6a98f7 100644 --- a/test/algorithms/buffer/buffer_geo_spheroid.cpp +++ b/test/algorithms/buffer/buffer_geo_spheroid.cpp @@ -2,6 +2,8 @@ // Unit Test // Copyright (c) 2022 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -16,6 +18,38 @@ namespace std::string const torg = "POINT(10.3937759 63.4302323)"; } +template +< + typename FormulaPolicy, + typename Spheroid, + typename CalculationType +> +struct geo_buffer_accurate_area + : public bg::strategies::buffer::geographic +{ + using base_t = bg::strategies::buffer::geographic; + +public: + + geo_buffer_accurate_area() = default; + + explicit geo_buffer_accurate_area(Spheroid const& spheroid) + : base_t(spheroid) + {} + + template + auto area(Geometry const&, + std::enable_if_t::value> * = nullptr) const + { + return bg::strategy::area::geographic + < + bg::strategy::karney, + bg::strategy::default_order::value, + Spheroid, CalculationType + >(base_t::m_spheroid); + } +}; + template void test_linestring(std::string const& label, Spheroid const& spheroid, double expected_area_round, double expected_area_miter) @@ -25,7 +59,9 @@ void test_linestring(std::string const& label, Spheroid const& spheroid, ut_settings settings(0.1); - bg::strategies::buffer::geographic strategy(spheroid); + using CT = typename bg::coordinate_type::type; + geo_buffer_accurate_area strategy(spheroid); + bg::strategy::buffer::geographic_side_straight side(spheroid); bg::strategy::buffer::geographic_join_miter join_miter(spheroid); bg::strategy::buffer::geographic_join_round join_round(spheroid, points_per_circle); @@ -45,7 +81,9 @@ void test_point(std::string const& label, Spheroid const& spheroid, double expec ut_settings settings(0.01); - bg::strategies::buffer::geographic strategy(spheroid); + using CT = typename bg::coordinate_type::type; + geo_buffer_accurate_area strategy(spheroid); + bg::strategy::buffer::geographic_point_circle circle(spheroid, points_per_circle); // All are ignored for points @@ -57,24 +95,31 @@ void test_point(std::string const& label, Spheroid const& spheroid, double expec test_one_geo(label, torg, strategy, side, circle, join_round, end_round, expected_area, 100.0, settings); } -int test_main(int, char* []) +template +void test_all() { - BoostGeometryWriteTestConfiguration(); - - using test_type = default_test_type; - using point_t = bg::model::point>; + using strategy = bg::strategy::andoyer; // Use the default spheroid bg::srs::spheroid def_spheroid; - test_linestring("line_def", def_spheroid, 7996.0, 8093.0); - test_point("point_def", def_spheroid, 31450.0); + test_linestring("line_def", def_spheroid, 8046.26, 8143.37); + test_point("point_def", def_spheroid, 31414.36); // Call it with a quite different spheroid (a near sphere), this changes internal geographic calculations // and should result in different areas. Using CSV creation, it's visible in QGis. bg::srs::spheroid alt_spheroid(6378000.0, 6375000.0); - test_linestring("line_alt", alt_spheroid, 8097.0, 8115.3); - test_point("point_alt", alt_spheroid, 31409.0); + test_linestring("line_alt", alt_spheroid, 8030.53, 8127.61); + test_point("point_alt", alt_spheroid, 31414.33); +} + +int test_main(int, char* []) +{ + BoostGeometryWriteTestConfiguration(); + + // There are several issues with float type such as invalid geometries as output and assertion fails + //test_all(); + test_all(); return 0; } diff --git a/test/algorithms/buffer/buffer_multi_linestring.cpp b/test/algorithms/buffer/buffer_multi_linestring.cpp index bc8cdfce5..55b3cbcdc 100644 --- a/test/algorithms/buffer/buffer_multi_linestring.cpp +++ b/test/algorithms/buffer/buffer_multi_linestring.cpp @@ -37,7 +37,7 @@ static std::string const mysql_2015_04_10a = "MULTILINESTRING((-58 19, 61 88),(1 static std::string const mysql_2015_04_10b = "MULTILINESTRING((-58 19, 61 88), (-63 -5, -262141 -536870908, -3 87, 77 -69))"; static std::string const mysql_2015_09_08a = "MULTILINESTRING((7 -4, -3 -5), (72057594037927936 15, 72057594037927940 70368744177660, 32771 36028797018963964, 8589934589 2305843009213693953, 7 2, 9.300367e+307 9.649737e+307, -4092 -274877906946, 5 10, -3 4))"; -static std::string const mysql_2015_09_08b = "MULTILINESTRING((-9 -10, 0 -1, 5 -10, -6 7, -7 7, 5.041061e+307 9.926906e+307, 6.870356e+307 1.064454e+307, 35184372088830 288230376151711743, 183673728842483250000000000000000000000.000000 244323751784861950000000000000000000000.000000), (-23530 -7131, -6 1, 1 1, 2 -6, 32766 -4194302, -4 -6), (134217725 0, 50336782742294697000000000000000000000.000000 36696596077212901000000000000000000000.000000, 7434 16486, 3.025467e+307 8.926790e+307), (2147483646 67108868, 71328904281592545000000000000000000000.000000 225041650340452780000000000000000000000.000000, -7 4, 1.667154e+307 3.990414e+307))"; +static std::string const mysql_2015_09_08b = "MULTILINESTRING((-9 -10, 0 -1, 5 -10, -6 7, -7 7, 5.041061e+307 9.926906e+307, 6.870356e+307 1.064454e+307, 35184372088830 288230376151711743, 183673728842483250000000000000000000000.000000 244323751784861950000000000000000000000.000000), (-23530 -7131, -6 1, 1 1, 2 -6, 32766 -4194302, -4 -6), (134217725 0, 50336782742294697000000000000000000000.000000 36696596077212901000000000000000000000.000000, 7434 16486, 3.025467e+307 8.926790e+307), (2147483646 67108868, 71328904281592545000000000000000000000.000000 225041650340452780000000000000000000000.000000, -7 4, 1.667154e+307 3.990414e+307))"; static std::string const mysql_23023665_1 = "MULTILINESTRING((-5 15, 7 15, 19 -10, -11 -2),(2 13, 2 -9))"; diff --git a/test/algorithms/buffer/buffer_multi_polygon_geo.cpp b/test/algorithms/buffer/buffer_multi_polygon_geo.cpp index da8f9b01d..c0d2ebe1f 100644 --- a/test/algorithms/buffer/buffer_multi_polygon_geo.cpp +++ b/test/algorithms/buffer/buffer_multi_polygon_geo.cpp @@ -47,7 +47,7 @@ std::string select_within_box(const std::string& wkt, const std::string& wkt_box geometry.erase(geometry.begin(), geometry.begin() + 1); } - geometry.erase(std::remove_if(boost::begin(geometry), boost::end(geometry), + geometry.erase(std::remove_if(boost::begin(geometry), boost::end(geometry), [&poly](const auto& p) { return ! bg::within(p, poly); }), boost::end(geometry)); std::ostringstream out; @@ -77,7 +77,7 @@ void test_geometry(const std::string& base_folder, bool test_all = false, bool g if (generate_cases) { const std::string gr = read_from_wkt_file(base_folder + "gr_ll.wkt"); - + test_one_geo("gr", gr, strategy, _s, _c, join, _e, 222719122493.0, 10000.0, settings); std::cout << "cyclades = " << select_within_box(gr, "BOX(24.1395 36.0147,26.1382 38.1464)") << std::endl; @@ -85,7 +85,7 @@ void test_geometry(const std::string& base_folder, bool test_all = false, bool g std::cout << "dodecaneses = " << select_within_box(gr, "BOX(25.8740 35.1906,28.4227 38.0700)") << std::endl; std::cout << "ionians = " << select_within_box(gr, "BOX(18.9540 37.2072,22.4337 40.6295)") << std::endl; std::cout << "crete = " << select_within_box(gr, "BOX(23.0592 34.4105,26.5606 35.9347)") << std::endl; - + std::cout << "aegeans = " << aegeans << std::endl; } diff --git a/test/algorithms/buffer/test_buffer.hpp b/test/algorithms/buffer/test_buffer.hpp index 776f01284..fd6261ea1 100644 --- a/test/algorithms/buffer/test_buffer.hpp +++ b/test/algorithms/buffer/test_buffer.hpp @@ -156,7 +156,7 @@ struct ut_settings : public ut_base_settings // Number of points in a circle. Not used for geo tests. int points_per_circle; - + double multiplier_min_area = 0.95; double multiplier_max_area = 1.05; double fraction_buffered_points_too_close = 0.10;