Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84839 - trunk/libs/geometry/index/test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-19 14:04:20


Author: awulkiew
Date: 2013-06-19 14:04:20 EDT (Wed, 19 Jun 2013)
New Revision: 84839
URL: http://svn.boost.org/trac/boost/changeset/84839

Log:
[geometry][index] test: added experimental tests for contains and covers predicates, removed experimental tests for reversed spatial predicates.

Text files modified:
   trunk/libs/geometry/index/test/rtree/test_rtree.hpp | 131 +++++++++++++++++++++++++++++----------
   1 files changed, 95 insertions(+), 36 deletions(-)

Modified: trunk/libs/geometry/index/test/rtree/test_rtree.hpp
==============================================================================
--- trunk/libs/geometry/index/test/rtree/test_rtree.hpp Wed Jun 19 14:00:27 2013 (r84838)
+++ trunk/libs/geometry/index/test/rtree/test_rtree.hpp 2013-06-19 14:04:20 EDT (Wed, 19 Jun 2013) (r84839)
@@ -702,12 +702,6 @@
     spatial_query(tree, bgi::intersects(qbox), expected_output);
     spatial_query(tree, !bgi::disjoint(qbox), expected_output);
 
-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
- spatial_query(tree, ~bgi::intersects(qbox), expected_output);
- spatial_query(tree, !~bgi::disjoint(qbox), expected_output);
- spatial_query(tree, ~!bgi::disjoint(qbox), expected_output);
-#endif
-
     /*typedef bg::traits::point_type<Box>::type P;
     bg::model::ring<P> qring;
     bg::convert(qbox, qring);
@@ -731,12 +725,6 @@
     spatial_query(tree, bgi::disjoint(qbox), expected_output);
     spatial_query(tree, !bgi::intersects(qbox), expected_output);
 
-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
- spatial_query(tree, ~bgi::disjoint(qbox), expected_output);
- spatial_query(tree, !~bgi::intersects(qbox), expected_output);
- spatial_query(tree, ~!bgi::intersects(qbox), expected_output);
-#endif
-
     /*typedef bg::traits::point_type<Box>::type P;
     bg::model::ring<P> qring;
     bg::convert(qbox, qring);
@@ -746,6 +734,51 @@
     spatial_query(tree, bgi::disjoint(qpoly), expected_output);*/
 }
 
+#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
+
+template <typename Tag>
+struct contains_impl
+{
+ template <typename Rtree, typename Value, typename Box>
+ static void apply(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
+ {
+ std::vector<Value> expected_output;
+
+ BOOST_FOREACH(Value const& v, input)
+ if ( bg::within(qbox, tree.indexable_get()(v)) )
+ expected_output.push_back(v);
+
+ spatial_query(tree, bgi::contains(qbox), expected_output);
+
+ /*typedef bg::traits::point_type<Box>::type P;
+ bg::model::ring<P> qring;
+ bg::convert(qbox, qring);
+ spatial_query(tree, bgi::contains(qring), expected_output);
+ bg::model::polygon<P> qpoly;
+ bg::convert(qbox, qpoly);
+ spatial_query(tree, bgi::contains(qpoly), expected_output);*/
+ }
+};
+
+template <>
+struct contains_impl<bg::point_tag>
+{
+ template <typename Rtree, typename Value, typename Box>
+ static void apply(Rtree const& /*tree*/, std::vector<Value> const& /*input*/, Box const& /*qbox*/)
+ {}
+};
+
+template <typename Rtree, typename Value, typename Box>
+void contains(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
+{
+ contains_impl<
+ typename bgi::detail::traits::tag<
+ typename Rtree::indexable_type
+ >::type
+ >::apply(tree, input, qbox);
+}
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
 
 template <typename Rtree, typename Value, typename Box>
 void covered_by(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
@@ -758,16 +791,6 @@
 
     spatial_query(tree, bgi::covered_by(qbox), expected_output);
 
-// TODO - run this only for Boxes
-//#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
-// expected_output.clear();
-// BOOST_FOREACH(Value const& v, input)
-// if ( bg::covered_by(qbox, tree.indexable_get()(v)) )
-// expected_output.push_back(v);
-//
-// spatial_query(tree, ~bgi::covered_by(qbox), expected_output);
-//#endif
-
     /*typedef bg::traits::point_type<Box>::type P;
     bg::model::ring<P> qring;
     bg::convert(qbox, qring);
@@ -777,6 +800,52 @@
     spatial_query(tree, bgi::covered_by(qpoly), expected_output);*/
 }
 
+#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
+
+template <typename Tag>
+struct covers_impl
+{
+ template <typename Rtree, typename Value, typename Box>
+ static void apply(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
+ {
+ std::vector<Value> expected_output;
+
+ BOOST_FOREACH(Value const& v, input)
+ if ( bg::covered_by(qbox, tree.indexable_get()(v)) )
+ expected_output.push_back(v);
+
+ spatial_query(tree, bgi::covers(qbox), expected_output);
+
+ /*typedef bg::traits::point_type<Box>::type P;
+ bg::model::ring<P> qring;
+ bg::convert(qbox, qring);
+ spatial_query(tree, bgi::covers(qring), expected_output);
+ bg::model::polygon<P> qpoly;
+ bg::convert(qbox, qpoly);
+ spatial_query(tree, bgi::covers(qpoly), expected_output);*/
+ }
+};
+
+template <>
+struct covers_impl<bg::point_tag>
+{
+ template <typename Rtree, typename Value, typename Box>
+ static void apply(Rtree const& /*tree*/, std::vector<Value> const& /*input*/, Box const& /*qbox*/)
+ {}
+};
+
+template <typename Rtree, typename Value, typename Box>
+void covers(Rtree const& tree, std::vector<Value> const& input, Box const& qbox)
+{
+ covers_impl<
+ typename bgi::detail::traits::tag<
+ typename Rtree::indexable_type
+ >::type
+ >::apply(tree, input, qbox);
+}
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
+
 template <typename Tag>
 struct overlaps_impl
 {
@@ -791,10 +860,6 @@
 
         spatial_query(tree, bgi::overlaps(qbox), expected_output);
 
-#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
- spatial_query(tree, ~bgi::overlaps(qbox), expected_output);
-#endif
-
         /*typedef bg::traits::point_type<Box>::type P;
         bg::model::ring<P> qring;
         bg::convert(qbox, qring);
@@ -867,16 +932,6 @@
 
     spatial_query(tree, bgi::within(qbox), expected_output);
 
-// TODO - run this only for Boxes
-//#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
-// expected_output.clear();
-// BOOST_FOREACH(Value const& v, input)
-// if ( bg::within(qbox, tree.indexable_get()(v)) )
-// expected_output.push_back(v);
-//
-// spatial_query(tree, ~bgi::within(qbox), expected_output);
-//#endif
-
     /*typedef bg::traits::point_type<Box>::type P;
     bg::model::ring<P> qring;
     bg::convert(qbox, qring);
@@ -1365,6 +1420,10 @@
     basictest::overlaps(tree, input, qbox);
     //basictest::touches(tree, input, qbox);
     basictest::within(tree, input, qbox);
+#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
+ basictest::contains(tree, input, qbox);
+ basictest::covers(tree, input, qbox);
+#endif
 
     typedef typename bgi::detail::traits::point_type<Box>::type P;
     P pt;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk