Boost logo

Geometry :

Subject: [geometry] R-Tree Nearest Neighbors Unique Member From Group
From: jpb (jberg_at_[hidden])
Date: 2018-05-16 16:06:09

Hi Guys,

I have an rtree where each item in the tree has a group ( Colors perhaps:
red, green, blue, orange...)
I want to do a nearest neighbor search where the search returns the nearest
k-neighbors with at most
one object from each group.

For example, if we have

Object A: Red, distance 1
Object B: Red, distance 2
Object C: Blue, distance 3
Object D: Green, distance 4

and I do a nearest neighbor at most one from each group search with k = 2
I get object A and C. B is skipped since A is closer of the same group.

It looks like I could get this done by creating a specialization of
distance_query_result class and have the distance_query_result::store method
to check the groups/distances of already stored items and act accordingly.
Then create a specialization of distance query and maybe query_dispatch to
get distance_query to use the new distance_query_result.

Is there a better way to go about this?

Thank you for any help.

Sent from:

Geometry list run by mateusz at