From e6633533d65055165f3d35beaeabb23d6a40e982 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 29 Sep 2011 00:03:45 +0000 Subject: [PATCH] operator!() predicates generators implemented. [SVN r74606] --- .../geometry/extensions/index/predicates.hpp | 78 ++++++++++++++++++- .../extensions/index/rtree/predicates.hpp | 6 -- tests/additional_sizes_and_times.cpp | 18 +++++ 3 files changed, 94 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/extensions/index/predicates.hpp b/include/boost/geometry/extensions/index/predicates.hpp index cffe33306..2f3921410 100644 --- a/include/boost/geometry/extensions/index/predicates.hpp +++ b/include/boost/geometry/extensions/index/predicates.hpp @@ -19,10 +19,10 @@ namespace boost { namespace geometry { namespace index { -// predicates - namespace detail { +// predicates + struct empty {}; template @@ -104,6 +104,8 @@ struct not_within } // namespace detail +// generators + inline detail::empty empty() { return detail::empty(); @@ -403,4 +405,76 @@ inline bool predicates_check(Predicates const& p, Value const& v, Indexable cons }}} // namespace boost::geometry::index +// operator! generators + +template +boost::geometry::index::detail::not_covered_by +operator!(boost::geometry::index::detail::covered_by const& p) +{ + return boost::geometry::index::detail::not_covered_by(p.geometry); +} + +template +boost::geometry::index::detail::covered_by +operator!(boost::geometry::index::detail::not_covered_by const& p) +{ + return boost::geometry::index::detail::covered_by(p.geometry); +} + +template +boost::geometry::index::detail::not_disjoint +operator!(boost::geometry::index::detail::disjoint const& p) +{ + return boost::geometry::index::detail::not_disjoint(p.geometry); +} + +template +boost::geometry::index::detail::disjoint +operator!(boost::geometry::index::detail::not_disjoint const& p) +{ + return boost::geometry::index::detail::disjoint(p.geometry); +} + +template +boost::geometry::index::detail::not_intersects +operator!(boost::geometry::index::detail::intersects const& p) +{ + return boost::geometry::index::detail::not_intersects(p.geometry); +} + +template +boost::geometry::index::detail::intersects +operator!(boost::geometry::index::detail::not_intersects const& p) +{ + return boost::geometry::index::detail::intersects(p.geometry); +} + +template +boost::geometry::index::detail::not_overlaps +operator!(boost::geometry::index::detail::overlaps const& p) +{ + return boost::geometry::index::detail::not_overlaps(p.geometry); +} + +template +boost::geometry::index::detail::overlaps +operator!(boost::geometry::index::detail::not_overlaps const& p) +{ + return boost::geometry::index::detail::overlaps(p.geometry); +} + +template +boost::geometry::index::detail::not_within +operator!(boost::geometry::index::detail::within const& p) +{ + return boost::geometry::index::detail::not_within(p.geometry); +} + +template +boost::geometry::index::detail::within +operator!(boost::geometry::index::detail::not_within const& p) +{ + return boost::geometry::index::detail::within(p.geometry); +} + #endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_PREDICATES_HPP diff --git a/include/boost/geometry/extensions/index/rtree/predicates.hpp b/include/boost/geometry/extensions/index/rtree/predicates.hpp index 145e926aa..5718e520d 100644 --- a/include/boost/geometry/extensions/index/rtree/predicates.hpp +++ b/include/boost/geometry/extensions/index/rtree/predicates.hpp @@ -140,12 +140,6 @@ struct predicate_check, rtree::node_tag> template static bool apply(not_overlaps const& p, Value const&, Box const& i) { - bool inters = geometry::intersects(i, p.geometry); - - //return !inters || ( inters && !geometry::overlaps(i, p.geometry) ); - - // TODO: awulkiew - write working condition - return true; } }; diff --git a/tests/additional_sizes_and_times.cpp b/tests/additional_sizes_and_times.cpp index 09aa04f4a..9272e8838 100644 --- a/tests/additional_sizes_and_times.cpp +++ b/tests/additional_sizes_and_times.cpp @@ -183,6 +183,24 @@ int main() std::cout << "found: " << temp << "\n"; } + // searching test + { + std::cout << "query(!disjoint(B)) searching time test... (" + << queries_count << ")\n"; + tim.restart(); + size_t temp = 0; + for (size_t i = 0 ; i < queries_count ; ++i ) + { + float x = coords[i].first; + float y = coords[i].second; + std::deque< std::pair > result; + t.query(!bgi::disjoint(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); + temp += result.size(); + } + std::cout << "time: " << tim.elapsed() << "s\n"; + std::cout << "found: " << temp << "\n"; + } + // searching test { std::cout << "query(B) searching time test... ("