mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-18 13:18:12 +00:00
Added thirdparty: boost library
This commit is contained in:
Vendored
Executable
+119
@@ -0,0 +1,119 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/buffer.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Let the buffer for linestrings be asymmetric
|
||||
\ingroup strategies
|
||||
\tparam NumericType \tparam_numeric
|
||||
\details This strategy can be used as DistanceStrategy for the buffer algorithm.
|
||||
It can be applied for (multi)linestrings. It uses a (potentially) different
|
||||
distances for left and for right. This means the (multi)linestrings are
|
||||
interpreted having a direction.
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_distance_asymmetric]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_distance_asymmetric.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
\* [link geometry.reference.strategies.strategy_buffer_distance_symmetric distance_symmetric]
|
||||
}
|
||||
*/
|
||||
template<typename NumericType>
|
||||
class distance_asymmetric
|
||||
{
|
||||
public :
|
||||
//! \brief Constructs the strategy, two distances must be specified
|
||||
//! \param left The distance (or radius) of the buffer on the left side
|
||||
//! \param right The distance on the right side
|
||||
distance_asymmetric(NumericType const& left,
|
||||
NumericType const& right)
|
||||
: m_left(left)
|
||||
, m_right(right)
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
//! Returns the distance-value for the specified side
|
||||
template <typename Point>
|
||||
inline NumericType apply(Point const& , Point const& ,
|
||||
buffer_side_selector side) const
|
||||
{
|
||||
NumericType result = side == buffer_side_left ? m_left : m_right;
|
||||
return negative() ? math::abs(result) : result;
|
||||
}
|
||||
|
||||
//! Used internally, returns -1 for deflate, 1 for inflate
|
||||
inline int factor() const
|
||||
{
|
||||
return negative() ? -1 : 1;
|
||||
}
|
||||
|
||||
//! Returns true if both distances are negative
|
||||
inline bool negative() const
|
||||
{
|
||||
return m_left < 0 && m_right < 0;
|
||||
}
|
||||
|
||||
inline bool empty(buffer_side_selector side) const
|
||||
{
|
||||
return side == buffer_side_left ? m_left == 0 : m_right == 0;
|
||||
}
|
||||
|
||||
//! Returns the max distance distance up to the buffer will reach
|
||||
template <typename JoinStrategy, typename EndStrategy>
|
||||
inline NumericType max_distance(JoinStrategy const& join_strategy,
|
||||
EndStrategy const& end_strategy) const
|
||||
{
|
||||
boost::ignore_unused(join_strategy, end_strategy);
|
||||
|
||||
NumericType const left = geometry::math::abs(m_left);
|
||||
NumericType const right = geometry::math::abs(m_right);
|
||||
NumericType const dist = (std::max)(left, right);
|
||||
return (std::max)(join_strategy.max_distance(dist),
|
||||
end_strategy.max_distance(dist));
|
||||
}
|
||||
|
||||
//! Returns the distance at which the input is simplified before the buffer process
|
||||
inline NumericType simplify_distance() const
|
||||
{
|
||||
NumericType const left = geometry::math::abs(m_left);
|
||||
NumericType const right = geometry::math::abs(m_right);
|
||||
return (std::min)(left, right) / 1000.0;
|
||||
}
|
||||
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
NumericType m_left;
|
||||
NumericType m_right;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_ASYMMETRIC_HPP
|
||||
Vendored
Executable
+112
@@ -0,0 +1,112 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP
|
||||
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/buffer.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace buffer
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Let the buffer algorithm create buffers with same distances
|
||||
\ingroup strategies
|
||||
\tparam NumericType \tparam_numeric
|
||||
\details This strategy can be used as DistanceStrategy for the buffer algorithm.
|
||||
It can be applied for all geometries. It uses one distance for left and
|
||||
for right.
|
||||
If the distance is negative and used with a (multi)polygon or ring, the
|
||||
geometry will shrink (deflate) instead of expand (inflate).
|
||||
|
||||
\qbk{
|
||||
[heading Example]
|
||||
[buffer_distance_symmetric]
|
||||
[heading Output]
|
||||
[$img/strategies/buffer_distance_symmetric.png]
|
||||
[heading See also]
|
||||
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
|
||||
\* [link geometry.reference.strategies.strategy_buffer_distance_asymmetric distance_asymmetric]
|
||||
}
|
||||
*/
|
||||
template<typename NumericType>
|
||||
class distance_symmetric
|
||||
{
|
||||
public :
|
||||
//! \brief Constructs the strategy, a distance must be specified
|
||||
//! \param distance The distance (or radius) of the buffer
|
||||
explicit inline distance_symmetric(NumericType const& distance)
|
||||
: m_distance(distance)
|
||||
{}
|
||||
|
||||
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
||||
//! Returns the distance-value
|
||||
template <typename Point>
|
||||
inline NumericType apply(Point const& , Point const& ,
|
||||
buffer_side_selector ) const
|
||||
{
|
||||
return negative() ? geometry::math::abs(m_distance) : m_distance;
|
||||
}
|
||||
|
||||
//! Used internally, returns -1 for deflate, 1 for inflate
|
||||
inline int factor() const
|
||||
{
|
||||
return negative() ? -1 : 1;
|
||||
}
|
||||
|
||||
//! Returns true if distance is negative (aka deflate)
|
||||
inline bool negative() const
|
||||
{
|
||||
return m_distance < 0;
|
||||
}
|
||||
|
||||
inline bool empty(buffer_side_selector ) const
|
||||
{
|
||||
return m_distance == 0;
|
||||
}
|
||||
|
||||
//! Returns the max distance distance up to the buffer will reach
|
||||
template <typename JoinStrategy, typename EndStrategy>
|
||||
inline NumericType max_distance(JoinStrategy const& join_strategy,
|
||||
EndStrategy const& end_strategy) const
|
||||
{
|
||||
boost::ignore_unused(join_strategy, end_strategy);
|
||||
|
||||
NumericType const dist = geometry::math::abs(m_distance);
|
||||
return (std::max)(join_strategy.max_distance(dist),
|
||||
end_strategy.max_distance(dist));
|
||||
}
|
||||
|
||||
|
||||
//! Returns the distance at which the input is simplified before the buffer process
|
||||
inline NumericType simplify_distance() const
|
||||
{
|
||||
return geometry::math::abs(m_distance) / 1000.0;
|
||||
}
|
||||
#endif // DOXYGEN_SHOULD_SKIP_THIS
|
||||
|
||||
private :
|
||||
NumericType m_distance;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::buffer
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_DISTANCE_SYMMETRIC_HPP
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2018-2020.
|
||||
// Modifications copyright (c) 2018-2020 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_STRATEGIES_AGNOSTIC_POINT_IN_BOX_BY_SIDE_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_POINT_IN_BOX_BY_SIDE_HPP
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/strategies/covered_by.hpp>
|
||||
#include <boost/geometry/strategies/geographic/side.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/ssf.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace strategy
|
||||
{
|
||||
|
||||
namespace within
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct decide_within
|
||||
{
|
||||
static inline bool apply(int side, bool& result)
|
||||
{
|
||||
if (side != 1)
|
||||
{
|
||||
result = false;
|
||||
return false;
|
||||
}
|
||||
return true; // continue
|
||||
}
|
||||
};
|
||||
|
||||
struct decide_covered_by
|
||||
{
|
||||
static inline bool apply(int side, bool& result)
|
||||
{
|
||||
if (side != 1)
|
||||
{
|
||||
result = side >= 0;
|
||||
return false;
|
||||
}
|
||||
return true; // continue
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// WARNING
|
||||
// This strategy is not suitable for boxes in non-cartesian CSes having edges
|
||||
// longer than 180deg because e.g. the SSF formula picks the side of the closer
|
||||
// longitude, so for long edges the side is the opposite.
|
||||
// Actually it is not suitable for shorter edges either because the edges of
|
||||
// boxes are defined by meridians and parallels, not great circles or geodesics.
|
||||
template <typename Decide, typename Point, typename Box, typename Strategy>
|
||||
inline bool point_in_box_by_side(Point const& point, Box const& box,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
boost::ignore_unused(strategy);
|
||||
|
||||
// Create (counterclockwise) array of points, the fifth one closes it
|
||||
// Every point should be on the LEFT side (=1), or ON the border (=0),
|
||||
// So >= 1 or >= 0
|
||||
std::array<typename point_type<Box>::type, 5> bp;
|
||||
geometry::detail::assign_box_corners_oriented<true>(box, bp);
|
||||
bp[4] = bp[0];
|
||||
|
||||
bool result = true;
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
int const side = strategy.apply(point, bp[i - 1], bp[i]);
|
||||
if (! Decide::apply(side, result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
// There should probably be another category of geometry different than box,
|
||||
// e.g. rectangle or convex_ring. This strategy should probably be an
|
||||
// algorithm calling side strategy.
|
||||
|
||||
template <typename CalculationType = void>
|
||||
struct cartesian_point_box_by_side
|
||||
{
|
||||
template <typename Point, typename Box>
|
||||
static inline bool apply(Point const& point, Box const& box)
|
||||
{
|
||||
using side_strategy_type
|
||||
= typename strategy::side::services::default_strategy
|
||||
<cartesian_tag, CalculationType>::type;
|
||||
|
||||
return within::detail::point_in_box_by_side
|
||||
<
|
||||
within::detail::decide_within
|
||||
>(point, box, side_strategy_type());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CalculationType = void>
|
||||
struct spherical_point_box_by_side
|
||||
{
|
||||
template <typename Point, typename Box>
|
||||
static inline bool apply(Point const& point, Box const& box)
|
||||
{
|
||||
return within::detail::point_in_box_by_side
|
||||
<
|
||||
within::detail::decide_within
|
||||
>(point, box,
|
||||
strategy::side::spherical_side_formula<CalculationType>());
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct geographic_point_box_by_side
|
||||
{
|
||||
geographic_point_box_by_side() = default;
|
||||
|
||||
explicit geographic_point_box_by_side(Spheroid const& spheroid)
|
||||
: m_side(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename Box>
|
||||
bool apply(Point const& point, Box const& box) const
|
||||
{
|
||||
return within::detail::point_in_box_by_side
|
||||
<
|
||||
within::detail::decide_within
|
||||
>(point, box, m_side);
|
||||
}
|
||||
|
||||
Spheroid const& model() const
|
||||
{
|
||||
return m_side.model();
|
||||
}
|
||||
|
||||
private:
|
||||
strategy::side::geographic
|
||||
<
|
||||
FormulaPolicy, Spheroid, CalculationType
|
||||
> m_side;
|
||||
};
|
||||
|
||||
|
||||
} // namespace within
|
||||
|
||||
|
||||
namespace covered_by
|
||||
{
|
||||
|
||||
|
||||
template <typename CalculationType = void>
|
||||
struct cartesian_point_box_by_side
|
||||
{
|
||||
template <typename Point, typename Box>
|
||||
static bool apply(Point const& point, Box const& box)
|
||||
{
|
||||
using side_strategy_type
|
||||
= typename strategy::side::services::default_strategy
|
||||
<cartesian_tag, CalculationType>::type;
|
||||
return within::detail::point_in_box_by_side
|
||||
<
|
||||
within::detail::decide_covered_by
|
||||
>(point, box, side_strategy_type());
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CalculationType = void>
|
||||
struct spherical_point_box_by_side
|
||||
{
|
||||
template <typename Point, typename Box>
|
||||
static bool apply(Point const& point, Box const& box)
|
||||
{
|
||||
return within::detail::point_in_box_by_side
|
||||
<
|
||||
within::detail::decide_covered_by
|
||||
>(point, box,
|
||||
strategy::side::spherical_side_formula<CalculationType>());
|
||||
}
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename FormulaPolicy = strategy::andoyer,
|
||||
typename Spheroid = srs::spheroid<double>,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct geographic_point_box_by_side
|
||||
{
|
||||
geographic_point_box_by_side() = default;
|
||||
|
||||
explicit geographic_point_box_by_side(Spheroid const& spheroid)
|
||||
: m_side(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point, typename Box>
|
||||
bool apply(Point const& point, Box const& box) const
|
||||
{
|
||||
return within::detail::point_in_box_by_side
|
||||
<
|
||||
within::detail::decide_covered_by
|
||||
>(point, box, m_side);
|
||||
}
|
||||
|
||||
Spheroid const& model() const
|
||||
{
|
||||
return m_side.model();
|
||||
}
|
||||
|
||||
private:
|
||||
strategy::side::geographic
|
||||
<
|
||||
FormulaPolicy, Spheroid, CalculationType
|
||||
> m_side;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}}} // namespace boost::geometry::strategy
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_POINT_IN_BOX_BY_SIDE_HPP
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2014-2018 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)
|
||||
|
||||
|
||||
#ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/point_in_point.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_point.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename Point1, typename Point2,
|
||||
typename CSTag = typename cs_tag<Point1>::type
|
||||
>
|
||||
struct point_in_point
|
||||
: strategy::within::cartesian_point_point
|
||||
{};
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
struct point_in_point<Point1, Point2, spherical_equatorial_tag>
|
||||
: strategy::within::spherical_point_point
|
||||
{};
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
struct point_in_point<Point1, Point2, spherical_polar_tag>
|
||||
: strategy::within::spherical_point_point
|
||||
{};
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
struct point_in_point<Point1, Point2, geographic_tag>
|
||||
: strategy::within::spherical_point_point
|
||||
{};
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POINT_HPP
|
||||
Vendored
Executable
+211
@@ -0,0 +1,211 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Copyright (c) 2023, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/point_order.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Within detection using winding rule, but checking if enclosing ring is
|
||||
counter clockwise and, if so, reverses the result
|
||||
\ingroup strategies
|
||||
\tparam Point \tparam_point
|
||||
\tparam Reverse True if parameter should be reversed
|
||||
\tparam PointOfSegment \tparam_segment_point
|
||||
\tparam CalculationType \tparam_calculation
|
||||
\author Barend Gehrels
|
||||
\note Only dependant on "side", -> agnostic, suitable for spherical/latlong
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
bool Reverse,
|
||||
typename Point,
|
||||
typename PointOfSegment = Point,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class oriented_winding
|
||||
{
|
||||
typedef typename select_calculation_type
|
||||
<
|
||||
Point,
|
||||
PointOfSegment,
|
||||
CalculationType
|
||||
>::type calculation_type;
|
||||
|
||||
|
||||
typedef typename strategy::side::services::default_strategy
|
||||
<
|
||||
typename cs_tag<Point>::type
|
||||
>::type strategy_side_type;
|
||||
|
||||
|
||||
/*! subclass to keep state */
|
||||
class counter
|
||||
{
|
||||
int m_count;
|
||||
bool m_touches;
|
||||
calculation_type m_sum_area;
|
||||
|
||||
inline int code() const
|
||||
{
|
||||
return m_touches ? 0 : m_count == 0 ? -1 : 1;
|
||||
}
|
||||
inline int clockwise_oriented_code() const
|
||||
{
|
||||
return (m_sum_area > 0) ? code() : -code();
|
||||
}
|
||||
inline int oriented_code() const
|
||||
{
|
||||
return Reverse
|
||||
? -clockwise_oriented_code()
|
||||
: clockwise_oriented_code();
|
||||
}
|
||||
|
||||
public :
|
||||
friend class oriented_winding;
|
||||
|
||||
inline counter()
|
||||
: m_count(0)
|
||||
, m_touches(false)
|
||||
, m_sum_area(0)
|
||||
{}
|
||||
|
||||
inline void add_to_area(calculation_type triangle)
|
||||
{
|
||||
m_sum_area += triangle;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <size_t D>
|
||||
static inline int check_touch(Point const& point,
|
||||
PointOfSegment const& seg1, PointOfSegment const& seg2,
|
||||
counter& state)
|
||||
{
|
||||
calculation_type const p = get<D>(point);
|
||||
calculation_type const s1 = get<D>(seg1);
|
||||
calculation_type const s2 = get<D>(seg2);
|
||||
if ((s1 <= p && s2 >= p) || (s2 <= p && s1 >= p))
|
||||
{
|
||||
state.m_touches = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
template <size_t D>
|
||||
static inline int check_segment(Point const& point,
|
||||
PointOfSegment const& seg1, PointOfSegment const& seg2,
|
||||
counter& state)
|
||||
{
|
||||
calculation_type const p = get<D>(point);
|
||||
calculation_type const s1 = get<D>(seg1);
|
||||
calculation_type const s2 = get<D>(seg2);
|
||||
|
||||
|
||||
// Check if one of segment endpoints is at same level of point
|
||||
bool eq1 = math::equals(s1, p);
|
||||
bool eq2 = math::equals(s2, p);
|
||||
|
||||
if (eq1 && eq2)
|
||||
{
|
||||
// Both equal p -> segment is horizontal (or vertical for D=0)
|
||||
// The only thing which has to be done is check if point is ON segment
|
||||
return check_touch<1 - D>(point, seg1, seg2, state);
|
||||
}
|
||||
|
||||
return
|
||||
eq1 ? (s2 > p ? 1 : -1) // Point on level s1, UP/DOWN depending on s2
|
||||
: eq2 ? (s1 > p ? -1 : 1) // idem
|
||||
: s1 < p && s2 > p ? 2 // Point between s1 -> s2 --> UP
|
||||
: s2 < p && s1 > p ? -2 // Point between s2 -> s1 --> DOWN
|
||||
: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public :
|
||||
|
||||
// Typedefs and static methods to fulfill the concept
|
||||
typedef Point point_type;
|
||||
typedef PointOfSegment segment_point_type;
|
||||
typedef counter state_type;
|
||||
|
||||
static inline bool apply(Point const& point,
|
||||
PointOfSegment const& s1, PointOfSegment const& s2,
|
||||
counter& state)
|
||||
{
|
||||
state.add_to_area(get<0>(s2) * get<1>(s1) - get<0>(s1) * get<1>(s2));
|
||||
|
||||
int count = check_segment<1>(point, s1, s2, state);
|
||||
if (count != 0)
|
||||
{
|
||||
int side = strategy_side_type::apply(s1, s2, point);
|
||||
if (side == 0)
|
||||
{
|
||||
// Point is lying on segment
|
||||
state.m_touches = true;
|
||||
state.m_count = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Side is NEG for right, POS for left.
|
||||
// The count is -2 for down, 2 for up (or -1/1)
|
||||
// Side positive thus means UP and LEFTSIDE or DOWN and RIGHTSIDE
|
||||
// See accompagnying figure (TODO)
|
||||
if (side * count > 0)
|
||||
{
|
||||
state.m_count += count;
|
||||
}
|
||||
}
|
||||
return ! state.m_touches;
|
||||
}
|
||||
|
||||
static inline int result(counter const& state)
|
||||
{
|
||||
return state.oriented_code();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013-2020.
|
||||
// Modifications copyright (c) 2013-2020 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
#include <boost/geometry/core/tag_cast.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/point_in_poly_winding.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace within
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename PointOfSegment,
|
||||
typename CalculationType,
|
||||
typename CSTag = typename tag_cast
|
||||
<
|
||||
typename cs_tag<Point>::type,
|
||||
spherical_tag
|
||||
>::type
|
||||
>
|
||||
struct winding_base_type
|
||||
{
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"Not implemented for this coordinate system.",
|
||||
Point, PointOfSegment, CSTag);
|
||||
};
|
||||
|
||||
template <typename Point, typename PointOfSegment, typename CalculationType>
|
||||
struct winding_base_type<Point, PointOfSegment, CalculationType, cartesian_tag>
|
||||
{
|
||||
using type = within::detail::cartesian_winding_base
|
||||
<
|
||||
typename strategy::side::services::default_strategy
|
||||
<
|
||||
typename cs_tag<Point>::type
|
||||
>::type,
|
||||
CalculationType
|
||||
>;
|
||||
};
|
||||
|
||||
template <typename Point, typename PointOfSegment, typename CalculationType>
|
||||
struct winding_base_type<Point, PointOfSegment, CalculationType, spherical_tag>
|
||||
{
|
||||
using type = within::detail::spherical_winding_base
|
||||
<
|
||||
typename strategy::side::services::default_strategy
|
||||
<
|
||||
typename cs_tag<Point>::type
|
||||
>::type,
|
||||
CalculationType
|
||||
>;
|
||||
};
|
||||
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief Within detection using winding rule. Side strategy used internally is
|
||||
choosen based on Point's coordinate system.
|
||||
\ingroup strategies
|
||||
\tparam Point \tparam_point
|
||||
\tparam PointOfSegment \tparam_segment_point
|
||||
\tparam CalculationType \tparam_calculation
|
||||
|
||||
\qbk{
|
||||
[heading See also]
|
||||
[link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
|
||||
}
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename PointOfSegment = Point,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class winding
|
||||
: public within::detail::winding_base_type
|
||||
<
|
||||
Point, PointOfSegment, CalculationType
|
||||
>::type
|
||||
{
|
||||
typedef typename within::detail::winding_base_type
|
||||
<
|
||||
Point, PointOfSegment, CalculationType
|
||||
>::type base_t;
|
||||
|
||||
public:
|
||||
winding() {}
|
||||
|
||||
template <typename Model>
|
||||
explicit winding(Model const& model)
|
||||
: base_t(model)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace strategy::within
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
|
||||
Vendored
Executable
+84
@@ -0,0 +1,84 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 1995, 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 1995 Maarten Hilferink, Amsterdam, the Netherlands
|
||||
|
||||
// This file was modified by Oracle on 2015-2021.
|
||||
// Modifications copyright (c) 2015-2021, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace simplify
|
||||
{
|
||||
|
||||
|
||||
// NOTE: Left here for backward compatibility.
|
||||
|
||||
|
||||
/*!
|
||||
\brief Implements the simplify algorithm.
|
||||
\ingroup strategies
|
||||
\details The douglas_peucker strategy simplifies a linestring, ring or
|
||||
vector of points using the well-known Douglas-Peucker algorithm.
|
||||
\tparam Point the point type
|
||||
\tparam PointDistanceStrategy point-segment distance strategy to be used
|
||||
\note This strategy uses itself a point-segment-distance strategy which
|
||||
can be specified
|
||||
\author Barend and Maarten, 1995/1996
|
||||
\author Barend, revised for Generic Geometry Library, 2008
|
||||
*/
|
||||
|
||||
/*
|
||||
For the algorithm, see for example:
|
||||
- http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
|
||||
- http://www2.dcs.hull.ac.uk/CISRG/projects/Royal-Inst/demos/dp.html
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename PointDistanceStrategy
|
||||
>
|
||||
class douglas_peucker
|
||||
{
|
||||
public :
|
||||
|
||||
typedef PointDistanceStrategy distance_strategy_type;
|
||||
|
||||
typedef typename strategy::distance::services::return_type
|
||||
<
|
||||
distance_strategy_type,
|
||||
Point, Point
|
||||
>::type distance_type;
|
||||
|
||||
template <typename Range, typename OutputIterator>
|
||||
static inline OutputIterator apply(Range const& ,
|
||||
OutputIterator out,
|
||||
distance_type const& )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace strategy::simplify
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_SIMPLIFY_DOUGLAS_PEUCKER_HPP
|
||||
Reference in New Issue
Block a user