// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2020 Digvijay Janartha, Hamirpur, India. // This file was modified by Oracle on 2023. // Modifications 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 // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) #include template bg::model::polygon

create_polygon() { bg::model::polygon

pl1; P p1; P p2; P p3; bg::assign_values(p1, 1, 2); bg::assign_values(p2, 2, 0); bg::assign_values(p3, 0, 0); bg::append(pl1, p1); bg::append(pl1, p2); bg::append(pl1, p3); bg::append(pl1, p1); return pl1; } template bg::model::multi_polygon create_multi_polygon() { bg::model::multi_polygon mpl1; PL pl1(create_polygon

()); mpl1.push_back(pl1); mpl1.push_back(pl1); return mpl1; } template void check_multi_polygon(MPL& to_check, PL pl1) { MPL cur; cur.push_back(pl1); cur.push_back(pl1); std::ostringstream out1, out2; out1 << bg::dsv(to_check); out2 << bg::dsv(cur); BOOST_CHECK_EQUAL(out1.str(), out2.str()); } template void test_default_constructor() { bg::model::multi_polygon mpl1(create_multi_polygon()); check_multi_polygon(mpl1, PL(create_polygon

())); } template void test_copy_constructor() { bg::model::multi_polygon mpl1 = create_multi_polygon(); check_multi_polygon(mpl1, PL(create_polygon

())); } template void test_copy_assignment() { bg::model::multi_polygon mpl1(create_multi_polygon()), mpl2; mpl2 = mpl1; check_multi_polygon(mpl2, PL(create_polygon

())); } template void test_concept() { typedef bg::model::multi_polygon MPL; BOOST_CONCEPT_ASSERT( (bg::concepts::ConstMultiPolygon) ); BOOST_CONCEPT_ASSERT( (bg::concepts::MultiPolygon) ); typedef typename bg::coordinate_type::type T; typedef typename bg::point_type::type PMPL; boost::ignore_unused(); } template void test_all() { typedef bg::model::polygon

PL; test_default_constructor(); test_copy_constructor(); test_copy_assignment(); test_concept(); } template void test_custom_multi_polygon(bg::model::polygon

IL) { typedef bg::model::polygon

PL; std::initializer_list PIL = {IL}; bg::model::multi_polygon mpl1(PIL); std::ostringstream out; out << bg::dsv(mpl1); BOOST_CHECK_EQUAL(out.str(), "((((3, 3), (3, 0), (0, 0), (0, 3), (3, 3))))"); } template void test_custom() { std::initializer_list

IL = {P(3, 3), P(3, 0), P(0, 0), P(0, 3), P(3, 3)}; bg::model::ring

r1(IL); std::initializer_list > RIL = {r1}; test_custom_multi_polygon

(RIL); } template void test_cs() { test_all >(); test_all >(); test_all >(); test_custom >(); } int test_main(int, char* []) { test_cs(); test_cs >(); test_cs >(); test_cs >(); test_custom >(); return 0; }