]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/num_points_multi.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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)
8 #include <geometry_test_common.hpp>
10 #include <boost/geometry/algorithms/num_points.hpp>
12 #include <boost/geometry/io/wkt/wkt.hpp>
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>
20 #include <boost/variant/variant.hpp>
23 template <typename Geometry
>
24 void check_geometry(Geometry
const& geometry
, std::string
const& wkt
, std::size_t expected
)
26 std::size_t detected
= bg::num_points(geometry
);
27 BOOST_CHECK_MESSAGE(detected
== expected
,
29 << " -> Expected: " << expected
30 << " detected: " << detected
);
33 template <typename Geometry
>
34 void test_geometry(std::string
const& wkt
, int expected
)
37 bg::read_wkt(wkt
, geometry
);
38 check_geometry(geometry
, wkt
, expected
);
39 check_geometry(boost::variant
<Geometry
>(geometry
), wkt
, expected
);
43 template <typename Point
>
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
;
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);
61 int test_main( int , char* [] )
63 test_all
<bg::model::d2::point_xy
<double> >();