GeometryHelper { public static boolean isWithin(final CoordinateSequence cs, final double minX, final double minY, final double maxX, final double maxY) { if (maxX < minX) { throw new IllegalArgumentException("maxX < minX"); } if (maxY < minY) { throw new IllegalArgumentException("maxY < minY"); } for (int i = 0; i < cs.size(); i++) { Coordinate c = cs.getCoordinate(i); double x = c.x; double y = c.y; if (x < minX || x > maxX) { return false; } if (y < minY || y > maxY) { return false; } } return true; }  static CoordinateSequence createLinearRing(GeometryFactory gf,
            double x1, double y1, double x2, double y2); static CoordinateSequence interpolateLinear(LineString line, double threshold, GeometryFactory gf); static boolean isWithin(final CoordinateSequence cs,
            final double minX, final double minY,
            final double maxX, final double maxY);  }
@Test public void testIsWithin() { GeometryFactory gf = new GeometryFactory(); CoordinateSequence cs = gf.getCoordinateSequenceFactory().create(2, 2); cs.setOrdinate(0, 0, -180.0); cs.setOrdinate(0, 1, -45.0); cs.setOrdinate(1, 0, 180.0); cs.setOrdinate(1, 1, 45.0); assertTrue("Happy", GeometryHelper.isWithin(cs, -180.0, -45.0, 180.0, 45.0)); assertFalse("< minX", GeometryHelper.isWithin(cs, -160.0, -45.0, 180.0, 45.0)); assertFalse("> maxX", GeometryHelper.isWithin(cs, -180.0, -45.0, 130.0, 45.0)); assertFalse("< minY", GeometryHelper.isWithin(cs, -180.0, 20.0, 180.0, 45.0)); assertFalse("> maxY", GeometryHelper.isWithin(cs, -180.0, -45.0, 180.0, 5.0)); try { GeometryHelper.isWithin(cs, 2, 5, 1, 6); fail(); } catch (IllegalArgumentException ignore) { assertEquals("maxX < minX", ignore.getMessage()); } try { GeometryHelper.isWithin(cs, 1, -5, 2, -7); fail(); } catch (IllegalArgumentException ignore) { assertEquals("maxY < minY", ignore.getMessage()); } }