// Boost.Geometry (aka GGL, Generic Geometry Library) // // 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) #include #include #include #include #include #include template void test_circle(std::string const& wkt_geometry, bool expected) { typedef bg::model::nsphere, double> circle_type; circle_type circle; bg::assign_values(circle, 1.0, 1.0, 3.0); Geometry geometry; bg::read_wkt(wkt_geometry, geometry); bool detected = bg::within(geometry, circle); BOOST_CHECK_MESSAGE(detected == expected, "within: " << wkt_geometry << " in circle (1,1) with radius 3" << " -> Expected: " << expected << " detected: " << detected); } template void test_circles() { test_circle

("POINT(2 1)", true); test_circle

("POINT(12 1)", false); test_circle >("LINESTRING(1 1,2 1,2 2)", true); test_circle >("LINESTRING(1 1,2 1,2 2,10 10)", false); test_circle >("POLYGON((1 1,2 1,2 2,1 1))", true); test_circle >("POLYGON((1 1,2 1,2 2,10 10,1 1))", false); test_circle >("BOX(1 1,2 2)", true); test_circle >("BOX(1 1,10 10)", false); } int test_main( int , char* [] ) { test_circles >(); return 0; }