// Boost.Geometry (aka GGL, Generic Geometry Library) test file // // Copyright Barend Gehrels 2007-2009, Geodan, 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 template struct check_result {}; template <> struct check_result<2> { template static void apply(Box const& b, const T& x1, const T& y1, const T& z1, const T& x2, const T& y2, const T& z2) { BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(x1), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(y1), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(x2), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(y2), 0.001); } }; template <> struct check_result<3> { template static void apply(Box const& b, const T& x1, const T& y1, const T& z1, const T& x2, const T& y2, const T& z2) { BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(x1), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(y1), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(z1), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(x2), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(y2), 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get(b)), double(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) { Geometry geometry; boost::geometry::read_wkt(wkt, geometry); boost::geometry::box::type > b; boost::geometry::envelope(geometry, b); check_result::type::value>::apply(b, x1, y1, z1, x2, y2, z2); } template void test_envelope_strategy(std::string const& wkt, const T& x1, const T& x2, const T& y1, const T& y2, const T& z1 = 0, const T& z2 = 0) { Geometry geometry; boost::geometry::read_wkt(wkt, geometry); boost::geometry::box::type > b; boost::geometry::envelope(geometry, b); check_result::type::value>::apply(b, x1, y1, z1, x2, y2, z2); } #endif