1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 //
3 // Copyright (c) 2011-2015 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)
7
8 #include <geometry_test_common.hpp>
9
10 #include <boost/geometry/algorithms/num_interior_rings.hpp>
11
12 #include <boost/geometry/io/wkt/wkt.hpp>
13
14 #include <boost/geometry/geometries/geometries.hpp>
15 #include <boost/geometry/geometries/point_xy.hpp>
16
17 template <typename Geometry>
test_geometry(std::string const & wkt,std::size_t expected)18 void test_geometry(std::string const& wkt, std::size_t expected)
19 {
20 Geometry geometry;
21 bg::read_wkt(wkt, geometry);
22 std::size_t detected = bg::num_interior_rings(geometry);
23 BOOST_CHECK_MESSAGE(detected == expected,
24 "num_interior_rings: " << wkt
25 << " -> Expected: " << expected
26 << " detected: " << detected);
27 }
28
29
30 template <typename Point>
test_all()31 void test_all()
32 {
33 typedef bg::model::polygon<Point> poly;
34 typedef bg::model::multi_polygon<poly> mpoly;
35
36 test_geometry<poly>("POLYGON((0 0,0 10,10 0,0 0),(1 1,1 9,9 1,1 1))", 1);
37 test_geometry<mpoly>("MULTIPOLYGON(((0 0,0 10,10 0,0 0),(1 1,1 9,9 1,1 1)),((0 0,0 10,10 0,0 0),(1 1,1 4,4 1,1 1),(5 1,5 4,9 1,5 1)))", 3);
38 }
39
40
test_main(int,char * [])41 int test_main( int , char* [] )
42 {
43 test_all<bg::model::d2::point_xy<double> >();
44
45 #ifdef HAVE_TTMATH
46 test_all<bg::model::d2::point_xy<ttmath_big> >();
47 #endif
48
49 return 0;
50 }
51