3 // Copyright (c) 2021, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
11 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP
16 #include <boost/concept_check.hpp>
17 #include <boost/range/concepts.hpp>
19 #include <boost/geometry/core/geometry_types.hpp>
20 #include <boost/geometry/core/mutable_range.hpp>
21 #include <boost/geometry/core/tag.hpp>
22 #include <boost/geometry/core/tags.hpp>
23 #include <boost/geometry/core/visit.hpp>
25 #include <boost/geometry/geometries/concepts/box_concept.hpp>
26 #include <boost/geometry/geometries/concepts/concept_type.hpp>
27 #include <boost/geometry/geometries/concepts/linestring_concept.hpp>
28 #include <boost/geometry/geometries/concepts/multi_point_concept.hpp>
29 #include <boost/geometry/geometries/concepts/multi_linestring_concept.hpp>
30 #include <boost/geometry/geometries/concepts/multi_polygon_concept.hpp>
31 #include <boost/geometry/geometries/concepts/point_concept.hpp>
32 #include <boost/geometry/geometries/concepts/polygon_concept.hpp>
33 #include <boost/geometry/geometries/concepts/ring_concept.hpp>
34 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
36 #include <boost/geometry/util/sequence.hpp>
37 #include <boost/geometry/util/type_traits.hpp>
40 namespace boost { namespace geometry { namespace concepts
50 typename Tag = typename tag<Geometry>::type,
51 bool IsSubDynamicOrCollection = util::is_dynamic_geometry<SubGeometry>::value
52 || util::is_geometry_collection<SubGeometry>::value
56 // Prevent recursive concept checking
57 template <typename Geometry, typename SubGeometry, typename Tag>
58 struct GeometryType<Geometry, SubGeometry, Tag, true> {};
60 template <typename Geometry, typename SubGeometry, typename Tag>
61 struct GeometryType<Geometry const, SubGeometry, Tag, true> {};
64 template <typename Geometry, typename SubGeometry>
65 struct GeometryType<Geometry, SubGeometry, geometry_collection_tag, false>
66 : concepts::concept_type<SubGeometry>::type
68 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
69 BOOST_CONCEPT_USAGE(GeometryType)
71 Geometry* gc = nullptr;
72 SubGeometry* sg = nullptr;
73 traits::emplace_back<Geometry>::apply(*gc, std::move(*sg));
75 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
78 template <typename Geometry, typename SubGeometry>
79 struct GeometryType<Geometry const, SubGeometry, geometry_collection_tag, false>
80 : concepts::concept_type<SubGeometry const>::type
84 template <typename Geometry, typename ...SubGeometries>
85 struct GeometryTypesPack {};
87 template <typename Geometry, typename SubGeometry, typename ...SubGeometries>
88 struct GeometryTypesPack<Geometry, SubGeometry, SubGeometries...>
89 : GeometryTypesPack<Geometry, SubGeometries...>
90 , GeometryType<Geometry, SubGeometry>
94 template <typename Geometry, typename SubGeometriesSequence>
97 template <typename Geometry, typename ...SubGeometries>
98 struct GeometryTypes<Geometry, util::type_sequence<SubGeometries...>>
99 : GeometryTypesPack<Geometry, SubGeometries...>
103 } // namespace detail
106 template <typename Geometry>
107 struct GeometryCollection
108 : boost::ForwardRangeConcept<Geometry>
110 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
111 using sequence_t = typename traits::geometry_types<Geometry>::type;
112 BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry, sequence_t>) );
114 BOOST_CONCEPT_USAGE(GeometryCollection)
116 Geometry* gc = nullptr;
117 traits::clear<Geometry>::apply(*gc);
118 traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
120 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
124 template <typename Geometry>
125 struct ConstGeometryCollection
126 : boost::ForwardRangeConcept<Geometry>
128 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
129 using sequence_t = typename traits::geometry_types<Geometry>::type;
130 BOOST_CONCEPT_ASSERT( (detail::GeometryTypes<Geometry const, sequence_t>) );
132 BOOST_CONCEPT_USAGE(ConstGeometryCollection)
134 Geometry const* gc = nullptr;
135 traits::iter_visit<Geometry>::apply([](auto &&) {}, boost::begin(*gc));
137 #endif // DOXYGEN_NO_CONCEPT_MEMBERS
141 template <typename Geometry>
142 struct concept_type<Geometry, geometry_collection_tag>
144 using type = GeometryCollection<Geometry>;
147 template <typename Geometry>
148 struct concept_type<Geometry const, geometry_collection_tag>
150 using type = ConstGeometryCollection<Geometry>;
154 }}} // namespace boost::geometry::concepts
157 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_GEOMETRY_COLLECTION_CONCEPT_HPP