// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_TEST_ENVELOPE_HPP #define BOOST_GEOMETRY_TEST_ENVELOPE_HPP #include #include #include #include #include #include template struct check_result {}; template struct check_result { typedef typename bg::coordinate_type::type ctype; typedef typename boost::mpl::if_ < boost::is_arithmetic, double, ctype >::type type; static void apply(Box const& b, const type& x1, const type& y1, const type& /*z1*/, const type& x2, const type& y2, const type& /*z2*/) { BOOST_CHECK_CLOSE((bg::get(b)), x1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), x2, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y2, 0.001); } }; template struct check_result { typedef typename bg::coordinate_type::type ctype; typedef typename boost::mpl::if_ < boost::is_arithmetic, double, ctype >::type type; static void apply(Box const& b, const type& x1, const type& y1, const type& z1, const type& x2, const type& y2, const type& z2) { BOOST_CHECK_CLOSE((bg::get(b)), x1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), z1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), x2, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y2, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), z2, 0.001); } }; template void test_envelope(std::string const& wkt, const T& x1, const T& x2, const T& y1, const T& y2, const T& z1 = 0, const T& z2 = 0) { typedef bg::model::box::type > box_type; box_type b; Geometry geometry; bg::read_wkt(wkt, geometry); bg::envelope(geometry, b); check_result::type::value> ::apply(b, x1, y1, z1, x2, y2, z2); boost::variant v(geometry); bg::envelope(v, b); check_result::type::value> ::apply(b, x1, y1, z1, x2, y2, z2); } #endif