|
|
|
|
|
|
|
|
|
|
/* ================================================
Lookup( (x,y), n, result )
(x,y) = coordinate of a point
n = current node of search
result = output
================================================= */
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 node n ) do
{
/* ====================================
Look in subtree if (x,y) is in box
==================================== */
if ( (x,y) ∈ BB )
{
Lookup( (x,y), childptr, result);
}
}
}
else
{
for ( each object Ob in node n ) do
{
if ( (x,y) ∈ MBB(Ob) )
{
Add Ob to result;
}
}
}
|
|
Result:
|
|
|
|
|
/* ================================================
Insert( (mbb,ObjID), n)
(mbb,ObjID) = object with given mbb
n = current node of operation
================================================= */
Insert( (mbb, ObjID), n )
{
// n = current node of the search in the R-tree
if ( n == internal node )
{
for ( each entry ( BB, childptr ) in node n ) do
{
/* ======================================================
Insert object in subtree if its mbb is contained by BB
====================================================== */
if ( mbb ⊆ BB )
{
|
|
Steps of the Insert Algorithm:
|
|
Steps of the Insert Algorithm:
|
|
Steps of the Insert Algorithm:
|
|
|
How should the objects be split ????
|
|
S = all possible subsets of {1 , 2, 3,...., n};
s1 ∈ S;
best_A = s1
best_B = {1,2,3,...,n} - s;
minArea = AreaOfBB(objects in A) + AreaOfBB(objects in B);
for ( each subset s ∈ S - s1 ) do
{
A = s;
B = {1,2,3,...,n} - s;
Area = AreaOfBB(objects in A) + AreaOfBB(objects in B);
if ( Area < minArea )
{
best_A = A;
best_B = B;
}
}
|
(Don't know it and this topic is outside the scope of the course)