$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
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:
http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/spatial_indexes/rtree_examples/index_of_polygons_stored_in_vector.html
http://www.boost.org/doc/libs/1_57_0/libs/geometry/doc/html/geometry/spatial_indexes/rtree_examples/iterative_query.html
Regards,
Adam