Chris@16: // Boost.Geometry Index Chris@16: // Chris@16: // Spatial index distance predicates, calculators and checkers used in nearest neighbor query Chris@16: // Chris@16: // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. Chris@16: // Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP Chris@16: #define BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: /*! Chris@16: \defgroup nearest_relations Nearest relations (boost::geometry::index::) Chris@16: */ Chris@16: Chris@16: namespace boost { namespace geometry { namespace index { Chris@16: Chris@16: // relations generators Chris@16: Chris@16: #ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL Chris@16: Chris@16: /*! Chris@16: \brief Generate to_nearest() relationship. Chris@16: Chris@16: Generate a nearest query Point and Value's Indexable relationship while calculating Chris@16: distances. This function may be used to define that knn query should calculate distances Chris@16: as smallest as possible between query Point and Indexable's points. In other words it Chris@16: should be the distance to the nearest Indexable's point. This function may be also used Chris@16: to define distances bounds which indicates that Indexable's nearest point should be Chris@16: closer or further than value v. This is default relation. Chris@16: Chris@16: \ingroup nearest_relations Chris@16: Chris@16: \tparam T Type of wrapped object. This may be a Point for PointRelation or CoordinateType for Chris@16: MinRelation or MaxRelation Chris@16: Chris@16: \param v Point or distance value. Chris@16: */ Chris@16: template Chris@16: detail::to_nearest to_nearest(T const& v) Chris@16: { Chris@16: return detail::to_nearest(v); Chris@16: } Chris@16: Chris@16: /*! Chris@16: \brief Generate to_centroid() relationship. Chris@16: Chris@16: Generate a nearest query Point and Value's Indexable relationship while calculating Chris@16: distances. This function may be used to define that knn query should calculate distances Chris@16: between query Point and Indexable's centroid. This function may be also used Chris@16: to define distances bounds which indicates that Indexable's centroid should be Chris@16: closer or further than value v. Chris@16: Chris@16: \ingroup nearest_relations Chris@16: Chris@16: \tparam T Type of wrapped object. This may be a Point for PointRelation or some CoordinateType for Chris@16: MinRelation or MaxRelation Chris@16: Chris@16: \param v Point or distance value. Chris@16: */ Chris@16: template Chris@16: detail::to_centroid to_centroid(T const& v) Chris@16: { Chris@16: return detail::to_centroid(v); Chris@16: } Chris@16: Chris@16: /*! Chris@16: \brief Generate to_furthest() relationship. Chris@16: Chris@16: Generate a nearest query Point and Value's Indexable relationship while calculating Chris@16: distances. This function may be used to define that knn query should calculate distances Chris@16: as biggest as possible between query Point and Indexable's points. In other words it Chris@16: should be the distance to the furthest Indexable's point. This function may be also used Chris@16: to define distances bounds which indicates that Indexable's furthest point should be Chris@16: closer or further than value v. Chris@16: Chris@16: \ingroup nearest_relations Chris@16: Chris@16: \tparam T Type of wrapped object. This may be a Point for PointRelation or some CoordinateType for Chris@16: MinRelation or MaxRelation Chris@16: Chris@16: \param v Point or distance value. Chris@16: */ Chris@16: template Chris@16: detail::to_furthest to_furthest(T const& v) Chris@16: { Chris@16: return detail::to_furthest(v); Chris@16: } Chris@16: Chris@16: #endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL Chris@16: Chris@16: // distance predicates generators Chris@16: Chris@16: /*! Chris@16: \brief Generate unbounded() distance predicate. Chris@16: Chris@16: Generate a distance predicate. This defines distances bounds which are used by knn query. Chris@16: This function indicates that there is no distance bounds and Values should be returned Chris@16: if distances between Point and Indexable are the smallest. Distance calculation is defined Chris@16: by PointRelation. This is default nearest predicate. Chris@16: Chris@16: \ingroup distance_predicates Chris@16: Chris@16: \tparam PointRelation PointRelation type. Chris@16: Chris@16: \param pr The point relation. This may be generated by \c index::to_nearest(), Chris@16: \c index::to_centroid() or \c index::to_furthest() with \c Point passed as a parameter. Chris@16: */ Chris@16: //template Chris@16: //inline detail::unbounded Chris@16: //unbounded(PointRelation const& pr) Chris@16: //{ Chris@16: // return detail::unbounded(pr); Chris@16: //} Chris@16: Chris@16: /*! Chris@16: \brief Generate min_bounded() distance predicate. Chris@16: Chris@16: Generate a distance predicate. This defines distances bounds which are used by knn query. Chris@16: This function indicates that Values should be returned only if distances between Point and Chris@16: Indexable are greater or equal to some min_distance passed in MinRelation. Check for closest Value is Chris@16: defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some Chris@16: Point but only if nearest points are further than some distance. Chris@16: Chris@16: \ingroup distance_predicates Chris@16: Chris@16: \tparam PointRelation PointRelation type. Chris@16: \tparam MinRelation MinRelation type. Chris@16: Chris@16: \param pr The point relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with \c Point passed as a parameter. Chris@16: \param minr The minimum bound relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with distance value passed as a parameter. Chris@16: */ Chris@16: //template Chris@16: //inline detail::min_bounded Chris@16: //min_bounded(PointRelation const& pr, MinRelation const& minr) Chris@16: //{ Chris@16: // return detail::min_bounded(pr, minr); Chris@16: //} Chris@16: Chris@16: /*! Chris@16: \brief Generate max_bounded() distance predicate. Chris@16: Chris@16: Generate a distance predicate. This defines distances bounds which are used by knn query. Chris@16: This function indicates that Values should be returned only if distances between Point and Chris@16: Indexable are lesser or equal to some max_distance passed in MaxRelation. Check for closest Value is Chris@16: defined by PointRelation. So it is possible e.g. to return Values with centroids closest to some Chris@16: Point but only if nearest points are closer than some distance. Chris@16: Chris@16: \ingroup distance_predicates Chris@16: Chris@16: \tparam PointRelation PointRelation type. Chris@16: \tparam MaxRelation MaxRelation type. Chris@16: Chris@16: \param pr The point relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with \c Point passed as a parameter. Chris@16: \param maxr The maximum bound relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with distance value passed as a parameter. Chris@16: */ Chris@16: //template Chris@16: //inline detail::max_bounded Chris@16: //max_bounded(PointRelation const& pr, MaxRelation const& maxr) Chris@16: //{ Chris@16: // return detail::max_bounded(pr, maxr); Chris@16: //} Chris@16: Chris@16: /*! Chris@16: \brief Generate bounded() distance predicate. Chris@16: Chris@16: Generate a distance predicate. This defines distances bounds which are used by knn query. Chris@16: This function indicates that Values should be returned only if distances between Point and Chris@16: Indexable are greater or equal to some min_distance passed in MinRelation and lesser or equal to Chris@16: some max_distance passed in MaxRelation. Check for closest Value is defined by PointRelation. Chris@16: So it is possible e.g. to return Values with centroids closest to some Point but only if nearest Chris@16: points are further than some distance and closer than some other distance. Chris@16: Chris@16: \ingroup distance_predicates Chris@16: Chris@16: \tparam PointRelation PointRelation type. Chris@16: \tparam MinRelation MinRelation type. Chris@16: \tparam MaxRelation MaxRelation type. Chris@16: Chris@16: \param pr The point relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with \c Point passed as a parameter. Chris@16: \param minr The minimum bound relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with distance value passed as a parameter. Chris@16: \param maxr The maximum bound relation. This may be generated by \c to_nearest(), Chris@16: \c to_centroid() or \c to_furthest() with distance value passed as a parameter. Chris@16: */ Chris@16: //template Chris@16: //inline detail::bounded Chris@16: //bounded(PointRelation const& pr, MinRelation const& minr, MaxRelation const& maxr) Chris@16: //{ Chris@16: // return detail::bounded(pr, minr, maxr); Chris@16: //} Chris@16: Chris@16: }}} // namespace boost::geometry::index Chris@16: Chris@16: #endif // BOOST_GEOMETRY_INDEX_DISTANCE_PREDICATES_HPP