add boost on mac
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_GEOMETRY_TO_RANGE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_GEOMETRY_TO_RANGE_HPP
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/dispatch/distance.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace closest_feature
|
||||
{
|
||||
|
||||
|
||||
|
||||
// returns the range iterator the realizes the closest
|
||||
// distance between the geometry and the element of the range
|
||||
class geometry_to_range
|
||||
{
|
||||
private:
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename RangeIterator,
|
||||
typename Strategy,
|
||||
typename Distance
|
||||
>
|
||||
static inline void apply(Geometry const& geometry,
|
||||
RangeIterator first,
|
||||
RangeIterator last,
|
||||
Strategy const& strategy,
|
||||
RangeIterator& it_min,
|
||||
Distance& dist_min)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT( first != last );
|
||||
|
||||
Distance const zero = Distance(0);
|
||||
|
||||
// start with first distance
|
||||
it_min = first;
|
||||
dist_min = dispatch::distance
|
||||
<
|
||||
Geometry,
|
||||
typename std::iterator_traits<RangeIterator>::value_type,
|
||||
Strategy
|
||||
>::apply(geometry, *it_min, strategy);
|
||||
|
||||
// check if other elements in the range are closer
|
||||
for (RangeIterator it = ++first; it != last; ++it)
|
||||
{
|
||||
Distance dist = dispatch::distance
|
||||
<
|
||||
Geometry,
|
||||
typename std::iterator_traits<RangeIterator>::value_type,
|
||||
Strategy
|
||||
>::apply(geometry, *it, strategy);
|
||||
|
||||
if (geometry::math::equals(dist, zero))
|
||||
{
|
||||
dist_min = dist;
|
||||
it_min = it;
|
||||
return;
|
||||
}
|
||||
else if (dist < dist_min)
|
||||
{
|
||||
dist_min = dist;
|
||||
it_min = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename RangeIterator,
|
||||
typename Strategy,
|
||||
typename Distance
|
||||
>
|
||||
static inline RangeIterator apply(Geometry const& geometry,
|
||||
RangeIterator first,
|
||||
RangeIterator last,
|
||||
Strategy const& strategy,
|
||||
Distance& dist_min)
|
||||
{
|
||||
RangeIterator it_min;
|
||||
apply(geometry, first, last, strategy, it_min, dist_min);
|
||||
|
||||
return it_min;
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename RangeIterator,
|
||||
typename Strategy
|
||||
>
|
||||
static inline RangeIterator apply(Geometry const& geometry,
|
||||
RangeIterator first,
|
||||
RangeIterator last,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typename strategy::distance::services::return_type
|
||||
<
|
||||
Strategy,
|
||||
typename point_type<Geometry>::type,
|
||||
typename point_type
|
||||
<
|
||||
typename std::iterator_traits
|
||||
<
|
||||
RangeIterator
|
||||
>::value_type
|
||||
>::type
|
||||
>::type dist_min;
|
||||
|
||||
return apply(geometry, first, last, strategy, dist_min);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace detail::closest_feature
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_GEOMETRY_TO_RANGE_HPP
|
||||
@@ -0,0 +1,250 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_POINT_TO_RANGE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_POINT_TO_RANGE_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/closure.hpp>
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace closest_feature
|
||||
{
|
||||
|
||||
|
||||
// returns the segment (pair of iterators) that realizes the closest
|
||||
// distance of the point to the range
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Range,
|
||||
closure_selector Closure,
|
||||
typename Strategy
|
||||
>
|
||||
class point_to_point_range
|
||||
{
|
||||
protected:
|
||||
typedef typename boost::range_iterator<Range const>::type iterator_type;
|
||||
|
||||
template <typename Distance>
|
||||
static inline void apply(Point const& point,
|
||||
iterator_type first,
|
||||
iterator_type last,
|
||||
Strategy const& strategy,
|
||||
iterator_type& it_min1,
|
||||
iterator_type& it_min2,
|
||||
Distance& dist_min)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT( first != last );
|
||||
|
||||
Distance const zero = Distance(0);
|
||||
|
||||
iterator_type it = first;
|
||||
iterator_type prev = it++;
|
||||
if (it == last)
|
||||
{
|
||||
it_min1 = it_min2 = first;
|
||||
dist_min = strategy.apply(point, *first, *first);
|
||||
return;
|
||||
}
|
||||
|
||||
// start with first segment distance
|
||||
dist_min = strategy.apply(point, *prev, *it);
|
||||
iterator_type prev_min_dist = prev;
|
||||
|
||||
// check if other segments are closer
|
||||
for (++prev, ++it; it != last; ++prev, ++it)
|
||||
{
|
||||
Distance dist = strategy.apply(point, *prev, *it);
|
||||
if (geometry::math::equals(dist, zero))
|
||||
{
|
||||
dist_min = zero;
|
||||
it_min1 = prev;
|
||||
it_min2 = it;
|
||||
return;
|
||||
}
|
||||
else if (dist < dist_min)
|
||||
{
|
||||
dist_min = dist;
|
||||
prev_min_dist = prev;
|
||||
}
|
||||
}
|
||||
|
||||
it_min1 = it_min2 = prev_min_dist;
|
||||
++it_min2;
|
||||
}
|
||||
|
||||
public:
|
||||
typedef typename std::pair<iterator_type, iterator_type> return_type;
|
||||
|
||||
template <typename Distance>
|
||||
static inline return_type apply(Point const& point,
|
||||
iterator_type first,
|
||||
iterator_type last,
|
||||
Strategy const& strategy,
|
||||
Distance& dist_min)
|
||||
{
|
||||
iterator_type it_min1, it_min2;
|
||||
apply(point, first, last, strategy, it_min1, it_min2, dist_min);
|
||||
|
||||
return std::make_pair(it_min1, it_min2);
|
||||
}
|
||||
|
||||
static inline return_type apply(Point const& point,
|
||||
iterator_type first,
|
||||
iterator_type last,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typename strategy::distance::services::return_type
|
||||
<
|
||||
Strategy,
|
||||
Point,
|
||||
typename boost::range_value<Range>::type
|
||||
>::type dist_min;
|
||||
|
||||
return apply(point, first, last, strategy, dist_min);
|
||||
}
|
||||
|
||||
template <typename Distance>
|
||||
static inline return_type apply(Point const& point,
|
||||
Range const& range,
|
||||
Strategy const& strategy,
|
||||
Distance& dist_min)
|
||||
{
|
||||
return apply(point,
|
||||
boost::begin(range),
|
||||
boost::end(range),
|
||||
strategy,
|
||||
dist_min);
|
||||
}
|
||||
|
||||
static inline return_type apply(Point const& point,
|
||||
Range const& range,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return apply(point, boost::begin(range), boost::end(range), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// specialization for open ranges
|
||||
template <typename Point, typename Range, typename Strategy>
|
||||
class point_to_point_range<Point, Range, open, Strategy>
|
||||
: point_to_point_range<Point, Range, closed, Strategy>
|
||||
{
|
||||
private:
|
||||
typedef point_to_point_range<Point, Range, closed, Strategy> base_type;
|
||||
typedef typename base_type::iterator_type iterator_type;
|
||||
|
||||
template <typename Distance>
|
||||
static inline void apply(Point const& point,
|
||||
iterator_type first,
|
||||
iterator_type last,
|
||||
Strategy const& strategy,
|
||||
iterator_type& it_min1,
|
||||
iterator_type& it_min2,
|
||||
Distance& dist_min)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT( first != last );
|
||||
|
||||
base_type::apply(point, first, last, strategy,
|
||||
it_min1, it_min2, dist_min);
|
||||
|
||||
iterator_type it_back = --last;
|
||||
Distance const zero = Distance(0);
|
||||
Distance dist = strategy.apply(point, *it_back, *first);
|
||||
|
||||
if (geometry::math::equals(dist, zero))
|
||||
{
|
||||
dist_min = zero;
|
||||
it_min1 = it_back;
|
||||
it_min2 = first;
|
||||
}
|
||||
else if (dist < dist_min)
|
||||
{
|
||||
dist_min = dist;
|
||||
it_min1 = it_back;
|
||||
it_min2 = first;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
typedef typename std::pair<iterator_type, iterator_type> return_type;
|
||||
|
||||
template <typename Distance>
|
||||
static inline return_type apply(Point const& point,
|
||||
iterator_type first,
|
||||
iterator_type last,
|
||||
Strategy const& strategy,
|
||||
Distance& dist_min)
|
||||
{
|
||||
iterator_type it_min1, it_min2;
|
||||
|
||||
apply(point, first, last, strategy, it_min1, it_min2, dist_min);
|
||||
|
||||
return std::make_pair(it_min1, it_min2);
|
||||
}
|
||||
|
||||
static inline return_type apply(Point const& point,
|
||||
iterator_type first,
|
||||
iterator_type last,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename strategy::distance::services::return_type
|
||||
<
|
||||
Strategy,
|
||||
Point,
|
||||
typename boost::range_value<Range>::type
|
||||
>::type distance_return_type;
|
||||
|
||||
distance_return_type dist_min;
|
||||
|
||||
return apply(point, first, last, strategy, dist_min);
|
||||
}
|
||||
|
||||
template <typename Distance>
|
||||
static inline return_type apply(Point const& point,
|
||||
Range const& range,
|
||||
Strategy const& strategy,
|
||||
Distance& dist_min)
|
||||
{
|
||||
return apply(point,
|
||||
boost::begin(range),
|
||||
boost::end(range),
|
||||
strategy,
|
||||
dist_min);
|
||||
}
|
||||
|
||||
static inline return_type apply(Point const& point,
|
||||
Range const& range,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return apply(point, boost::begin(range), boost::end(range), strategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::closest_feature
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_POINT_TO_RANGE_HPP
|
||||
@@ -0,0 +1,196 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
// Licensed under the Boost Software License version 1.0.
|
||||
// http://www.boost.org/users/license.html
|
||||
|
||||
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_RANGE_TO_RANGE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_RANGE_TO_RANGE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/distance.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace closest_feature
|
||||
{
|
||||
|
||||
|
||||
// returns a pair of a objects where the first is an object of the
|
||||
// r-tree range and the second an object of the query range that
|
||||
// realizes the closest feature of the two ranges
|
||||
class range_to_range_rtree
|
||||
{
|
||||
private:
|
||||
template
|
||||
<
|
||||
typename RTreeRangeIterator,
|
||||
typename QueryRangeIterator,
|
||||
typename Strategy,
|
||||
typename RTreeValueType,
|
||||
typename Distance
|
||||
>
|
||||
static inline void apply(RTreeRangeIterator rtree_first,
|
||||
RTreeRangeIterator rtree_last,
|
||||
QueryRangeIterator queries_first,
|
||||
QueryRangeIterator queries_last,
|
||||
Strategy const& strategy,
|
||||
RTreeValueType& rtree_min,
|
||||
QueryRangeIterator& qit_min,
|
||||
Distance& dist_min)
|
||||
{
|
||||
typedef index::rtree<RTreeValueType, index::linear<8> > rtree_type;
|
||||
|
||||
BOOST_GEOMETRY_ASSERT( rtree_first != rtree_last );
|
||||
BOOST_GEOMETRY_ASSERT( queries_first != queries_last );
|
||||
|
||||
Distance const zero = Distance(0);
|
||||
dist_min = zero;
|
||||
|
||||
// create -- packing algorithm
|
||||
rtree_type rt(rtree_first, rtree_last);
|
||||
|
||||
RTreeValueType t_v;
|
||||
bool first = true;
|
||||
|
||||
for (QueryRangeIterator qit = queries_first;
|
||||
qit != queries_last; ++qit, first = false)
|
||||
{
|
||||
std::size_t n = rt.query(index::nearest(*qit, 1), &t_v);
|
||||
|
||||
BOOST_GEOMETRY_ASSERT( n > 0 );
|
||||
// n above is unused outside BOOST_GEOMETRY_ASSERT,
|
||||
// hence the call to boost::ignore_unused below
|
||||
//
|
||||
// however, t_v (initialized by the call to rt.query(...))
|
||||
// is used below, which is why we cannot put the call to
|
||||
// rt.query(...) inside BOOST_GEOMETRY_ASSERT
|
||||
boost::ignore_unused(n);
|
||||
|
||||
Distance dist = dispatch::distance
|
||||
<
|
||||
RTreeValueType,
|
||||
typename std::iterator_traits
|
||||
<
|
||||
QueryRangeIterator
|
||||
>::value_type,
|
||||
Strategy
|
||||
>::apply(t_v, *qit, strategy);
|
||||
|
||||
if (first || dist < dist_min)
|
||||
{
|
||||
dist_min = dist;
|
||||
rtree_min = t_v;
|
||||
qit_min = qit;
|
||||
if ( math::equals(dist_min, zero) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename RTreeRangeIterator, typename QueryRangeIterator>
|
||||
struct return_type
|
||||
{
|
||||
typedef std::pair
|
||||
<
|
||||
typename std::iterator_traits<RTreeRangeIterator>::value_type,
|
||||
QueryRangeIterator
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename RTreeRangeIterator,
|
||||
typename QueryRangeIterator,
|
||||
typename Strategy,
|
||||
typename Distance
|
||||
>
|
||||
static inline typename return_type
|
||||
<
|
||||
RTreeRangeIterator, QueryRangeIterator
|
||||
>::type apply(RTreeRangeIterator rtree_first,
|
||||
RTreeRangeIterator rtree_last,
|
||||
QueryRangeIterator queries_first,
|
||||
QueryRangeIterator queries_last,
|
||||
Strategy const& strategy,
|
||||
Distance& dist_min)
|
||||
{
|
||||
typedef typename std::iterator_traits
|
||||
<
|
||||
RTreeRangeIterator
|
||||
>::value_type rtree_value_type;
|
||||
|
||||
rtree_value_type rtree_min;
|
||||
QueryRangeIterator qit_min;
|
||||
|
||||
apply(rtree_first, rtree_last, queries_first, queries_last,
|
||||
strategy, rtree_min, qit_min, dist_min);
|
||||
|
||||
return std::make_pair(rtree_min, qit_min);
|
||||
}
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename RTreeRangeIterator,
|
||||
typename QueryRangeIterator,
|
||||
typename Strategy
|
||||
>
|
||||
static inline typename return_type
|
||||
<
|
||||
RTreeRangeIterator, QueryRangeIterator
|
||||
>::type apply(RTreeRangeIterator rtree_first,
|
||||
RTreeRangeIterator rtree_last,
|
||||
QueryRangeIterator queries_first,
|
||||
QueryRangeIterator queries_last,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename std::iterator_traits
|
||||
<
|
||||
RTreeRangeIterator
|
||||
>::value_type rtree_value_type;
|
||||
|
||||
typename strategy::distance::services::return_type
|
||||
<
|
||||
Strategy,
|
||||
typename point_type<rtree_value_type>::type,
|
||||
typename point_type
|
||||
<
|
||||
typename std::iterator_traits
|
||||
<
|
||||
QueryRangeIterator
|
||||
>::value_type
|
||||
>::type
|
||||
>::type dist_min;
|
||||
|
||||
return apply(rtree_first, rtree_last, queries_first, queries_last,
|
||||
strategy, dist_min);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::closest_feature
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_FEATURE_RANGE_TO_RANGE_HPP
|
||||
Reference in New Issue
Block a user