boost::geometry::strategy::distance::haversine< RadiusType, CalculationType > Class Template Reference
strategies: strategies

Distance calculation for spherical coordinates on a perfect sphere using haversine. More...

List of all members.

## Classes

struct | calculation_type

## Public Types

typedef RadiusType | radius_type

## Public Member Functions

template<typename Point1 , typename Point2 >
calculation_type< Point1, Point2 >::type | apply (Point1 const &p1, Point2 const &p2) const
| applies the distance calculation
| haversine (RadiusType const &radius=1.0)
| Constructor.
RadiusType | radius () const
| access to radius value

## Detailed Description

### template<typename RadiusType, typename CalculationType = void>
class boost::geometry::strategy::distance::haversine< RadiusType, CalculationType >

Distance calculation for spherical coordinates on a perfect sphere using haversine.

Template Parameters:

  RadiusType | numeric type for radius (of sphere, earth)
  CalculationType | numeric type for calculation (e.g. high precision); if [*void] then it is extracted automatically from the coordinate type and (if necessary) promoted to floating point

Author:
  Adapted from: http://williams.best.vwh.net/avform.htm

See also:
  http://en.wikipedia.org/wiki/Great-circle_distance

Note:
  (from Wiki:) The great circle distance d between two points with coordinates {lat1,lon1} and {lat2,lon2} is given by: d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2)) A mathematically equivalent formula, which is less subject to rounding error for short distances is: d=2*asin(sqrt((sin((lat1-lat2) / 2))^2 + cos(lat1)*cos(lat2)*(sin((lon1-lon2) / 2))^2))

Examples:
  07_a_graph_route_example.cpp, and 07_b_graph_route_example.cpp.

## Member Typedef Documentation

template<typename RadiusType, typename CalculationType = void>

typedef RadiusType boost::geometry::strategy::distance::haversine< RadiusType, CalculationType >::radius_type

## Constructor & Destructor Documentation

template<typename RadiusType, typename CalculationType = void>

boost::geometry::strategy::distance::haversine< RadiusType, CalculationType >::haversine | ( | RadiusType const & | radius = `1.0` | ) |

Constructor.

Parameters:

  radius | radius of the sphere, defaults to 1.0 for the unit sphere

## Member Function Documentation

template<typename RadiusType, typename CalculationType = void>
template<typename Point1 , typename Point2 >

calculation_type<Point1, Point2>::type boost::geometry::strategy::distance::haversine< RadiusType, CalculationType >::apply | ( | Point1 const & | p1,
|  | Point2 const & | p2
| ) |  | const

applies the distance calculation

Returns:
  the calculated distance (including multiplying with radius)

Parameters:

  p1 | first point
  p2 | second point

template<typename RadiusType, typename CalculationType = void>

RadiusType boost::geometry::strategy::distance::haversine< RadiusType, CalculationType >::radius | ( |  | ) | const

access to radius value

Returns:
  the radius

April 2, 2011 | Copyright © 2007-2011 Barend Gehrels, Amsterdam, the Netherlands Copyright © 2008-2011 Bruno Lalande, Paris, France Copyright © 2009-2010 Mateusz Loskot, London, UK