if (hasROI && !roiBounds.contains(ix, iy) && !roi.contains(ix, iy)) {
if (hasROI && !roiBounds.contains(ix, iy) && !roi.contains(ix, iy)) {
@Override public boolean validateIndex(int pixelIndex) { final int x = pixelIndex % rasterWidth; final int y = lineOffset + pixelIndex / rasterWidth; return roi.contains(x, y); } }
if (hasROI && !roiBounds.contains(ix, iy) && !roi.contains(ix, iy)) {
roiDisjointTile = true; } else { roiContainsTile = roi.contains(srcRectExpanded); if (!roiContainsTile) { if (!roi.intersects(srcRectExpanded)) {
/** * Checks whether or not the pixel located at (x,y) is valid. * The method first test whether a pixel is valid by using the {@link #isPixelValid(int, int)} method, * and secondly, if the pixel is within the ROI (if any). * * @param x the X co-ordinate of the pixel location * @param y the Y co-ordinate of the pixel location * @param roi the ROI, if null the method returns {@link #isPixelValid(int, int)} * @return <code>true</code> if the pixel is valid * @throws ArrayIndexOutOfBoundsException if the co-ordinates are not in bounds * @see #isPixelValid(int, int) * @see #setNoDataValueUsed(boolean) * @see #setNoDataValue(double) * @see #setValidPixelExpression(String) */ public boolean isPixelValid(int x, int y, ROI roi) { return isPixelValid(x, y) && (roi == null || roi.contains(x, y)); }
public boolean[] readValidMask(int x, int y, int w, int h, boolean[] validMask) throws IOException { if (validMask == null) { validMask = new boolean[w * h]; } if (isValidMaskUsed()) { int index = 0; ROI roi = getValidMaskROI(); for (int yi = y; yi < y + h; yi++) { for (int xi = x; xi < x + w; xi++) { validMask[index] = roi.contains(xi, yi); index++; } } } else { Arrays.fill(validMask, true); } return validMask; }
if (imageROI.contains(footprint.getBounds2D().getBounds())) { imageROI = footprint; } else {
private boolean checkInROI(int y0, int x0) { boolean contains; // Coordinate object creation for the spatial indexing Coordinate p1 = new Coordinate(x0, y0); // Envelope associated to the coordinate object Envelope searchEnv = new Envelope(p1); // Query on the geometry list List<ROI> roiList = spatialIndex.query(searchEnv); contains = false; // Cycle on all the geometries found for (ROI roi : roiList) { synchronized (this) { // HACK contains = roi.contains(x0, y0); } if (contains) { break; } } return contains; }
@Test public void intersectImageROI() throws ParseException { ROI leftRight = createLeftRightROIImage(); ROIGeometry topBottom = createTopBottomROIGeometry(); // intersect the image roi from the geom one ROI result = topBottom.intersect(leftRight); // checks the quadrants assertTrue(result.contains(64, 64)); assertFalse(result.contains(192, 64)); assertFalse(result.contains(64, 192)); assertFalse(result.contains(192, 192)); }
@Test public void unionImageROI() throws ParseException { ROI leftRight = createLeftRightROIImage(); ROIGeometry topBottom = createTopBottomROIGeometry(); // add them ROI result = topBottom.add(leftRight); // checks the quadrants assertTrue(result.contains(64, 64)); assertTrue(result.contains(192, 64)); assertTrue(result.contains(64, 192)); assertFalse(result.contains(192, 192)); }
@Test public void subtractImageROI() throws ParseException { ROI leftRight = createLeftRightROIImage(); ROIGeometry topBottom = createTopBottomROIGeometry(); // subtract the image roi from the geom one ROI result = topBottom.subtract(leftRight); // checks the quadrants assertFalse(result.contains(64, 64)); assertTrue(result.contains(192, 64)); assertFalse(result.contains(64, 192)); assertFalse(result.contains(192, 192)); }
@Test public void xorImageROI() throws ParseException { ROI leftRight = createLeftRightROIImage(); ROIGeometry topBottom = createTopBottomROIGeometry(); // xor the image roi from the geom one ROI result = topBottom.exclusiveOr(leftRight); // checks the quadrants assertFalse(result.contains(64, 64)); assertTrue(result.contains(192, 64)); assertTrue(result.contains(64, 192)); assertFalse(result.contains(192, 192)); }
@Test public void xorInvalidPolygon() throws ParseException, IOException { ROI leftRight = createLeftRightROIGeometry(); ROIGeometry bowTie = createBowTieROIGeometry(); // xor them, the invalid geometry should cause a topology exception and a fallback // onto the more robust raster path ROI result = bowTie.exclusiveOr(leftRight); // sample and check points assertFalse(result.contains(64, 64)); assertTrue(result.contains(192, 64)); assertTrue(result.contains(64, 192)); assertFalse(result.contains(192, 192)); // the two "holes" inside the bowtie assertTrue(result.contains(120, 32)); assertTrue(result.contains(120, 96)); assertFalse(result.contains(140, 32)); assertFalse(result.contains(140, 96)); }
@Test public void unionInvalidPolygon() throws ParseException, IOException { ROI leftRight = createLeftRightROIGeometry(); ROIGeometry bowTie = createBowTieROIGeometry(); // add them, the invalid geometry should cause a topology exception and a fallback // onto the more robust raster path ROI result = bowTie.add(leftRight); // sample and check points assertTrue(result.contains(64, 64)); assertTrue(result.contains(192, 64)); assertTrue(result.contains(64, 192)); assertFalse(result.contains(192, 192)); // in the holes left by the bowtie assertFalse(result.contains(130, 32)); assertFalse(result.contains(130, 96)); }
@Test public void intersectInvalidPolygon() throws ParseException, IOException { ROI leftRight = createLeftRightROIGeometry(); ROIGeometry bowTie = createBowTieROIGeometry(); // xor them, the invalid geometry should cause a topology exception and a fallback // onto the more robust raster path ROI result = bowTie.intersect(leftRight); // sample and check points assertTrue(result.contains(64, 64)); assertFalse(result.contains(192, 64)); assertFalse(result.contains(64, 192)); assertFalse(result.contains(192, 192)); }
@Test public void subtractInvalidPolygon() throws ParseException, IOException { ROI leftRight = createLeftRightROIGeometry(); ROIGeometry bowTie = createBowTieROIGeometry(); // subtract them, the invalid geometry should cause a topology exception and a fallback // onto the more robust raster path ROI result = bowTie.subtract(leftRight); // sample and check points assertFalse(result.contains(64, 64)); assertTrue(result.contains(192, 64)); assertFalse(result.contains(64, 192)); assertFalse(result.contains(192, 192)); }
} else { roiTile = roi.intersect(new ROIShape(srcRectExpanded)); roiContainsTile = roiTile.contains(srcRectExpanded); if (!roiContainsTile) { if (!roiTile.intersects(srcRectExpanded)) {
assertFalse(roi.contains(x, y));