Boost logo

Geometry :

Subject: Re: [geometry] rtree nearest polygon to a point
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2014-12-01 21:01:22

Hi Andrew,

Andrew Hundt wrote:
> I'm considering using rtree to store a set of triangles (I will use
> polygons), and query for the closet triangle to a point. Are there any
> examples I could use to help with setting up the appropriate objects
> and types?

You could store pairs of triangle bounding box and index and then
iterate over the nearest boxes using iterative nearest query and check
distance to corresponding triangles. If the distance to the next box was
greater than to the nearest triangle or the distance to the triangle was
equal to 0 you could break the loop.

Some examples:


Geometry list run by mateusz at