1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
6 // Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
8 // This file was modified by Oracle on 2014.
9 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP
21 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP
23 #include <boost/geometry/core/closure.hpp>
24 #include <boost/geometry/core/point_type.hpp>
25 #include <boost/geometry/core/tags.hpp>
27 #include <boost/geometry/strategies/distance.hpp>
28 #include <boost/geometry/strategies/tags.hpp>
30 #include <boost/geometry/algorithms/assign.hpp>
32 #include <boost/geometry/algorithms/dispatch/distance.hpp>
34 #include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
35 #include <boost/geometry/algorithms/detail/distance/point_to_geometry.hpp>
36 #include <boost/geometry/algorithms/detail/distance/multipoint_to_geometry.hpp>
39 namespace boost { namespace geometry
43 #ifndef DOXYGEN_NO_DETAIL
44 namespace detail { namespace distance
48 template<typename Point, typename Segment, typename Strategy>
49 struct point_to_segment
51 static inline typename strategy::distance::services::return_type
55 typename point_type<Segment>::type
57 apply(Point const& point, Segment const& segment, Strategy const& )
59 typename detail::distance::default_ps_strategy
62 typename point_type<Segment>::type,
64 >::type segment_strategy;
66 typename point_type<Segment>::type p[2];
67 geometry::detail::assign_point_from_index<0>(segment, p[0]);
68 geometry::detail::assign_point_from_index<1>(segment, p[1]);
69 return segment_strategy.apply(point, p[0], p[1]);
74 }} // namespace detail::distance
75 #endif // DOXYGEN_NO_DETAIL
80 #ifndef DOXYGEN_NO_DISPATCH
85 // Point-segment version 1, with point-point strategy
86 template <typename Point, typename Segment, typename Strategy>
89 Point, Segment, Strategy,
90 point_tag, segment_tag, strategy_tag_distance_point_point,
92 > : detail::distance::point_to_segment<Point, Segment, Strategy>
96 // Point-line version 1, where point-point strategy is specified
97 template <typename Point, typename Linestring, typename Strategy>
100 Point, Linestring, Strategy,
101 point_tag, linestring_tag, strategy_tag_distance_point_point,
106 static inline typename strategy::distance::services::return_type
108 Strategy, Point, typename point_type<Linestring>::type
110 apply(Point const& point,
111 Linestring const& linestring,
114 typedef typename detail::distance::default_ps_strategy
117 typename point_type<Linestring>::type,
119 >::type ps_strategy_type;
121 return detail::distance::point_to_range
123 Point, Linestring, closed, ps_strategy_type
124 >::apply(point, linestring, ps_strategy_type());
129 // Point-ring , where point-point strategy is specified
130 template <typename Point, typename Ring, typename Strategy>
133 Point, Ring, Strategy,
134 point_tag, ring_tag, strategy_tag_distance_point_point,
138 typedef typename strategy::distance::services::return_type
140 Strategy, Point, typename point_type<Ring>::type
143 static inline return_type apply(Point const& point,
147 typedef typename detail::distance::default_ps_strategy
150 typename point_type<Ring>::type,
152 >::type ps_strategy_type;
154 return detail::distance::point_to_ring
157 geometry::closure<Ring>::value,
159 >::apply(point, ring, ps_strategy_type());
164 // Point-polygon , where point-point strategy is specified
165 template <typename Point, typename Polygon, typename Strategy>
168 Point, Polygon, Strategy,
169 point_tag, polygon_tag, strategy_tag_distance_point_point,
173 typedef typename strategy::distance::services::return_type
175 Strategy, Point, typename point_type<Polygon>::type
178 static inline return_type apply(Point const& point,
179 Polygon const& polygon,
182 typedef typename detail::distance::default_ps_strategy
185 typename point_type<Polygon>::type,
187 >::type ps_strategy_type;
189 return detail::distance::point_to_polygon
193 geometry::closure<Polygon>::value,
195 >::apply(point, polygon, ps_strategy_type());
205 typename MultiGeometry,
206 typename MultiGeometryTag,
211 Point, MultiGeometry, Strategy,
212 point_tag, MultiGeometryTag,
213 strategy_tag_distance_point_point, false
216 typedef typename strategy::distance::services::return_type
218 Strategy, Point, typename point_type<MultiGeometry>::type
221 static inline return_type apply(Point const& point,
222 MultiGeometry const& multigeometry,
225 typedef typename detail::distance::default_ps_strategy
228 typename point_type<MultiGeometry>::type,
230 >::type ps_strategy_type;
234 Point, MultiGeometry, ps_strategy_type,
235 point_tag, MultiGeometryTag,
236 strategy_tag_distance_point_segment, false
237 >::apply(point, multigeometry, ps_strategy_type());
246 typename GeometryTag,
251 Geometry, MultiPoint, Strategy,
252 GeometryTag, multi_point_tag,
253 strategy_tag_distance_point_point, false
256 typedef typename strategy::distance::services::return_type
259 typename point_type<MultiPoint>::type,
260 typename point_type<Geometry>::type
263 static inline return_type apply(Geometry const& geometry,
264 MultiPoint const& multipoint,
267 typedef typename detail::distance::default_ps_strategy
269 typename point_type<MultiPoint>::type,
270 typename point_type<Geometry>::type,
272 >::type ps_strategy_type;
276 Geometry, MultiPoint, ps_strategy_type,
277 GeometryTag, multi_point_tag,
278 strategy_tag_distance_point_segment, false
279 >::apply(geometry, multipoint, ps_strategy_type());
287 typename MultiGeometry,
288 typename MultiGeometryTag,
293 MultiPoint, MultiGeometry, Strategy,
294 multi_point_tag, MultiGeometryTag,
295 strategy_tag_distance_point_point, false
298 typedef typename strategy::distance::services::return_type
301 typename point_type<MultiPoint>::type,
302 typename point_type<MultiGeometry>::type
305 static inline return_type apply(MultiPoint const& multipoint,
306 MultiGeometry const& multigeometry,
309 typedef typename detail::distance::default_ps_strategy
311 typename point_type<MultiPoint>::type,
312 typename point_type<MultiGeometry>::type,
314 >::type ps_strategy_type;
318 MultiPoint, MultiGeometry, ps_strategy_type,
319 multi_point_tag, MultiGeometryTag,
320 strategy_tag_distance_point_segment, false
321 >::apply(multipoint, multigeometry, ps_strategy_type());
326 } // namespace dispatch
327 #endif // DOXYGEN_NO_DISPATCH
330 }} // namespace boost::geometry
333 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_BACKWARD_COMPATIBILITY_HPP