mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 05:24:02 +00:00
[geometry] adapted examples to new distance strategy structure
[SVN r85291]
This commit is contained in:
parent
5af7da4f86
commit
269b55c2e6
@ -306,7 +306,7 @@ int main()
|
|||||||
<< std::fixed << std::setprecision(0);
|
<< std::fixed << std::setprecision(0);
|
||||||
|
|
||||||
// To calculate distance, declare and construct a strategy with average earth radius
|
// To calculate distance, declare and construct a strategy with average earth radius
|
||||||
boost::geometry::strategy::distance::haversine<point_type> haversine(6372795.0);
|
boost::geometry::strategy::distance::haversine<double> haversine(6372795.0);
|
||||||
|
|
||||||
// Main functionality: calculate shortest routes from/to all cities
|
// Main functionality: calculate shortest routes from/to all cities
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ int main()
|
|||||||
<< std::fixed << std::setprecision(0);
|
<< std::fixed << std::setprecision(0);
|
||||||
|
|
||||||
// To calculate distance, declare and construct a strategy with average earth radius
|
// To calculate distance, declare and construct a strategy with average earth radius
|
||||||
boost::geometry::strategy::distance::haversine<point_type> haversine(6372795.0);
|
boost::geometry::strategy::distance::haversine<double> haversine(6372795.0);
|
||||||
|
|
||||||
// Main functionality: calculate shortest routes from/to all cities
|
// Main functionality: calculate shortest routes from/to all cities
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ struct default_strategy<cartesian_tag, cartesian_tag, cart, cart_shifted5, 2, 2,
|
|||||||
|
|
||||||
|
|
||||||
// 5: implement a distance strategy between the two different ones
|
// 5: implement a distance strategy between the two different ones
|
||||||
template <typename P1, typename P2>
|
|
||||||
struct shift_and_calc_distance
|
struct shift_and_calc_distance
|
||||||
{
|
{
|
||||||
|
template <typename P1, typename P2>
|
||||||
inline double apply(P1 const& p1, P2 const& p2) const
|
inline double apply(P1 const& p1, P2 const& p2) const
|
||||||
{
|
{
|
||||||
P2 p1_shifted;
|
P2 p1_shifted;
|
||||||
@ -77,14 +77,14 @@ typedef boost::geometry::model::point<double, 2, cart_shifted5> point2;
|
|||||||
// 7: register the distance strategy
|
// 7: register the distance strategy
|
||||||
namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services
|
namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services
|
||||||
{
|
{
|
||||||
template <typename Point1, typename Point2>
|
template <>
|
||||||
struct tag<shift_and_calc_distance<Point1, Point2> >
|
struct tag<shift_and_calc_distance>
|
||||||
{
|
{
|
||||||
typedef strategy_tag_distance_point_point type;
|
typedef strategy_tag_distance_point_point type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Point1, typename Point2>
|
template <typename P1, typename P2>
|
||||||
struct return_type<shift_and_calc_distance<Point1, Point2> >
|
struct return_type<shift_and_calc_distance, P1, P2>
|
||||||
{
|
{
|
||||||
typedef double type;
|
typedef double type;
|
||||||
};
|
};
|
||||||
@ -92,7 +92,7 @@ namespace boost { namespace geometry { namespace strategy { namespace distance {
|
|||||||
template <>
|
template <>
|
||||||
struct default_strategy<point_tag, point1, point2, cartesian_tag, cartesian_tag>
|
struct default_strategy<point_tag, point1, point2, cartesian_tag, cartesian_tag>
|
||||||
{
|
{
|
||||||
typedef shift_and_calc_distance<point1, point2> type;
|
typedef shift_and_calc_distance type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user