[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/boostorg/geometry/develop/test/algorithms/assign.cpp [Back]  [Original]

// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Copyright (c) 2014 Samuel Debionne, Grenoble, France. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // 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 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) template void check_geometry(Geometry const& geometry, std::string const& expected) { std::ostringstream out; out 9999)); BOOST_CHECK((bg::get(geometry) > 9999)); BOOST_CHECK((bg::get(geometry) < 9999)); BOOST_CHECK((bg::get(geometry) < 9999)); } } template void test_assign_box_or_segment_2d() { detail::test_assign_box_or_segment_2d(); detail::test_assign_box_or_segment_2d(); } template void test_assign_box_2d() { detail::test_assign_box_or_segment_2d(); } template void test_assign_point_3d() { Point p; bg::assign_values(p, 1, 2, 3); check_geometry(p, "POINT(1 2 3)"); bg::assign_value(p, 123); check_geometry(p, "POINT(123 123 123)"); bg::assign_zero(p); check_geometry(p, "POINT(0 0 0)"); } template void test_assign_conversion() { typedef bg::model::box

box_type; typedef bg::model::ring

ring_type; typedef bg::model::polygon

polygon_type; P p; bg::assign_values(p, 1, 2); box_type b; bg::assign(b, p); BOOST_CHECK_CLOSE((bg::get(b)), 1.0, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), 2.0, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), 1.0, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), 2.0, 0.001); bg::set(b, 1); bg::set(b, 2); bg::set(b, 3); bg::set(b, 4); ring_type ring; bg::assign(ring, b); { typedef bg::model::ring ring_type_ccw; ring_type_ccw ring_ccw; // Should NOT compile (currently): bg::assign(ring_ccw, ring); } typename boost::range_const_iterator::type it = ring.begin(); BOOST_CHECK_CLOSE(bg::get(*it), 1.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 2.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 1.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 4.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 3.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 4.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 3.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 2.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 1.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 2.0, 0.001); BOOST_CHECK_EQUAL(ring.size(), 5u); polygon_type polygon; bg::assign(polygon, ring); BOOST_CHECK_EQUAL(bg::num_points(polygon), 5u); ring_type ring2; bg::assign(ring2, polygon); BOOST_CHECK_EQUAL(bg::num_points(ring2), 5u); } template void test_assign_conversion_variant() { typedef bg::model::box

box_type; typedef bg::model::ring

ring_type; typedef bg::model::polygon

polygon_type; P p; bg::assign_values(p, 1, 2); box_type b; boost::variant variant_b(b); bg::assign(variant_b, p); BOOST_CHECK_CLOSE((bg::get(b)), 1.0, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), 2.0, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), 1.0, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), 2.0, 0.001); bg::set(b, 1); bg::set(b, 2); bg::set(b, 3); bg::set(b, 4); ring_type ring; boost::variant variant_ring(ring); bg::assign(variant_ring, boost::variant(b)); { typedef bg::model::ring ring_type_ccw; ring_type_ccw ring_ccw; // Should NOT compile (currently): bg::assign(ring_ccw, ring); } typename boost::range_const_iterator::type it = ring.begin(); BOOST_CHECK_CLOSE(bg::get(*it), 1.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 2.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 1.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 4.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 3.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 4.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 3.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 2.0, 0.001); it++; BOOST_CHECK_CLOSE(bg::get(*it), 1.0, 0.001); BOOST_CHECK_CLOSE(bg::get(*it), 2.0, 0.001); BOOST_CHECK_EQUAL(ring.size(), 5u); polygon_type polygon; boost::variant variant_polygon(polygon); bg::assign(variant_polygon, boost::variant(ring)); BOOST_CHECK_EQUAL(bg::num_points(polygon), 5u); ring_type ring2; boost::variant variant_ring2(ring2); bg::assign(variant_ring2, boost::variant(polygon)); BOOST_CHECK_EQUAL(bg::num_points(ring2), 5u); } template void test_assign_point_2d() { Point p; bg::assign_values(p, 1, 2); check_geometry(p, "POINT(1 2)"); bg::assign_value(p, 123); check_geometry(p, "POINT(123 123)"); bg::assign_zero(p); check_geometry(p, "POINT(0 0)"); } int test_main(int, char* []) { test_assign_point_3d(); test_assign_point_3d(); test_assign_point_3d(); test_assign_point_3d(); test_assign_point_3d(); test_assign_point_3d(); test_assign_point_3d(); test_assign_point_2d(); test_assign_point_2d(); test_assign_point_2d(); test_assign_point_2d(); test_assign_point_2d(); test_assign_point_2d(); test_assign_conversion(); test_assign_conversion_variant(); // Segment (currently) cannot handle array's because derived from std::pair test_assign_box_2d(); test_assign_box_2d(); test_assign_box_2d(); test_assign_box_or_segment_2d(); test_assign_box_or_segment_2d(); test_assign_box_or_segment_2d(); test_assign_linestring_2d(); test_assign_linestring_2d(); test_assign_linestring_2d(); return 0; }


Web Proxy Viewer  |  New URL  |  Original Page