MapElementGridSet extends AbstractGISGridSet<P> implements GISElementSet<P> { @Override public boolean add(P point) { if (this.grid.addElement(point)) { updateComponentType(point); return true; } return false; } MapElementGridSet(int nRows, int nColumns, double boundsX, double boundsY, double boundsWidth, double boundsHeight);  MapElementGridSet(int nRows, int nColumns, Rectangle2d bounds); @Override boolean add(P point); @Override @Pure final P getNearest(Point2D<?, ?> position); @Override @Pure final P getNearest(double x, double y); @Override @Pure final Pair<P, Double> getNearestData(double x, double y); @Override @Pure Pair<P, Double> getNearestData(Point2D<?, ?> position);  }
@Test public void testAddE() { StandardGISGridSet<GISPrimitive> test = new StandardGISGridSet<>(100,100,this.bounds); assertTrue(test.addAll(this.reference)); assertEquals(this.reference.size(), test.size()); String msg; Random rnd = new Random(); int testCount = rnd.nextInt(5)+1; for(int i=0; i<testCount; ++i) { msg = "test "+(i+1)+"/"+testCount; getLogger().info(msg+"..."); double x = this.bounds.getMinX() + rnd.nextDouble() * this.bounds.getWidth(); double y = this.bounds.getMinY() + rnd.nextDouble() * this.bounds.getHeight(); MapPolyline newElement = new MapPolyline(); newElement.addPoint(x, y); x = this.bounds.getMinX() + rnd.nextDouble() * this.bounds.getWidth(); y = this.bounds.getMinY() + rnd.nextDouble() * this.bounds.getHeight(); newElement.addPoint(x, y); assertTrue(this.reference.add(newElement), msg); assertTrue(test.add(newElement), msg); assertEquals(this.reference.size(), test.size(), msg); assertTrue(test.slowContains(newElement), msg); assertEpsilonEquals(this.reference.toArray(),test.toArray(), msg); getLogger().info("done"); } }