Boost Library and closest points
Asked Answered
A

1

8

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.

Accomplishment answered 13/8, 2014 at 7:7 Comment(0)
G
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.

Gouge answered 13/8, 2014 at 11:2 Comment(2)
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?Accomplishment
@Accomplishment i think yes. Seems its not very complicated.Gouge

© 2022 - 2024 — McMap. All rights reserved.