@Test
public void testIteratorRectangle() {

	StandardGISGridSet<GISPrimitive> test = new StandardGISGridSet<>(100,100,this.worldBounds);
	test.addAll(this.reference);
	assertEquals(this.reference.size(), test.size());
	Random rnd = new Random();
	int testCount = rnd.nextInt(20)+10;
	Rectangle2d bounds;
	Collection<GISPrimitive> inter = new TreeSet<>(new Comparator<GISPrimitive>() {
		@Override
		public int compare(GISPrimitive o1, GISPrimitive o2) {
			return System.identityHashCode(o2) - System.identityHashCode(o1);
		}
	});
	Iterator<GISPrimitive> iter;
	int deltaX,deltaY,width,height;
	String msg;
	for(int idxTest=0; idxTest<testCount; ++idxTest) {
		msg = "test "+(idxTest+1)+"/"+testCount; //$NON-NLS-1$ //$NON-NLS-2$
		getLogger().info(msg+"..."); //$NON-NLS-1$
		deltaX = rnd.nextInt(1000)*(rnd.nextBoolean() ? -1 : 1);
		deltaY = rnd.nextInt(1000)*(rnd.nextBoolean() ? -1 : 1);
		width = rnd.nextInt(100);
		height = rnd.nextInt(100);
		bounds = new Rectangle2d();
		bounds.setFromCorners(
				this.center.getX()+deltaX, this.center.getY()+deltaY,
				this.center.getX()+deltaX+width,
				this.center.getY()+deltaY+height);
		inter.clear();
		for (GISPrimitive primitive : this.reference) {
			Shape2d<?> primitiveRect = primitive.getGeoLocation().toBounds2D();
			if (bounds.intersects(primitiveRect)) {
				inter.add(primitive);
			}
		}
		iter = test.iterator(bounds);
		GISPrimitive primitive;
		while (iter.hasNext()) {
			primitive = iter.next();
			assertTrue(inter.remove(primitive), msg);
		}
		if (!inter.isEmpty()) {
			for (GISPrimitive pr: this.reference) {
				Shape2d<?> primitiveRect = pr.getGeoLocation().toBounds2D();
				if (bounds.intersects(primitiveRect)) {
					inter.add(pr);
				}
			}
			iter = test.iterator(bounds);
			while (iter.hasNext()) {
				primitive = iter.next();
				assertTrue(inter.remove(primitive), msg);
			}
		}
		//TODO: assertEquals(0, inter.size());
		getLogger().info("done"); //$NON-NLS-1$
	}
}