3 // Copyright (c) 2020, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 // Licensed under the Boost Software License version 1.0.
7 // http://www.boost.org/users/license.html
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_AREAL_AREAL_HPP
10 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_AREAL_AREAL_HPP
13 #include <boost/core/ignore_unused.hpp>
15 #include <boost/geometry/algorithms/detail/intersection/interface.hpp>
18 namespace boost { namespace geometry
21 #ifndef DOXYGEN_NO_DETAIL
22 namespace detail { namespace intersection
29 typename OutTag = typename geometry::detail::setop_insert_output_tag
31 typename geometry::detail::output_geometry_value
37 struct intersection_areal_areal_
43 typename RobustPolicy,
46 static inline void apply(Areal1 const& areal1,
48 RobustPolicy const& robust_policy,
49 GeometryOut& geometry_out,
50 Strategy const& strategy)
52 geometry::dispatch::intersection_insert
55 typename boost::range_value<GeometryOut>::type,
57 >::apply(areal1, areal2, robust_policy,
58 geometry::range::back_inserter(geometry_out),
63 // TODO: Ideally this should be done in one call of intersection_insert
64 // just like it's done for all other combinations
65 template <typename TupledOut>
66 struct intersection_areal_areal_<TupledOut, tupled_output_tag>
72 typename RobustPolicy,
75 static inline void apply(Areal1 const& areal1,
77 RobustPolicy const& robust_policy,
78 TupledOut& geometry_out,
79 Strategy const& strategy)
81 typedef typename geometry::detail::output_geometry_value
88 geometry::detail::expect_output
90 Areal1, Areal2, single_out,
91 point_tag, linestring_tag, polygon_tag
95 typedef geometry::detail::output_geometry_access
97 single_out, polygon_tag, polygon_tag
99 typedef geometry::detail::output_geometry_access
101 single_out, linestring_tag, linestring_tag
103 typedef geometry::detail::output_geometry_access
105 single_out, point_tag, point_tag
108 typedef typename geometry::tuples::element
110 areal::index, TupledOut
111 >::type areal_out_type;
112 typedef typename geometry::tuples::element
114 pointlike::index, TupledOut
115 >::type pointlike_out_type;
117 // NOTE: The same robust_policy is used in each call of
118 // intersection_insert. Is that correct?
121 call_intersection(areal1, areal2, robust_policy,
122 areal::get(geometry_out),
125 bool const is_areal_empty = boost::empty(areal::get(geometry_out));
129 call_intersection(geometry::detail::boundary_view<Areal1 const>(areal1),
130 geometry::detail::boundary_view<Areal2 const>(areal2),
137 if (! is_areal_empty)
139 // NOTE: the original areal geometry could be used instead of boundary here
140 // however this results in static assert failure related to rescale policy
141 typedef geometry::detail::boundary_view
144 > areal_out_boundary_type;
146 areal_out_boundary_type areal_out_boundary(areal::get(geometry_out));
149 call_difference(linear::get(temp_out),
152 linear::get(geometry_out),
156 call_difference(pointlike::get(temp_out),
159 pointlike::get(geometry_out),
160 strategy.template get_point_in_geometry_strategy
163 areal_out_boundary_type
175 typename RobustPolicy,
176 typename GeometryOut,
179 static inline void call_intersection(Geometry1 const& geometry1,
180 Geometry2 const& geometry2,
181 RobustPolicy const& robust_policy,
182 GeometryOut& geometry_out,
183 Strategy const& strategy)
185 geometry::dispatch::intersection_insert
189 typename geometry::detail::output_geometry_value
197 geometry::detail::output_geometry_back_inserter(geometry_out),
205 typename RobustPolicy,
206 typename GeometryOut,
209 static inline void call_difference(Geometry1 const& geometry1,
210 Geometry2 const& geometry2,
211 RobustPolicy const& robust_policy,
212 GeometryOut& geometry_out,
213 Strategy const& strategy)
215 geometry::dispatch::intersection_insert
219 typename boost::range_value<GeometryOut>::type,
224 geometry::range::back_inserter(geometry_out),
230 struct intersection_areal_areal
236 typename RobustPolicy,
237 typename GeometryOut,
240 static inline bool apply(Areal1 const& areal1,
241 Areal2 const& areal2,
242 RobustPolicy const& robust_policy,
243 GeometryOut& geometry_out,
244 Strategy const& strategy)
246 intersection_areal_areal_
249 >::apply(areal1, areal2, robust_policy, geometry_out, strategy);
256 }} // namespace detail::intersection
257 #endif // DOXYGEN_NO_DETAIL
260 #ifndef DOXYGEN_NO_DISPATCH
267 typename Polygon1, typename Polygon2
272 polygon_tag, polygon_tag,
275 : detail::intersection::intersection_areal_areal
280 typename Polygon, typename Ring
285 polygon_tag, ring_tag,
288 : detail::intersection::intersection_areal_areal
293 typename Ring1, typename Ring2
301 : detail::intersection::intersection_areal_areal
306 typename Polygon, typename MultiPolygon
310 Polygon, MultiPolygon,
311 polygon_tag, multi_polygon_tag,
314 : detail::intersection::intersection_areal_areal
319 typename MultiPolygon, typename Ring
324 multi_polygon_tag, ring_tag,
327 : detail::intersection::intersection_areal_areal
332 typename MultiPolygon1, typename MultiPolygon2
336 MultiPolygon1, MultiPolygon2,
337 multi_polygon_tag, multi_polygon_tag,
340 : detail::intersection::intersection_areal_areal
344 } // namespace dispatch
345 #endif // DOXYGEN_NO_DISPATCH
347 }} // namespace boost::geometry
349 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_AREAL_AREAL_HPP