PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/geometry/test/multi/algorithms/multi_num_interior_rings.cpp

http://hadesmem.googlecode.com/
C++ | 54 lines | 36 code | 12 blank | 6 comment | 1 complexity | 4d965699188eddc8786a17267b334638 MD5 | raw file
 1// Boost.Geometry (aka GGL, Generic Geometry Library)
 2//
 3// Copyright 2011 Barend Gehrels (barend@xs4all.nl), 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#include <boost/geometry/multi/algorithms/num_interior_rings.hpp>
12
13#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
14
15#include <boost/geometry/geometries/geometries.hpp>
16#include <boost/geometry/geometries/point_xy.hpp>
17#include <boost/geometry/multi/geometries/multi_point.hpp>
18#include <boost/geometry/multi/geometries/multi_linestring.hpp>
19#include <boost/geometry/multi/geometries/multi_polygon.hpp>
20
21template <typename Geometry>
22void test_geometry(std::string const& wkt, int expected)
23{
24    Geometry geometry;
25    bg::read_wkt(wkt, geometry);
26    int detected = bg::num_interior_rings(geometry);
27    BOOST_CHECK_MESSAGE(detected == expected,
28        "num_interior_rings: " << wkt
29        << " -> Expected: " << expected
30        << " detected: " << detected);
31}
32
33
34template <typename Point>
35void test_all()
36{
37    typedef bg::model::polygon<Point> poly;
38    typedef bg::model::multi_polygon<poly> mpoly;
39
40    test_geometry<poly>("POLYGON((0 0,0 10,10 0,0 0),(1 1,1 9,9 1,1 1))", 1);
41    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);
42}
43
44
45int test_main( int , char* [] )
46{
47    test_all<bg::model::d2::point_xy<double> >();
48
49#ifdef HAVE_TTMATH
50    test_all<bg::model::d2::point_xy<ttmath_big> >();
51#endif
52
53    return 0;
54}