summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/detail/relate/topology_check.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/detail/relate/topology_check.hpp')
-rw-r--r--boost/geometry/algorithms/detail/relate/topology_check.hpp62
1 files changed, 32 insertions, 30 deletions
diff --git a/boost/geometry/algorithms/detail/relate/topology_check.hpp b/boost/geometry/algorithms/detail/relate/topology_check.hpp
index 810466ec05..a12acaf42b 100644
--- a/boost/geometry/algorithms/detail/relate/topology_check.hpp
+++ b/boost/geometry/algorithms/detail/relate/topology_check.hpp
@@ -1,6 +1,6 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2014-2017, Oracle and/or its affiliates.
+// Copyright (c) 2014-2018, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
@@ -13,6 +13,7 @@
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
+#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/policies/compare.hpp>
@@ -28,6 +29,7 @@ namespace detail { namespace relate {
// TODO: change the name for e.g. something with the word "exterior"
template <typename Geometry,
+ typename EqPPStrategy,
typename Tag = typename geometry::tag<Geometry>::type>
struct topology_check
: not_implemented<Tag>
@@ -47,8 +49,8 @@ struct topology_check
// topology_check(Point const&, IgnoreBoundaryPoint const&) {}
//};
-template <typename Linestring>
-struct topology_check<Linestring, linestring_tag>
+template <typename Linestring, typename EqPPStrategy>
+struct topology_check<Linestring, EqPPStrategy, linestring_tag>
{
static const char interior = '1';
static const char boundary = '0';
@@ -100,7 +102,9 @@ private:
m_has_interior = count > 0;
// NOTE: Linestring with all points equal is treated as 1d linear ring
m_has_boundary = count > 1
- && ! detail::equals::equals_point_point(range::front(m_ls), range::back(m_ls));
+ && ! detail::equals::equals_point_point(range::front(m_ls),
+ range::back(m_ls),
+ EqPPStrategy());
m_is_initialized = true;
}
@@ -112,8 +116,8 @@ private:
mutable bool m_has_boundary;
};
-template <typename MultiLinestring>
-struct topology_check<MultiLinestring, multi_linestring_tag>
+template <typename MultiLinestring, typename EqPPStrategy>
+struct topology_check<MultiLinestring, EqPPStrategy, multi_linestring_tag>
{
static const char interior = '1';
static const char boundary = '0';
@@ -159,6 +163,9 @@ struct topology_check<MultiLinestring, multi_linestring_tag>
}
private:
+// TODO: CS-specific less derived from EqPPStrategy
+ typedef geometry::less<> less_type;
+
void init() const
{
if (m_is_initialized)
@@ -192,7 +199,7 @@ private:
point_reference back_pt = range::back(ls);
// don't store boundaries of linear rings, this doesn't change anything
- if (! equals::equals_point_point(front_pt, back_pt))
+ if (! equals::equals_point_point(front_pt, back_pt, EqPPStrategy()))
{
// do not add points containing NaN coordinates
// because they cannot be reasonably compared, e.g. with MSVC
@@ -215,7 +222,7 @@ private:
if (! m_endpoints.empty() )
{
- std::sort(m_endpoints.begin(), m_endpoints.end(), geometry::less<>());
+ std::sort(m_endpoints.begin(), m_endpoints.end(), less_type());
m_has_boundary = find_odd_count(m_endpoints.begin(), m_endpoints.end());
}
@@ -225,7 +232,7 @@ private:
template <typename It, typename Point>
static inline std::size_t count_equal(It first, It last, Point const& point)
{
- std::pair<It, It> rng = std::equal_range(first, last, point, geometry::less<>());
+ std::pair<It, It> rng = std::equal_range(first, last, point, less_type());
return (std::size_t)std::distance(rng.first, rng.second);
}
@@ -261,7 +268,7 @@ private:
for ( ; first != last ; ++first, ++prev )
{
// the end of the equal points subrange
- if ( ! equals::equals_point_point(*first, *prev) )
+ if ( ! equals::equals_point_point(*first, *prev, EqPPStrategy()) )
{
// odd count -> boundary
if ( count % 2 != 0 )
@@ -298,40 +305,35 @@ private:
mutable std::vector<point_type> m_endpoints;
};
-template <typename Ring>
-struct topology_check<Ring, ring_tag>
+struct topology_check_areal
{
static const char interior = '2';
static const char boundary = '1';
- topology_check(Ring const&) {}
-
static bool has_interior() { return true; }
static bool has_boundary() { return true; }
};
-template <typename Polygon>
-struct topology_check<Polygon, polygon_tag>
+template <typename Ring, typename EqPPStrategy>
+struct topology_check<Ring, EqPPStrategy, ring_tag>
+ : topology_check_areal
{
- static const char interior = '2';
- static const char boundary = '1';
-
- topology_check(Polygon const&) {}
+ topology_check(Ring const&) {}
+};
- static bool has_interior() { return true; }
- static bool has_boundary() { return true; }
+template <typename Polygon, typename EqPPStrategy>
+struct topology_check<Polygon, EqPPStrategy, polygon_tag>
+ : topology_check_areal
+{
+ topology_check(Polygon const&) {}
};
-template <typename MultiPolygon>
-struct topology_check<MultiPolygon, multi_polygon_tag>
+template <typename MultiPolygon, typename EqPPStrategy>
+struct topology_check<MultiPolygon, EqPPStrategy, multi_polygon_tag>
+ : topology_check_areal
{
- static const char interior = '2';
- static const char boundary = '1';
-
topology_check(MultiPolygon const&) {}
-
- static bool has_interior() { return true; }
- static bool has_boundary() { return true; }
+
template <typename Point>
static bool check_boundary_point(Point const& ) { return true; }
};