multipoint.hpp 2.3 KB

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