diff --git a/extensions/test/nsphere/Jamfile.v2 b/extensions/test/nsphere/Jamfile.v2 index 800447e7e..dfc9d2351 100644 --- a/extensions/test/nsphere/Jamfile.v2 +++ b/extensions/test/nsphere/Jamfile.v2 @@ -18,6 +18,9 @@ test-suite boost-geometry-extensions-nsphere [ run point_type.cpp ] [ run within.cpp ] + [ run nsphere_in_box.cpp ] + [ run point_in_nsphere.cpp ] + [ run disjoint.cpp ] [ run index_content.cpp ] [ run index_margin.cpp ] diff --git a/extensions/test/nsphere/area.cpp b/extensions/test/nsphere/area.cpp index 0870d3958..282c620fd 100644 --- a/extensions/test/nsphere/area.cpp +++ b/extensions/test/nsphere/area.cpp @@ -12,8 +12,7 @@ #include #include -#include -#include +#include template @@ -21,9 +20,9 @@ void test_area_circle() { bg::model::nsphere c; - bg::set<0>(c.center(), 0); - bg::set<1>(c.center(), 0); - c.radius(2); + bg::set<0>(c, 0); + bg::set<1>(c, 0); + bg::set_radius<0>(c, 2); double d = bg::area(c); BOOST_CHECK_CLOSE(d, 4 * 3.1415926535897932384626433832795, 0.001); diff --git a/extensions/test/nsphere/circle.cpp b/extensions/test/nsphere/circle.cpp index 9f9a73d16..4a8b9104f 100644 --- a/extensions/test/nsphere/circle.cpp +++ b/extensions/test/nsphere/circle.cpp @@ -10,9 +10,7 @@ #include -#include -#include -#include +#include #include #include diff --git a/extensions/test/nsphere/nsphere_in_box.cpp b/extensions/test/nsphere/nsphere_in_box.cpp new file mode 100644 index 000000000..2f16acc08 --- /dev/null +++ b/extensions/test/nsphere/nsphere_in_box.cpp @@ -0,0 +1,63 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// +// 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 + +typedef bg::model::d2::point_xy point_type; +typedef bg::model::nsphere circle_type; +typedef bg::model::box box_type; + +template +void test_circle(std::string const& wkt_geometry, bool expected_within, bool expected_covered_by) +{ + circle_type circle(point_type(1.0, 1.0), 3.0); + //bg::assign(circle, 1.0, 1.0, 3.0); + + Geometry geometry; + bg::read_wkt(wkt_geometry, geometry); + + bool detected = bg::within(circle, geometry); + + BOOST_CHECK_MESSAGE(detected == expected_within, + "circle (1,1) with radius 3 within : " << wkt_geometry + << " -> Expected: " << expected_within + << " detected: " << detected); + + detected = bg::covered_by(circle, geometry); + + BOOST_CHECK_MESSAGE(detected == expected_covered_by, + "circle (1,1) with radius 3 covered_by : " << wkt_geometry + << " -> Expected: " << expected_covered_by + << " detected: " << detected); +} + +void test_circles() +{ + test_circle("BOX(1 1, 1.1 1.1)", false, false); + test_circle("BOX(2 1, 4 4)", false, false); + test_circle("BOX(-2 -2, 4 4)", false, true); + test_circle("BOX(-2.1 -2.1, 4.1 4.1)", true, true); +} + + +int test_main( int , char* [] ) +{ + test_circles(); + + return 0; +} diff --git a/extensions/test/nsphere/point_in_nsphere.cpp b/extensions/test/nsphere/point_in_nsphere.cpp new file mode 100644 index 000000000..9f584f13e --- /dev/null +++ b/extensions/test/nsphere/point_in_nsphere.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. +// +// 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 + +typedef bg::model::d2::point_xy point_type; +typedef bg::model::nsphere circle_type; + +template +void test_circle(std::string const& wkt_geometry, bool expected_within, bool expected_covered_by) +{ + circle_type circle(point_type(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, + "circle (1,1) with radius 3 containing : " << wkt_geometry + << " -> Expected: " << expected_within + << " detected: " << detected); + + detected = bg::covered_by(geometry, circle); + + BOOST_CHECK_MESSAGE(detected == expected_covered_by, + "circle (1,1) with radius 3 covering : " << wkt_geometry + << " -> Expected: " << expected_covered_by + << " detected: " << detected); +} + +void test_circles() +{ + test_circle("POINT(1 1)", true, true); + test_circle("POINT(1 4)", false, true); + test_circle("POINT(4 1)", false, true); + test_circle("POINT(4 4)", false, false); +} + + +int test_main( int , char* [] ) +{ + test_circles(); + + return 0; +} diff --git a/extensions/test/nsphere/within.cpp b/extensions/test/nsphere/within.cpp index 497d66b27..549d54d66 100644 --- a/extensions/test/nsphere/within.cpp +++ b/extensions/test/nsphere/within.cpp @@ -22,12 +22,11 @@ void test_circle(std::string const& wkt_geometry, bool expected) { typedef bg::model::nsphere, double> circle_type; circle_type circle; - bg::assign(circle, 1.0, 1.0, 3.0); + bg::assign_values(circle, 1.0, 1.0, 3.0); Geometry geometry; bg::read_wkt(wkt_geometry, geometry); - /* todo: fix bool detected = bg::within(geometry, circle); BOOST_CHECK_MESSAGE(detected == expected, @@ -35,7 +34,6 @@ void test_circle(std::string const& wkt_geometry, bool expected) << " in circle (1,1) with radius 3" << " -> Expected: " << expected << " detected: " << detected); - */ } @@ -47,8 +45,8 @@ 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 >("LINESTRING(1 1,2 1,2 2)", true); + //test_circle >("LINESTRING(1 1,2 1,2 2,10 10)", false); } diff --git a/index/example/benchmark_experimental.cpp b/index/example/benchmark_experimental.cpp index da288581d..5d9c229a3 100644 --- a/index/example/benchmark_experimental.cpp +++ b/index/example/benchmark_experimental.cpp @@ -45,6 +45,16 @@ struct generate_value

static inline P apply(float x, float y) { return P(x, y); } }; +//#include +//typedef bg::model::nsphere NS; +//typedef NS V; +// +//template <> +//struct generate_value +//{ +// static inline NS apply(float x, float y) { return NS(P(x, y), 0.5); } +//}; + template void mycopy(I1 first, I2 last, O o) { @@ -101,9 +111,9 @@ int main() std::cout << "randomized\n"; } - //typedef bgi::rtree > RT; + typedef bgi::rtree > RT; //typedef bgi::rtree > RT; - typedef bgi::rtree > RT; + //typedef bgi::rtree > RT; std::cout << "sizeof rtree: " << sizeof(RT) << std::endl;