/** * Compute the footprint. * * @param geometriesList the List of all the geometries found across the dataset * @param transform * @throws MismatchedDimensionException * @throws TransformException * @throws FactoryException */ private void computeFootprint(List<Polygon> geometriesList, MathTransform transform) throws MismatchedDimensionException, TransformException, FactoryException { // Creating the final multipolygon Polygon[] polArray = new Polygon[geometriesList.size()]; Polygon[] polygons = geometriesList.toArray(polArray); final Geometry innerGeometry = new MultiPolygon(polygons, GF); if (footprintCoordinates == FootprintCoordinates.MODEL_SPACE) { this.footprint = JTS.transform(innerGeometry, transform); } else { this.footprint = innerGeometry; innerGeometry.setSRID(NO_SRID); } // Compute the ROIShape if (!innerGeometry.isEmpty()) { LiteShape2 shape = new LiteShape2(innerGeometry, TRANSLATED_TX, null, false); roiShape = (ROIShape) new ROIShape(shape); } }
/** * Gets a {@link Geometry} from an input {@link ROI}. * * @param roi the ROI * @return a {@link Geometry} instance from the provided input; null in case the input roi * is neither a geometry, nor a shape. */ private Geometry getGeometry(ROI roi) { if (roi instanceof ROIGeometry) { return ((ROIGeometry) roi).getAsGeometry(); } else if (roi instanceof ROIShape) { final Shape shape = ((ROIShape) roi).getAsShape(); final Geometry geom = ShapeReader.read(shape, 0, new GeometryFactory()); geom.apply(Y_INVERSION); return geom; } return null; } }
raster.getWidth(), raster.getHeight()); roi = new ROIShape(bounds);
/** * Gets a {@link Geometry} from an input {@link ROI}. * * @param roi the ROI * @return a {@link Geometry} instance from the provided input; null in case the input roi * is neither a geometry, nor a shape. */ private Geometry getGeometry(ROI roi) { if (roi instanceof ROIGeometry) { return ((ROIGeometry) roi).getAsGeometry(); } else if (roi instanceof ROIShape) { final Shape shape = ((ROIShape) roi).getAsShape(); final Geometry geom = ShapeReader.read(shape, 0, new GeometryFactory()); geom.apply(Y_INVERSION); return geom; } return null; } }
Rectangle roiBounds = roi.getBounds();
new ROIShape( new Rectangle2D.Double( ri.getMinX(),
return add(geometry); } else if (roi instanceof ROIShape) { Shape shape = ((ROIShape) roi).getAsShape(); Geometry geometry = JTS.toGeometry(shape); return add(geometry);
private void printRoiShape(ROIShape rs1) { PathIterator pt1 = rs1.getAsShape().getPathIterator(null); float [] coords = new float[2]; System.out.print("POLYGON (("); while (!pt1.isDone()){ pt1.currentSegment(coords); System.out.print(coords[0] + " " + coords[1] + ","); pt1.next(); } System.out.println("))/n"); }
private static void printRoiShape(final ROIShape rs1, final String title) { printShape(rs1.getAsShape(), title); }
convertPolygon(roiInput, worldToGridTransform); block.setParameter("roi", new ROIShape(shapePolygon));
/** * Gets a {@link Geometry} from an input {@link ROI}. * * @param roi the ROI * @return a {@link Geometry} instance from the provided input; * null in case the input roi is neither a geometry, nor a shape. */ private Geometry getGeometry(ROI roi){ if (roi instanceof ROIGeometry){ return ((ROIGeometry) roi).getAsGeometry(); } else if (roi instanceof ROIShape){ final Shape shape = ((ROIShape) roi).getAsShape(); final Geometry geom = ShapeReader.read(shape, 0, geomFactory); geom.apply(Y_INVERSION); return geom; } return null; }
convertPolygon(roiInput, worldToGridTransform); outputList.add(new ROIShape(shapePolygon));
/** * Gets a {@link Geometry} from an input {@link ROI}. * * @param roi the ROI * @return a {@link Geometry} instance from the provided input; * null in case the input roi is neither a geometry, nor a shape. */ private Geometry getGeometry(ROI roi){ if (roi instanceof ROIGeometry){ return ((ROIGeometry) roi).getAsGeometry(); } else if (roi instanceof ROIShape){ final Shape shape = ((ROIShape) roi).getAsShape(); final Geometry geom = ShapeReader.read(shape, 0, geomFactory); geom.apply(Y_INVERSION); return geom; } return null; }
/** * Gets a {@link Geometry} from an input {@link ROI}. * * @param roi the ROI * @return a {@link Geometry} instance from the provided input; * null in case the input roi is neither a geometry, nor a shape. */ private Geometry getGeometry(ROI roi){ if (roi instanceof ROIGeometry){ return ((ROIGeometry) roi).getAsGeometry(); } else if (roi instanceof ROIShape){ final Shape shape = ((ROIShape) roi).getAsShape(); final Geometry geom = ShapeReader.read(shape, 0, geomFactory); geom.apply(Y_INVERSION); return geom; } return null; }
protected ROIShape roiCreation() { int roiHeight = imageHeigth / 2; int roiWidth = imageWidth / 2; Rectangle roiBound = new Rectangle(0, 0, roiWidth, roiHeight); ROIShape roi = new ROIShape(roiBound); return roi; }