Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:07

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2014-2020, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0007 
0008 // Licensed under the Boost Software License version 1.0.
0009 // http://www.boost.org/users/license.html
0010 
0011 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POINTLIKE_HPP
0012 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POINTLIKE_HPP
0013 
0014 #include <boost/core/ignore_unused.hpp>
0015 #include <boost/range/empty.hpp>
0016 
0017 #include <boost/geometry/core/tags.hpp>
0018 
0019 #include <boost/geometry/algorithms/validity_failure_type.hpp>
0020 #include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
0021 #include <boost/geometry/algorithms/dispatch/is_valid.hpp>
0022 
0023 #include <boost/geometry/util/condition.hpp>
0024 
0025 
0026 namespace boost { namespace geometry
0027 {
0028 
0029 
0030 
0031 #ifndef DOXYGEN_NO_DISPATCH
0032 namespace dispatch
0033 {
0034 
0035 // A point is always simple
0036 template <typename Point>
0037 struct is_valid<Point, point_tag>
0038 {
0039     template <typename VisitPolicy, typename Strategy>
0040     static inline bool apply(Point const& point, VisitPolicy& visitor, Strategy const&)
0041     {
0042         boost::ignore_unused(visitor);
0043         return ! detail::is_valid::has_invalid_coordinate
0044             <
0045                 Point
0046             >::apply(point, visitor);
0047     }
0048 };
0049 
0050 
0051 
0052 // A MultiPoint is simple if no two Points in the MultiPoint are equal
0053 // (have identical coordinate values in X and Y)
0054 //
0055 // Reference: OGC 06-103r4 (6.1.5)
0056 template <typename MultiPoint, bool AllowEmptyMultiGeometries>
0057 struct is_valid<MultiPoint, multi_point_tag, AllowEmptyMultiGeometries>
0058 {
0059     template <typename VisitPolicy, typename Strategy>
0060     static inline bool apply(MultiPoint const& multipoint,
0061                              VisitPolicy& visitor,
0062                              Strategy const&)
0063     {
0064         boost::ignore_unused(multipoint, visitor);
0065 
0066         if (BOOST_GEOMETRY_CONDITION(
0067                 AllowEmptyMultiGeometries || !boost::empty(multipoint)))
0068         {
0069             // we allow empty multi-geometries, so an empty multipoint
0070             // is considered valid
0071             return ! detail::is_valid::has_invalid_coordinate
0072                 <
0073                     MultiPoint
0074                 >::apply(multipoint, visitor);
0075         }
0076         else
0077         {
0078             // we do not allow an empty multipoint
0079             return visitor.template apply<failure_few_points>();
0080         }
0081     }
0082 };
0083 
0084 
0085 } // namespace dispatch
0086 #endif // DOXYGEN_NO_DISPATCH
0087 
0088 
0089 }} // namespace boost::geometry
0090 
0091 
0092 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_POINTLIKE_HPP