// Boost.Geometry (aka GGL, Generic Geometry Library) test file // // Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands // Copyright Bruno Lalande 2008, 2009 // 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) #include #include #include #include #include #include #include #include #include template void test_all() { typedef boost::geometry::box

box_type; P p; boost::geometry::assign(p, 1, 2); box_type b; boost::geometry::convert(p, b); BOOST_CHECK_CLOSE(double(boost::geometry::get<0, 0>(b)), 1.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<0, 1>(b)), 2.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1, 0>(b)), 1.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1, 1>(b)), 2.0, 0.001); } template void test_std() { test_all

(); typedef boost::geometry::box

box_type; typedef boost::geometry::linear_ring

ring_type; typedef boost::geometry::polygon

polygon_type; box_type b; boost::geometry::set(b, 1); boost::geometry::set(b, 2); boost::geometry::set(b, 3); boost::geometry::set(b, 4); ring_type ring; boost::geometry::convert(b, ring); //std::cout << boost::geometry::wkt(b) << std::endl; //std::cout << boost::geometry::wkt(ring) << std::endl; typename boost::range_const_iterator::type it = ring.begin(); BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(*it)), 1.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(*it)), 2.0, 0.001); it++; BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(*it)), 1.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(*it)), 4.0, 0.001); it++; BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(*it)), 3.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(*it)), 4.0, 0.001); it++; BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(*it)), 3.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(*it)), 2.0, 0.001); it++; BOOST_CHECK_CLOSE(double(boost::geometry::get<0>(*it)), 1.0, 0.001); BOOST_CHECK_CLOSE(double(boost::geometry::get<1>(*it)), 2.0, 0.001); BOOST_CHECK_EQUAL(ring.size(), 5); polygon_type polygon; boost::geometry::convert(ring, polygon); BOOST_CHECK_EQUAL(boost::geometry::num_points(polygon), 5); boost::geometry::convert(polygon, ring); BOOST_CHECK_EQUAL(boost::geometry::num_points(ring), 5); } int test_main(int, char* []) { test_std >(); test_std >(); test_std >(); return 0; }