1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
8 // This file was modified by Oracle on 2014, 2015.
9 // Modifications copyright (c) 2014-2015, Oracle and/or its affiliates.
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
23 #include <boost/concept/requires.hpp>
24 #include <geometry_test_common.hpp>
26 #include <boost/geometry/core/access.hpp>
27 #include <boost/geometry/core/point_type.hpp>
28 #include <boost/geometry/core/tags.hpp>
29 #include <boost/geometry/algorithms/make.hpp>
30 #include <boost/geometry/algorithms/clear.hpp>
31 #include <boost/geometry/algorithms/append.hpp>
32 #include <boost/geometry/algorithms/num_points.hpp>
33 #include <boost/geometry/geometries/geometries.hpp>
34 #include <boost/geometry/geometries/concepts/check.hpp>
35 #include <boost/geometry/geometries/register/linestring.hpp>
36 #include <boost/variant/variant.hpp>
38 #include <test_common/test_point.hpp>
39 #include <test_geometries/wrapped_boost_array.hpp>
42 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector
)
43 BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque
)
46 template <bool EnableAll
>
50 static inline void apply(G
const& geometry
,
55 BOOST_CHECK_EQUAL(bg::num_points(geometry
), size1
);
61 struct do_checks
<true>
64 static inline void apply(G
const& geometry
,
66 std::size_t size2
= 0,
67 std::size_t size3
= 0)
69 do_checks
<false>::apply(geometry
, size1
);
70 BOOST_CHECK_EQUAL(bg::num_points(geometry
[0]), size2
);
71 BOOST_CHECK_EQUAL(bg::num_points(geometry
[1]), size3
);
77 template <bool HasMultiIndex
, bool IsVariant
>
81 static inline void apply(G
& geometry
, bool check
)
83 typedef typename
bg::point_type
<G
>::type P
;
84 typedef do_checks
<HasMultiIndex
&& !IsVariant
> checks
;
86 bg::append(geometry
, bg::make_zero
<P
>(), -1, 0);
89 checks::apply(geometry
, 1u, 1u, 0u);
94 v
.push_back(bg::make_zero
<P
>());
95 v
.push_back(bg::make_zero
<P
>());
96 bg::append(geometry
, v
, -1, 1);
100 checks::apply(geometry
, 3u, 1u, 2u);
107 do_checks
<false>::apply(geometry
, 0u);
114 template <typename G
>
115 void test_geometry_and_variant(bool check
= true)
118 boost::variant
<G
> variant_geometry
= G();
119 test_geometry
<false, false>::apply(geometry
, check
);
120 test_geometry
<false, true>::apply(variant_geometry
, check
);
124 template <typename MG
>
125 void test_multigeometry_and_variant(bool check
= true)
127 typedef typename
boost::range_value
<MG
>::type G
;
131 bg::traits::push_back
<MG
>::apply(multigeometry
, geometry
);
132 bg::traits::push_back
<MG
>::apply(multigeometry
, geometry
);
134 boost::variant
<MG
> variant_multigeometry
= multigeometry
;
135 test_geometry
<true, false>::apply(multigeometry
, check
);
136 test_geometry
<true, true>::apply(variant_multigeometry
, check
);
140 template <typename P
>
143 test_geometry_and_variant
<P
>(false);
144 test_geometry_and_variant
<bg::model::box
<P
> >(false);
145 test_geometry_and_variant
<bg::model::segment
<P
> >(false);
146 test_geometry_and_variant
<bg::model::linestring
<P
> >();
147 test_geometry_and_variant
<bg::model::ring
<P
> >();
148 test_geometry_and_variant
<bg::model::polygon
<P
> >();
149 test_geometry_and_variant
<bg::model::multi_point
<P
> >();
150 test_multigeometry_and_variant
152 bg::model::multi_linestring
<bg::model::linestring
<P
> >
154 test_multigeometry_and_variant
156 bg::model::multi_polygon
<bg::model::polygon
<P
> >
159 test_geometry_and_variant
<std::vector
<P
> >();
160 test_geometry_and_variant
<std::deque
<P
> >();
163 int test_main(int, char* [])
165 test_all
<test::test_point
>();
166 test_all
<bg::model::point
<int, 2, bg::cs::cartesian
> >();
167 test_all
<bg::model::point
<float, 2, bg::cs::cartesian
> >();
168 test_all
<bg::model::point
<double, 2, bg::cs::cartesian
> >();