// 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
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
+#include <boost/geometry/algorithms/not_implemented.hpp>
#include <boost/geometry/policies/compare.hpp>
// 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>
// 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';
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;
}
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';
}
private:
+ typedef geometry::less<void, -1, typename EqPPStrategy::cs_tag> less_type;
+
void init() const
{
if (m_is_initialized)
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
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());
}
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);
}
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 )
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; }
};