new com.infomatiq.jsi.rtree.RTree();
private int lowid = 0;
- private HashMap<Integer, V> idToV = new HashMap<Integer, V>();
- private HashMap<V, Integer> vToId = new HashMap<V, Integer>();
+ private HashMap<Integer, V> idToV = new HashMap<Integer, V>();
+ private HashMap<V, Integer> vToId = new HashMap<V, Integer>();
+ private HashMap<V, Rectangle> vToRect = new HashMap<V, Rectangle>();
public Iterator<V> iterator() { return vToId.keySet().iterator(); }
private final MyIntProcedure myIntProcedure = new MyIntProcedure();
- private final com.infomatiq.jsi.Rectangle rect = new com.infomatiq.jsi.Rectangle(0,0,0,0,0,0);
+ private final Rectangle rect = new Rectangle(0,0,0,0,0,0);
private final com.infomatiq.jsi.Point point = new com.infomatiq.jsi.Point(0,0,0);
private V found = null;
private Visitor<V> visitor = null;
public void clear() {
idToV.clear();
vToId.clear();
+ vToRect.clear();
rtree.init(props);
}
int id = lowid++;
idToV.put(id, v);
vToId.put(v, id);
- rect.set(v.getMinX(), v.getMinY(), v.getMinZ(), v.getMaxX(), v.getMaxY(), v.getMaxZ());
+ Rectangle rect = new Rectangle(v.getMinX(), v.getMinY(), v.getMinZ(), v.getMaxX(), v.getMaxY(), v.getMaxZ());
rtree.add(rect, id);
+ vToRect.put(v, rect);
}
public void remove(V v) {
int id = idi;
idToV.remove(id);
vToId.remove(v);
- rect.set(v.getMinX(), v.getMinY(), v.getMinZ(), v.getMaxX(), v.getMaxY(), v.getMaxZ());
- rtree.delete(rect, id);
+ rtree.delete(vToRect.get(v), id);
+ vToRect.remove(v);
}
public V nearest(Point p) { return nearest(p, null); }