1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Use, modification and distribution is subject to the Boost Software License,
5 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
8 #include <geometry_test_common.hpp>
10 #include <boost/foreach.hpp>
11 #include <boost/range/algorithm/copy.hpp>
12 #include <boost/tuple/tuple.hpp>
13 #include <boost/typeof/typeof.hpp>
15 #include <algorithms/test_overlay.hpp>
17 #include <boost/geometry/geometry.hpp>
18 #include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
19 #include <boost/geometry/algorithms/detail/overlay/assign_parents.hpp>
21 #include <boost/geometry/geometries/point_xy.hpp>
22 #include <boost/geometry/geometries/polygon.hpp>
24 #include <boost/geometry/io/wkt/read.hpp>
26 #include <boost/assign/list_of.hpp>
33 bg::overlay_type OverlayType,
36 void test_geometry(std::string const& wkt1, std::string const& wkt2,
37 RingIdVector const& expected_ids)
39 typedef bg::detail::overlay::ring_properties<typename bg::point_type<Geometry1>::type> properties;
44 bg::read_wkt(wkt1, geometry1);
45 bg::read_wkt(wkt2, geometry2);
47 typedef std::map<bg::ring_identifier, properties> map_type;
49 std::map<bg::ring_identifier, bg::detail::overlay::ring_turn_info> empty;
51 bg::detail::overlay::select_rings<OverlayType>(geometry1, geometry2, empty, selected);
53 BOOST_CHECK_EQUAL(selected.size(), expected_ids.size());
55 if (selected.size() <= expected_ids.size())
57 BOOST_AUTO(eit, expected_ids.begin());
58 for(typename map_type::const_iterator it = selected.begin(); it != selected.end(); ++it, ++eit)
60 bg::ring_identifier const ring_id = it->first;
61 BOOST_CHECK_EQUAL(ring_id.source_index, eit->source_index);
62 BOOST_CHECK_EQUAL(ring_id.multi_index, eit->multi_index);
63 BOOST_CHECK_EQUAL(ring_id.ring_index, eit->ring_index);
74 // Point in correct clockwise ring -> should return true
75 typedef bg::ring_identifier rid;
77 test_geometry<bg::model::polygon<P>, bg::model::polygon<P>, bg::overlay_union>(
79 boost::assign::list_of
87 test_geometry<bg::model::polygon<P>, bg::model::polygon<P>, bg::overlay_intersection>(
89 boost::assign::list_of
99 int test_main( int , char* [] )
101 test_all<bg::model::d2::point_xy<double> >();