Slideshow:
|
|
/* ==================================================================== Lookup( (x,y), n, result ): Look for object that contain point (x,y) (x,y) = coordinate of a point n = current node of search result = output Comment: it's a DFS algorithm with pruning on (x,y) ∉ Subtree ==================================================================== */ Lookup( (x, y), n, result ) { // n = current node of the search in the R-tree if ( n == internal node ) { for ( each entry ( BB, childptr ) in internal node n ) do { /* =============================================== Look in subtree if (x,y) is inside bounding box =============================================== */ if ( (x,y) ∈ BB ) { Lookup( (x,y), childptr, result); } } } else { /* ======================================= n is a leaf node.... ======================================= */ for ( each object Ob in node n ) do { if ( (x,y) ∈ MBB(Ob) ) { Add Ob to result; // Object Ob contains point (x,y) } } } |
Execution of the search algorithm:
|
Execution of the search algorithm:
|
|
|
|
Algorithm to find rectangle Obj
/* ==================================================================== Lookup( Obj, n, result ): Look for object that contain rectangle Obj Obj = representation of a rectangle object n = current node of search result = output ==================================================================== */ Lookup( Obj, n, result ) { // n = current node of the search in the R-tree if ( n == internal node ) { for ( each entry ( BB, childptr ) in internal node n ) do { /* =============================================== Look in subtree if Obj is inside bounding box =============================================== */ if ( Obj ⊆ BB ) { Lookup( Obj, childptr, result); } } } else { /* ======================================= n is a leaf node.... ======================================= */ for ( each object Ob in node n ) do { if ( MBB(Obj) == MBB(Ob) ) { Add Ob to result; // Object Ob contains point Obj return; // Obj found, done !! } } } |