[geometry] added extreme_points for multi-polygon to fix compilation in disjoint for multi polygon. Also fixed bug in multi by using within, we have to use rings_containing, that one is restored. It is now duplicated (temporary) in touches because that one has to use point_on_border still (somehow), to be found out

[SVN r86580]
This commit is contained in:
Barend Gehrels
2013-11-06 23:27:02 +00:00
parent 42c3e28ff7
commit 1bb3745741
3 changed files with 106 additions and 11 deletions

View File

@@ -32,8 +32,10 @@
#include <boost/geometry/algorithms/detail/disjoint.hpp>
#include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
#include <boost/geometry/algorithms/detail/point_on_border.hpp>
#include <boost/geometry/algorithms/point_on_surface.hpp>
#include <boost/geometry/algorithms/within.hpp>
#include <boost/geometry/algorithms/detail/for_each_range.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
@@ -48,6 +50,38 @@ namespace boost { namespace geometry
namespace detail { namespace disjoint
{
template<typename Geometry>
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 <typename Range>
inline void apply(Range const& range)
{
if (geometry::within(geometry::return_point_on_surface(range), m_geometry))
{
has_within = true;
}
}
};
template <typename FirstGeometry, typename SecondGeometry>
inline bool rings_containing(FirstGeometry const& geometry1,
SecondGeometry const& geometry2)
{
check_each_ring_for_within<FirstGeometry> 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<Geometry1>::type point_type1;
typedef typename geometry::point_type<Geometry2>::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

View File

@@ -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 <cstddef>
#include <boost/range.hpp>
#include <boost/geometry/multi/core/tags.hpp>
#include <boost/geometry/multi/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/detail/extreme_points.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
template<typename MultiPolygon, std::size_t Dimension>
struct extreme_points<MultiPolygon, Dimension, multi_polygon_tag>
{
template <typename Extremes, typename Intruders>
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<MultiPolygon const>::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

View File

@@ -14,6 +14,7 @@
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/multi/algorithms/covered_by.hpp>
#include <boost/geometry/multi/algorithms/detail/extreme_points.hpp>
#include <boost/geometry/multi/core/tags.hpp>
#include <boost/geometry/multi/geometries/concepts/check.hpp>