mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 05:24:02 +00:00
Replace check_iterator_range by std::any_of, std::all_of or std::none_of (#934)
This commit is contained in:
parent
5627d023da
commit
01374135af
@ -1,71 +0,0 @@
|
|||||||
// 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_CHECK_ITERATOR_RANGE_HPP
|
|
||||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CHECK_ITERATOR_RANGE_HPP
|
|
||||||
|
|
||||||
#include <boost/core/ignore_unused.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost { namespace geometry
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifndef DOXYGEN_NO_DETAIL
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
|
|
||||||
// Check whether (each element of) an iterator range satisfies a given
|
|
||||||
// predicate.
|
|
||||||
// The predicate must be implemented as having a static apply unary
|
|
||||||
// method that returns a bool.
|
|
||||||
// By default an empty range is accepted
|
|
||||||
template <typename Predicate, bool AllowEmptyRange = true>
|
|
||||||
struct check_iterator_range
|
|
||||||
{
|
|
||||||
template <typename InputIterator>
|
|
||||||
static inline bool apply(InputIterator first, InputIterator beyond)
|
|
||||||
{
|
|
||||||
for (InputIterator it = first; it != beyond; ++it)
|
|
||||||
{
|
|
||||||
if (! Predicate::apply(*it))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AllowEmptyRange || first != beyond;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// version where we can pass a predicate object
|
|
||||||
template <typename InputIterator>
|
|
||||||
static inline bool apply(InputIterator first,
|
|
||||||
InputIterator beyond,
|
|
||||||
Predicate const& predicate)
|
|
||||||
{
|
|
||||||
// in case predicate's apply method is static, MSVC will
|
|
||||||
// complain that predicate is not used
|
|
||||||
boost::ignore_unused(predicate);
|
|
||||||
|
|
||||||
for (InputIterator it = first; it != beyond; ++it)
|
|
||||||
{
|
|
||||||
if (! predicate.apply(*it))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AllowEmptyRange || first != beyond;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
#endif // DOXYGEN_NO_DETAIL
|
|
||||||
|
|
||||||
}} // namespace boost::geometry
|
|
||||||
|
|
||||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CHECK_ITERATOR_RANGE_HPP
|
|
@ -13,7 +13,6 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/closest_points/range_to_geometry_rtree.hpp>
|
#include <boost/geometry/algorithms/detail/closest_points/range_to_geometry_rtree.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/closest_points/utilities.hpp>
|
#include <boost/geometry/algorithms/detail/closest_points/utilities.hpp>
|
||||||
#include <boost/geometry/algorithms/dispatch/closest_points.hpp>
|
#include <boost/geometry/algorithms/dispatch/closest_points.hpp>
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
// This file was modified by Oracle on 2013-2021.
|
// This file was modified by Oracle on 2013-2021.
|
||||||
// Modifications copyright (c) 2013-2021, Oracle and/or its affiliates.
|
// Modifications copyright (c) 2013-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// 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
|
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||||
@ -40,7 +41,6 @@
|
|||||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
||||||
@ -141,28 +141,25 @@ struct disjoint_segment_areal
|
|||||||
template <typename Segment, typename Polygon>
|
template <typename Segment, typename Polygon>
|
||||||
class disjoint_segment_areal<Segment, Polygon, polygon_tag>
|
class disjoint_segment_areal<Segment, Polygon, polygon_tag>
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
template <typename InteriorRings, typename Strategy>
|
template <typename InteriorRings, typename Strategy>
|
||||||
static inline
|
static inline
|
||||||
bool check_interior_rings(InteriorRings const& interior_rings,
|
bool check_interior_rings(InteriorRings const& interior_rings,
|
||||||
Segment const& segment,
|
Segment const& segment,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
typedef typename boost::range_value<InteriorRings>::type ring_type;
|
using ring_type = typename boost::range_value<InteriorRings>::type;
|
||||||
|
|
||||||
typedef unary_disjoint_geometry_to_query_geometry
|
using unary_predicate_type = unary_disjoint_geometry_to_query_geometry
|
||||||
<
|
<
|
||||||
Segment,
|
Segment,
|
||||||
Strategy,
|
Strategy,
|
||||||
disjoint_range_segment_or_box<ring_type, Segment>
|
disjoint_range_segment_or_box<ring_type, Segment>
|
||||||
> unary_predicate_type;
|
>;
|
||||||
|
|
||||||
return check_iterator_range
|
return std::all_of(boost::begin(interior_rings),
|
||||||
<
|
boost::end(interior_rings),
|
||||||
unary_predicate_type
|
unary_predicate_type(segment, strategy));
|
||||||
>::apply(boost::begin(interior_rings),
|
|
||||||
boost::end(interior_rings),
|
|
||||||
unary_predicate_type(segment, strategy));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -31,7 +33,6 @@
|
|||||||
#include <boost/geometry/algorithms/envelope.hpp>
|
#include <boost/geometry/algorithms/envelope.hpp>
|
||||||
#include <boost/geometry/algorithms/expand.hpp>
|
#include <boost/geometry/algorithms/expand.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/partition.hpp>
|
#include <boost/geometry/algorithms/detail/partition.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
|
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
|
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
|
||||||
@ -63,24 +64,24 @@ class multipoint_multipoint
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
template <typename Iterator, typename CSTag>
|
template <typename Iterator, typename CSTag>
|
||||||
class unary_disjoint_predicate
|
class unary_not_disjoint_predicate
|
||||||
: geometry::less<void, -1, CSTag>
|
: geometry::less<void, -1, CSTag>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef geometry::less<void, -1, CSTag> base_type;
|
typedef geometry::less<void, -1, CSTag> base_type;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unary_disjoint_predicate(Iterator first, Iterator last)
|
unary_not_disjoint_predicate(Iterator first, Iterator last)
|
||||||
: base_type(), m_first(first), m_last(last)
|
: base_type(), m_first(first), m_last(last)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Point>
|
template <typename Point>
|
||||||
inline bool apply(Point const& point) const
|
inline bool operator()(Point const& point) const
|
||||||
{
|
{
|
||||||
return !std::binary_search(m_first,
|
return std::binary_search(m_first,
|
||||||
m_last,
|
m_last,
|
||||||
point,
|
point,
|
||||||
static_cast<base_type const&>(*this));
|
static_cast<base_type const&>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -93,30 +94,26 @@ public:
|
|||||||
MultiPoint2 const& multipoint2,
|
MultiPoint2 const& multipoint2,
|
||||||
Strategy const&)
|
Strategy const&)
|
||||||
{
|
{
|
||||||
typedef typename Strategy::cs_tag cs_tag;
|
|
||||||
typedef geometry::less<void, -1, cs_tag> less_type;
|
|
||||||
|
|
||||||
BOOST_GEOMETRY_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) );
|
BOOST_GEOMETRY_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) );
|
||||||
|
|
||||||
typedef typename boost::range_value<MultiPoint1>::type point1_type;
|
using cs_tag = typename Strategy::cs_tag;
|
||||||
|
using less_type = geometry::less<void, -1, cs_tag>;
|
||||||
|
using point1_type = typename boost::range_value<MultiPoint1>::type;
|
||||||
|
|
||||||
std::vector<point1_type> points1(boost::begin(multipoint1),
|
std::vector<point1_type> points1(boost::begin(multipoint1),
|
||||||
boost::end(multipoint1));
|
boost::end(multipoint1));
|
||||||
|
|
||||||
std::sort(points1.begin(), points1.end(), less_type());
|
std::sort(points1.begin(), points1.end(), less_type());
|
||||||
|
|
||||||
typedef unary_disjoint_predicate
|
using predicate_type = unary_not_disjoint_predicate
|
||||||
<
|
<
|
||||||
typename std::vector<point1_type>::const_iterator,
|
typename std::vector<point1_type>::const_iterator,
|
||||||
cs_tag
|
cs_tag
|
||||||
> predicate_type;
|
>;
|
||||||
|
|
||||||
return check_iterator_range
|
return none_of(boost::begin(multipoint2),
|
||||||
<
|
boost::end(multipoint2),
|
||||||
predicate_type
|
predicate_type(points1.begin(), points1.end()));
|
||||||
>::apply(boost::begin(multipoint2),
|
|
||||||
boost::end(multipoint2),
|
|
||||||
predicate_type(points1.begin(), points1.end()));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -16,7 +17,6 @@
|
|||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
#include <boost/range/value_type.hpp>
|
#include <boost/range/value_type.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||||
|
|
||||||
|
|
||||||
@ -34,13 +34,13 @@ class unary_disjoint_geometry_to_query_geometry
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unary_disjoint_geometry_to_query_geometry(Geometry const& geometry,
|
unary_disjoint_geometry_to_query_geometry(Geometry const& geometry,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
: m_geometry(geometry)
|
: m_geometry(geometry)
|
||||||
, m_strategy(strategy)
|
, m_strategy(strategy)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename QueryGeometry>
|
template <typename QueryGeometry>
|
||||||
inline bool apply(QueryGeometry const& query_geometry) const
|
inline bool operator()(QueryGeometry const& query_geometry) const
|
||||||
{
|
{
|
||||||
return BinaryPredicate::apply(query_geometry, m_geometry, m_strategy);
|
return BinaryPredicate::apply(query_geometry, m_geometry, m_strategy);
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ struct multirange_constant_size_geometry
|
|||||||
ConstantSizeGeometry const& constant_size_geometry,
|
ConstantSizeGeometry const& constant_size_geometry,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
typedef unary_disjoint_geometry_to_query_geometry
|
using disjoint = unary_disjoint_geometry_to_query_geometry
|
||||||
<
|
<
|
||||||
ConstantSizeGeometry,
|
ConstantSizeGeometry,
|
||||||
Strategy,
|
Strategy,
|
||||||
@ -68,13 +68,11 @@ struct multirange_constant_size_geometry
|
|||||||
typename boost::range_value<MultiRange>::type,
|
typename boost::range_value<MultiRange>::type,
|
||||||
ConstantSizeGeometry
|
ConstantSizeGeometry
|
||||||
>
|
>
|
||||||
> unary_predicate_type;
|
>;
|
||||||
|
|
||||||
return detail::check_iterator_range
|
return std::all_of(boost::begin(multirange),
|
||||||
<
|
boost::end(multirange),
|
||||||
unary_predicate_type
|
disjoint(constant_size_geometry, strategy));
|
||||||
>::apply(boost::begin(multirange), boost::end(multirange),
|
|
||||||
unary_predicate_type(constant_size_geometry, strategy));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Strategy>
|
template <typename Strategy>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||||
|
|
||||||
// Copyright (c) 2014-2021 Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -16,7 +17,6 @@
|
|||||||
#include <boost/range/size.hpp>
|
#include <boost/range/size.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/covered_by.hpp>
|
#include <boost/geometry/algorithms/covered_by.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/distance/range_to_geometry_rtree.hpp>
|
#include <boost/geometry/algorithms/detail/distance/range_to_geometry_rtree.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp>
|
#include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp>
|
||||||
#include <boost/geometry/algorithms/dispatch/distance.hpp>
|
#include <boost/geometry/algorithms/dispatch/distance.hpp>
|
||||||
@ -46,7 +46,6 @@ struct multipoint_to_multipoint
|
|||||||
Strategies const& strategies)
|
Strategies const& strategies)
|
||||||
{
|
{
|
||||||
if (boost::size(multipoint2) < boost::size(multipoint1))
|
if (boost::size(multipoint2) < boost::size(multipoint1))
|
||||||
|
|
||||||
{
|
{
|
||||||
return point_or_segment_range_to_geometry_rtree
|
return point_or_segment_range_to_geometry_rtree
|
||||||
<
|
<
|
||||||
@ -103,16 +102,16 @@ template <typename MultiPoint, typename Areal, typename Strategies>
|
|||||||
class multipoint_to_areal
|
class multipoint_to_areal
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct not_covered_by_areal
|
struct covered_by_areal
|
||||||
{
|
{
|
||||||
not_covered_by_areal(Areal const& areal, Strategies const& strategy)
|
covered_by_areal(Areal const& areal, Strategies const& strategy)
|
||||||
: m_areal(areal), m_strategy(strategy)
|
: m_areal(areal), m_strategy(strategy)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Point>
|
template <typename Point>
|
||||||
inline bool apply(Point const& point) const
|
inline bool operator()(Point const& point) const
|
||||||
{
|
{
|
||||||
return !geometry::covered_by(point, m_areal, m_strategy);
|
return geometry::covered_by(point, m_areal, m_strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
Areal const& m_areal;
|
Areal const& m_areal;
|
||||||
@ -126,14 +125,10 @@ public:
|
|||||||
Areal const& areal,
|
Areal const& areal,
|
||||||
Strategies const& strategies)
|
Strategies const& strategies)
|
||||||
{
|
{
|
||||||
not_covered_by_areal predicate(areal, strategies);
|
covered_by_areal predicate(areal, strategies);
|
||||||
|
|
||||||
if (check_iterator_range
|
if (! boost::empty(multipoint) &&
|
||||||
<
|
std::none_of(boost::begin(multipoint), boost::end(multipoint), predicate))
|
||||||
not_covered_by_areal, false
|
|
||||||
>::apply(boost::begin(multipoint),
|
|
||||||
boost::end(multipoint),
|
|
||||||
predicate))
|
|
||||||
{
|
{
|
||||||
return detail::distance::point_or_segment_range_to_geometry_rtree
|
return detail::distance::point_or_segment_range_to_geometry_rtree
|
||||||
<
|
<
|
||||||
|
@ -49,12 +49,12 @@ template <typename InteriorRings, typename Strategy>
|
|||||||
inline bool are_simple_interior_rings(InteriorRings const& interior_rings,
|
inline bool are_simple_interior_rings(InteriorRings const& interior_rings,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
auto const end = boost::end(interior_rings);
|
return std::all_of(boost::begin(interior_rings),
|
||||||
return std::find_if(boost::begin(interior_rings), end,
|
boost::end(interior_rings),
|
||||||
[&](auto const& r)
|
[&](auto const& r)
|
||||||
{
|
{
|
||||||
return ! is_simple_ring(r, strategy);
|
return is_simple_ring(r, strategy);
|
||||||
}) == end; // non-simple ring not found
|
}); // non-simple ring not found
|
||||||
// allow empty ring
|
// allow empty ring
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,12 +116,11 @@ struct is_simple<MultiPolygon, multi_polygon_tag>
|
|||||||
template <typename Strategy>
|
template <typename Strategy>
|
||||||
static inline bool apply(MultiPolygon const& multipolygon, Strategy const& strategy)
|
static inline bool apply(MultiPolygon const& multipolygon, Strategy const& strategy)
|
||||||
{
|
{
|
||||||
auto const end = boost::end(multipolygon);
|
return std::none_of(boost::begin(multipolygon), boost::end(multipolygon),
|
||||||
return std::find_if(boost::begin(multipolygon), end,
|
[&](auto const& po) {
|
||||||
[&](auto const& po) {
|
return ! detail::is_simple::is_simple_polygon(po, strategy);
|
||||||
return ! detail::is_simple::is_simple_polygon(po, strategy);
|
}); // non-simple polygon not found
|
||||||
}) == end; // non-simple polygon not found
|
// allow empty multi-polygon
|
||||||
// allow empty multi-polygon
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -36,7 +37,6 @@
|
|||||||
#include <boost/geometry/algorithms/intersects.hpp>
|
#include <boost/geometry/algorithms/intersects.hpp>
|
||||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/signed_size_type.hpp>
|
#include <boost/geometry/algorithms/detail/signed_size_type.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>
|
||||||
@ -261,16 +261,16 @@ struct is_simple_multilinestring
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
template <typename Strategy>
|
template <typename Strategy>
|
||||||
struct per_linestring
|
struct not_simple
|
||||||
{
|
{
|
||||||
per_linestring(Strategy const& strategy)
|
not_simple(Strategy const& strategy)
|
||||||
: m_strategy(strategy)
|
: m_strategy(strategy)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Linestring>
|
template <typename Linestring>
|
||||||
inline bool apply(Linestring const& linestring) const
|
inline bool operator()(Linestring const& linestring) const
|
||||||
{
|
{
|
||||||
return detail::is_simple::is_simple_linestring
|
return ! detail::is_simple::is_simple_linestring
|
||||||
<
|
<
|
||||||
Linestring,
|
Linestring,
|
||||||
false // do not compute self-intersections
|
false // do not compute self-intersections
|
||||||
@ -285,19 +285,16 @@ public:
|
|||||||
static inline bool apply(MultiLinestring const& multilinestring,
|
static inline bool apply(MultiLinestring const& multilinestring,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
typedef per_linestring<Strategy> per_ls;
|
|
||||||
|
|
||||||
// check each of the linestrings for simplicity
|
// check each of the linestrings for simplicity
|
||||||
// but do not compute self-intersections yet; these will be
|
// but do not compute self-intersections yet; these will be
|
||||||
// computed for the entire multilinestring
|
// computed for the entire multilinestring
|
||||||
if ( ! detail::check_iterator_range
|
// return true for empty multilinestring
|
||||||
<
|
|
||||||
per_ls, // do not compute self-intersections
|
using not_simple = not_simple<Strategy>; // do not compute self-intersections
|
||||||
true // allow empty multilinestring
|
|
||||||
>::apply(boost::begin(multilinestring),
|
if (std::any_of(boost::begin(multilinestring),
|
||||||
boost::end(multilinestring),
|
boost::end(multilinestring),
|
||||||
per_ls(strategy))
|
not_simple(strategy)))
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -14,7 +15,6 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/core/coordinate_type.hpp>
|
#include <boost/geometry/core/coordinate_type.hpp>
|
||||||
@ -80,26 +80,19 @@ struct indexed_has_invalid_coordinate
|
|||||||
|
|
||||||
struct range_has_invalid_coordinate
|
struct range_has_invalid_coordinate
|
||||||
{
|
{
|
||||||
struct point_has_valid_coordinates
|
|
||||||
{
|
|
||||||
template <typename Point>
|
|
||||||
static inline bool apply(Point const& point)
|
|
||||||
{
|
|
||||||
return ! point_has_invalid_coordinate::apply(point);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Geometry, typename VisitPolicy>
|
template <typename Geometry, typename VisitPolicy>
|
||||||
static inline bool apply(Geometry const& geometry, VisitPolicy& visitor)
|
static inline bool apply(Geometry const& geometry, VisitPolicy& visitor)
|
||||||
{
|
{
|
||||||
boost::ignore_unused(visitor);
|
boost::ignore_unused(visitor);
|
||||||
|
|
||||||
bool const has_valid_coordinates = detail::check_iterator_range
|
auto const points_end = geometry::points_end(geometry);
|
||||||
<
|
bool const has_valid_coordinates = std::none_of
|
||||||
point_has_valid_coordinates,
|
(
|
||||||
true // do not consider an empty range as problematic
|
geometry::points_begin(geometry), points_end,
|
||||||
>::apply(geometry::points_begin(geometry),
|
[]( auto const& point ){
|
||||||
geometry::points_end(geometry));
|
return point_has_invalid_coordinate::apply(point);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return has_valid_coordinates
|
return has_valid_coordinates
|
||||||
?
|
?
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -20,7 +21,6 @@
|
|||||||
|
|
||||||
#include <boost/geometry/algorithms/equals.hpp>
|
#include <boost/geometry/algorithms/equals.hpp>
|
||||||
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
|
#include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/is_valid/has_spikes.hpp>
|
#include <boost/geometry/algorithms/detail/is_valid/has_spikes.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp>
|
#include <boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp>
|
||||||
@ -131,7 +131,6 @@ class is_valid
|
|||||||
MultiLinestring, multi_linestring_tag, AllowEmptyMultiGeometries
|
MultiLinestring, multi_linestring_tag, AllowEmptyMultiGeometries
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
template <typename VisitPolicy, typename Strategy>
|
template <typename VisitPolicy, typename Strategy>
|
||||||
struct per_linestring
|
struct per_linestring
|
||||||
{
|
{
|
||||||
@ -141,7 +140,7 @@ private:
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Linestring>
|
template <typename Linestring>
|
||||||
inline bool apply(Linestring const& linestring) const
|
inline bool operator()(Linestring const& linestring) const
|
||||||
{
|
{
|
||||||
return detail::is_valid::is_valid_linestring
|
return detail::is_valid::is_valid_linestring
|
||||||
<
|
<
|
||||||
@ -165,15 +164,11 @@ public:
|
|||||||
return visitor.template apply<no_failure>();
|
return visitor.template apply<no_failure>();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef per_linestring<VisitPolicy, Strategy> per_ls;
|
using per_ls = per_linestring<VisitPolicy, Strategy>;
|
||||||
|
|
||||||
return detail::check_iterator_range
|
return std::all_of(boost::begin(multilinestring),
|
||||||
<
|
boost::end(multilinestring),
|
||||||
per_ls,
|
per_ls(visitor, strategy));
|
||||||
false // do not check for empty multilinestring (done above)
|
|
||||||
>::apply(boost::begin(multilinestring),
|
|
||||||
boost::end(multilinestring),
|
|
||||||
per_ls(visitor, strategy));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -34,7 +35,6 @@
|
|||||||
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
||||||
#include <boost/geometry/algorithms/within.hpp>
|
#include <boost/geometry/algorithms/within.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/partition.hpp>
|
#include <boost/geometry/algorithms/detail/partition.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp>
|
#include <boost/geometry/algorithms/detail/is_valid/has_valid_self_turns.hpp>
|
||||||
@ -257,29 +257,30 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
template <typename VisitPolicy, typename Strategy>
|
template <typename VisitPolicy, typename Strategy>
|
||||||
struct per_polygon
|
struct is_invalid_polygon
|
||||||
{
|
{
|
||||||
per_polygon(VisitPolicy& policy, Strategy const& strategy)
|
is_invalid_polygon(VisitPolicy& policy, Strategy const& strategy)
|
||||||
: m_policy(policy)
|
: m_policy(policy)
|
||||||
, m_strategy(strategy)
|
, m_strategy(strategy)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Polygon>
|
template <typename Polygon>
|
||||||
inline bool apply(Polygon const& polygon) const
|
inline bool operator()(Polygon const& polygon) const
|
||||||
{
|
{
|
||||||
return base::apply(polygon, m_policy, m_strategy);
|
return ! base::apply(polygon, m_policy, m_strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
VisitPolicy& m_policy;
|
VisitPolicy& m_policy;
|
||||||
Strategy const& m_strategy;
|
Strategy const& m_strategy;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template <typename VisitPolicy, typename Strategy>
|
template <typename VisitPolicy, typename Strategy>
|
||||||
static inline bool apply(MultiPolygon const& multipolygon,
|
static inline bool apply(MultiPolygon const& multipolygon,
|
||||||
VisitPolicy& visitor,
|
VisitPolicy& visitor,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
typedef debug_validity_phase<MultiPolygon> debug_phase;
|
using debug_phase = debug_validity_phase<MultiPolygon>;
|
||||||
|
|
||||||
if (BOOST_GEOMETRY_CONDITION(AllowEmptyMultiGeometries)
|
if (BOOST_GEOMETRY_CONDITION(AllowEmptyMultiGeometries)
|
||||||
&& boost::empty(multipolygon))
|
&& boost::empty(multipolygon))
|
||||||
@ -290,22 +291,20 @@ public:
|
|||||||
// check validity of all polygons ring
|
// check validity of all polygons ring
|
||||||
debug_phase::apply(1);
|
debug_phase::apply(1);
|
||||||
|
|
||||||
if (! detail::check_iterator_range
|
if (std::any_of(boost::begin(multipolygon), boost::end(multipolygon),
|
||||||
<
|
is_invalid_polygon<VisitPolicy, Strategy>(visitor, strategy)))
|
||||||
per_polygon<VisitPolicy, Strategy>,
|
|
||||||
false // do not check for empty multipolygon (done above)
|
|
||||||
>::apply(boost::begin(multipolygon),
|
|
||||||
boost::end(multipolygon),
|
|
||||||
per_polygon<VisitPolicy, Strategy>(visitor, strategy)))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// compute turns and check if all are acceptable
|
// compute turns and check if all are acceptable
|
||||||
debug_phase::apply(2);
|
debug_phase::apply(2);
|
||||||
|
|
||||||
typedef has_valid_self_turns<MultiPolygon, typename Strategy::cs_tag> has_valid_turns;
|
using has_valid_turns = has_valid_self_turns
|
||||||
|
<
|
||||||
|
MultiPolygon,
|
||||||
|
typename Strategy::cs_tag
|
||||||
|
>;
|
||||||
|
|
||||||
std::deque<typename has_valid_turns::turn_type> turns;
|
std::deque<typename has_valid_turns::turn_type> turns;
|
||||||
bool has_invalid_turns =
|
bool has_invalid_turns =
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -50,7 +51,6 @@
|
|||||||
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
||||||
#include <boost/geometry/algorithms/within.hpp>
|
#include <boost/geometry/algorithms/within.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/partition.hpp>
|
#include <boost/geometry/algorithms/detail/partition.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/is_valid/complement_graph.hpp>
|
#include <boost/geometry/algorithms/detail/is_valid/complement_graph.hpp>
|
||||||
@ -86,17 +86,17 @@ class is_valid_polygon
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
template <typename VisitPolicy, typename Strategy>
|
template <typename VisitPolicy, typename Strategy>
|
||||||
struct per_ring
|
struct is_invalid_ring
|
||||||
{
|
{
|
||||||
per_ring(VisitPolicy& policy, Strategy const& strategy)
|
is_invalid_ring(VisitPolicy& policy, Strategy const& strategy)
|
||||||
: m_policy(policy)
|
: m_policy(policy)
|
||||||
, m_strategy(strategy)
|
, m_strategy(strategy)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename Ring>
|
template <typename Ring>
|
||||||
inline bool apply(Ring const& ring) const
|
inline bool operator()(Ring const& ring) const
|
||||||
{
|
{
|
||||||
return detail::is_valid::is_valid_ring
|
return ! detail::is_valid::is_valid_ring
|
||||||
<
|
<
|
||||||
Ring, false, true
|
Ring, false, true
|
||||||
>::apply(ring, m_policy, m_strategy);
|
>::apply(ring, m_policy, m_strategy);
|
||||||
@ -111,14 +111,9 @@ protected:
|
|||||||
VisitPolicy& visitor,
|
VisitPolicy& visitor,
|
||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
return
|
return std::none_of(boost::begin(interior_rings),
|
||||||
detail::check_iterator_range
|
boost::end(interior_rings),
|
||||||
<
|
is_invalid_ring<VisitPolicy, Strategy>(visitor, strategy));
|
||||||
per_ring<VisitPolicy, Strategy>,
|
|
||||||
true // allow for empty interior ring range
|
|
||||||
>::apply(boost::begin(interior_rings),
|
|
||||||
boost::end(interior_rings),
|
|
||||||
per_ring<VisitPolicy, Strategy>(visitor, strategy));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct has_valid_rings
|
struct has_valid_rings
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||||
|
|
||||||
// This file was modified by Oracle on 2014-2020.
|
// This file was modified by Oracle on 2014-2021.
|
||||||
// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
|
// Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -25,7 +26,6 @@
|
|||||||
#include <boost/range/size.hpp>
|
#include <boost/range/size.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/convert.hpp>
|
#include <boost/geometry/algorithms/convert.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/overlay/clip_linestring.hpp>
|
#include <boost/geometry/algorithms/detail/overlay/clip_linestring.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/overlay/follow.hpp>
|
#include <boost/geometry/algorithms/detail/overlay/follow.hpp>
|
||||||
|
@ -298,11 +298,10 @@ public:
|
|||||||
bool is_outside(TurnInfo const& turn) const
|
bool is_outside(TurnInfo const& turn) const
|
||||||
{
|
{
|
||||||
return m_other_entry_points.empty()
|
return m_other_entry_points.empty()
|
||||||
|| std::find_if(m_other_entry_points.begin(),
|
|| std::none_of(m_other_entry_points.begin(),
|
||||||
m_other_entry_points.end(),
|
m_other_entry_points.end(),
|
||||||
same_single(
|
same_single(
|
||||||
turn.operations[other_op_id].seg_id))
|
turn.operations[other_op_id].seg_id));
|
||||||
== m_other_entry_points.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
overlay::operation_type get_exit_operation() const
|
overlay::operation_type get_exit_operation() const
|
||||||
|
@ -94,9 +94,8 @@ struct multi_point_geometry_eb<Geometry, linestring_tag>
|
|||||||
template <typename Point, typename Strategy>
|
template <typename Point, typename Strategy>
|
||||||
bool apply(Point const& boundary_point, Strategy const& strategy)
|
bool apply(Point const& boundary_point, Strategy const& strategy)
|
||||||
{
|
{
|
||||||
if ( std::find_if(m_points.begin(), m_points.end(),
|
if ( std::none_of(m_points.begin(), m_points.end(),
|
||||||
find_pred<Point, Strategy>(boundary_point, strategy))
|
find_pred<Point, Strategy>(boundary_point, strategy)))
|
||||||
== m_points.end() )
|
|
||||||
{
|
{
|
||||||
m_boundary_found = true;
|
m_boundary_found = true;
|
||||||
return false;
|
return false;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
// Copyright (c) 2015-2021, Oracle and/or its affiliates.
|
// Copyright (c) 2015-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -16,7 +17,6 @@
|
|||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
#include <boost/geometry/algorithms/detail/visit.hpp>
|
#include <boost/geometry/algorithms/detail/visit.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/core/exterior_ring.hpp>
|
#include <boost/geometry/core/exterior_ring.hpp>
|
||||||
@ -62,10 +62,8 @@ class polygon_is_empty
|
|||||||
template <typename InteriorRings>
|
template <typename InteriorRings>
|
||||||
static inline bool check_interior_rings(InteriorRings const& interior_rings)
|
static inline bool check_interior_rings(InteriorRings const& interior_rings)
|
||||||
{
|
{
|
||||||
return check_iterator_range
|
return std::all_of(boost::begin(interior_rings), boost::end(interior_rings),
|
||||||
<
|
[]( auto const& range ){ return boost::empty(range); });
|
||||||
range_is_empty, true // allow empty range
|
|
||||||
>::apply(boost::begin(interior_rings), boost::end(interior_rings));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -83,12 +81,10 @@ struct multi_is_empty
|
|||||||
template <typename MultiGeometry>
|
template <typename MultiGeometry>
|
||||||
static inline bool apply(MultiGeometry const& multigeometry)
|
static inline bool apply(MultiGeometry const& multigeometry)
|
||||||
{
|
{
|
||||||
return check_iterator_range
|
return std::all_of(boost::begin(multigeometry),
|
||||||
<
|
boost::end(multigeometry),
|
||||||
Policy, true // allow empty range
|
[]( auto const& range ){ return Policy::apply(range); });
|
||||||
>::apply(boost::begin(multigeometry), boost::end(multigeometry));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace detail::is_empty
|
}} // namespace detail::is_empty
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -13,8 +15,6 @@
|
|||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace boost { namespace geometry
|
namespace boost { namespace geometry
|
||||||
{
|
{
|
||||||
@ -43,12 +43,14 @@ struct stateless_predicate_based_interrupt_policy
|
|||||||
template <typename Range>
|
template <typename Range>
|
||||||
inline bool apply(Range const& range)
|
inline bool apply(Range const& range)
|
||||||
{
|
{
|
||||||
// if there is at least one unacceptable turn in the range, return false
|
// if there is at least one unacceptable turn in the range, return true
|
||||||
has_intersections = !detail::check_iterator_range
|
bool const has_unacceptable_turn = std::any_of(boost::begin(range), boost::end(range),
|
||||||
<
|
[](auto const& turn) {
|
||||||
IsAcceptableTurnPredicate,
|
return ! IsAcceptableTurnPredicate::apply(turn);
|
||||||
AllowEmptyTurnRange
|
});
|
||||||
>::apply(boost::begin(range), boost::end(range));
|
|
||||||
|
has_intersections = has_unacceptable_turn
|
||||||
|
&& !(AllowEmptyTurnRange && boost::empty(range));
|
||||||
|
|
||||||
return has_intersections;
|
return has_intersections;
|
||||||
}
|
}
|
||||||
@ -78,12 +80,15 @@ struct predicate_based_interrupt_policy
|
|||||||
template <typename Range>
|
template <typename Range>
|
||||||
inline bool apply(Range const& range)
|
inline bool apply(Range const& range)
|
||||||
{
|
{
|
||||||
// if there is at least one unacceptable turn in the range, return false
|
// if there is at least one unacceptable turn in the range, return true
|
||||||
has_intersections = !detail::check_iterator_range
|
bool const has_unacceptable_turn = std::any_of(boost::begin(range),
|
||||||
<
|
boost::end(range),
|
||||||
IsAcceptableTurnPredicate,
|
[&]( auto const& turn ) {
|
||||||
AllowEmptyTurnRange
|
return ! m_predicate.apply(turn);
|
||||||
>::apply(boost::begin(range), boost::end(range), m_predicate);
|
});
|
||||||
|
|
||||||
|
has_intersections = has_unacceptable_turn
|
||||||
|
&& !(AllowEmptyTurnRange && boost::empty(range));
|
||||||
|
|
||||||
return has_intersections;
|
return has_intersections;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||||
// Unit Test
|
// Unit Test
|
||||||
|
|
||||||
// Copyright (c) 2014-2020, Oracle and/or its affiliates.
|
// Copyright (c) 2014-2021, Oracle and/or its affiliates.
|
||||||
|
|
||||||
|
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||||
|
|
||||||
@ -49,8 +50,6 @@
|
|||||||
#include <boost/geometry/algorithms/num_points.hpp>
|
#include <boost/geometry/algorithms/num_points.hpp>
|
||||||
#include <boost/geometry/algorithms/is_valid.hpp>
|
#include <boost/geometry/algorithms/is_valid.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
|
||||||
|
|
||||||
#include <from_wkt.hpp>
|
#include <from_wkt.hpp>
|
||||||
|
|
||||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||||
@ -98,17 +97,17 @@ struct is_convertible_to_closed<Ring, bg::ring_tag, bg::open>
|
|||||||
template <typename Polygon>
|
template <typename Polygon>
|
||||||
struct is_convertible_to_closed<Polygon, bg::polygon_tag, bg::open>
|
struct is_convertible_to_closed<Polygon, bg::polygon_tag, bg::open>
|
||||||
{
|
{
|
||||||
typedef typename bg::ring_type<Polygon>::type ring_type;
|
using ring_type = typename bg::ring_type<Polygon>::type;
|
||||||
|
|
||||||
template <typename InteriorRings>
|
template <typename InteriorRings>
|
||||||
static inline
|
static inline
|
||||||
bool apply_to_interior_rings(InteriorRings const& interior_rings)
|
bool apply_to_interior_rings(InteriorRings const& interior_rings)
|
||||||
{
|
{
|
||||||
return bg::detail::check_iterator_range
|
return std::all_of(boost::begin(interior_rings),
|
||||||
<
|
boost::end(interior_rings),
|
||||||
is_convertible_to_closed<ring_type>
|
[]( auto const& ring ){
|
||||||
>::apply(boost::begin(interior_rings),
|
return is_convertible_to_closed<ring_type>::apply(ring);
|
||||||
boost::end(interior_rings));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool apply(Polygon const& polygon)
|
static inline bool apply(Polygon const& polygon)
|
||||||
@ -121,16 +120,15 @@ struct is_convertible_to_closed<Polygon, bg::polygon_tag, bg::open>
|
|||||||
template <typename MultiPolygon>
|
template <typename MultiPolygon>
|
||||||
struct is_convertible_to_closed<MultiPolygon, bg::multi_polygon_tag, bg::open>
|
struct is_convertible_to_closed<MultiPolygon, bg::multi_polygon_tag, bg::open>
|
||||||
{
|
{
|
||||||
typedef typename boost::range_value<MultiPolygon>::type polygon;
|
using polygon_type = typename boost::range_value<MultiPolygon>::type;
|
||||||
|
|
||||||
static inline bool apply(MultiPolygon const& multi_polygon)
|
static inline bool apply(MultiPolygon const& multi_polygon)
|
||||||
{
|
{
|
||||||
return bg::detail::check_iterator_range
|
return !boost::empty(multi_polygon) && // do not allow empty multi-polygon
|
||||||
<
|
std::none_of(boost::begin(multi_polygon), boost::end(multi_polygon),
|
||||||
is_convertible_to_closed<polygon>,
|
[]( auto const& polygon ){
|
||||||
false // do not allow empty multi-polygon
|
return ! is_convertible_to_closed<polygon_type>::apply(polygon);
|
||||||
>::apply(boost::begin(multi_polygon),
|
});
|
||||||
boost::end(multi_polygon));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user