summaryrefslogtreecommitdiff
path: root/boost/geometry/index/detail/predicates.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/index/detail/predicates.hpp')
-rw-r--r--boost/geometry/index/detail/predicates.hpp200
1 files changed, 118 insertions, 82 deletions
diff --git a/boost/geometry/index/detail/predicates.hpp b/boost/geometry/index/detail/predicates.hpp
index 72c6c661b7..ba564f8c58 100644
--- a/boost/geometry/index/detail/predicates.hpp
+++ b/boost/geometry/index/detail/predicates.hpp
@@ -4,6 +4,10 @@
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
//
+// This file was modified by Oracle on 2019.
+// Modifications copyright (c) 2019 Oracle and/or its affiliates.
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+//
// 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)
@@ -128,8 +132,8 @@ struct predicate_check
template <typename Fun>
struct predicate_check<predicates::satisfies<Fun, false>, value_tag>
{
- template <typename Value, typename Indexable>
- static inline bool apply(predicates::satisfies<Fun, false> const& p, Value const& v, Indexable const&)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(predicates::satisfies<Fun, false> const& p, Value const& v, Indexable const& , Strategy const&)
{
return p.fun(v);
}
@@ -138,8 +142,8 @@ struct predicate_check<predicates::satisfies<Fun, false>, value_tag>
template <typename Fun>
struct predicate_check<predicates::satisfies<Fun, true>, value_tag>
{
- template <typename Value, typename Indexable>
- static inline bool apply(predicates::satisfies<Fun, true> const& p, Value const& v, Indexable const&)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(predicates::satisfies<Fun, true> const& p, Value const& v, Indexable const& , Strategy const&)
{
return !p.fun(v);
}
@@ -156,8 +160,8 @@ struct spatial_predicate_call
template <>
struct spatial_predicate_call<predicates::contains_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::within(g2, g1);
}
@@ -166,8 +170,8 @@ struct spatial_predicate_call<predicates::contains_tag>
template <>
struct spatial_predicate_call<predicates::covered_by_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::covered_by(g1, g2);
}
@@ -176,8 +180,8 @@ struct spatial_predicate_call<predicates::covered_by_tag>
template <>
struct spatial_predicate_call<predicates::covers_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::covered_by(g2, g1);
}
@@ -186,28 +190,60 @@ struct spatial_predicate_call<predicates::covers_tag>
template <>
struct spatial_predicate_call<predicates::disjoint_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::disjoint(g1, g2);
}
};
+// TEMP: used to implement CS-specific intersects predicate for certain
+// combinations of geometries until umbrella strategies are implemented
+template
+<
+ typename G1, typename G2,
+ typename Tag1 = typename tag<G1>::type,
+ typename Tag2 = typename tag<G2>::type
+>
+struct spatial_predicate_intersects
+{
+ template <typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
+ {
+ return geometry::intersects(g1, g2);
+ }
+};
+// TEMP: used in within and relate
+template <typename G1, typename G2>
+struct spatial_predicate_intersects<G1, G2, box_tag, point_tag>
+{
+ static inline bool apply(G1 const& g1, G2 const& g2, default_strategy const&)
+ {
+ return geometry::intersects(g1, g2);
+ }
+
+ template <typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const& )
+ {
+ return geometry::intersects(g1, g2, typename S::covered_by_point_box_strategy_type());
+ }
+};
+
template <>
struct spatial_predicate_call<predicates::intersects_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const& s)
{
- return geometry::intersects(g1, g2);
+ return spatial_predicate_intersects<G1, G2>::apply(g1, g2, s);
}
};
template <>
struct spatial_predicate_call<predicates::overlaps_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::overlaps(g1, g2);
}
@@ -216,8 +252,8 @@ struct spatial_predicate_call<predicates::overlaps_tag>
template <>
struct spatial_predicate_call<predicates::touches_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::touches(g1, g2);
}
@@ -226,8 +262,8 @@ struct spatial_predicate_call<predicates::touches_tag>
template <>
struct spatial_predicate_call<predicates::within_tag>
{
- template <typename G1, typename G2>
- static inline bool apply(G1 const& g1, G2 const& g2)
+ template <typename G1, typename G2, typename S>
+ static inline bool apply(G1 const& g1, G2 const& g2, S const&)
{
return geometry::within(g1, g2);
}
@@ -241,10 +277,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, Tag, false>, valu
{
typedef predicates::spatial_predicate<Geometry, Tag, false> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return spatial_predicate_call<Tag>::apply(i, p.geometry);
+ return spatial_predicate_call<Tag>::apply(i, p.geometry, s);
}
};
@@ -254,10 +290,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, Tag, true>, value
{
typedef predicates::spatial_predicate<Geometry, Tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return !spatial_predicate_call<Tag>::apply(i, p.geometry);
+ return !spatial_predicate_call<Tag>::apply(i, p.geometry, s);
}
};
@@ -266,8 +302,8 @@ struct predicate_check<predicates::spatial_predicate<Geometry, Tag, true>, value
template <typename DistancePredicates>
struct predicate_check<predicates::nearest<DistancePredicates>, value_tag>
{
- template <typename Value, typename Box>
- static inline bool apply(predicates::nearest<DistancePredicates> const&, Value const&, Box const&)
+ template <typename Value, typename Box, typename Strategy>
+ static inline bool apply(predicates::nearest<DistancePredicates> const&, Value const&, Box const&, Strategy const&)
{
return true;
}
@@ -276,8 +312,8 @@ struct predicate_check<predicates::nearest<DistancePredicates>, value_tag>
template <typename Linestring>
struct predicate_check<predicates::path<Linestring>, value_tag>
{
- template <typename Value, typename Box>
- static inline bool apply(predicates::path<Linestring> const&, Value const&, Box const&)
+ template <typename Value, typename Box, typename Strategy>
+ static inline bool apply(predicates::path<Linestring> const&, Value const&, Box const&, Strategy const&)
{
return true;
}
@@ -290,8 +326,8 @@ struct predicate_check<predicates::path<Linestring>, value_tag>
template <typename Fun, bool Negated>
struct predicate_check<predicates::satisfies<Fun, Negated>, bounds_tag>
{
- template <typename Value, typename Box>
- static bool apply(predicates::satisfies<Fun, Negated> const&, Value const&, Box const&)
+ template <typename Value, typename Box, typename Strategy>
+ static bool apply(predicates::satisfies<Fun, Negated> const&, Value const&, Box const&, Strategy const&)
{
return true;
}
@@ -317,10 +353,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, Tag, false>, boun
{
typedef predicates::spatial_predicate<Geometry, Tag, false> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return spatial_predicate_call<predicates::intersects_tag>::apply(i, p.geometry);
+ return spatial_predicate_call<predicates::intersects_tag>::apply(i, p.geometry, s);
}
};
@@ -330,10 +366,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::conta
{
typedef predicates::spatial_predicate<Geometry, predicates::contains_tag, false> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return spatial_predicate_call<predicates::covers_tag>::apply(i, p.geometry);
+ return spatial_predicate_call<predicates::covers_tag>::apply(i, p.geometry, s);
}
};
@@ -343,10 +379,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::cover
{
typedef predicates::spatial_predicate<Geometry, predicates::covers_tag, false> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return spatial_predicate_call<predicates::covers_tag>::apply(i, p.geometry);
+ return spatial_predicate_call<predicates::covers_tag>::apply(i, p.geometry, s);
}
};
@@ -356,10 +392,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::disjo
{
typedef predicates::spatial_predicate<Geometry, predicates::disjoint_tag, false> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return !spatial_predicate_call<predicates::covered_by_tag>::apply(i, p.geometry);
+ return !spatial_predicate_call<predicates::covered_by_tag>::apply(i, p.geometry, s);
}
};
@@ -381,10 +417,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, Tag, true>, bound
{
typedef predicates::spatial_predicate<Geometry, Tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return !spatial_predicate_call<Tag>::apply(i, p.geometry);
+ return !spatial_predicate_call<Tag>::apply(i, p.geometry, s);
}
};
@@ -394,8 +430,8 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::conta
{
typedef predicates::spatial_predicate<Geometry, predicates::contains_tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& , Value const&, Indexable const& )
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& , Value const&, Indexable const&, Strategy const&)
{
return true;
}
@@ -407,8 +443,8 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::cover
{
typedef predicates::spatial_predicate<Geometry, predicates::covers_tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& , Value const&, Indexable const& )
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& , Value const&, Indexable const&, Strategy const&)
{
return true;
}
@@ -420,10 +456,10 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::inter
{
typedef predicates::spatial_predicate<Geometry, predicates::intersects_tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const& s)
{
- return !spatial_predicate_call<predicates::covered_by_tag>::apply(i, p.geometry);
+ return !spatial_predicate_call<predicates::covered_by_tag>::apply(i, p.geometry, s);
}
};
@@ -433,8 +469,8 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::overl
{
typedef predicates::spatial_predicate<Geometry, predicates::overlaps_tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& , Value const&, Indexable const& )
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& , Value const&, Indexable const&, Strategy const&)
{
return true;
}
@@ -446,8 +482,8 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::touch
{
typedef predicates::spatial_predicate<Geometry, predicates::touches_tag, true> Pred;
- template <typename Value, typename Indexable>
- static inline bool apply(Pred const& p, Value const&, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Pred const& p, Value const&, Indexable const& i, Strategy const&)
{
return !spatial_predicate_call<predicates::intersects_tag>::apply(i, p.geometry);
}
@@ -458,8 +494,8 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::touch
template <typename DistancePredicates>
struct predicate_check<predicates::nearest<DistancePredicates>, bounds_tag>
{
- template <typename Value, typename Box>
- static inline bool apply(predicates::nearest<DistancePredicates> const&, Value const&, Box const&)
+ template <typename Value, typename Box, typename Strategy>
+ static inline bool apply(predicates::nearest<DistancePredicates> const&, Value const&, Box const&, Strategy const&)
{
return true;
}
@@ -468,8 +504,8 @@ struct predicate_check<predicates::nearest<DistancePredicates>, bounds_tag>
template <typename Linestring>
struct predicate_check<predicates::path<Linestring>, bounds_tag>
{
- template <typename Value, typename Box>
- static inline bool apply(predicates::path<Linestring> const&, Value const&, Box const&)
+ template <typename Value, typename Box, typename Strategy>
+ static inline bool apply(predicates::path<Linestring> const&, Value const&, Box const&, Strategy const&)
{
return true;
}
@@ -600,23 +636,23 @@ struct predicates_element< I, boost::tuples::cons<Head, Tail> >
template <typename TuplePredicates, typename Tag, unsigned First, unsigned Last>
struct predicates_check_tuple
{
- template <typename Value, typename Indexable>
- static inline bool apply(TuplePredicates const& p, Value const& v, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(TuplePredicates const& p, Value const& v, Indexable const& i, Strategy const& s)
{
- return
- predicate_check<
- typename boost::tuples::element<First, TuplePredicates>::type,
- Tag
- >::apply(boost::get<First>(p), v, i) &&
- predicates_check_tuple<TuplePredicates, Tag, First+1, Last>::apply(p, v, i);
+ return predicate_check
+ <
+ typename boost::tuples::element<First, TuplePredicates>::type,
+ Tag
+ >::apply(boost::get<First>(p), v, i, s)
+ && predicates_check_tuple<TuplePredicates, Tag, First+1, Last>::apply(p, v, i, s);
}
};
template <typename TuplePredicates, typename Tag, unsigned First>
struct predicates_check_tuple<TuplePredicates, Tag, First, First>
{
- template <typename Value, typename Indexable>
- static inline bool apply(TuplePredicates const& , Value const& , Indexable const& )
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(TuplePredicates const& , Value const& , Indexable const& , Strategy const& )
{
return true;
}
@@ -628,10 +664,10 @@ struct predicates_check_impl
static const bool check = First < 1 && Last <= 1 && First <= Last;
BOOST_MPL_ASSERT_MSG((check), INVALID_INDEXES, (predicates_check_impl));
- template <typename Value, typename Indexable>
- static inline bool apply(Predicate const& p, Value const& v, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(Predicate const& p, Value const& v, Indexable const& i, Strategy const& s)
{
- return predicate_check<Predicate, Tag>::apply(p, v, i);
+ return predicate_check<Predicate, Tag>::apply(p, v, i, s);
}
};
@@ -685,21 +721,21 @@ struct predicates_check_impl<
static const bool check = First < pred_len && Last <= pred_len && First <= Last;
BOOST_MPL_ASSERT_MSG((check), INVALID_INDEXES, (predicates_check_impl));
- template <typename Value, typename Indexable>
- static inline bool apply(predicates_type const& p, Value const& v, Indexable const& i)
+ template <typename Value, typename Indexable, typename Strategy>
+ static inline bool apply(predicates_type const& p, Value const& v, Indexable const& i, Strategy const& s)
{
return predicates_check_tuple<
predicates_type,
Tag, First, Last
- >::apply(p, v, i);
+ >::apply(p, v, i, s);
}
};
-template <typename Tag, unsigned First, unsigned Last, typename Predicates, typename Value, typename Indexable>
-inline bool predicates_check(Predicates const& p, Value const& v, Indexable const& i)
+template <typename Tag, unsigned First, unsigned Last, typename Predicates, typename Value, typename Indexable, typename Strategy>
+inline bool predicates_check(Predicates const& p, Value const& v, Indexable const& i, Strategy const& s)
{
return detail::predicates_check_impl<Predicates, Tag, First, Last>
- ::apply(p, v, i);
+ ::apply(p, v, i, s);
}
// ------------------------------------------------------------------ //