I am experimening with QuadTree class and QuadTreeNode class. My question is the following. Once I putted elements into the QuadTree, is there any way to extract these elements according to their geographical locations, i.e. NORTHWEST, NORTHEAST, SOUTHWEST and SOUTHEAST, without defining the bounding box?
This is what I did so far. In the QuadTree class I introduced the function getChildren
:
public Vector<E> getChildren(int loc)
{
return top.getChildren(loc);
}
And in the class QuadTreeNode I introduced this:
public Vector<E> getChildren(int loc)
{
if (loc == 0)
return _children[NORTHWEST].getItems();
else if (loc == 1)
return _children[NORTHEAST].getItems();
else if (loc == 2)
return _children[SOUTHEAST].getItems();
else
return _children[SOUTHWEST].getItems();
}
Then I created a QuadTree and tried to obtain elements according to their geographical location.
_Qtree = new ITSQtree<Obj>();
for(Obj o : Objs )
_Qtree.put(o);
List<Obj> childrenNORTHWEST = _Qtree.getChildren(0);
List<Obj> childrenNORTHEAST = _Qtree.getChildren(1);
List<Obj> childrenSOUTHEAST = _Qtree.getChildren(2);
List<Obj> childrenSOUTWEST = _Qtree.getChildren(3);
The problem is the the result is always an empty set []
.