operator!() predicates generators implemented.

[SVN r74606]
This commit is contained in:
Adam Wulkiewicz
2011-09-29 00:03:45 +00:00
parent c6c1fee74b
commit e6633533d6
3 changed files with 94 additions and 8 deletions

View File

@@ -19,10 +19,10 @@
namespace boost { namespace geometry { namespace index {
// predicates
namespace detail {
// predicates
struct empty {};
template <typename ValuePredicate>
@@ -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 <typename Geometry>
boost::geometry::index::detail::not_covered_by<Geometry>
operator!(boost::geometry::index::detail::covered_by<Geometry> const& p)
{
return boost::geometry::index::detail::not_covered_by<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::covered_by<Geometry>
operator!(boost::geometry::index::detail::not_covered_by<Geometry> const& p)
{
return boost::geometry::index::detail::covered_by<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::not_disjoint<Geometry>
operator!(boost::geometry::index::detail::disjoint<Geometry> const& p)
{
return boost::geometry::index::detail::not_disjoint<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::disjoint<Geometry>
operator!(boost::geometry::index::detail::not_disjoint<Geometry> const& p)
{
return boost::geometry::index::detail::disjoint<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::not_intersects<Geometry>
operator!(boost::geometry::index::detail::intersects<Geometry> const& p)
{
return boost::geometry::index::detail::not_intersects<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::intersects<Geometry>
operator!(boost::geometry::index::detail::not_intersects<Geometry> const& p)
{
return boost::geometry::index::detail::intersects<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::not_overlaps<Geometry>
operator!(boost::geometry::index::detail::overlaps<Geometry> const& p)
{
return boost::geometry::index::detail::not_overlaps<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::overlaps<Geometry>
operator!(boost::geometry::index::detail::not_overlaps<Geometry> const& p)
{
return boost::geometry::index::detail::overlaps<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::not_within<Geometry>
operator!(boost::geometry::index::detail::within<Geometry> const& p)
{
return boost::geometry::index::detail::not_within<Geometry>(p.geometry);
}
template <typename Geometry>
boost::geometry::index::detail::within<Geometry>
operator!(boost::geometry::index::detail::not_within<Geometry> const& p)
{
return boost::geometry::index::detail::within<Geometry>(p.geometry);
}
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_PREDICATES_HPP

View File

@@ -140,12 +140,6 @@ struct predicate_check<not_overlaps<Geometry>, rtree::node_tag>
template <typename Value, typename Box>
static bool apply(not_overlaps<Geometry> 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;
}
};

View File

@@ -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<B, size_t> > 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... ("