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