Boost.Geometry.Index
/home/travis/build/boostorg/boost/boost/geometry/index/predicates.hpp
00001 // Boost.Geometry Index
00002 //
00003 // Spatial query predicates
00004 //
00005 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
00006 //
00007 // Use, modification and distribution is subject to the Boost Software License,
00008 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00009 // http://www.boost.org/LICENSE_1_0.txt)
00010 
00011 #ifndef BOOST_GEOMETRY_INDEX_PREDICATES_HPP
00012 #define BOOST_GEOMETRY_INDEX_PREDICATES_HPP
00013 
00014 #include <utility>
00015 #include <boost/tuple/tuple.hpp>
00016 #include <boost/mpl/assert.hpp>
00017 
00018 #include <boost/geometry/index/detail/predicates.hpp>
00019 #include <boost/geometry/index/detail/tuples.hpp>
00020 
00025 namespace boost { namespace geometry { namespace index {
00026 
00045 template <typename Geometry> inline
00046 detail::predicates::spatial_predicate<Geometry, detail::predicates::contains_tag, false>
00047 contains(Geometry const& g)
00048 {
00049     return detail::predicates::spatial_predicate
00050                 <
00051                     Geometry,
00052                     detail::predicates::contains_tag,
00053                     false
00054                 >(g);
00055 }
00056 
00075 template <typename Geometry> inline
00076 detail::predicates::spatial_predicate<Geometry, detail::predicates::covered_by_tag, false>
00077 covered_by(Geometry const& g)
00078 {
00079     return detail::predicates::spatial_predicate
00080                 <
00081                     Geometry,
00082                     detail::predicates::covered_by_tag,
00083                     false
00084                 >(g);
00085 }
00086 
00105 template <typename Geometry> inline
00106 detail::predicates::spatial_predicate<Geometry, detail::predicates::covers_tag, false>
00107 covers(Geometry const& g)
00108 {
00109     return detail::predicates::spatial_predicate
00110                 <
00111                     Geometry,
00112                     detail::predicates::covers_tag,
00113                     false
00114                 >(g);
00115 }
00116 
00135 template <typename Geometry> inline
00136 detail::predicates::spatial_predicate<Geometry, detail::predicates::disjoint_tag, false>
00137 disjoint(Geometry const& g)
00138 {
00139     return detail::predicates::spatial_predicate
00140                 <
00141                     Geometry,
00142                     detail::predicates::disjoint_tag,
00143                     false
00144                 >(g);
00145 }
00146 
00167 template <typename Geometry> inline
00168 detail::predicates::spatial_predicate<Geometry, detail::predicates::intersects_tag, false>
00169 intersects(Geometry const& g)
00170 {
00171     return detail::predicates::spatial_predicate
00172                 <
00173                     Geometry,
00174                     detail::predicates::intersects_tag,
00175                     false
00176                 >(g);
00177 }
00178 
00197 template <typename Geometry> inline
00198 detail::predicates::spatial_predicate<Geometry, detail::predicates::overlaps_tag, false>
00199 overlaps(Geometry const& g)
00200 {
00201     return detail::predicates::spatial_predicate
00202                 <
00203                     Geometry,
00204                     detail::predicates::overlaps_tag,
00205                     false
00206                 >(g);
00207 }
00208 
00209 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
00210 
00224 template <typename Geometry> inline
00225 detail::predicates::spatial_predicate<Geometry, detail::predicates::touches_tag, false>
00226 touches(Geometry const& g)
00227 {
00228     return detail::predicates::spatial_predicate
00229                 <
00230                     Geometry,
00231                     detail::predicates::touches_tag,
00232                     false
00233                 >(g);
00234 }
00235 
00236 #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
00237 
00256 template <typename Geometry> inline
00257 detail::predicates::spatial_predicate<Geometry, detail::predicates::within_tag, false>
00258 within(Geometry const& g)
00259 {
00260     return detail::predicates::spatial_predicate
00261                 <
00262                     Geometry,
00263                     detail::predicates::within_tag,
00264                     false
00265                 >(g);
00266 }
00267 
00301 template <typename UnaryPredicate> inline
00302 detail::predicates::satisfies<UnaryPredicate, false>
00303 satisfies(UnaryPredicate const& pred)
00304 {
00305     return detail::predicates::satisfies<UnaryPredicate, false>(pred);
00306 }
00307 
00331 template <typename Geometry> inline
00332 detail::predicates::nearest<Geometry>
00333 nearest(Geometry const& geometry, unsigned k)
00334 {
00335     return detail::predicates::nearest<Geometry>(geometry, k);
00336 }
00337 
00338 #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
00339 
00361 template <typename SegmentOrLinestring> inline
00362 detail::predicates::path<SegmentOrLinestring>
00363 path(SegmentOrLinestring const& linestring, unsigned k)
00364 {
00365     return detail::predicates::path<SegmentOrLinestring>(linestring, k);
00366 }
00367 
00368 #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
00369 
00370 namespace detail { namespace predicates {
00371 
00372 // operator! generators
00373 
00374 template <typename Fun, bool Negated> inline
00375 satisfies<Fun, !Negated>
00376 operator!(satisfies<Fun, Negated> const& p)
00377 {
00378     return satisfies<Fun, !Negated>(p);
00379 }
00380 
00381 template <typename Geometry, typename Tag, bool Negated> inline
00382 spatial_predicate<Geometry, Tag, !Negated>
00383 operator!(spatial_predicate<Geometry, Tag, Negated> const& p)
00384 {
00385     return spatial_predicate<Geometry, Tag, !Negated>(p.geometry);
00386 }
00387 
00388 // operator&& generators
00389 
00390 template <typename Pred1, typename Pred2> inline
00391 boost::tuples::cons<
00392     Pred1,
00393     boost::tuples::cons<Pred2, boost::tuples::null_type>
00394 >
00395 operator&&(Pred1 const& p1, Pred2 const& p2)
00396 {
00397     /*typedef typename boost::mpl::if_c<is_predicate<Pred1>::value, Pred1, Pred1 const&>::type stored1;
00398     typedef typename boost::mpl::if_c<is_predicate<Pred2>::value, Pred2, Pred2 const&>::type stored2;*/
00399     namespace bt = boost::tuples;
00400 
00401     return
00402     bt::cons< Pred1, bt::cons<Pred2, bt::null_type> >
00403         ( p1, bt::cons<Pred2, bt::null_type>(p2, bt::null_type()) );
00404 }
00405 
00406 template <typename Head, typename Tail, typename Pred> inline
00407 typename tuples::push_back<
00408     boost::tuples::cons<Head, Tail>, Pred
00409 >::type
00410 operator&&(boost::tuples::cons<Head, Tail> const& t, Pred const& p)
00411 {
00412     //typedef typename boost::mpl::if_c<is_predicate<Pred>::value, Pred, Pred const&>::type stored;
00413     namespace bt = boost::tuples;
00414 
00415     return
00416     tuples::push_back<
00417         bt::cons<Head, Tail>, Pred
00418     >::apply(t, p);
00419 }
00420     
00421 }} // namespace detail::predicates
00422 
00423 }}} // namespace boost::geometry::index
00424 
00425 #endif // BOOST_GEOMETRY_INDEX_PREDICATES_HPP
 All Classes Functions Typedefs