Calculate the Hilbert value of a point for use in a Hilbert R-Tree?

后端 未结 8 1452
北恋
北恋 2020-12-13 05:15

I have an application where a Hilbert R-Tree (wikipedia) (citeseer) would seem to be an appropriate data structure. Specifically, it requires reasonably fast spatial querie

8条回答
  •  天涯浪人
    2020-12-13 05:25

    Michael,

    thanks for your Java code! I tested it and it seems to work fine, but I noticed that the bit-interleaving function overflows at recursion level 7 (at least in my tests, but I used long values), because the "n"-value is calculated using highestOneBit()-function, which returns the value and not the position of the highest one bit; so the loop does unnecessarily many interleavings.

    I just changed it to the following snippet, and after that it worked fine.

      int max = Math.max(odd, even);
      int n = 0;
      while (max > 0) {
        n++;
        max >>= 1;
      }
    

提交回复
热议问题