RegionFilter implements FilterComponent { @Override public boolean accept(OpendapLeaf leaf) { ThreddsMetadata.GeospatialCoverage geospatialCoverage = leaf.getDataset().getGeospatialCoverage(); if (geospatialCoverage == null) { return true; } Double eastBound = eastBoundProperty.getValue(); Double westBound = westBoundProperty.getValue(); Double northBound = northBoundProperty.getValue(); Double southBound = southBoundProperty.getValue(); LatLonPointImpl northWest = new LatLonPointImpl(northBound, westBound); LatLonPointImpl southEast = new LatLonPointImpl(southBound, eastBound); LatLonRect latLonRect = new LatLonRect(northWest, southEast); return latLonRect.intersect(geospatialCoverage.getBoundingBox()) != null; } RegionFilter(final JCheckBox useRegionFilter); @Override JComponent getUI(); @Override boolean accept(OpendapLeaf leaf); @Override void addFilterChangeListener(FilterChangeListener listener);  }
@Test public void testAccept() throws Exception { OpendapLeaf opendapLeafFullyInside = createLeaf(45.0, -8.0, -68.0, 19.0); OpendapLeaf opendapLeafGoingHorizontallyThroughBox = createLeaf(89.0, -1.0, -89.0, 1.0); OpendapLeaf opendapLeafGoingVerticallyThroughBox = createLeaf(45.0, -179.0, -68.0, 179.0); OpendapLeaf opendapLeafContainingOneEdge = createLeaf(55.0, -12.0, 45.0, -8.0); OpendapLeaf opendapLeafWholeWorld = createLeaf(90.0, -180.0, -90.0, 180.0); OpendapLeaf opendapLeafAbove = createLeaf(90.0, -180.0, 80.0, 180.0); OpendapLeaf opendapLeafRight = createLeaf(90, 30.0, -90.0, 180.0); OpendapLeaf opendapLeafBelow = createLeaf(-80.0, -180, -90.0, 180.0); OpendapLeaf opendapLeafLeft = createLeaf(90.0, -180, -90.0, -11.0); assertTrue(regionFilter.accept(opendapLeafFullyInside)); assertTrue(regionFilter.accept(opendapLeafGoingHorizontallyThroughBox)); assertTrue(regionFilter.accept(opendapLeafGoingVerticallyThroughBox)); assertTrue(regionFilter.accept(opendapLeafContainingOneEdge)); assertTrue(regionFilter.accept(opendapLeafWholeWorld)); assertFalse(regionFilter.accept(opendapLeafAbove)); assertFalse(regionFilter.accept(opendapLeafRight)); assertFalse(regionFilter.accept(opendapLeafBelow)); assertFalse(regionFilter.accept(opendapLeafLeft)); }