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@16
|
6
|
Chris@16
|
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
9
|
Chris@16
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
|
Chris@16
|
15 #define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
|
Chris@16
|
16
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/geometry/algorithms/distance.hpp>
|
Chris@16
|
19
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace geometry
|
Chris@16
|
22 {
|
Chris@16
|
23
|
Chris@16
|
24
|
Chris@16
|
25 /*!
|
Chris@16
|
26 \brief \brief_calc2{comparable distance measurement}
|
Chris@16
|
27 \ingroup distance
|
Chris@16
|
28 \details The free function comparable_distance does not necessarily calculate the distance,
|
Chris@16
|
29 but it calculates a distance measure such that two distances are comparable to each other.
|
Chris@16
|
30 For example: for the Cartesian coordinate system, Pythagoras is used but the square root
|
Chris@16
|
31 is not taken, which makes it faster and the results of two point pairs can still be
|
Chris@16
|
32 compared to each other.
|
Chris@16
|
33 \tparam Geometry1 first geometry type
|
Chris@16
|
34 \tparam Geometry2 second geometry type
|
Chris@16
|
35 \param geometry1 \param_geometry
|
Chris@16
|
36 \param geometry2 \param_geometry
|
Chris@16
|
37 \return \return_calc{comparable distance}
|
Chris@16
|
38
|
Chris@16
|
39 \qbk{[include reference/algorithms/comparable_distance.qbk]}
|
Chris@16
|
40 */
|
Chris@16
|
41 template <typename Geometry1, typename Geometry2>
|
Chris@16
|
42 inline typename default_distance_result<Geometry1, Geometry2>::type comparable_distance(
|
Chris@16
|
43 Geometry1 const& geometry1, Geometry2 const& geometry2)
|
Chris@16
|
44 {
|
Chris@16
|
45 concept::check<Geometry1 const>();
|
Chris@16
|
46 concept::check<Geometry2 const>();
|
Chris@16
|
47
|
Chris@16
|
48 typedef typename point_type<Geometry1>::type point1_type;
|
Chris@16
|
49 typedef typename point_type<Geometry2>::type point2_type;
|
Chris@16
|
50
|
Chris@16
|
51 // Define a point-point-distance-strategy
|
Chris@16
|
52 // for either the normal case, either the reversed case
|
Chris@16
|
53
|
Chris@16
|
54 typedef typename strategy::distance::services::comparable_type
|
Chris@16
|
55 <
|
Chris@16
|
56 typename boost::mpl::if_c
|
Chris@16
|
57 <
|
Chris@16
|
58 geometry::reverse_dispatch
|
Chris@16
|
59 <Geometry1, Geometry2>::type::value,
|
Chris@16
|
60 typename strategy::distance::services::default_strategy
|
Chris@16
|
61 <point_tag, point2_type, point1_type>::type,
|
Chris@16
|
62 typename strategy::distance::services::default_strategy
|
Chris@16
|
63 <point_tag, point1_type, point2_type>::type
|
Chris@16
|
64 >::type
|
Chris@16
|
65 >::type strategy_type;
|
Chris@16
|
66
|
Chris@16
|
67 return distance(geometry1, geometry2, strategy_type());
|
Chris@16
|
68 }
|
Chris@16
|
69
|
Chris@16
|
70
|
Chris@16
|
71 }} // namespace boost::geometry
|
Chris@16
|
72
|
Chris@16
|
73
|
Chris@16
|
74 #endif // BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
|