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 detail::intersection::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 detail::intersection::expect_output_pla
90 Areal1, Areal2, single_out
94 typedef geometry::detail::output_geometry_access
96 single_out, polygon_tag, polygon_tag
98 typedef geometry::detail::output_geometry_access
100 single_out, linestring_tag, linestring_tag
102 typedef geometry::detail::output_geometry_access
104 single_out, point_tag, point_tag
107 typedef typename geometry::tuples::element
109 areal::index, TupledOut
110 >::type areal_out_type;
111 typedef typename geometry::tuples::element
113 pointlike::index, TupledOut
114 >::type pointlike_out_type;
116 // NOTE: The same robust_policy is used in each call of
117 // intersection_insert. Is that correct?
120 call_intersection(areal1, areal2, robust_policy,
121 areal::get(geometry_out),
124 bool const is_areal_empty = boost::empty(areal::get(geometry_out));
128 call_intersection(geometry::detail::boundary_view<Areal1 const>(areal1),
129 geometry::detail::boundary_view<Areal2 const>(areal2),
136 if (! is_areal_empty)
138 // NOTE: the original areal geometry could be used instead of boundary here
139 // however this results in static assert failure related to rescale policy
140 typedef geometry::detail::boundary_view
143 > areal_out_boundary_type;
145 areal_out_boundary_type areal_out_boundary(areal::get(geometry_out));
148 call_difference(linear::get(temp_out),
151 linear::get(geometry_out),
155 call_difference(pointlike::get(temp_out),
158 pointlike::get(geometry_out),
159 strategy.template get_point_in_geometry_strategy
162 areal_out_boundary_type
174 typename RobustPolicy,
175 typename GeometryOut,
178 static inline void call_intersection(Geometry1 const& geometry1,
179 Geometry2 const& geometry2,
180 RobustPolicy const& robust_policy,
181 GeometryOut& geometry_out,
182 Strategy const& strategy)
184 geometry::dispatch::intersection_insert
188 typename geometry::detail::output_geometry_value
196 geometry::detail::output_geometry_back_inserter(geometry_out),
204 typename RobustPolicy,
205 typename GeometryOut,
208 static inline void call_difference(Geometry1 const& geometry1,
209 Geometry2 const& geometry2,
210 RobustPolicy const& robust_policy,
211 GeometryOut& geometry_out,
212 Strategy const& strategy)
214 geometry::dispatch::intersection_insert
218 typename boost::range_value<GeometryOut>::type,
223 geometry::range::back_inserter(geometry_out),
229 struct intersection_areal_areal
235 typename RobustPolicy,
236 typename GeometryOut,
239 static inline bool apply(Areal1 const& areal1,
240 Areal2 const& areal2,
241 RobustPolicy const& robust_policy,
242 GeometryOut& geometry_out,
243 Strategy const& strategy)
245 intersection_areal_areal_
248 >::apply(areal1, areal2, robust_policy, geometry_out, strategy);
255 }} // namespace detail::intersection
256 #endif // DOXYGEN_NO_DETAIL
259 #ifndef DOXYGEN_NO_DISPATCH
266 typename Polygon1, typename Polygon2
271 polygon_tag, polygon_tag,
274 : detail::intersection::intersection_areal_areal
279 typename Polygon, typename Ring
284 polygon_tag, ring_tag,
287 : detail::intersection::intersection_areal_areal
292 typename Ring1, typename Ring2
300 : detail::intersection::intersection_areal_areal
305 typename Polygon, typename MultiPolygon
309 Polygon, MultiPolygon,
310 polygon_tag, multi_polygon_tag,
313 : detail::intersection::intersection_areal_areal
318 typename MultiPolygon, typename Ring
323 multi_polygon_tag, ring_tag,
326 : detail::intersection::intersection_areal_areal
331 typename MultiPolygon1, typename MultiPolygon2
335 MultiPolygon1, MultiPolygon2,
336 multi_polygon_tag, multi_polygon_tag,
339 : detail::intersection::intersection_areal_areal
343 } // namespace dispatch
344 #endif // DOXYGEN_NO_DISPATCH
346 }} // namespace boost::geometry
348 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_AREAL_AREAL_HPP