diff --git a/include/boost/geometry/algorithms/disjoint.hpp b/include/boost/geometry/algorithms/disjoint.hpp index 94f951ac0..0b3885655 100644 --- a/include/boost/geometry/algorithms/disjoint.hpp +++ b/include/boost/geometry/algorithms/disjoint.hpp @@ -32,8 +32,10 @@ #include #include +#include #include #include +#include #include @@ -48,6 +50,38 @@ namespace boost { namespace geometry namespace detail { namespace disjoint { +template +struct check_each_ring_for_within +{ + bool has_within; + Geometry const& m_geometry; + + inline check_each_ring_for_within(Geometry const& g) + : has_within(false) + , m_geometry(g) + {} + + template + inline void apply(Range const& range) + { + if (geometry::within(geometry::return_point_on_surface(range), m_geometry)) + { + has_within = true; + } + } +}; + +template +inline bool rings_containing(FirstGeometry const& geometry1, + SecondGeometry const& geometry2) +{ + check_each_ring_for_within checker(geometry1); + geometry::detail::for_each_range(geometry2, checker); + return checker.has_within; +} + + + struct assign_disjoint_policy { // We want to include all points: @@ -139,17 +173,8 @@ struct general_areal typedef typename geometry::point_type::type point_type1; typedef typename geometry::point_type::type point_type2; - if (geometry::within - ( - geometry::return_point_on_surface(geometry1), - geometry2 - ) - || geometry::within - ( - geometry::return_point_on_surface(geometry2), - geometry1 - ) - ) + if (rings_containing(geometry1, geometry2) + || rings_containing(geometry2, geometry1)) { return false; } @@ -204,6 +229,7 @@ struct disjoint_linestring_box } }; + }} // namespace detail::disjoint #endif // DOXYGEN_NO_DETAIL diff --git a/include/boost/geometry/multi/algorithms/detail/extreme_points.hpp b/include/boost/geometry/multi/algorithms/detail/extreme_points.hpp new file mode 100644 index 000000000..922754b5e --- /dev/null +++ b/include/boost/geometry/multi/algorithms/detail/extreme_points.hpp @@ -0,0 +1,68 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2013 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2013 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2013 Mateusz Loskot, London, UK. +// Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_EXTREME_POINTS_HPP +#define BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_EXTREME_POINTS_HPP + + +#include + +#include + +#include +#include + +#include + + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + + +template +struct extreme_points +{ + template + static inline bool apply(MultiPolygon const& multi, Extremes& extremes, Intruders& intruders) + { + // Get one for the very first polygon, that is (for the moment) enough. + // It is not guaranteed the "extreme" then, but for the current purpose + // (point_on_surface) it can just be this point. + if (boost::size(multi) >= 1) + { + return extreme_points + < + typename boost::range_value::type, + Dimension, + polygon_tag + >::apply(*boost::begin(multi), extremes, intruders); + } + + return false; + } +}; + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_DETAIL_EXTREME_POINTS_HPP diff --git a/include/boost/geometry/multi/algorithms/disjoint.hpp b/include/boost/geometry/multi/algorithms/disjoint.hpp index c01e520f5..e5f57b2a8 100644 --- a/include/boost/geometry/multi/algorithms/disjoint.hpp +++ b/include/boost/geometry/multi/algorithms/disjoint.hpp @@ -14,6 +14,7 @@ #include #include +#include #include #include