// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 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) #if defined(_MSC_VER) // We deliberately mix float/double's here so turn off warning #pragma warning( disable : 4305 ) #endif // defined(_MSC_VER) #include #include #include #include #include #include template void test_selected(G const& g, P const& point, bool result, double dist) { bool sel = bg::selected(g, point, dist); BOOST_CHECK_EQUAL(sel, result); } template void test_selected(std::string const& wkt, P const& point, bool result, double dist) { G g; bg::read_wkt(wkt, g); test_selected(g, point, result, dist); } template void test_all() { test_selected

("POINT(1 1)", P(1,1), true, 0.001); test_selected

("POINT(1 1)", P(3,3), false, 2); test_selected

("POINT(1 1)", P(1,2.00001), false, 1); test_selected

("POINT(1 1)", P(1,1.99999), true, 1); test_selected

("POINT(1 1)", P(1.99999,1.99999), false, 1); test_selected >("LINESTRING(1 1,2 2)", P(1,1), true, 0.0001); test_selected >("LINESTRING(1 1,2 2)", P(2,2), true, 0.0001); test_selected >("LINESTRING(1 1,2 2)", P(2.01,2.01), false, 0.0001); test_selected >("LINESTRING(1 1,2 2)", P(1,0.9), false, 0.0001); test_selected >("LINESTRING(1 1,2 2)", P(1.5,1.5), true, 0.0001); test_selected >("LINESTRING(1 1,2 2)", P(1.5,1.6), false, 0.0001); test_selected >("LINESTRING(1 1,2 2,3 0,5 0,5 8)", P(5,5.000001), true, 0.0001); // Lines with zero,one points test_selected >("LINESTRING( )", P(1,1), false, 0.0001); test_selected >("LINESTRING(1 1)", P(1,1), true, 0.0001); test_selected >("LINESTRING(1 2)", P(1,1), false, 0.0001); // nyi //test_selected >(); test_selected >("POLYGON((0 0,0 7,4 2,2 0,0 0))", P(0.001, 0.001), true, 0.0001); test_selected >("POLYGON((0 0,0 7,4 2,2 0,0 0))", P(1, 1), true, 0.0001); test_selected >("POLYGON((0 0,0 7,4 2,2 0,0 0))", P(2, 5), false, 0.0001); typedef bg::model::box

B; test_selected(bg::make(0,0,4,4), P(2,2), true, 0.001); test_selected(bg::make(0,0,4,4), P(5,5), false, 0.001); test_selected(bg::make(0,0,4,4), P(0,0), false, 0.001); test_selected(bg::make(0,0,4,4), P(4,4), false, 0.001); // nyi //test_selected >(); //test_selected >(); } int test_main(int, char* []) { // Integer not applicable here, just because of the tests using floating point // test_all >(); test_all >(); test_all >(); return 0; }