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/clear.hpp>
11 #include <boost/geometry/algorithms/num_points.hpp>
12 
13 #include <boost/geometry/io/wkt/wkt.hpp>
14 
15 #include <boost/geometry/geometries/geometries.hpp>
16 #include <boost/geometry/geometries/point_xy.hpp>
17 
18 #include <boost/variant/variant.hpp>
19 
20 
21 template <typename Geometry>
test_geometry(std::string const & wkt,unsigned int expected)22 void test_geometry(std::string const& wkt, unsigned int expected)
23 {
24     Geometry geometry;
25     bg::read_wkt(wkt, geometry);
26     boost::variant<Geometry> variant_geometry(geometry);
27 
28     bg::clear(geometry);
29     BOOST_CHECK_EQUAL(bg::num_points(geometry), expected);
30 
31     bg::clear(variant_geometry);
32     BOOST_CHECK_EQUAL(bg::num_points(variant_geometry), expected);
33 }
34 
35 
36 template <typename Point>
test_all()37 void test_all()
38 {
39     typedef bg::model::polygon<Point> poly;
40     typedef bg::model::linestring<Point> ls;
41     typedef bg::model::multi_point<Point> mpoint;
42     typedef bg::model::multi_linestring<ls> mls;
43     typedef bg::model::multi_polygon<poly> mpoly;
44 
45     test_geometry<Point>("POINT(0 0)", 1);
46     test_geometry<ls>("LINESTRING(0 0,0 1)", 0);
47     test_geometry<poly>("POLYGON((0 0,0 1,1 0,0 0))", 0);
48     test_geometry<mpoint>("MULTIPOINT((0 0),(0 1),(1 0),(0 0))", 0);
49     test_geometry<mls>("MULTILINESTRING((0 0,0 1),(1 0,0 0))", 0);
50     test_geometry<mpoly>("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((10 0,10 1,11 0,10 0)))", 0);
51 }
52 
53 
test_main(int,char * [])54 int test_main( int , char* [] )
55 {
56     test_all<bg::model::d2::point_xy<double> >();
57 
58     return 0;
59 }
60