/
usr
/
include
/
boost
/
geometry
/
algorithms
/
/usr/include/boost/geometry/algorithms
mkdir
upload
Name
Size
Mode
Actions
detail/
-
0755
rm
dispatch/
-
0755
rm
append.hpp
11493
0644
edit
dl
rm
area.hpp
10657
0644
edit
dl
rm
assign.hpp
10709
0644
edit
dl
rm
buffer.hpp
8656
0644
edit
dl
rm
centroid.hpp
19620
0644
edit
dl
rm
clear.hpp
5156
0644
edit
dl
rm
comparable_distance.hpp
1107
0644
edit
dl
rm
convert.hpp
17327
0644
edit
dl
rm
convex_hull.hpp
11589
0644
edit
dl
rm
correct.hpp
9956
0644
edit
dl
rm
correct_closure.hpp
5862
0644
edit
dl
rm
covered_by.hpp
1077
0644
edit
dl
rm
crosses.hpp
8478
0644
edit
dl
rm
densify.hpp
12472
0644
edit
dl
rm
difference.hpp
16591
0644
edit
dl
rm
discrete_frechet_distance.hpp
7844
0644
edit
dl
rm
discrete_hausdorff_distance.hpp
11281
0644
edit
dl
rm
disjoint.hpp
1191
0644
edit
dl
rm
distance.hpp
1110
0644
edit
dl
rm
envelope.hpp
1021
0644
edit
dl
rm
equals.hpp
1196
0644
edit
dl
rm
expand.hpp
1073
0644
edit
dl
rm
for_each.hpp
9831
0644
edit
dl
rm
intersection.hpp
806
0644
edit
dl
rm
intersects.hpp
1145
0644
edit
dl
rm
is_convex.hpp
6508
0644
edit
dl
rm
is_empty.hpp
4853
0644
edit
dl
rm
is_simple.hpp
575
0644
edit
dl
rm
is_valid.hpp
570
0644
edit
dl
rm
length.hpp
9341
0644
edit
dl
rm
line_interpolate.hpp
13054
0644
edit
dl
rm
make.hpp
5170
0644
edit
dl
rm
not_implemented.hpp
3839
0644
edit
dl
rm
num_geometries.hpp
3586
0644
edit
dl
rm
num_interior_rings.hpp
3756
0644
edit
dl
rm
num_points.hpp
5565
0644
edit
dl
rm
num_segments.hpp
4775
0644
edit
dl
rm
overlaps.hpp
1067
0644
edit
dl
rm
perimeter.hpp
7212
0644
edit
dl
rm
point_on_surface.hpp
13281
0644
edit
dl
rm
relate.hpp
642
0644
edit
dl
rm
relation.hpp
652
0644
edit
dl
rm
remove_spikes.hpp
9753
0644
edit
dl
rm
reverse.hpp
4386
0644
edit
dl
rm
simplify.hpp
22696
0644
edit
dl
rm
sym_difference.hpp
23169
0644
edit
dl
rm
touches.hpp
1127
0644
edit
dl
rm
transform.hpp
14105
0644
edit
dl
rm
union.hpp
21383
0644
edit
dl
rm
unique.hpp
4682
0644
edit
dl
rm
validity_failure_type.hpp
3684
0644
edit
dl
rm
within.hpp
1057
0644
edit
dl
rm
Edit:
/usr/include/boost/geometry/algorithms/line_interpolate.hpp
(13054B)
// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2018, 2019 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // 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) #ifndef BOOST_GEOMETRY_ALGORITHMS_LINE_INTERPOLATE_HPP #define BOOST_GEOMETRY_ALGORITHMS_LINE_INTERPOLATE_HPP #include <iterator> #include <boost/range/begin.hpp> #include <boost/range/end.hpp> #include <boost/range/iterator.hpp> #include <boost/range/value_type.hpp> #include <boost/geometry/core/cs.hpp> #include <boost/geometry/core/closure.hpp> #include <boost/geometry/core/tags.hpp> #include <boost/geometry/geometries/concepts/check.hpp> #include <boost/geometry/algorithms/assign.hpp> #include <boost/geometry/algorithms/length.hpp> #include <boost/geometry/strategies/default_strategy.hpp> #include <boost/geometry/strategies/line_interpolate.hpp> namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace line_interpolate { struct convert_and_push_back { template <typename Range, typename Point> inline void apply(Point const& p, Range& range) { typename boost::range_value<Range>::type p2; geometry::detail::conversion::convert_point_to_point(p, p2); range::push_back(range, p2); } }; struct convert_and_assign { template <typename Point1, typename Point2> inline void apply(Point1 const& p1, Point2& p2) { geometry::detail::conversion::convert_point_to_point(p1, p2); } }; /*! \brief Internal, calculates interpolation point of a linestring using iterator pairs and specified strategy */ template <typename Policy> struct interpolate_range { template < typename Range, typename Distance, typename PointLike, typename Strategy > static inline void apply(Range const& range, Distance const& max_distance, PointLike & pointlike, Strategy const& strategy) { Policy policy; typedef typename boost::range_iterator<Range const>::type iterator_t; typedef typename boost::range_value<Range const>::type point_t; iterator_t it = boost::begin(range); iterator_t end = boost::end(range); if (it == end) // empty(range) { BOOST_THROW_EXCEPTION(empty_input_exception()); return; } if (max_distance <= 0) //non positive distance { policy.apply(*it, pointlike); return; } iterator_t prev = it++; Distance repeated_distance = max_distance; Distance prev_distance = 0; Distance current_distance = 0; point_t start_p = *prev; for ( ; it != end ; ++it) { Distance dist = strategy.get_distance_pp_strategy().apply(*prev, *it); current_distance = prev_distance + dist; while (current_distance >= repeated_distance) { point_t p; Distance diff_distance = current_distance - prev_distance; BOOST_ASSERT(diff_distance != Distance(0)); strategy.apply(start_p, *it, (repeated_distance - prev_distance)/diff_distance, p, diff_distance); policy.apply(p, pointlike); if (boost::is_same<PointLike, point_t>::value) { return; } start_p = p; prev_distance = repeated_distance; repeated_distance += max_distance; } prev_distance = current_distance; prev = it; start_p = *prev; } // case when max_distance is larger than linestring's length // return the last point in range (range is not empty) if (repeated_distance == max_distance) { policy.apply(*(end-1), pointlike); } } }; template <typename Policy> struct interpolate_segment { template <typename Segment, typename Distance, typename Pointlike, typename Strategy> static inline void apply(Segment const& segment, Distance const& max_distance, Pointlike & point, Strategy const& strategy) { interpolate_range<Policy>().apply(segment_view<Segment>(segment), max_distance, point, strategy); } }; }} // namespace detail::line_interpolate #endif // DOXYGEN_NO_DETAIL #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { template < typename Geometry, typename Pointlike, typename Tag1 = typename tag<Geometry>::type, typename Tag2 = typename tag<Pointlike>::type > struct line_interpolate { BOOST_MPL_ASSERT_MSG ( false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE , (types<Geometry>) ); }; template <typename Geometry, typename Pointlike> struct line_interpolate<Geometry, Pointlike, linestring_tag, point_tag> : detail::line_interpolate::interpolate_range < detail::line_interpolate::convert_and_assign > {}; template <typename Geometry, typename Pointlike> struct line_interpolate<Geometry, Pointlike, linestring_tag, multi_point_tag> : detail::line_interpolate::interpolate_range < detail::line_interpolate::convert_and_push_back > {}; template <typename Geometry, typename Pointlike> struct line_interpolate<Geometry, Pointlike, segment_tag, point_tag> : detail::line_interpolate::interpolate_segment < detail::line_interpolate::convert_and_assign > {}; template <typename Geometry, typename Pointlike> struct line_interpolate<Geometry, Pointlike, segment_tag, multi_point_tag> : detail::line_interpolate::interpolate_segment < detail::line_interpolate::convert_and_push_back > {}; } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH namespace resolve_strategy { struct line_interpolate { template < typename Geometry, typename Distance, typename Pointlike, typename Strategy > static inline void apply(Geometry const& geometry, Distance const& max_distance, Pointlike & pointlike, Strategy const& strategy) { dispatch::line_interpolate<Geometry, Pointlike>::apply(geometry, max_distance, pointlike, strategy); } template <typename Geometry, typename Distance, typename Pointlike> static inline void apply(Geometry const& geometry, Distance const& max_distance, Pointlike & pointlike, default_strategy) { typedef typename strategy::line_interpolate::services::default_strategy < typename cs_tag<Geometry>::type >::type strategy_type; dispatch::line_interpolate<Geometry, Pointlike>::apply(geometry, max_distance, pointlike, strategy_type()); } }; } // namespace resolve_strategy namespace resolve_variant { template <typename Geometry> struct line_interpolate { template <typename Distance, typename Pointlike, typename Strategy> static inline void apply(Geometry const& geometry, Distance const& max_distance, Pointlike & pointlike, Strategy const& strategy) { return resolve_strategy::line_interpolate::apply(geometry, max_distance, pointlike, strategy); } }; template <BOOST_VARIANT_ENUM_PARAMS(typename T)> struct line_interpolate<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> > { template <typename Pointlike, typename Strategy> struct visitor: boost::static_visitor<void> { Pointlike const& m_pointlike; Strategy const& m_strategy; visitor(Pointlike const& pointlike, Strategy const& strategy) : m_pointlike(pointlike) , m_strategy(strategy) {} template <typename Geometry, typename Distance> void operator()(Geometry const& geometry, Distance const& max_distance) const { line_interpolate<Geometry>::apply(geometry, max_distance, m_pointlike, m_strategy); } }; template <typename Distance, typename Pointlike, typename Strategy> static inline void apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry, double const& max_distance, Pointlike & pointlike, Strategy const& strategy) { boost::apply_visitor( visitor<Pointlike, Strategy>(pointlike, strategy), geometry, max_distance ); } }; } // namespace resolve_variant /*! \brief Returns one or more points interpolated along a LineString \brief_strategy \ingroup line_interpolate \tparam Geometry Any type fulfilling a LineString concept \tparam Distance A numerical distance measure \tparam Pointlike Any type fulfilling Point or Multipoint concept \tparam Strategy A type fulfilling a LineInterpolatePointStrategy concept \param geometry Input geometry \param max_distance Distance threshold (in units depending on coordinate system) representing the spacing between the points \param pointlike Output: either a Point (exactly one point will be constructed) or a MultiPoint (depending on the max_distance one or more points will be constructed) \param strategy line_interpolate strategy to be used for interpolation of points \qbk{[include reference/algorithms/line_interpolate.qbk]} \qbk{distinguish,with strategy} \qbk{ [heading Available Strategies] \* [link geometry.reference.strategies.strategy_line_interpolate_cartesian Cartesian] \* [link geometry.reference.strategies.strategy_line_interpolate_spherical Spherical] \* [link geometry.reference.strategies.strategy_line_interpolate_geographic Geographic] [heading Example] [line_interpolate_strategy] [line_interpolate_strategy_output] [heading See also] \* [link geometry.reference.algorithms.densify densify] } */ template < typename Geometry, typename Distance, typename Pointlike, typename Strategy > inline void line_interpolate(Geometry const& geometry, Distance const& max_distance, Pointlike & pointlike, Strategy const& strategy) { concepts::check<Geometry const>(); // detail::throw_on_empty_input(geometry); return resolve_variant::line_interpolate<Geometry> ::apply(geometry, max_distance, pointlike, strategy); } /*! \brief Returns one or more points interpolated along a LineString. \ingroup line_interpolate \tparam Geometry Any type fulfilling a LineString concept \tparam Distance A numerical distance measure \tparam Pointlike Any type fulfilling Point or Multipoint concept \param geometry Input geometry \param max_distance Distance threshold (in units depending on coordinate system) representing the spacing between the points \param pointlike Output: either a Point (exactly one point will be constructed) or a MultiPoint (depending on the max_distance one or more points will be constructed) \qbk{[include reference/algorithms/line_interpolate.qbk] [heading Example] [line_interpolate] [line_interpolate_output] [heading See also] \* [link geometry.reference.algorithms.densify densify] } */ template<typename Geometry, typename Distance, typename Pointlike> inline void line_interpolate(Geometry const& geometry, Distance const& max_distance, Pointlike & pointlike) { concepts::check<Geometry const>(); // detail::throw_on_empty_input(geometry); return resolve_variant::line_interpolate<Geometry> ::apply(geometry, max_distance, pointlike, default_strategy()); } }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_LINE_INTERPOLATE_HPP
Save
cmd:
run