]>
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 | // 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_VALID_POINTLIKE_HPP | |
12 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POINTLIKE_HPP | |
13 | ||
14 | #include <boost/core/ignore_unused.hpp> | |
15 | #include <boost/range.hpp> | |
16 | ||
17 | #include <boost/geometry/core/tags.hpp> | |
18 | ||
19 | #include <boost/geometry/algorithms/validity_failure_type.hpp> | |
20 | #include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp> | |
21 | #include <boost/geometry/algorithms/dispatch/is_valid.hpp> | |
22 | ||
23 | #include <boost/geometry/util/condition.hpp> | |
24 | ||
25 | ||
26 | namespace boost { namespace geometry | |
27 | { | |
28 | ||
29 | ||
30 | ||
31 | #ifndef DOXYGEN_NO_DISPATCH | |
32 | namespace dispatch | |
33 | { | |
34 | ||
35 | // A point is always simple | |
36 | template <typename Point> | |
37 | struct is_valid<Point, point_tag> | |
38 | { | |
39 | template <typename VisitPolicy> | |
40 | static inline bool apply(Point const& point, VisitPolicy& visitor) | |
41 | { | |
42 | boost::ignore_unused(visitor); | |
43 | return ! detail::is_valid::has_invalid_coordinate | |
44 | < | |
45 | Point | |
46 | >::apply(point, visitor); | |
47 | } | |
48 | }; | |
49 | ||
50 | ||
51 | ||
52 | // A MultiPoint is simple if no two Points in the MultiPoint are equal | |
53 | // (have identical coordinate values in X and Y) | |
54 | // | |
55 | // Reference: OGC 06-103r4 (6.1.5) | |
56 | template <typename MultiPoint, bool AllowEmptyMultiGeometries> | |
57 | struct is_valid<MultiPoint, multi_point_tag, AllowEmptyMultiGeometries> | |
58 | { | |
59 | template <typename VisitPolicy> | |
60 | static inline bool apply(MultiPoint const& multipoint, | |
61 | VisitPolicy& visitor) | |
62 | { | |
63 | boost::ignore_unused(multipoint, visitor); | |
64 | ||
65 | if (BOOST_GEOMETRY_CONDITION( | |
66 | AllowEmptyMultiGeometries || !boost::empty(multipoint))) | |
67 | { | |
68 | // we allow empty multi-geometries, so an empty multipoint | |
69 | // is considered valid | |
70 | return ! detail::is_valid::has_invalid_coordinate | |
71 | < | |
72 | MultiPoint | |
73 | >::apply(multipoint, visitor); | |
74 | } | |
75 | else | |
76 | { | |
77 | // we do not allow an empty multipoint | |
78 | return visitor.template apply<failure_few_points>(); | |
79 | } | |
80 | } | |
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_VALID_POINTLIKE_HPP |