...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 between two geometries using the specified strategy.

The free function distance calculates the distance between two geometries 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> auto 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.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)