mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-10 23:42:12 +00:00
[comparable distance] add free function for comparable distance that takes a strategy
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
@@ -15,13 +20,45 @@
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_COMPARABLE_DISTANCE_HPP
|
||||
|
||||
|
||||
#include <boost/mpl/if.hpp>
|
||||
|
||||
#include <boost/geometry/core/reverse_dispatch.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
#include <boost/geometry/algorithms/detail/distance/default_strategies.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
// MK::need to add qbk documentation
|
||||
template <typename Geometry1, typename Geometry2, typename Strategy>
|
||||
inline typename strategy::distance::services::return_type
|
||||
<
|
||||
typename strategy::distance::services::comparable_type
|
||||
<
|
||||
Strategy
|
||||
>::type,
|
||||
typename point_type<Geometry1>::type,
|
||||
typename point_type<Geometry2>::type
|
||||
>::type
|
||||
comparable_distance(Geometry1 const& geometry1, Geometry2 const& geometry2,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
concept::check<Geometry1 const>();
|
||||
concept::check<Geometry2 const>();
|
||||
|
||||
return distance(geometry1, geometry2,
|
||||
strategy::distance::services::get_comparable
|
||||
<
|
||||
Strategy
|
||||
>::apply(strategy)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\brief \brief_calc2{comparable distance measurement}
|
||||
\ingroup distance
|
||||
@@ -45,10 +82,7 @@ inline typename default_distance_result<Geometry1, Geometry2>::type comparable_d
|
||||
concept::check<Geometry1 const>();
|
||||
concept::check<Geometry2 const>();
|
||||
|
||||
typedef typename point_type<Geometry1>::type point1_type;
|
||||
typedef typename point_type<Geometry2>::type point2_type;
|
||||
|
||||
// Define a point-point-distance-strategy
|
||||
// Define a default-distance-strategy
|
||||
// for either the normal case, either the reversed case
|
||||
|
||||
typedef typename strategy::distance::services::comparable_type
|
||||
@@ -57,14 +91,18 @@ inline typename default_distance_result<Geometry1, Geometry2>::type comparable_d
|
||||
<
|
||||
geometry::reverse_dispatch
|
||||
<Geometry1, Geometry2>::type::value,
|
||||
typename strategy::distance::services::default_strategy
|
||||
<point_tag, point2_type, point1_type>::type,
|
||||
typename strategy::distance::services::default_strategy
|
||||
<point_tag, point1_type, point2_type>::type
|
||||
typename detail::distance::default_strategy
|
||||
<
|
||||
Geometry2, Geometry1
|
||||
>::type,
|
||||
typename detail::distance::default_strategy
|
||||
<
|
||||
Geometry1, Geometry2
|
||||
>::type
|
||||
>::type
|
||||
>::type strategy_type;
|
||||
>::type default_comparable_strategy_type;
|
||||
|
||||
return distance(geometry1, geometry2, strategy_type());
|
||||
return distance(geometry1, geometry2, default_comparable_strategy_type());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user