/** * Creates an empty QuadTree with the bounds minX/minY -- maxX/maxY. For * optimal performance, all points should be evenly distributed within this * rectangle. * * @param minX The smallest x coordinate (easting, longitude) expected * @param minY The smallest y coordinate (northing, latitude) expected * @param maxX The largest x coordinate (easting, longitude) expected * @param maxY The largest y coordinate (northing, latitude) expected */ public QuadTree(final double minX, final double minY, final double maxX, final double maxY) { this.top = new Node<T>(minX, minY, maxX, maxY); }
private void split() { this.northwest = new Node<>(this.bounds.minX, this.bounds.centerY, this.bounds.centerX, this.bounds.maxY); this.northeast = new Node<>(this.bounds.centerX, this.bounds.centerY, this.bounds.maxX, this.bounds.maxY); this.southeast = new Node<>(this.bounds.centerX, this.bounds.minY, this.bounds.maxX, this.bounds.centerY); this.southwest = new Node<>(this.bounds.minX, this.bounds.minY, this.bounds.centerX, this.bounds.centerY); this.hasChilds = true; if (this.leaves != null) { for (Leaf<T> leaf : this.leaves) { getChild(leaf.x, leaf.y).put(leaf); } this.leaves= null; } }
/** * Sets a new top node in case the extremities from the c'tor are not * good anymore, it also clear the QuadTree * @param minX The smallest x coordinate expected * @param minY The smallest y coordinate expected * @param maxX The largest x coordinate expected * @param maxY The largest y coordinate expected */ protected void setTopNode(final double minX, final double minY, final double maxX, final double maxY) { this.top = new Node<OTFDataWriter>(minX, minY, maxX, maxY); }