mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23: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 <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/utilities.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/closest_points.hpp>
|
||||
|
@ -8,8 +8,9 @@
|
||||
// This file was modified by Oracle on 2013-2021.
|
||||
// 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 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.
|
||||
@ -40,7 +41,6 @@
|
||||
#include <boost/geometry/algorithms/not_implemented.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/disjoint/linear_linear.hpp>
|
||||
@ -141,28 +141,25 @@ struct disjoint_segment_areal
|
||||
template <typename Segment, typename Polygon>
|
||||
class disjoint_segment_areal<Segment, Polygon, polygon_tag>
|
||||
{
|
||||
private:
|
||||
|
||||
template <typename InteriorRings, typename Strategy>
|
||||
static inline
|
||||
bool check_interior_rings(InteriorRings const& interior_rings,
|
||||
Segment const& segment,
|
||||
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,
|
||||
Strategy,
|
||||
disjoint_range_segment_or_box<ring_type, Segment>
|
||||
> unary_predicate_type;
|
||||
|
||||
return check_iterator_range
|
||||
<
|
||||
unary_predicate_type
|
||||
>::apply(boost::begin(interior_rings),
|
||||
boost::end(interior_rings),
|
||||
unary_predicate_type(segment, strategy));
|
||||
>;
|
||||
|
||||
return std::all_of(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) 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -31,7 +33,6 @@
|
||||
#include <boost/geometry/algorithms/envelope.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/disjoint/box_box.hpp>
|
||||
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
|
||||
@ -63,24 +64,24 @@ class multipoint_multipoint
|
||||
{
|
||||
private:
|
||||
template <typename Iterator, typename CSTag>
|
||||
class unary_disjoint_predicate
|
||||
class unary_not_disjoint_predicate
|
||||
: geometry::less<void, -1, CSTag>
|
||||
{
|
||||
private:
|
||||
typedef geometry::less<void, -1, CSTag> base_type;
|
||||
|
||||
public:
|
||||
unary_disjoint_predicate(Iterator first, Iterator last)
|
||||
unary_not_disjoint_predicate(Iterator first, Iterator last)
|
||||
: base_type(), m_first(first), m_last(last)
|
||||
{}
|
||||
|
||||
template <typename Point>
|
||||
inline bool apply(Point const& point) const
|
||||
inline bool operator()(Point const& point) const
|
||||
{
|
||||
return !std::binary_search(m_first,
|
||||
m_last,
|
||||
point,
|
||||
static_cast<base_type const&>(*this));
|
||||
return std::binary_search(m_first,
|
||||
m_last,
|
||||
point,
|
||||
static_cast<base_type const&>(*this));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -93,30 +94,26 @@ public:
|
||||
MultiPoint2 const& multipoint2,
|
||||
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) );
|
||||
|
||||
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),
|
||||
boost::end(multipoint1));
|
||||
|
||||
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,
|
||||
cs_tag
|
||||
> predicate_type;
|
||||
>;
|
||||
|
||||
return check_iterator_range
|
||||
<
|
||||
predicate_type
|
||||
>::apply(boost::begin(multipoint2),
|
||||
boost::end(multipoint2),
|
||||
predicate_type(points1.begin(), points1.end()));
|
||||
return none_of(boost::begin(multipoint2),
|
||||
boost::end(multipoint2),
|
||||
predicate_type(points1.begin(), points1.end()));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -16,7 +17,6 @@
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
|
||||
|
||||
|
||||
@ -34,13 +34,13 @@ class unary_disjoint_geometry_to_query_geometry
|
||||
{
|
||||
public:
|
||||
unary_disjoint_geometry_to_query_geometry(Geometry const& geometry,
|
||||
Strategy const& strategy)
|
||||
Strategy const& strategy)
|
||||
: m_geometry(geometry)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
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);
|
||||
}
|
||||
@ -59,7 +59,7 @@ struct multirange_constant_size_geometry
|
||||
ConstantSizeGeometry const& constant_size_geometry,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef unary_disjoint_geometry_to_query_geometry
|
||||
using disjoint = unary_disjoint_geometry_to_query_geometry
|
||||
<
|
||||
ConstantSizeGeometry,
|
||||
Strategy,
|
||||
@ -68,13 +68,11 @@ struct multirange_constant_size_geometry
|
||||
typename boost::range_value<MultiRange>::type,
|
||||
ConstantSizeGeometry
|
||||
>
|
||||
> unary_predicate_type;
|
||||
>;
|
||||
|
||||
return detail::check_iterator_range
|
||||
<
|
||||
unary_predicate_type
|
||||
>::apply(boost::begin(multirange), boost::end(multirange),
|
||||
unary_predicate_type(constant_size_geometry, strategy));
|
||||
return std::all_of(boost::begin(multirange),
|
||||
boost::end(multirange),
|
||||
disjoint(constant_size_geometry, strategy));
|
||||
}
|
||||
|
||||
template <typename Strategy>
|
||||
|
@ -1,7 +1,8 @@
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -16,7 +17,6 @@
|
||||
#include <boost/range/size.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/strategy_utils.hpp>
|
||||
#include <boost/geometry/algorithms/dispatch/distance.hpp>
|
||||
@ -46,7 +46,6 @@ struct multipoint_to_multipoint
|
||||
Strategies const& strategies)
|
||||
{
|
||||
if (boost::size(multipoint2) < boost::size(multipoint1))
|
||||
|
||||
{
|
||||
return point_or_segment_range_to_geometry_rtree
|
||||
<
|
||||
@ -103,16 +102,16 @@ template <typename MultiPoint, typename Areal, typename Strategies>
|
||||
class multipoint_to_areal
|
||||
{
|
||||
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)
|
||||
{}
|
||||
|
||||
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;
|
||||
@ -126,14 +125,10 @@ public:
|
||||
Areal const& areal,
|
||||
Strategies const& strategies)
|
||||
{
|
||||
not_covered_by_areal predicate(areal, strategies);
|
||||
covered_by_areal predicate(areal, strategies);
|
||||
|
||||
if (check_iterator_range
|
||||
<
|
||||
not_covered_by_areal, false
|
||||
>::apply(boost::begin(multipoint),
|
||||
boost::end(multipoint),
|
||||
predicate))
|
||||
if (! boost::empty(multipoint) &&
|
||||
std::none_of(boost::begin(multipoint), boost::end(multipoint), predicate))
|
||||
{
|
||||
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,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
auto const end = boost::end(interior_rings);
|
||||
return std::find_if(boost::begin(interior_rings), end,
|
||||
[&](auto const& r)
|
||||
{
|
||||
return ! is_simple_ring(r, strategy);
|
||||
}) == end; // non-simple ring not found
|
||||
return std::all_of(boost::begin(interior_rings),
|
||||
boost::end(interior_rings),
|
||||
[&](auto const& r)
|
||||
{
|
||||
return is_simple_ring(r, strategy);
|
||||
}); // non-simple ring not found
|
||||
// allow empty ring
|
||||
}
|
||||
|
||||
@ -116,12 +116,11 @@ struct is_simple<MultiPolygon, multi_polygon_tag>
|
||||
template <typename Strategy>
|
||||
static inline bool apply(MultiPolygon const& multipolygon, Strategy const& strategy)
|
||||
{
|
||||
auto const end = boost::end(multipolygon);
|
||||
return std::find_if(boost::begin(multipolygon), end,
|
||||
[&](auto const& po) {
|
||||
return ! detail::is_simple::is_simple_polygon(po, strategy);
|
||||
}) == end; // non-simple polygon not found
|
||||
// allow empty multi-polygon
|
||||
return std::none_of(boost::begin(multipolygon), boost::end(multipolygon),
|
||||
[&](auto const& po) {
|
||||
return ! detail::is_simple::is_simple_polygon(po, strategy);
|
||||
}); // non-simple polygon not found
|
||||
// allow empty multi-polygon
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -36,7 +37,6 @@
|
||||
#include <boost/geometry/algorithms/intersects.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/disjoint/linear_linear.hpp>
|
||||
@ -261,16 +261,16 @@ struct is_simple_multilinestring
|
||||
{
|
||||
private:
|
||||
template <typename Strategy>
|
||||
struct per_linestring
|
||||
struct not_simple
|
||||
{
|
||||
per_linestring(Strategy const& strategy)
|
||||
not_simple(Strategy const& strategy)
|
||||
: m_strategy(strategy)
|
||||
{}
|
||||
|
||||
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,
|
||||
false // do not compute self-intersections
|
||||
@ -285,19 +285,16 @@ public:
|
||||
static inline bool apply(MultiLinestring const& multilinestring,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef per_linestring<Strategy> per_ls;
|
||||
|
||||
// check each of the linestrings for simplicity
|
||||
// but do not compute self-intersections yet; these will be
|
||||
// computed for the entire multilinestring
|
||||
if ( ! detail::check_iterator_range
|
||||
<
|
||||
per_ls, // do not compute self-intersections
|
||||
true // allow empty multilinestring
|
||||
>::apply(boost::begin(multilinestring),
|
||||
boost::end(multilinestring),
|
||||
per_ls(strategy))
|
||||
)
|
||||
// return true for empty multilinestring
|
||||
|
||||
using not_simple = not_simple<Strategy>; // do not compute self-intersections
|
||||
|
||||
if (std::any_of(boost::begin(multilinestring),
|
||||
boost::end(multilinestring),
|
||||
not_simple(strategy)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -14,7 +15,6 @@
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
#include <boost/geometry/algorithms/validity_failure_type.hpp>
|
||||
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
@ -80,26 +80,19 @@ struct indexed_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>
|
||||
static inline bool apply(Geometry const& geometry, VisitPolicy& visitor)
|
||||
{
|
||||
boost::ignore_unused(visitor);
|
||||
|
||||
bool const has_valid_coordinates = detail::check_iterator_range
|
||||
<
|
||||
point_has_valid_coordinates,
|
||||
true // do not consider an empty range as problematic
|
||||
>::apply(geometry::points_begin(geometry),
|
||||
geometry::points_end(geometry));
|
||||
auto const points_end = geometry::points_end(geometry);
|
||||
bool const has_valid_coordinates = std::none_of
|
||||
(
|
||||
geometry::points_begin(geometry), points_end,
|
||||
[]( auto const& point ){
|
||||
return point_has_invalid_coordinate::apply(point);
|
||||
}
|
||||
);
|
||||
|
||||
return has_valid_coordinates
|
||||
?
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -20,7 +21,6 @@
|
||||
|
||||
#include <boost/geometry/algorithms/equals.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_spikes.hpp>
|
||||
#include <boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp>
|
||||
@ -131,7 +131,6 @@ class is_valid
|
||||
MultiLinestring, multi_linestring_tag, AllowEmptyMultiGeometries
|
||||
>
|
||||
{
|
||||
private:
|
||||
template <typename VisitPolicy, typename Strategy>
|
||||
struct per_linestring
|
||||
{
|
||||
@ -141,7 +140,7 @@ private:
|
||||
{}
|
||||
|
||||
template <typename Linestring>
|
||||
inline bool apply(Linestring const& linestring) const
|
||||
inline bool operator()(Linestring const& linestring) const
|
||||
{
|
||||
return detail::is_valid::is_valid_linestring
|
||||
<
|
||||
@ -165,15 +164,11 @@ public:
|
||||
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
|
||||
<
|
||||
per_ls,
|
||||
false // do not check for empty multilinestring (done above)
|
||||
>::apply(boost::begin(multilinestring),
|
||||
boost::end(multilinestring),
|
||||
per_ls(visitor, strategy));
|
||||
return std::all_of(boost::begin(multilinestring),
|
||||
boost::end(multilinestring),
|
||||
per_ls(visitor, strategy));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -34,7 +35,6 @@
|
||||
#include <boost/geometry/algorithms/validity_failure_type.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/is_valid/has_valid_self_turns.hpp>
|
||||
@ -257,29 +257,30 @@ private:
|
||||
|
||||
|
||||
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_strategy(strategy)
|
||||
{}
|
||||
|
||||
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;
|
||||
Strategy const& m_strategy;
|
||||
};
|
||||
|
||||
public:
|
||||
template <typename VisitPolicy, typename Strategy>
|
||||
static inline bool apply(MultiPolygon const& multipolygon,
|
||||
VisitPolicy& visitor,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef debug_validity_phase<MultiPolygon> debug_phase;
|
||||
using debug_phase = debug_validity_phase<MultiPolygon>;
|
||||
|
||||
if (BOOST_GEOMETRY_CONDITION(AllowEmptyMultiGeometries)
|
||||
&& boost::empty(multipolygon))
|
||||
@ -290,22 +291,20 @@ public:
|
||||
// check validity of all polygons ring
|
||||
debug_phase::apply(1);
|
||||
|
||||
if (! detail::check_iterator_range
|
||||
<
|
||||
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)))
|
||||
if (std::any_of(boost::begin(multipolygon), boost::end(multipolygon),
|
||||
is_invalid_polygon<VisitPolicy, Strategy>(visitor, strategy)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// compute turns and check if all are acceptable
|
||||
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;
|
||||
bool has_invalid_turns =
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -50,7 +51,6 @@
|
||||
#include <boost/geometry/algorithms/detail/point_on_border.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/is_valid/complement_graph.hpp>
|
||||
@ -86,17 +86,17 @@ class is_valid_polygon
|
||||
protected:
|
||||
|
||||
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_strategy(strategy)
|
||||
{}
|
||||
|
||||
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
|
||||
>::apply(ring, m_policy, m_strategy);
|
||||
@ -111,14 +111,9 @@ protected:
|
||||
VisitPolicy& visitor,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
return
|
||||
detail::check_iterator_range
|
||||
<
|
||||
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));
|
||||
return std::none_of(boost::begin(interior_rings),
|
||||
boost::end(interior_rings),
|
||||
is_invalid_ring<VisitPolicy, Strategy>(visitor, strategy));
|
||||
}
|
||||
|
||||
struct has_valid_rings
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014-2020.
|
||||
// Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014-2021.
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -25,7 +26,6 @@
|
||||
#include <boost/range/size.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/overlay/clip_linestring.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/follow.hpp>
|
||||
|
@ -298,11 +298,10 @@ public:
|
||||
bool is_outside(TurnInfo const& turn) const
|
||||
{
|
||||
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(),
|
||||
same_single(
|
||||
turn.operations[other_op_id].seg_id))
|
||||
== m_other_entry_points.end();
|
||||
turn.operations[other_op_id].seg_id));
|
||||
}
|
||||
|
||||
overlay::operation_type get_exit_operation() const
|
||||
|
@ -94,9 +94,8 @@ struct multi_point_geometry_eb<Geometry, linestring_tag>
|
||||
template <typename Point, typename Strategy>
|
||||
bool apply(Point const& boundary_point, Strategy const& strategy)
|
||||
{
|
||||
if ( std::find_if(m_points.begin(), m_points.end(),
|
||||
find_pred<Point, Strategy>(boundary_point, strategy))
|
||||
== m_points.end() )
|
||||
if ( std::none_of(m_points.begin(), m_points.end(),
|
||||
find_pred<Point, Strategy>(boundary_point, strategy)))
|
||||
{
|
||||
m_boundary_found = true;
|
||||
return false;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -16,7 +17,6 @@
|
||||
#include <boost/range/end.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/core/exterior_ring.hpp>
|
||||
@ -62,10 +62,8 @@ class polygon_is_empty
|
||||
template <typename InteriorRings>
|
||||
static inline bool check_interior_rings(InteriorRings const& interior_rings)
|
||||
{
|
||||
return check_iterator_range
|
||||
<
|
||||
range_is_empty, true // allow empty range
|
||||
>::apply(boost::begin(interior_rings), boost::end(interior_rings));
|
||||
return std::all_of(boost::begin(interior_rings), boost::end(interior_rings),
|
||||
[]( auto const& range ){ return boost::empty(range); });
|
||||
}
|
||||
|
||||
public:
|
||||
@ -83,12 +81,10 @@ struct multi_is_empty
|
||||
template <typename MultiGeometry>
|
||||
static inline bool apply(MultiGeometry const& multigeometry)
|
||||
{
|
||||
return check_iterator_range
|
||||
<
|
||||
Policy, true // allow empty range
|
||||
>::apply(boost::begin(multigeometry), boost::end(multigeometry));
|
||||
return std::all_of(boost::begin(multigeometry),
|
||||
boost::end(multigeometry),
|
||||
[]( auto const& range ){ return Policy::apply(range); });
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}} // namespace detail::is_empty
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -13,8 +15,6 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
@ -43,12 +43,14 @@ struct stateless_predicate_based_interrupt_policy
|
||||
template <typename Range>
|
||||
inline bool apply(Range const& range)
|
||||
{
|
||||
// if there is at least one unacceptable turn in the range, return false
|
||||
has_intersections = !detail::check_iterator_range
|
||||
<
|
||||
IsAcceptableTurnPredicate,
|
||||
AllowEmptyTurnRange
|
||||
>::apply(boost::begin(range), boost::end(range));
|
||||
// if there is at least one unacceptable turn in the range, return true
|
||||
bool const has_unacceptable_turn = std::any_of(boost::begin(range), boost::end(range),
|
||||
[](auto const& turn) {
|
||||
return ! IsAcceptableTurnPredicate::apply(turn);
|
||||
});
|
||||
|
||||
has_intersections = has_unacceptable_turn
|
||||
&& !(AllowEmptyTurnRange && boost::empty(range));
|
||||
|
||||
return has_intersections;
|
||||
}
|
||||
@ -78,12 +80,15 @@ struct predicate_based_interrupt_policy
|
||||
template <typename Range>
|
||||
inline bool apply(Range const& range)
|
||||
{
|
||||
// if there is at least one unacceptable turn in the range, return false
|
||||
has_intersections = !detail::check_iterator_range
|
||||
<
|
||||
IsAcceptableTurnPredicate,
|
||||
AllowEmptyTurnRange
|
||||
>::apply(boost::begin(range), boost::end(range), m_predicate);
|
||||
// if there is at least one unacceptable turn in the range, return true
|
||||
bool const has_unacceptable_turn = std::any_of(boost::begin(range),
|
||||
boost::end(range),
|
||||
[&]( auto const& turn ) {
|
||||
return ! m_predicate.apply(turn);
|
||||
});
|
||||
|
||||
has_intersections = has_unacceptable_turn
|
||||
&& !(AllowEmptyTurnRange && boost::empty(range));
|
||||
|
||||
return has_intersections;
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// 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 Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -49,8 +50,6 @@
|
||||
#include <boost/geometry/algorithms/num_points.hpp>
|
||||
#include <boost/geometry/algorithms/is_valid.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
|
||||
|
||||
#include <from_wkt.hpp>
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||
@ -98,17 +97,17 @@ struct is_convertible_to_closed<Ring, bg::ring_tag, bg::open>
|
||||
template <typename Polygon>
|
||||
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>
|
||||
static inline
|
||||
bool apply_to_interior_rings(InteriorRings const& interior_rings)
|
||||
{
|
||||
return bg::detail::check_iterator_range
|
||||
<
|
||||
is_convertible_to_closed<ring_type>
|
||||
>::apply(boost::begin(interior_rings),
|
||||
boost::end(interior_rings));
|
||||
return std::all_of(boost::begin(interior_rings),
|
||||
boost::end(interior_rings),
|
||||
[]( auto const& ring ){
|
||||
return is_convertible_to_closed<ring_type>::apply(ring);
|
||||
});
|
||||
}
|
||||
|
||||
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>
|
||||
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)
|
||||
{
|
||||
return bg::detail::check_iterator_range
|
||||
<
|
||||
is_convertible_to_closed<polygon>,
|
||||
false // do not allow empty multi-polygon
|
||||
>::apply(boost::begin(multi_polygon),
|
||||
boost::end(multi_polygon));
|
||||
return !boost::empty(multi_polygon) && // do not allow empty multi-polygon
|
||||
std::none_of(boost::begin(multi_polygon), boost::end(multi_polygon),
|
||||
[]( auto const& polygon ){
|
||||
return ! is_convertible_to_closed<polygon_type>::apply(polygon);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user