Search code examples
c++boostboost-geometryclosest-points

Boost Library and closest points


I can find the distance between a point MyPoint and a polygon MyPolygon with

double dist = boost::geometry::distance(MyPoint, MyPolygon)

obviously the actual closest point on MyPolygon has to be computed somewhere. Is there an easy way to get that closest point? I can't find anything in the Boost Documentation and I'm sure others had that problem too.


Solution

  • According to source its iterating all points of polygon inside class distance_single_to_multi. Its not storing the iterator, so probably you should to the same.

    You can find out how to do this in comparable_distance example.