]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/num_points_multi.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / num_points_multi.cpp
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_points.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 #include <boost/geometry/geometries/multi_point.hpp>
17 #include <boost/geometry/geometries/multi_linestring.hpp>
18 #include <boost/geometry/geometries/multi_polygon.hpp>
19
20 #include <boost/variant/variant.hpp>
21
22
23 template <typename Geometry>
24 void check_geometry(Geometry const& geometry, std::string const& wkt, std::size_t expected)
25 {
26 std::size_t detected = bg::num_points(geometry);
27 BOOST_CHECK_MESSAGE(detected == expected,
28 "num_points: " << wkt
29 << " -> Expected: " << expected
30 << " detected: " << detected);
31 }
32
33 template <typename Geometry>
34 void test_geometry(std::string const& wkt, int expected)
35 {
36 Geometry geometry;
37 bg::read_wkt(wkt, geometry);
38 check_geometry(geometry, wkt, expected);
39 check_geometry(boost::variant<Geometry>(geometry), wkt, expected);
40 }
41
42
43 template <typename Point>
44 void test_all()
45 {
46 typedef bg::model::polygon<Point> poly;
47 typedef bg::model::linestring<Point> ls;
48 typedef bg::model::multi_point<Point> mpoint;
49 typedef bg::model::multi_linestring<ls> mls;
50 typedef bg::model::multi_polygon<poly> mpoly;
51
52 test_geometry<Point>("POINT(0 0)", 1);
53 test_geometry<ls>("LINESTRING(0 0,0 1)", 2);
54 test_geometry<poly>("POLYGON((0 0,0 1,1 0,0 0))", 4);
55 test_geometry<mpoint>("MULTIPOINT((0 0),(0 1),(1 0),(0 0))", 4);
56 test_geometry<mls>("MULTILINESTRING((0 0,0 1),(1 0,0 0))", 4);
57 test_geometry<mpoly>("MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((10 0,10 1,11 0,10 0)))", 8);
58 }
59
60
61 int test_main( int , char* [] )
62 {
63 test_all<bg::model::d2::point_xy<double> >();
64
65 return 0;
66 }