DggUtils { public static Rectangle2D createGridPointRectangle(double lon, double lat) { lon -= 0.02; if (lon < -180.0) { lon = -180.0; } else if (lon + 0.04 > 180.0) { lon -= 0.04; } lat -= 0.01; if (lat < -90.0) { lat = -90.0; } else if (lat + 0.02 > 90.0) { lat -= 0.02; } return new Rectangle2D.Double(lon, lat, 0.04, 0.02); }  static Area computeArea(PointList pointList); static Rectangle2D createGridPointRectangle(double lon, double lat);  }
@Test public void testCreateGridPointRectangle() { final Rectangle2D rectangle = DggUtils.createGridPointRectangle(34, -10); assertEquals(33.98, rectangle.getX(), 1e-8); assertEquals(-10.01, rectangle.getY(), 1e-8); assertEquals(0.04, rectangle.getWidth(), 1e-8); assertEquals(0.02, rectangle.getHeight(), 1e-8); }
@Test public void testCreateGridPointRectangle_lonCrossesAntiMeridian() { Rectangle2D rectangle = DggUtils.createGridPointRectangle(-181, 19); assertEquals(-180.0, rectangle.getX(), 1e-8); assertEquals(18.99, rectangle.getY(), 1e-8); assertEquals(0.04, rectangle.getWidth(), 1e-8); assertEquals(0.02, rectangle.getHeight(), 1e-8); rectangle = DggUtils.createGridPointRectangle(179.99, 20); assertEquals(179.93, rectangle.getX(), 1e-8); assertEquals(19.99, rectangle.getY(), 1e-8); assertEquals(0.04, rectangle.getWidth(), 1e-8); assertEquals(0.02, rectangle.getHeight(), 1e-8); }
@Test public void testCreateGridPointRectangle_latBeyondPole() { Rectangle2D rectangle = DggUtils.createGridPointRectangle(35, -90.2); assertEquals(34.98, rectangle.getX(), 1e-8); assertEquals(-90.0, rectangle.getY(), 1e-8); assertEquals(0.04, rectangle.getWidth(), 1e-8); assertEquals(0.02, rectangle.getHeight(), 1e-8); rectangle = DggUtils.createGridPointRectangle(36, 90.0); assertEquals(35.98, rectangle.getX(), 1e-8); assertEquals(89.97, rectangle.getY(), 1e-8); assertEquals(0.04, rectangle.getWidth(), 1e-8); assertEquals(0.02, rectangle.getHeight(), 1e-8); }