private Envelope getMaxBounds() { return Node.makePrecise(maxBoundsFloat64); }
@Override protected ClusteringStrategy buildInternal(DAGStorageProvider dagStoreProvider) { checkState(maxBounds != null, "QuadTree max bounds was not set"); Envelope preciseBounds = Node.makePrecise(maxBounds); int maxDepth; if (this.maxDepth > -1) { maxDepth = this.maxDepth; } else { maxDepth = Quadrant.findMaxDepth(preciseBounds, QuadTreeClusteringStrategyBuilder.ABSOLUTE_MAX_DEPTH); } return new QuadTreeClusteringStrategy(original, dagStoreProvider, preciseBounds, maxDepth); }
@Override protected Envelope createMaxBounds() { return Node.makePrecise(QuadTreeTestSupport.wgs84Bounds()); }
@Override protected Envelope createMaxBounds() { return Node.makePrecise(QuadTreeTestSupport.epsg3857Bounds()); }
private void testSliceMaxDepth(final Envelope maxBounds) { final int maxDepth = Quadrant.findMaxDepth(maxBounds, ABSOLUTE_MAX_DEPTH); Envelope parent = Node.makePrecise(maxBounds); Envelope[] qbounds; for (int d = 0; d < maxDepth; d++) { qbounds = assertSlice(parent); Envelope sw = qbounds[0]; Envelope minimalEnv = Node.makePrecise(new Envelope(sw.centre())); assertTrue("at index " + d, sw.contains(minimalEnv)); parent = sw; } }
public static int findMaxDepth(Envelope maxBounds, final int absoluteMaxDepth) { // choose the quad that tends to the biggest abs value maxBounds = Node.makePrecise(maxBounds); final Quadrant testQuad = findBiggestMagnitudeQuad(maxBounds); Envelope parent = new Envelope(maxBounds); Envelope child = new Envelope(); Envelope float32Center = new Envelope(); for (int d = 0; d < absoluteMaxDepth; d++) { testQuad.slice(parent, child); Coordinate center = child.centre(); toFloat32(center, float32Center); if (!child.contains(float32Center)) { return d; } parent.init(child); } return absoluteMaxDepth; }
Envelope precise = Node.makePrecise(target); target.init(precise);
private void checkTreeBounds(int size) { RevTreeBuilder b = createBuiler(); List<Node> nodes = createNodes(size); Envelope expectedBounds = new Envelope(); for (Node n : nodes) { b.put(n); n.expand(expectedBounds); } expectedBounds = Node.makePrecise(expectedBounds); RevTree tree = b.build(); assertEquals(size, tree.size()); Envelope bounds = SpatialOps.boundsOf(tree); bounds = Node.makePrecise(bounds); assertEquals(expectedBounds, bounds); }
public Envelope getQuadCenter(Quadrant... quadrants) { Envelope quadBounds = getMaxBounds(); if (quadrants != null) { for (Quadrant quad : quadrants) { quadBounds = quad.slice(quadBounds); } } Coordinate center = quadBounds.centre(); Envelope nodeBounds = Node.makePrecise(new Envelope(center)); if (!quadBounds.contains(nodeBounds)) { GeometryFactory gf = new GeometryFactory(); Polygon qgeom = JTS.toGeometry(quadBounds, gf); ArrayList<Geometry> pointGeoms = Lists.newArrayList(gf.createPoint(center), JTS.toGeometry(nodeBounds, gf)); Geometry point = gf.buildGeometry(pointGeoms); String msg = qgeom + " does not contain " + point; Assert.fail(msg); } return nodeBounds; }
/** * Creates an envelope that "just fits" inside the quadarant bounds */ public Envelope createBounds(Quadrant... quadrants) { Envelope quadBounds = getMaxBounds(); if (quadrants != null) { for (Quadrant quad : quadrants) { quadBounds = quad.slice(quadBounds); } } Envelope nodeBounds; double deltaX = quadBounds.getWidth() / 100.0; double deltaY = quadBounds.getHeight() / 100.0; double x1 = quadBounds.getMinX() + deltaX; double x2 = quadBounds.getMaxX() - deltaX; double y1 = quadBounds.getMinY() + deltaY; double y2 = quadBounds.getMaxY() - deltaY; nodeBounds = Node.makePrecise(new Envelope(x1, x2, y1, y2)); if (!quadBounds.contains(nodeBounds)) { nodeBounds = new Envelope(quadBounds); Assert.assertTrue(quadBounds.contains(nodeBounds)); } return nodeBounds; }