• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2014-2019, Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 
8 // Licensed under the Boost Software License version 1.0.
9 // http://www.boost.org/users/license.html
10 
11 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_MULTIPOINT_HPP
12 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_MULTIPOINT_HPP
13 
14 #include <algorithm>
15 
16 #include <boost/range.hpp>
17 
18 #include <boost/geometry/core/closure.hpp>
19 #include <boost/geometry/core/tags.hpp>
20 #include <boost/geometry/core/tags.hpp>
21 
22 #include <boost/geometry/policies/compare.hpp>
23 
24 #include <boost/geometry/algorithms/detail/is_valid/has_duplicates.hpp>
25 #include <boost/geometry/algorithms/detail/is_simple/failure_policy.hpp>
26 
27 #include <boost/geometry/algorithms/dispatch/is_simple.hpp>
28 
29 
30 namespace boost { namespace geometry
31 {
32 
33 
34 #ifndef DOXYGEN_NO_DETAIL
35 namespace detail { namespace is_simple
36 {
37 
38 
39 template <typename MultiPoint>
40 struct is_simple_multipoint
41 {
42     template <typename Strategy>
applyboost::geometry::detail::is_simple::is_simple_multipoint43     static inline bool apply(MultiPoint const& multipoint, Strategy const&)
44     {
45         typedef typename Strategy::cs_tag cs_tag;
46         typedef geometry::less
47             <
48                 typename point_type<MultiPoint>::type,
49                 -1,
50                 cs_tag
51             > less_type;
52 
53         if (boost::empty(multipoint))
54         {
55             return true;
56         }
57 
58         MultiPoint mp(multipoint);
59         std::sort(boost::begin(mp), boost::end(mp), less_type());
60 
61         simplicity_failure_policy policy;
62         return !detail::is_valid::has_duplicates
63             <
64                 MultiPoint, closed, cs_tag
65             >::apply(mp, policy);
66     }
67 };
68 
69 
70 }} // namespace detail::is_simple
71 #endif // DOXYGEN_NO_DETAIL
72 
73 
74 
75 
76 #ifndef DOXYGEN_NO_DISPATCH
77 namespace dispatch
78 {
79 
80 
81 // A MultiPoint is simple if no two Points in the MultiPoint are equal
82 // (have identical coordinate values in X and Y)
83 //
84 // Reference: OGC 06-103r4 (6.1.5)
85 template <typename MultiPoint>
86 struct is_simple<MultiPoint, multi_point_tag>
87     : detail::is_simple::is_simple_multipoint<MultiPoint>
88 {};
89 
90 
91 } // namespace dispatch
92 #endif // DOXYGEN_NO_DISPATCH
93 
94 
95 }} // namespace boost::geometry
96 
97 
98 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_MULTIPOINT_HPP
99