1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-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)
10 #ifndef BOOST_GEOMETRY_TEST_AREA_HPP
11 #define BOOST_GEOMETRY_TEST_AREA_HPP
14 #include <geometry_test_common.hpp>
16 #include <boost/geometry/algorithms/area.hpp>
17 #include <boost/geometry/algorithms/correct.hpp>
18 #include <boost/geometry/strategies/strategies.hpp>
20 #include <boost/geometry/io/wkt/read.hpp>
23 template <typename Geometry>
24 void test_area(Geometry const& geometry,
25 typename bg::default_area_result<Geometry>::type expected_area)
27 typename bg::default_area_result<Geometry>::type area = bg::area(geometry);
29 #ifdef BOOST_GEOMETRY_TEST_DEBUG
30 std::ostringstream out;
31 out << typeid(typename bg::coordinate_type<Geometry>::type).name()
33 << typeid(typename bg::default_area_result<Geometry>::type).name()
35 << "area : " << bg::area(geometry)
37 std::cout << out.str();
40 BOOST_CHECK_CLOSE(area, expected_area, 0.0001);
42 // Test with explicitly defined strategies
43 bg::strategy::area::surveyor
45 typename bg::point_type<Geometry>::type
48 area = bg::area(geometry, strategy1);
50 bg::strategy::area::surveyor
52 typename bg::point_type<Geometry>::type,
53 typename bg::coordinate_type<Geometry>::type
56 area = bg::area(geometry, strategy2);
60 template <typename Geometry>
61 void test_geometry(std::string const& wkt,
62 typename bg::default_area_result<Geometry>::type expected_area)
65 bg::read_wkt(wkt, geometry);
66 test_area(geometry, expected_area);
69 template <typename Geometry>
70 void test_empty_input(Geometry const& geometry)
76 catch(bg::empty_input_exception const& )
80 BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );