annotate DEPENDENCIES/generic/include/boost/geometry/algorithms/unique.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // Boost.Geometry (aka GGL, Generic Geometry Library)
Chris@16 2
Chris@16 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Chris@16 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Chris@16 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Chris@101 6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
Chris@16 7
Chris@16 8 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
Chris@16 9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
Chris@16 10
Chris@16 11 // Use, modification and distribution is subject to the Boost Software License,
Chris@16 12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 13 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 14
Chris@16 15 #ifndef BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP
Chris@16 16 #define BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP
Chris@16 17
Chris@16 18 #include <algorithm>
Chris@16 19
Chris@16 20 #include <boost/range.hpp>
Chris@101 21 #include <boost/type_traits/remove_reference.hpp>
Chris@16 22
Chris@101 23 #include <boost/geometry/algorithms/detail/interior_iterator.hpp>
Chris@16 24 #include <boost/geometry/core/interior_rings.hpp>
Chris@16 25 #include <boost/geometry/core/mutable_range.hpp>
Chris@101 26 #include <boost/geometry/core/tags.hpp>
Chris@16 27 #include <boost/geometry/geometries/concepts/check.hpp>
Chris@16 28 #include <boost/geometry/policies/compare.hpp>
Chris@16 29
Chris@16 30
Chris@16 31 namespace boost { namespace geometry
Chris@16 32 {
Chris@16 33
Chris@16 34
Chris@16 35 #ifndef DOXYGEN_NO_DETAIL
Chris@16 36 namespace detail { namespace unique
Chris@16 37 {
Chris@16 38
Chris@16 39
Chris@16 40 struct range_unique
Chris@16 41 {
Chris@16 42 template <typename Range, typename ComparePolicy>
Chris@16 43 static inline void apply(Range& range, ComparePolicy const& policy)
Chris@16 44 {
Chris@16 45 typename boost::range_iterator<Range>::type it
Chris@16 46 = std::unique
Chris@16 47 (
Chris@16 48 boost::begin(range),
Chris@16 49 boost::end(range),
Chris@16 50 policy
Chris@16 51 );
Chris@16 52
Chris@16 53 traits::resize<Range>::apply(range, it - boost::begin(range));
Chris@16 54 }
Chris@16 55 };
Chris@16 56
Chris@16 57
Chris@16 58 struct polygon_unique
Chris@16 59 {
Chris@16 60 template <typename Polygon, typename ComparePolicy>
Chris@16 61 static inline void apply(Polygon& polygon, ComparePolicy const& policy)
Chris@16 62 {
Chris@16 63 range_unique::apply(exterior_ring(polygon), policy);
Chris@16 64
Chris@101 65 typename interior_return_type<Polygon>::type
Chris@101 66 rings = interior_rings(polygon);
Chris@101 67
Chris@101 68 for (typename detail::interior_iterator<Polygon>::type
Chris@101 69 it = boost::begin(rings); it != boost::end(rings); ++it)
Chris@16 70 {
Chris@16 71 range_unique::apply(*it, policy);
Chris@16 72 }
Chris@16 73 }
Chris@16 74 };
Chris@16 75
Chris@16 76
Chris@101 77 template <typename Policy>
Chris@101 78 struct multi_unique
Chris@101 79 {
Chris@101 80 template <typename MultiGeometry, typename ComparePolicy>
Chris@101 81 static inline void apply(MultiGeometry& multi, ComparePolicy const& compare)
Chris@101 82 {
Chris@101 83 for (typename boost::range_iterator<MultiGeometry>::type
Chris@101 84 it = boost::begin(multi);
Chris@101 85 it != boost::end(multi);
Chris@101 86 ++it)
Chris@101 87 {
Chris@101 88 Policy::apply(*it, compare);
Chris@101 89 }
Chris@101 90 }
Chris@101 91 };
Chris@101 92
Chris@16 93
Chris@16 94 }} // namespace detail::unique
Chris@16 95 #endif // DOXYGEN_NO_DETAIL
Chris@16 96
Chris@16 97
Chris@16 98
Chris@16 99 #ifndef DOXYGEN_NO_DISPATCH
Chris@16 100 namespace dispatch
Chris@16 101 {
Chris@16 102
Chris@16 103
Chris@16 104 template
Chris@16 105 <
Chris@16 106 typename Geometry,
Chris@16 107 typename Tag = typename tag<Geometry>::type
Chris@16 108 >
Chris@16 109 struct unique
Chris@16 110 {
Chris@16 111 template <typename ComparePolicy>
Chris@16 112 static inline void apply(Geometry&, ComparePolicy const& )
Chris@16 113 {}
Chris@16 114 };
Chris@16 115
Chris@16 116
Chris@16 117 template <typename Ring>
Chris@16 118 struct unique<Ring, ring_tag>
Chris@16 119 : detail::unique::range_unique
Chris@16 120 {};
Chris@16 121
Chris@16 122
Chris@16 123 template <typename LineString>
Chris@16 124 struct unique<LineString, linestring_tag>
Chris@16 125 : detail::unique::range_unique
Chris@16 126 {};
Chris@16 127
Chris@16 128
Chris@16 129 template <typename Polygon>
Chris@16 130 struct unique<Polygon, polygon_tag>
Chris@16 131 : detail::unique::polygon_unique
Chris@16 132 {};
Chris@16 133
Chris@16 134
Chris@101 135 // For points, unique is not applicable and does nothing
Chris@101 136 // (Note that it is not "spatially unique" but that it removes duplicate coordinates,
Chris@101 137 // like std::unique does). Spatially unique is "dissolve" which can (or will be)
Chris@101 138 // possible for multi-points as well, removing points at the same location.
Chris@101 139
Chris@101 140
Chris@101 141 template <typename MultiLineString>
Chris@101 142 struct unique<MultiLineString, multi_linestring_tag>
Chris@101 143 : detail::unique::multi_unique<detail::unique::range_unique>
Chris@101 144 {};
Chris@101 145
Chris@101 146
Chris@101 147 template <typename MultiPolygon>
Chris@101 148 struct unique<MultiPolygon, multi_polygon_tag>
Chris@101 149 : detail::unique::multi_unique<detail::unique::polygon_unique>
Chris@101 150 {};
Chris@101 151
Chris@101 152
Chris@16 153 } // namespace dispatch
Chris@16 154 #endif
Chris@16 155
Chris@16 156
Chris@16 157 /*!
Chris@16 158 \brief \brief_calc{minimal set}
Chris@16 159 \ingroup unique
Chris@16 160 \details \details_calc{unique,minimal set (where duplicate consecutive points are removed)}.
Chris@16 161 \tparam Geometry \tparam_geometry
Chris@16 162 \param geometry \param_geometry which will be made unique
Chris@16 163
Chris@16 164 \qbk{[include reference/algorithms/unique.qbk]}
Chris@16 165 */
Chris@16 166 template <typename Geometry>
Chris@16 167 inline void unique(Geometry& geometry)
Chris@16 168 {
Chris@16 169 concept::check<Geometry>();
Chris@16 170
Chris@16 171 // Default strategy is the default point-comparison policy
Chris@16 172 typedef geometry::equal_to
Chris@16 173 <
Chris@16 174 typename geometry::point_type<Geometry>::type
Chris@16 175 > policy;
Chris@16 176
Chris@16 177
Chris@16 178 dispatch::unique<Geometry>::apply(geometry, policy());
Chris@16 179 }
Chris@16 180
Chris@16 181 }} // namespace boost::geometry
Chris@16 182
Chris@16 183
Chris@16 184 #endif // BOOST_GEOMETRY_ALGORITHMS_UNIQUE_HPP