...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

Calculate the distance of two geometries using the specified strategy.

The free function area calculates the area of a geometry. using the specified strategy. Reasons to specify a strategy include: use another coordinate system for calculations; construct the strategy beforehand (e.g. with the radius of the Earth); select a strategy when there are more than one available for a calculation.

template<typename Geometry1, typename Geometry2, typename Strategy> strategy::distance::services::return_type<Strategy>::type distance(Geometry1 const & geometry1, Geometry2 const & geometry2, Strategy const & strategy)

Type |
Concept |
Name |
Description |
---|---|---|---|

Geometry1 const & |
Any type fulfilling a Geometry Concept |
geometry1 |
A model of the specified concept |

Geometry2 const & |
Any type fulfilling a Geometry Concept |
geometry2 |
A model of the specified concept |

Strategy const & |
Any type fulfilling a Distance Strategy Concept |
strategy |
The strategy which will be used for distance calculations |

The calculated distance

Either

`#include <boost/geometry/geometry.hpp>`

Or

`#include <boost/geometry/algorithms/distance.hpp>`

- Pythagoras (cartesian)
- Haversine (spherical)
- Cross track (spherical, point-to-segment)
- Projected point (cartesian, point-to-segment)
- more (currently extensions): Vincenty, Andoyer (geographic)