Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:14:02

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