Skip to content

getElements not working propper #1

@TypeOverride

Description

@TypeOverride

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions