nushoin / RTree

N-dimensional RTree implementation in C++
Other
376 stars 109 forks source link

How to get coordinate for a target match? #11

Closed Zhenyu-Liu closed 6 years ago

Zhenyu-Liu commented 6 years ago

Is there any way to get the coordinate when we have the match, instead of loop through the whole tree using the iterator?

Also, where can I set the a_searchResult array?

  /// Find all within search rectangle
  /// \param a_min Min of search bounding rect
  /// \param a_max Max of search bounding rect
  /// \param a_searchResult Search result array.  Caller should set grow size. Function will reset, not append to array.
  /// \param a_resultCallback Callback function to return result.  Callback should return 'true' to continue searching
  /// \param a_context User context to pass as parameter to a_resultCallback
  /// \return Returns the number of entries found
  int Search(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], t_resultCallback a_resultCallback, void* a_context);
AlexVonB commented 6 years ago

Hi, I hacked a quick fix into my branch from this master: https://github.com/AlexVonB/RTree/tree/f/return-branch For an example see https://github.com/AlexVonB/RTree/blob/f/return-branch/Test.cpp#L45

a_searchResult might be an old input variable, no idea.

Zhenyu-Liu commented 6 years ago

@AlexVonB nice solution, Also I wonder if this Rtree implementation supports for the 4-dimension coordinate. I was trying to initialize it with 4 dimensions but I got the segment fault.

I found the problem is in here, but not sure how?

image

AlexVonB commented 6 years ago

How do you initialize and fill your Tree? This is what it should look like:

RTree<int, int, 4, float> tree;                                                                                         
int min[4] = {0, 0, 0, 0};
int max[4] = {1, 1, 1, 1};                                                                                           
tree.Insert(min, max, 0);