-
Notifications
You must be signed in to change notification settings - Fork 8
Description
i have the problem that when i try to fetch the elements that are inside a rectangle (with getElements) that
A) you insert all the time a new element
My solution to this was modifying the findRegion(..) method:
private int findRegion(QuadRectangle r) {
return findRegion(r, false);
}
private int findRegion(QuadRectangle r, boolean split) {
....
if (nodes.size() >= maxItemByNode && this.level < maxLevel) {
if (regions == null) {
if(split) {
// then create the subregions
this.split();
}
}
if(regions != null) {
....
}
....
}
public void insert(QuadRectangle r, T element) {
int region = this.findRegion(r, true);
....
}
B) when you are on an edge of a region, the method getElements(...) gives you all elements back that are inside this region.. thats a lot of elements. This means (worst case).. when you are on the edge of the utter region, that every element in the quadTree will be returned. This means that on edges the quadtree will return elements that you dont want to fetch. This is making the quad tree useless in usage (to say it straight).