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