private long computeMemorySizeInBytes(ItemBoundable item) { return ENVELOPE_INSTANCE_SIZE + ((GeometryWithPosition) item.getItem()).getEstimatedMemorySizeInBytes(); }
/** * Computes the distance between two {@link Geometry} items, * using the {@link Geometry#distance(Geometry)} method. * * @param item1 an item which is a Geometry * @param item2 an item which is a Geometry * @return the distance between the geometries * @throws ClassCastException if either item is not a Geometry */ public double distance(ItemBoundable item1, ItemBoundable item2) { Geometry g1 = (Geometry) item1.getItem(); Geometry g2 = (Geometry) item2.getItem(); return g1.distance(g2); } }
private long computeMemorySizeInBytes(ItemBoundable item) { return ENVELOPE_INSTANCE_SIZE + ((GeometryWithPosition) item.getItem()).getEstimatedMemorySizeInBytes(); }
private long computeMemorySizeInBytes(ItemBoundable item) { return ENVELOPE_INSTANCE_SIZE + ((GeometryWithPosition) item.getItem()).getEstimatedMemorySizeInBytes(); }
private boolean removeItem(AbstractNode node, Object item) { Boundable childToRemove = null; for (Iterator i = node.getChildBoundables().iterator(); i.hasNext(); ) { Boundable childBoundable = (Boundable) i.next(); if (childBoundable instanceof ItemBoundable) { if ( ((ItemBoundable) childBoundable).getItem() == item) childToRemove = childBoundable; } } if (childToRemove != null) { node.getChildBoundables().remove(childToRemove); return true; } return false; }
private static Object[] getItems(java.util.PriorityQueue<BoundablePair> kNearestNeighbors) { /** * Iterate the K Nearest Neighbour Queue and retrieve the item from each BoundablePair * in this queue */ Object[] items = new Object[kNearestNeighbors.size()]; Iterator<BoundablePair> resultIterator = kNearestNeighbors.iterator(); int count=0; while(resultIterator.hasNext()) { items[count]=((ItemBoundable)resultIterator.next().getBoundable(0)).getItem(); count++; } return items; } }
private List itemsTree(AbstractNode node) { List valuesTreeForNode = new ArrayList(); for (Iterator i = node.getChildBoundables().iterator(); i.hasNext(); ) { Boundable childBoundable = (Boundable) i.next(); if (childBoundable instanceof AbstractNode) { List valuesTreeForChild = itemsTree((AbstractNode) childBoundable); // only add if not null (which indicates an item somewhere in this tree if (valuesTreeForChild != null) valuesTreeForNode.add(valuesTreeForChild); } else if (childBoundable instanceof ItemBoundable) { valuesTreeForNode.add(((ItemBoundable)childBoundable).getItem()); } else { Assert.shouldNeverReachHere(); } } if (valuesTreeForNode.size() <= 0) return null; return valuesTreeForNode; }
private void queryInternal(Object searchBounds, AbstractNode node, List matches) { List childBoundables = node.getChildBoundables(); for (int i = 0; i < childBoundables.size(); i++) { Boundable childBoundable = (Boundable) childBoundables.get(i); if (! getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds)) { continue; } if (childBoundable instanceof AbstractNode) { queryInternal(searchBounds, (AbstractNode) childBoundable, matches); } else if (childBoundable instanceof ItemBoundable) { matches.add(((ItemBoundable)childBoundable).getItem()); } else { Assert.shouldNeverReachHere(); } } }
private void queryInternal(Object searchBounds, AbstractNode node, ItemVisitor visitor) { List childBoundables = node.getChildBoundables(); for (int i = 0; i < childBoundables.size(); i++) { Boundable childBoundable = (Boundable) childBoundables.get(i); if (! getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds)) { continue; } if (childBoundable instanceof AbstractNode) { queryInternal(searchBounds, (AbstractNode) childBoundable, visitor); } else if (childBoundable instanceof ItemBoundable) { visitor.visitItem(((ItemBoundable)childBoundable).getItem()); } else { Assert.shouldNeverReachHere(); } } }