|  | Home | Libraries | People | FAQ | More | 
Calculate discrete Frechet distance between two geometries (currently work for LineString-LineString).
template<typename Geometry1, typename Geometry2> auto discrete_frechet_distance(Geometry1 const & geometry1, Geometry2 const & geometry2)
| Type | Concept | Name | Description | 
|---|---|---|---|
| Geometry1 const & | Any type fulfilling a Geometry Concept | geometry1 | Input geometry | 
| Geometry2 const & | Any type fulfilling a Geometry Concept | geometry2 | Input geometry | 
Either
            #include <boost/geometry.hpp>
          
Or
            #include <boost/geometry/algorithms/discrete_frechet_distance.hpp>
          
The algorithm calculate discrete frechet distance between two geometries.
| ![[Note]](../../../../../../../../doc/src/images/note.png) | Note | 
|---|---|
| The units of the distance depends on strategy. In order to change the default behavior a user has to create a strategy and pass it explicitly into the algorithm. | 
Calculate Similarity between two geometries as the discrete frechet distance between them.
#include <iostream> #include <boost/geometry.hpp> #include <boost/geometry/geometries/point_xy.hpp> #include <boost/geometry/geometries/linestring.hpp> int main() { typedef boost::geometry::model::d2::point_xy<double> point_type; typedef boost::geometry::model::linestring<point_type> linestring_type; linestring_type ls1, ls2; boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", ls1); boost::geometry::read_wkt("LINESTRING(1 0,0 1,1 1,2 1,3 1)", ls2); double res = boost::geometry::discrete_frechet_distance(ls1, ls2); std::cout << "Discrete Frechet Distance: " << res << std::endl; return 0; }
Output:
Discrete Frechet Distance: 1.41421