1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
15 #include <geometry_test_common.hpp>
17 #include <boost/geometry/views/reversible_view.hpp>
19 #include <boost/geometry/io/wkt/wkt.hpp>
20 #include <boost/geometry/io/dsv/write.hpp>
21 #include <boost/geometry/geometries/geometries.hpp>
22 #include <boost/geometry/geometries/point_xy.hpp>
23 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
25 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
28 template <bg::iterate_direction Direction
, typename Range
>
29 void test_forward_or_reverse(Range
const& range
, std::string
const& expected
)
31 typedef typename
bg::reversible_view
37 view_type
view(range
);
40 std::ostringstream out
;
41 for (typename
boost::range_iterator
<view_type
const>::type
42 it
= boost::begin(view
);
43 it
!= boost::end(view
);
46 out
<< (first
? "" : " ") << bg::dsv(*it
);
48 BOOST_CHECK_EQUAL(out
.str(), expected
);
53 template <typename Geometry
>
54 void test_geometry(std::string
const& wkt
,
55 std::string
const& expected_forward
, std::string
const& expected_reverse
)
58 bg::read_wkt(wkt
, geo
);
60 test_forward_or_reverse
<bg::iterate_forward
>(geo
, expected_forward
);
61 test_forward_or_reverse
<bg::iterate_reverse
>(geo
, expected_reverse
);
67 test_geometry
<bg::model::linestring
<P
> >(
68 "linestring(1 1,2 2,3 3)",
69 "(1, 1) (2, 2) (3, 3)",
70 "(3, 3) (2, 2) (1, 1)");
74 int test_main(int, char* [])
76 test_all
<bg::model::d2::point_xy
<double> >();
77 test_all
<bg::model::point
<int, 2, bg::cs::cartesian
> >();
78 test_all
<boost::tuple
<double, double> >();