7

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.

genpfault
  • 47,669
  • 9
  • 68
  • 119
user3049681
  • 267
  • 3
  • 11

1 Answers1

2

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.

PSIAlt
  • 7,033
  • 1
  • 21
  • 46
  • Thank you. From some test though it looks like `return_type dist = geometry::distance(geometry, *it);` in `distance_single_to_multi` tests more than just the endpoints of the segments of the polygonboundary and the comparable_distance example does check just the endpoints. But in any case that means I have to write my own solution right? – user3049681 Aug 13 '14 at 11:18
  • @user3049681 i think yes. Seems its not very complicated. – PSIAlt Aug 13 '14 at 12:06