update boost

This commit is contained in:
2023-11-24 12:56:13 -06:00
parent cfc99971af
commit 19d727037a
9260 changed files with 849256 additions and 299957 deletions

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2019.
// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2022.
// Modifications copyright (c) 2013-2022, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@@ -23,14 +23,16 @@
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/detail/covered_by/implementation.hpp>
#include <boost/geometry/algorithms/detail/for_each_range.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/segment_box.hpp>
#include <boost/geometry/iterators/segment_iterator.hpp>
#include <boost/geometry/geometries/helper_geometry.hpp>
#include <boost/geometry/algorithms/for_each.hpp>
namespace boost { namespace geometry
@@ -46,51 +48,25 @@ inline bool point_on_border_covered_by(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
typename geometry::point_type<Geometry1>::type pt;
using point_type = typename geometry::point_type<Geometry1>::type;
typename helper_geometry<point_type>::type pt;
return geometry::point_on_border(pt, geometry1)
&& geometry::covered_by(pt, geometry2, strategy);
}
/*!
\tparam Strategy point_in_geometry strategy
*/
template<typename Geometry, typename Strategy>
struct check_each_ring_for_within
{
bool not_disjoint;
Geometry const& m_geometry;
Strategy const& m_strategy;
inline check_each_ring_for_within(Geometry const& g,
Strategy const& strategy)
: not_disjoint(false)
, m_geometry(g)
, m_strategy(strategy)
{}
template <typename Range>
inline void apply(Range const& range)
{
not_disjoint = not_disjoint
|| point_on_border_covered_by(range, m_geometry, m_strategy);
}
};
/*!
\tparam Strategy point_in_geometry strategy
*/
template <typename FirstGeometry, typename SecondGeometry, typename Strategy>
inline bool rings_containing(FirstGeometry const& geometry1,
SecondGeometry const& geometry2,
template <typename Geometry1, typename Geometry2, typename Strategy>
inline bool rings_containing(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
check_each_ring_for_within
<
FirstGeometry, Strategy
> checker(geometry1, strategy);
geometry::detail::for_each_range(geometry2, checker);
return checker.not_disjoint;
return geometry::detail::any_range_of(geometry2, [&](auto const& range)
{
return point_on_border_covered_by(range, geometry1, strategy);
});
}
@@ -117,10 +93,8 @@ struct areal_areal
// We check that using a point on the border (external boundary),
// and see if that is contained in the other geometry. And vice versa.
if ( rings_containing(geometry1, geometry2,
strategy.template get_point_in_geometry_strategy<Geometry2, Geometry1>())
|| rings_containing(geometry2, geometry1,
strategy.template get_point_in_geometry_strategy<Geometry1, Geometry2>()) )
if ( rings_containing(geometry1, geometry2, strategy)
|| rings_containing(geometry2, geometry1, strategy) )
{
return false;
}
@@ -141,10 +115,10 @@ struct areal_box
Box const& box,
Strategy const& strategy)
{
if ( ! for_each_segment(geometry::segments_begin(areal),
geometry::segments_end(areal),
box,
strategy.get_disjoint_segment_box_strategy()) )
if (! geometry::all_segments_of(areal, [&](auto const& s)
{
return disjoint_segment_box::apply(s, box, strategy);
}) )
{
return false;
}
@@ -152,31 +126,13 @@ struct areal_box
// If there is no intersection of any segment and box,
// the box might be located inside areal geometry
if ( point_on_border_covered_by(box, areal,
strategy.template get_point_in_geometry_strategy<Box, Areal>()) )
if ( point_on_border_covered_by(box, areal, strategy) )
{
return false;
}
return true;
}
private:
template <typename SegIter, typename Strategy>
static inline bool for_each_segment(SegIter first,
SegIter last,
Box const& box,
Strategy const& strategy)
{
for ( ; first != last ; ++first)
{
if (! disjoint_segment_box::apply(*first, box, strategy))
{
return false;
}
}
return true;
}
};

View File

@@ -5,9 +5,8 @@
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2018.
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
// 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 Menelaos Karavelas, on behalf of Oracle
@@ -25,9 +24,7 @@
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
// For backward compatibility
#include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
#include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
#include <boost/geometry/strategies/detail.hpp>
namespace boost { namespace geometry
{
@@ -43,8 +40,23 @@ namespace detail { namespace disjoint
\note Is used from other algorithms, declared separately
to avoid circular references
*/
template <typename Box1, typename Box2, typename Strategy>
inline bool disjoint_box_box(Box1 const& box1, Box2 const& box2, Strategy const&)
template
<
typename Box1, typename Box2, typename Strategy,
std::enable_if_t<strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
>
inline bool disjoint_box_box(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
{
typedef decltype(strategy.disjoint(box1, box2)) strategy_type;
return strategy_type::apply(box1, box2);
}
template
<
typename Box1, typename Box2, typename Strategy,
std::enable_if_t<! strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
>
inline bool disjoint_box_box(Box1 const& box1, Box2 const& box2, Strategy const& )
{
return Strategy::apply(box1, box2);
}
@@ -63,9 +75,10 @@ template <typename Box1, typename Box2, std::size_t DimensionCount>
struct disjoint<Box1, Box2, DimensionCount, box_tag, box_tag, false>
{
template <typename Strategy>
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const&)
static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
{
return Strategy::apply(box1, box2);
typedef decltype(strategy.disjoint(box1, box2)) strategy_type;
return strategy_type::apply(box1, box2);
}
};

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2017.
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
// 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 Menelaos Karavelas, on behalf of Oracle
@@ -33,5 +33,9 @@
#include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp>
#include <boost/geometry/strategies/relate/cartesian.hpp>
#include <boost/geometry/strategies/relate/geographic.hpp>
#include <boost/geometry/strategies/relate/spherical.hpp>
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_IMPLEMENTATION_HPP

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2017.
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
// 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 Menelaos Karavelas, on behalf of Oracle
@@ -23,16 +23,16 @@
#include <cstddef>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/algorithms/detail/relate/interface.hpp>
#include <boost/geometry/algorithms/detail/visit.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/strategies/disjoint.hpp>
#include <boost/geometry/strategies/default_strategy.hpp>
#include <boost/geometry/strategies/detail.hpp>
#include <boost/geometry/strategies/relate/services.hpp>
namespace boost { namespace geometry
@@ -41,9 +41,14 @@ namespace boost { namespace geometry
namespace resolve_strategy
{
template
<
typename Strategy,
bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
>
struct disjoint
{
template <typename Geometry1, typename Geometry2, typename Strategy>
template <typename Geometry1, typename Geometry2>
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
@@ -53,13 +58,35 @@ struct disjoint
Geometry1, Geometry2
>::apply(geometry1, geometry2, strategy);
}
};
template <typename Strategy>
struct disjoint<Strategy, false>
{
template <typename Geometry1, typename Geometry2>
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
using strategies::relate::services::strategy_converter;
return dispatch::disjoint
<
Geometry1, Geometry2
>::apply(geometry1, geometry2,
strategy_converter<Strategy>::get(strategy));
}
};
template <>
struct disjoint<default_strategy, false>
{
template <typename Geometry1, typename Geometry2>
static inline bool apply(Geometry1 const& geometry1,
Geometry2 const& geometry2,
default_strategy)
{
typedef typename strategy::disjoint::services::default_strategy
typedef typename strategies::relate::services::default_strategy
<
Geometry1, Geometry2
>::type strategy_type;
@@ -74,13 +101,21 @@ struct disjoint
} // namespace resolve_strategy
namespace resolve_variant {
namespace resolve_dynamic {
template <typename Geometry1, typename Geometry2>
template
<
typename Geometry1, typename Geometry2,
bool IsDynamic = util::is_dynamic_geometry<Geometry1>::value
|| util::is_dynamic_geometry<Geometry2>::value,
bool IsCollection = util::is_geometry_collection<Geometry1>::value
|| util::is_geometry_collection<Geometry2>::value
>
struct disjoint
{
template <typename Strategy>
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
Strategy const& strategy)
{
concepts::check_concepts_and_equal_dimensions
<
@@ -88,108 +123,60 @@ struct disjoint
Geometry2 const
>();
return resolve_strategy::disjoint::apply(geometry1, geometry2, strategy);
return resolve_strategy::disjoint
<
Strategy
>::apply(geometry1, geometry2, strategy);
}
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Geometry2>
struct disjoint<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Geometry2>
template <typename Geometry1, typename Geometry2>
struct disjoint<Geometry1, Geometry2, true, false>
{
template <typename Strategy>
struct visitor: boost::static_visitor<bool>
{
Geometry2 const& m_geometry2;
Strategy const& m_strategy;
visitor(Geometry2 const& geometry2, Strategy const& strategy)
: m_geometry2(geometry2)
, m_strategy(strategy)
{}
template <typename Geometry1>
bool operator()(Geometry1 const& geometry1) const
{
return disjoint<Geometry1, Geometry2>::apply(geometry1, m_geometry2, m_strategy);
}
};
template <typename Strategy>
static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry1,
Geometry2 const& geometry2,
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
Strategy const& strategy)
{
return boost::apply_visitor(visitor<Strategy>(geometry2, strategy), geometry1);
bool result = true;
detail::visit([&](auto const& g1, auto const& g2)
{
result = disjoint
<
util::remove_cref_t<decltype(g1)>, util::remove_cref_t<decltype(g2)>
>::apply(g1, g2, strategy);
}, geometry1, geometry2);
return result;
}
};
template <typename Geometry1, BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct disjoint<Geometry1, boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
// TODO: The complexity is quadratic for two GCs
// Decrease e.g. with spatial index
template <typename Geometry1, typename Geometry2, bool IsDynamic>
struct disjoint<Geometry1, Geometry2, IsDynamic, true>
{
template <typename Strategy>
struct visitor: boost::static_visitor<bool>
{
Geometry1 const& m_geometry1;
Strategy const& m_strategy;
visitor(Geometry1 const& geometry1, Strategy const& strategy)
: m_geometry1(geometry1)
, m_strategy(strategy)
{}
template <typename Geometry2>
bool operator()(Geometry2 const& geometry2) const
{
return disjoint<Geometry1, Geometry2>::apply(m_geometry1, geometry2, m_strategy);
}
};
template <typename Strategy>
static inline bool apply(Geometry1 const& geometry1,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry2,
static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
Strategy const& strategy)
{
return boost::apply_visitor(visitor<Strategy>(geometry1, strategy), geometry2);
bool result = true;
detail::visit_breadth_first([&](auto const& g1)
{
detail::visit_breadth_first([&](auto const& g2)
{
result = disjoint
<
util::remove_cref_t<decltype(g1)>, util::remove_cref_t<decltype(g2)>
>::apply(g1, g2, strategy);
// If any of the combination intersects then the final result is not disjoint
return result;
}, geometry2);
return result;
}, geometry1);
return result;
}
};
template
<
BOOST_VARIANT_ENUM_PARAMS(typename T1),
BOOST_VARIANT_ENUM_PARAMS(typename T2)
>
struct disjoint
<
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)>,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)>
>
{
template <typename Strategy>
struct visitor: boost::static_visitor<bool>
{
Strategy const& m_strategy;
visitor(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Geometry1, typename Geometry2>
bool operator()(Geometry1 const& geometry1,
Geometry2 const& geometry2) const
{
return disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2, m_strategy);
}
};
template <typename Strategy>
static inline bool apply(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T1)> const& geometry1,
boost::variant<BOOST_VARIANT_ENUM_PARAMS(T2)> const& geometry2,
Strategy const& strategy)
{
return boost::apply_visitor(visitor<Strategy>(strategy), geometry1, geometry2);
}
};
} // namespace resolve_variant
} // namespace resolve_dynamic
/*!
@@ -211,7 +198,7 @@ inline bool disjoint(Geometry1 const& geometry1,
Geometry2 const& geometry2,
Strategy const& strategy)
{
return resolve_variant::disjoint
return resolve_dynamic::disjoint
<
Geometry1, Geometry2
>::apply(geometry1, geometry2, strategy);
@@ -228,12 +215,17 @@ inline bool disjoint(Geometry1 const& geometry1,
\return \return_check2{are disjoint}
\qbk{[include reference/algorithms/disjoint.qbk]}
\qbk{
[heading Examples]
[disjoint]
[disjoint_output]
}
*/
template <typename Geometry1, typename Geometry2>
inline bool disjoint(Geometry1 const& geometry1,
Geometry2 const& geometry2)
{
return resolve_variant::disjoint
return resolve_dynamic::disjoint
<
Geometry1, Geometry2
>::apply(geometry1, geometry2, default_strategy());

View File

@@ -5,11 +5,12 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2018.
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2022.
// Modifications copyright (c) 2013-2022, 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.
@@ -23,7 +24,9 @@
#include <iterator>
#include <boost/range.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/value_type.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/point_type.hpp>
@@ -34,11 +37,10 @@
#include <boost/geometry/core/tag_cast.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/detail/covered_by/implementation.hpp>
#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>
@@ -49,6 +51,7 @@
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/geometries/helper_geometry.hpp>
namespace boost { namespace geometry
{
@@ -68,11 +71,11 @@ struct disjoint_no_intersections_policy
template <typename Strategy>
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
{
typedef typename point_type<Geometry1>::type point1_type;
point1_type p;
using point_type = typename point_type<Geometry1>::type;
typename helper_geometry<point_type>::type p;
geometry::point_on_border(p, g1);
return !geometry::covered_by(p, g2, strategy);
return ! geometry::covered_by(p, g2, strategy);
}
};
@@ -86,12 +89,11 @@ struct disjoint_no_intersections_policy<Geometry1, Geometry2, Tag1, multi_tag>
static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
{
// TODO: use partition or rtree on g2
typedef typename boost::range_iterator<Geometry1 const>::type iterator;
for ( iterator it = boost::begin(g1) ; it != boost::end(g1) ; ++it )
for (auto it = boost::begin(g1); it != boost::end(g1); ++it)
{
typedef typename boost::range_value<Geometry1 const>::type value_type;
if ( ! disjoint_no_intersections_policy<value_type const, Geometry2>
::apply(*it, g2, strategy) )
if (! disjoint_no_intersections_policy<value_type const, Geometry2>
::apply(*it, g2, strategy))
{
return false;
}
@@ -118,9 +120,7 @@ struct disjoint_linear_areal
return false;
}
return NoIntersectionsPolicy
::apply(g1, g2,
strategy.template get_point_in_geometry_strategy<Geometry1, Geometry2>());
return NoIntersectionsPolicy::apply(g1, g2, strategy);
}
};
@@ -141,31 +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, closure<ring_type>::value, 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));
disjoint_range_segment_or_box<ring_type, Segment>
>;
return std::all_of(boost::begin(interior_rings),
boost::end(interior_rings),
unary_predicate_type(segment, strategy));
}
@@ -175,17 +169,16 @@ public:
Polygon const& polygon,
IntersectionStrategy const& strategy)
{
typedef typename geometry::ring_type<Polygon>::type ring;
if ( !disjoint_range_segment_or_box
<
ring, closure<Polygon>::value, Segment
>::apply(geometry::exterior_ring(polygon), segment, strategy) )
if (! disjoint_range_segment_or_box
<
typename geometry::ring_type<Polygon>::type,
Segment
>::apply(geometry::exterior_ring(polygon), segment, strategy))
{
return false;
}
if ( !check_interior_rings(geometry::interior_rings(polygon), segment, strategy) )
if (! check_interior_rings(geometry::interior_rings(polygon), segment, strategy))
{
return false;
}
@@ -193,8 +186,7 @@ public:
typename point_type<Segment>::type p;
detail::assign_point_from_index<0>(segment, p);
return !geometry::covered_by(p, polygon,
strategy.template get_point_in_geometry_strategy<Segment, Polygon>());
return ! geometry::covered_by(p, polygon, strategy);
}
};
@@ -222,10 +214,7 @@ struct disjoint_segment_areal<Segment, Ring, ring_tag>
Ring const& ring,
IntersectionStrategy const& strategy)
{
if ( !disjoint_range_segment_or_box
<
Ring, closure<Ring>::value, Segment
>::apply(ring, segment, strategy) )
if (! disjoint_range_segment_or_box<Ring, Segment>::apply(ring, segment, strategy))
{
return false;
}
@@ -233,8 +222,7 @@ struct disjoint_segment_areal<Segment, Ring, ring_tag>
typename point_type<Segment>::type p;
detail::assign_point_from_index<0>(segment, p);
return !geometry::covered_by(p, ring,
strategy.template get_point_in_geometry_strategy<Segment, Ring>());
return ! geometry::covered_by(p, ring, strategy);
}
};

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2017.
// Modifications copyright (c) 2013-2017, Oracle and/or its affiliates.
// 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
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@@ -24,9 +24,6 @@
#include <cstddef>
#include <deque>
#include <boost/range.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
@@ -34,10 +31,12 @@
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/overlay/do_reverse.hpp>
#include <boost/geometry/algorithms/detail/overlay/segment_as_subrange.hpp>
#include <boost/geometry/geometries/helper_geometry.hpp>
#include <boost/geometry/policies/disjoint_interrupt_policy.hpp>
#include <boost/geometry/policies/robustness/no_rescale_policy.hpp>
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
@@ -59,28 +58,17 @@ struct disjoint_segment
{
typedef typename point_type<Segment1>::type point_type;
// We don't need to rescale to detect disjointness
typedef no_rescale_policy rescale_policy_type;
rescale_policy_type robust_policy;
typedef segment_intersection_points
<
point_type,
typename segment_ratio_type
<
point_type,
rescale_policy_type
>::type
> intersection_return_type;
typedef segment_intersection_points<point_type> intersection_return_type;
typedef policies::relate::segments_intersection_points
<
intersection_return_type
> intersection_policy;
intersection_return_type is = strategy.apply(segment1, segment2,
intersection_policy(),
robust_policy);
detail::segment_as_subrange<Segment1> sub_range1(segment1);
detail::segment_as_subrange<Segment2> sub_range2(segment2);
intersection_return_type is = strategy.relate().apply(sub_range1, sub_range2,
intersection_policy());
return is.count == 0;
}
@@ -93,6 +81,7 @@ struct assign_disjoint_policy
static bool const include_no_turn = true;
static bool const include_degenerate = true;
static bool const include_opposite = true;
static bool const include_start_turn = false;
};
@@ -104,21 +93,21 @@ struct disjoint_linear
Geometry2 const& geometry2,
Strategy const& strategy)
{
typedef typename geometry::point_type<Geometry1>::type point_type;
typedef detail::no_rescale_policy rescale_policy_type;
typedef typename geometry::segment_ratio_type
using point_type = typename geometry::point_type<Geometry1>::type;
using mutable_point_type = typename helper_geometry<point_type>::type;
using ratio_type = geometry::segment_ratio
<
point_type, rescale_policy_type
>::type segment_ratio_type;
typedef overlay::turn_info
typename coordinate_type<point_type>::type
> ;
using turn_info_type = overlay::turn_info
<
point_type,
segment_ratio_type,
mutable_point_type,
ratio_type,
typename detail::get_turns::turn_operation_type
<
Geometry1, Geometry2, segment_ratio_type
Geometry1, Geometry2, mutable_point_type, ratio_type
>::type
> turn_info_type;
>;
std::deque<turn_info_type> turns;
@@ -139,7 +128,7 @@ struct disjoint_linear
Geometry1, Geometry2, assign_disjoint_policy
>
>::apply(0, geometry1, 1, geometry2,
strategy, rescale_policy_type(), turns, interrupt_policy);
strategy, detail::no_rescale_policy(), turns, interrupt_policy);
return !interrupt_policy.has_intersections;
}

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2014.
// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates.
// 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 Menelaos Karavelas, on behalf of Oracle
@@ -21,19 +21,14 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP
#include <boost/range.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/views/closeable_view.hpp>
#include <boost/geometry/algorithms/detail/disjoint/multirange_geometry.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/util/range.hpp>
#include <boost/geometry/views/closeable_view.hpp>
namespace boost { namespace geometry
@@ -47,10 +42,41 @@ namespace detail { namespace disjoint
template
<
typename Range,
closure_selector Closure,
typename SegmentOrBox
typename SegmentOrBox,
typename Tag = typename tag<SegmentOrBox>::type
>
struct disjoint_point_segment_or_box
: not_implemented<Tag>
{};
template <typename Segment>
struct disjoint_point_segment_or_box<Segment, segment_tag>
{
template <typename Point, typename Strategy>
static inline bool apply(Point const& point, Segment const& segment, Strategy const& strategy)
{
return dispatch::disjoint
<
Point, Segment
>::apply(point, segment, strategy);
}
};
template <typename Box>
struct disjoint_point_segment_or_box<Box, box_tag>
{
template <typename Point, typename Strategy>
static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
{
return dispatch::disjoint
<
Point, Box
>::apply(point, box, strategy);
}
};
template <typename Range, typename SegmentOrBox>
struct disjoint_range_segment_or_box
{
template <typename Strategy>
@@ -58,24 +84,12 @@ struct disjoint_range_segment_or_box
SegmentOrBox const& segment_or_box,
Strategy const& strategy)
{
typedef typename closeable_view<Range const, Closure>::type view_type;
using point_type = typename point_type<Range>::type;
using range_segment = typename geometry::model::referring_segment<point_type const>;
typedef typename ::boost::range_value<view_type>::type point_type;
typedef typename ::boost::range_iterator
<
view_type const
>::type const_iterator;
detail::closed_view<Range const> const view(range);
typedef typename ::boost::range_size<view_type>::type size_type;
typedef typename geometry::model::referring_segment
<
point_type const
> range_segment;
view_type view(range);
const size_type count = ::boost::size(view);
auto const count = ::boost::size(view);
if ( count == 0 )
{
@@ -83,22 +97,22 @@ struct disjoint_range_segment_or_box
}
else if ( count == 1 )
{
return dispatch::disjoint
return disjoint_point_segment_or_box
<
point_type, SegmentOrBox
>::apply(geometry::range::front<view_type const>(view),
segment_or_box,
strategy.template get_point_in_geometry_strategy<Range, SegmentOrBox>());
SegmentOrBox
>::apply(range::front(view), segment_or_box, strategy);
}
else
{
const_iterator it0 = ::boost::begin(view);
const_iterator it1 = ::boost::begin(view) + 1;
const_iterator last = ::boost::end(view);
auto it0 = ::boost::begin(view);
auto it1 = ::boost::begin(view) + 1;
auto const last = ::boost::end(view);
for ( ; it1 != last ; ++it0, ++it1 )
{
range_segment rng_segment(*it0, *it1);
point_type const& p0 = *it0;
point_type const& p1 = *it1;
range_segment rng_segment(p0, p1);
if ( !dispatch::disjoint
<
range_segment, SegmentOrBox
@@ -128,7 +142,7 @@ struct disjoint_linear_segment_or_box
template <typename Linestring, typename SegmentOrBox>
struct disjoint_linear_segment_or_box<Linestring, SegmentOrBox, linestring_tag>
: disjoint_range_segment_or_box<Linestring, closed, SegmentOrBox>
: disjoint_range_segment_or_box<Linestring, SegmentOrBox>
{};

View File

@@ -2,7 +2,9 @@
// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2014-2018, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, 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
@@ -15,8 +17,10 @@
#include <algorithm>
#include <vector>
#include <boost/range.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/range/value_type.hpp>
#include <boost/geometry/core/assert.hpp>
#include <boost/geometry/core/tag.hpp>
@@ -29,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>
@@ -42,6 +45,12 @@
#include <boost/geometry/policies/compare.hpp>
// TEMP
#include <boost/geometry/strategies/envelope/cartesian.hpp>
#include <boost/geometry/strategies/envelope/geographic.hpp>
#include <boost/geometry/strategies/envelope/spherical.hpp>
namespace boost { namespace geometry
{
@@ -51,29 +60,28 @@ namespace detail { namespace disjoint
{
template <typename MultiPoint1, typename MultiPoint2>
class multipoint_multipoint
{
private:
template <typename Iterator>
class unary_disjoint_predicate
: geometry::less<>
template <typename Iterator, typename Strategy>
class unary_not_disjoint_predicate
: geometry::less<void, -1, Strategy>
{
private:
typedef geometry::less<> base_type;
using less_type = geometry::less<void, -1, Strategy>;
public:
unary_disjoint_predicate(Iterator first, Iterator last)
: base_type(), m_first(first), m_last(last)
unary_not_disjoint_predicate(Iterator first, Iterator last)
: less_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<less_type const&>(*this));
}
private:
@@ -81,29 +89,30 @@ private:
};
public:
template <typename MultiPoint1, typename MultiPoint2, typename Strategy>
static inline bool apply(MultiPoint1 const& multipoint1,
MultiPoint2 const& multipoint2)
MultiPoint2 const& multipoint2,
Strategy const&)
{
BOOST_GEOMETRY_ASSERT( boost::size(multipoint1) <= boost::size(multipoint2) );
typedef typename boost::range_value<MultiPoint1>::type point1_type;
using less_type = geometry::less<void, -1, Strategy>;
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(), geometry::less<>());
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
> predicate_type;
typename std::vector<point1_type>::const_iterator,
Strategy
>;
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()));
}
};
@@ -112,65 +121,78 @@ template <typename MultiPoint, typename Linear>
class multipoint_linear
{
private:
template <typename Strategy>
struct expand_box_point
{
explicit expand_box_point(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename Point>
static inline void apply(Box& total, Point const& point)
void apply(Box& total, Point const& point) const
{
geometry::expand(total, point);
geometry::expand(total, point, m_strategy);
}
Strategy const& m_strategy;
};
template <typename EnvelopeStrategy>
template <typename Strategy>
struct expand_box_segment
{
explicit expand_box_segment(EnvelopeStrategy const& strategy)
explicit expand_box_segment(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename Segment>
inline void apply(Box& total, Segment const& segment) const
void apply(Box& total, Segment const& segment) const
{
geometry::expand(total,
geometry::return_envelope<Box>(segment, m_strategy));
geometry::return_envelope<Box>(segment, m_strategy),
m_strategy);
}
EnvelopeStrategy const& m_strategy;
Strategy const& m_strategy;
};
template <typename DisjointPointBoxStrategy>
template <typename Strategy>
struct overlaps_box_point
{
explicit overlaps_box_point(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename Point>
static inline bool apply(Box const& box, Point const& point)
bool apply(Box const& box, Point const& point) const
{
// The default strategy is enough in this case
return ! detail::disjoint::disjoint_point_box(point, box,
DisjointPointBoxStrategy());
m_strategy);
}
Strategy const& m_strategy;
};
template <typename DisjointStrategy>
template <typename Strategy>
struct overlaps_box_segment
{
explicit overlaps_box_segment(DisjointStrategy const& strategy)
explicit overlaps_box_segment(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename Segment>
inline bool apply(Box const& box, Segment const& segment) const
bool apply(Box const& box, Segment const& segment) const
{
return ! dispatch::disjoint<Segment, Box>::apply(segment, box, m_strategy);
}
DisjointStrategy const& m_strategy;
Strategy const& m_strategy;
};
template <typename PtSegStrategy>
template <typename Strategy>
class item_visitor_type
{
public:
item_visitor_type(PtSegStrategy const& strategy)
item_visitor_type(Strategy const& strategy)
: m_intersection_found(false)
, m_strategy(strategy)
{}
@@ -191,7 +213,7 @@ private:
private:
bool m_intersection_found;
PtSegStrategy const& m_strategy;
Strategy const& m_strategy;
};
// structs for partition -- end
@@ -225,10 +247,6 @@ public:
{
item_visitor_type<Strategy> visitor(strategy);
typedef typename Strategy::envelope_strategy_type envelope_strategy_type;
typedef typename Strategy::disjoint_strategy_type disjoint_strategy_type;
typedef typename Strategy::disjoint_point_box_strategy_type disjoint_pb_strategy_type;
// TODO: disjoint Segment/Box may be called in partition multiple times
// possibly for non-cartesian segments which could be slow. We should consider
// passing a range of bounding boxes of segments after calculating them once.
@@ -238,16 +256,17 @@ public:
<
geometry::model::box<typename point_type<MultiPoint>::type>
>::apply(multipoint, segment_range(linear), visitor,
expand_box_point(),
overlaps_box_point<disjoint_pb_strategy_type>(),
expand_box_segment<envelope_strategy_type>(strategy.get_envelope_strategy()),
overlaps_box_segment<disjoint_strategy_type>(strategy.get_disjoint_strategy()));
expand_box_point<Strategy>(strategy),
overlaps_box_point<Strategy>(strategy),
expand_box_segment<Strategy>(strategy),
overlaps_box_segment<Strategy>(strategy));
return ! visitor.intersection_found();
}
template <typename Strategy>
static inline bool apply(Linear const& linear, MultiPoint const& multipoint, Strategy const& strategy)
static inline bool apply(Linear const& linear, MultiPoint const& multipoint,
Strategy const& strategy)
{
return apply(multipoint, linear, strategy);
}
@@ -263,21 +282,18 @@ public:
SingleGeometry const& single_geometry,
Strategy const& strategy)
{
typedef typename Strategy::disjoint_point_box_strategy_type d_pb_strategy_type;
typedef typename point_type<MultiPoint>::type point1_type;
typedef typename point_type<SingleGeometry>::type point2_type;
typedef model::box<point2_type> box2_type;
box2_type box2;
geometry::envelope(single_geometry, box2, strategy.get_envelope_strategy());
geometry::envelope(single_geometry, box2, strategy);
geometry::detail::expand_by_epsilon(box2);
typedef typename boost::range_const_iterator<MultiPoint>::type iterator;
for ( iterator it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it )
for (auto it = boost::begin(multi_point) ; it != boost::end(multi_point) ; ++it)
{
// The default strategy is enough for Point/Box
if (! detail::disjoint::disjoint_point_box(*it, box2, d_pb_strategy_type())
if (! detail::disjoint::disjoint_point_box(*it, box2, strategy)
&& ! dispatch::disjoint<point1_type, SingleGeometry>::apply(*it, single_geometry, strategy))
{
return false;
@@ -288,7 +304,8 @@ public:
}
template <typename Strategy>
static inline bool apply(SingleGeometry const& single_geometry, MultiPoint const& multi_point, Strategy const& strategy)
static inline bool apply(SingleGeometry const& single_geometry, MultiPoint const& multi_point,
Strategy const& strategy)
{
return apply(multi_point, single_geometry, strategy);
}
@@ -299,54 +316,77 @@ template <typename MultiPoint, typename MultiGeometry>
class multi_point_multi_geometry
{
private:
template <typename Strategy>
struct expand_box_point
{
explicit expand_box_point(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename Point>
static inline void apply(Box& total, Point const& point)
void apply(Box& total, Point const& point) const
{
geometry::expand(total, point);
geometry::expand(total, point, m_strategy);
}
Strategy const& m_strategy;
};
template <typename Strategy>
struct expand_box_box_pair
{
explicit expand_box_box_pair(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename BoxPair>
inline void apply(Box& total, BoxPair const& box_pair) const
void apply(Box& total, BoxPair const& box_pair) const
{
geometry::expand(total, box_pair.first);
geometry::expand(total, box_pair.first, m_strategy);
}
Strategy const& m_strategy;
};
template <typename DisjointPointBoxStrategy>
template <typename Strategy>
struct overlaps_box_point
{
explicit overlaps_box_point(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename Point>
static inline bool apply(Box const& box, Point const& point)
bool apply(Box const& box, Point const& point) const
{
// The default strategy is enough for Point/Box
return ! detail::disjoint::disjoint_point_box(point, box,
DisjointPointBoxStrategy());
return ! detail::disjoint::disjoint_point_box(point, box, m_strategy);
}
Strategy const& m_strategy;
};
template <typename DisjointBoxBoxStrategy>
template <typename Strategy>
struct overlaps_box_box_pair
{
explicit overlaps_box_box_pair(Strategy const& strategy)
: m_strategy(strategy)
{}
template <typename Box, typename BoxPair>
inline bool apply(Box const& box, BoxPair const& box_pair) const
bool apply(Box const& box, BoxPair const& box_pair) const
{
// The default strategy is enough for Box/Box
return ! detail::disjoint::disjoint_box_box(box_pair.first, box,
DisjointBoxBoxStrategy());
m_strategy);
}
Strategy const& m_strategy;
};
template <typename PtSegStrategy>
template <typename Strategy>
class item_visitor_type
{
public:
item_visitor_type(MultiGeometry const& multi_geometry,
PtSegStrategy const& strategy)
Strategy const& strategy)
: m_intersection_found(false)
, m_multi_geometry(multi_geometry)
, m_strategy(strategy)
@@ -355,14 +395,15 @@ private:
template <typename Point, typename BoxPair>
inline bool apply(Point const& point, BoxPair const& box_pair)
{
typedef typename PtSegStrategy::disjoint_point_box_strategy_type d_pb_strategy_type;
typedef typename boost::range_value<MultiGeometry>::type single_type;
// The default strategy is enough for Point/Box
if (! m_intersection_found
&& ! detail::disjoint::disjoint_point_box(point, box_pair.first, d_pb_strategy_type())
&& ! dispatch::disjoint<Point, single_type>::apply(point, range::at(m_multi_geometry, box_pair.second), m_strategy))
&& ! detail::disjoint::disjoint_point_box(point, box_pair.first, m_strategy)
&& ! dispatch::disjoint
<
Point, single_type
>::apply(point, range::at(m_multi_geometry, box_pair.second), m_strategy))
{
m_intersection_found = true;
return false;
@@ -375,7 +416,7 @@ private:
private:
bool m_intersection_found;
MultiGeometry const& m_multi_geometry;
PtSegStrategy const& m_strategy;
Strategy const& m_strategy;
};
// structs for partition -- end
@@ -389,37 +430,25 @@ public:
typedef model::box<point2_type> box2_type;
typedef std::pair<box2_type, std::size_t> box_pair_type;
typename Strategy::envelope_strategy_type const
envelope_strategy = strategy.get_envelope_strategy();
std::size_t count2 = boost::size(multi_geometry);
std::vector<box_pair_type> boxes(count2);
for (std::size_t i = 0 ; i < count2 ; ++i)
{
geometry::envelope(range::at(multi_geometry, i), boxes[i].first, envelope_strategy);
geometry::envelope(range::at(multi_geometry, i), boxes[i].first, strategy);
geometry::detail::expand_by_epsilon(boxes[i].first);
boxes[i].second = i;
}
item_visitor_type<Strategy> visitor(multi_geometry, strategy);
typedef overlaps_box_point
<
typename Strategy::disjoint_point_box_strategy_type
> overlaps_box_point_type;
typedef overlaps_box_box_pair
<
typename Strategy::disjoint_box_box_strategy_type
> overlaps_box_box_pair_type;
geometry::partition
<
box1_type
>::apply(multi_point, boxes, visitor,
expand_box_point(),
overlaps_box_point_type(),
expand_box_box_pair(),
overlaps_box_box_pair_type());
expand_box_point<Strategy>(strategy),
overlaps_box_point<Strategy>(strategy),
expand_box_box_pair<Strategy>(strategy),
overlaps_box_box_pair<Strategy>(strategy));
return ! visitor.intersection_found();
}
@@ -493,20 +522,16 @@ struct disjoint
template <typename Strategy>
static inline bool apply(MultiPoint1 const& multipoint1,
MultiPoint2 const& multipoint2,
Strategy const& )
Strategy const& strategy)
{
if ( boost::size(multipoint2) < boost::size(multipoint1) )
{
return detail::disjoint::multipoint_multipoint
<
MultiPoint2, MultiPoint1
>::apply(multipoint2, multipoint1);
}
::apply(multipoint2, multipoint1, strategy);
}
return detail::disjoint::multipoint_multipoint
<
MultiPoint1, MultiPoint2
>::apply(multipoint1, multipoint2);
::apply(multipoint1, multipoint2, strategy);
}
};

View File

@@ -1,7 +1,8 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2014-2017, Oracle and/or its affiliates.
// Copyright (c) 2014-2023, 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
@@ -11,9 +12,12 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
#include <boost/range.hpp>
#include <algorithm>
#include <boost/range/begin.hpp>
#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>
@@ -31,13 +35,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);
}
@@ -56,7 +60,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,
@@ -65,13 +69,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>

View File

@@ -5,9 +5,8 @@
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
// This file was modified by Oracle on 2013-2018.
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
// 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 Menelaos Karavelas, on behalf of Oracle
@@ -23,12 +22,13 @@
#include <cstddef>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/strategies/disjoint.hpp>
#include <boost/geometry/strategies/detail.hpp>
namespace boost { namespace geometry
{
@@ -41,8 +41,26 @@ namespace detail { namespace disjoint
/*!
\brief Internal utility function to detect if point/box are disjoint
*/
template <typename Point, typename Box, typename Strategy>
inline bool disjoint_point_box(Point const& point, Box const& box, Strategy const& )
template
<
typename Point, typename Box, typename Strategy,
std::enable_if_t<strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
>
inline bool disjoint_point_box(Point const& point, Box const& box,
Strategy const& strategy)
{
typedef decltype(strategy.covered_by(point, box)) strategy_type;
// ! covered_by(point, box)
return ! strategy_type::apply(point, box);
}
template
<
typename Point, typename Box, typename Strategy,
std::enable_if_t<! strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
>
inline bool disjoint_point_box(Point const& point, Box const& box,
Strategy const& )
{
// ! covered_by(point, box)
return ! Strategy::apply(point, box);
@@ -62,10 +80,12 @@ template <typename Point, typename Box, std::size_t DimensionCount>
struct disjoint<Point, Box, DimensionCount, point_tag, box_tag, false>
{
template <typename Strategy>
static inline bool apply(Point const& point, Box const& box, Strategy const& )
static inline bool apply(Point const& point, Box const& box,
Strategy const& strategy)
{
typedef decltype(strategy.covered_by(point, box)) strategy_type;
// ! covered_by(point, box)
return ! Strategy::apply(point, box);
return ! strategy_type::apply(point, box);
}
};

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013, 2014, 2015.
// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2022.
// Modifications copyright (c) 2013-2022, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@@ -21,7 +21,7 @@
#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_GEOMETRY_HPP
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/detail/covered_by/implementation.hpp>
#include <boost/geometry/algorithms/detail/disjoint/linear_linear.hpp>

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
// This file was modified by Oracle on 2013, 2014, 2015, 2017, 2018.
// Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
// 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
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
@@ -22,11 +22,14 @@
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
#include <cstddef>
#include <type_traits>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/strategies/detail.hpp>
// For backward compatibility
#include <boost/geometry/strategies/disjoint.hpp>
#include <boost/geometry/strategies/cartesian/point_in_point.hpp>
@@ -46,10 +49,28 @@ namespace detail { namespace disjoint
\brief Internal utility function to detect of points are disjoint
\note To avoid circular references
*/
template <typename Point1, typename Point2, typename Strategy>
template
<
typename Point1, typename Point2, typename Strategy,
std::enable_if_t<strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
>
inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2,
Strategy const& strategy)
{
typedef decltype(strategy.relate(point1, point2)) strategy_type;
// ! within(point1, point2)
return ! strategy_type::apply(point1, point2);
}
template
<
typename Point1, typename Point2, typename Strategy,
std::enable_if_t<! strategies::detail::is_umbrella_strategy<Strategy>::value, int> = 0
>
inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2,
Strategy const& )
{
// ! within(point1, point2)
return ! Strategy::apply(point1, point2);
}
@@ -68,9 +89,11 @@ struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, false>
{
template <typename Strategy>
static inline bool apply(Point1 const& point1, Point2 const& point2,
Strategy const& )
Strategy const& strategy)
{
return ! Strategy::apply(point1, point2);
typedef decltype(strategy.relate(point1, point2)) strategy_type;
// ! within(point1, point2)
return ! strategy_type::apply(point1, point2);
}
};

View File

@@ -5,8 +5,8 @@
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2013-2019.
// Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
// This file was modified by Oracle on 2013-2021.
// Modifications copyright (c) 2013-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
@@ -33,14 +33,13 @@
#include <boost/geometry/algorithms/detail/envelope/segment.hpp>
#include <boost/geometry/algorithms/detail/normalize.hpp>
#include <boost/geometry/algorithms/dispatch/disjoint.hpp>
#include <boost/geometry/algorithms/envelope.hpp>
#include <boost/geometry/formulas/vertex_longitude.hpp>
#include <boost/geometry/geometries/box.hpp>
// Temporary, for envelope_segment_impl
#include <boost/geometry/strategies/spherical/envelope_segment.hpp>
#include <boost/geometry/strategy/spherical/envelope_segment.hpp>
namespace boost { namespace geometry
{
@@ -181,12 +180,31 @@ struct disjoint_segment_box_sphere_or_spheroid
azimuth_strategy.apply(lon1, lat1, b_lon_min, b_lat_max, a_b2);
azimuth_strategy.apply(lon1, lat1, b_lon_max, b_lat_max, a_b3);
bool b0 = formula::azimuth_side_value(alp1, a_b0) > 0;
bool b1 = formula::azimuth_side_value(alp1, a_b1) > 0;
bool b2 = formula::azimuth_side_value(alp1, a_b2) > 0;
bool b3 = formula::azimuth_side_value(alp1, a_b3) > 0;
int s0 = formula::azimuth_side_value(alp1, a_b0);
int s1 = formula::azimuth_side_value(alp1, a_b1);
int s2 = formula::azimuth_side_value(alp1, a_b2);
int s3 = formula::azimuth_side_value(alp1, a_b3);
if (!(b0 && b1 && b2 && b3) && (b0 || b1 || b2 || b3))
if (s0 == 0 || s1 == 0 || s2 == 0 || s3 == 0)
{
return disjoint_info::intersect;
}
bool s0_positive = s0 > 0;
bool s1_positive = s1 > 0;
bool s2_positive = s2 > 0;
bool s3_positive = s3 > 0;
bool all_positive = s0_positive && s1_positive && s2_positive && s3_positive;
bool all_non_positive = !(s0_positive || s1_positive || s2_positive || s3_positive);
bool vertex_north = lat1 + lat2 > 0;
if ((all_positive && vertex_north) || (all_non_positive && !vertex_north))
{
return disjoint_info::disjoint_no_vertex;
}
if (!all_positive && !all_non_positive)
{
return disjoint_info::intersect;
}
@@ -196,14 +214,13 @@ struct disjoint_segment_box_sphere_or_spheroid
// hemisphere. Then we have to compute the vertex of the segment
CT vertex_lat;
CT lat_sum = lat1 + lat2;
if ((lat1 < b_lat_min && lat_sum > CT(0))
|| (lat1 > b_lat_max && lat_sum < CT(0)))
if ((lat1 < b_lat_min && vertex_north)
|| (lat1 > b_lat_max && !vertex_north))
{
CT b_lat_below; //latitude of box closest to equator
if (lat_sum > CT(0))
if (vertex_north)
{
vertex_lat = geometry::get_as_radian<geometry::max_corner, 1>(box_seg);
b_lat_below = b_lat_min;
@@ -247,7 +264,7 @@ struct disjoint_segment_box
Box const& box,
Strategy const& strategy)
{
return strategy.apply(segment, box);
return strategy.disjoint(segment, box).apply(segment, box);
}
};