java - 具有空间数据的四叉树
问题描述
我正在使用由Ryan Pelletier 在 Github 上的 java-simple-quadtree 实现的四叉树来读取纬度和经度的空间数据,并且它们没有被插入到树中。这是我的数据:
-73.807029724121094,40.699657440185547
这是 QuadTree 类的搜索功能
private List<RectangleObject> search(List<RectangleObject> rectangleObjects, RectangleObject rectangleObject){
rectangleObjects.addAll(this.rectangleObjects);
int index = getChildIndexRectangleBelongsIn(rectangleObject);
//if the search area does not fit into any of the children perfectly
if(index == QuadTree.THIS_QUADTREE || this.children[0] == null){
//add anything that is on this QuadTree, may need to recurse down and add more
if(this.children[0] != null){
//for each of the children, if the search area overlaps with the child area, search the child
for(int i = 0; i < this.children.length; i++){
if(GeometryUtil.rectangleObjectsOverlap(new SearchRectangleObject(Double.valueOf(this.children[i].getX()), Double.valueOf(this.children[i].getY()),Double.valueOf(this.children[i].getW()), Double.valueOf(this.children[i].getH())), rectangleObject)){
this.children[i].search(rectangleObjects, rectangleObject);
}
}
}
}else if(this.children[index] != null){
//search area is in one of the children totally, but we still can't exclude the objects on this node, because that search area could include one
this.children[index].search(rectangleObjects, rectangleObject);
}
return rectangleObjects;
}
解决方案
推荐阅读
- java - Use Spring Beans In Micronaut Applications
- .htaccess - Converting .htaccess to lighttpd for a subdirectory
- sql - 在 QGIS 中为属性搜索表找到正确的 SQL 表达式
- go - How to build extensions to existing packages idiomatically
- scala - polymorphic dispatch from object-oriented programming with pattern matching
- r - 如何在 R 中舍入数据帧的数字以保留总和?
- python - 如何在 python 中修复“IndexError:单个位置索引器越界”?
- mysql - MySQL get rows starting with specific id after sort / order by
- lua - 如何修复 eof 附近的最终预期错误
- javascript - "
" 不是从 "./path" 导出的