Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / geometry / algorithms / detail / is_simple / multipoint.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2014-2017, 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>
43     static inline bool apply(MultiPoint const& multipoint, Strategy const&)
44     {
45         if (boost::empty(multipoint))
46         {
47             return true;
48         }
49
50         MultiPoint mp(multipoint);
51         std::sort(boost::begin(mp), boost::end(mp),
52                   geometry::less<typename point_type<MultiPoint>::type>());
53
54         simplicity_failure_policy policy;
55         return !detail::is_valid::has_duplicates
56             <
57                 MultiPoint, closed
58             >::apply(mp, policy);
59     }
60 };
61
62
63 }} // namespace detail::is_simple
64 #endif // DOXYGEN_NO_DETAIL
65
66
67
68
69 #ifndef DOXYGEN_NO_DISPATCH
70 namespace dispatch
71 {
72
73
74 // A MultiPoint is simple if no two Points in the MultiPoint are equal
75 // (have identical coordinate values in X and Y)
76 //
77 // Reference: OGC 06-103r4 (6.1.5)
78 template <typename MultiPoint>
79 struct is_simple<MultiPoint, multi_point_tag>
80     : detail::is_simple::is_simple_multipoint<MultiPoint>
81 {};
82
83
84 } // namespace dispatch
85 #endif // DOXYGEN_NO_DISPATCH
86
87
88 }} // namespace boost::geometry
89
90
91 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_SIMPLE_MULTIPOINT_HPP