ProcessingRectangleCalculator { public static Rectangle getGeometryAsRectangle(Product product, Geometry regionGeometry) { if (!(product == null || regionGeometry == null || regionGeometry.isEmpty() || GeometryUtils.isGlobalCoverageGeometry(regionGeometry))) { try { if (product.getSceneGeoCoding() != null) { LOG.info("getGeometryAsRectangle:..SubsetOp.computePixelRegion"); try { return SubsetOp.computePixelRegion(product, regionGeometry, 1); } catch (TopologyException e2) { return SubsetOp.computePixelRegion(product, new ConvexHull(regionGeometry).getConvexHull(), 1); } } else { return EosRectangleCalculator.computePixelRegion(product, regionGeometry, 1); } } catch (Exception e) { String msg = "Exception from SubsetOp.computePixelRegion: " + e.getMessage(); LogRecord lr = new LogRecord(Level.WARNING, msg); lr.setSourceClassName("ProcessingRectangleCalculator"); lr.setSourceMethodName("getGeometryAsRectangle"); lr.setThrown(e); LOG.log(lr); LOG.warning("ignoring product"); return new Rectangle(); } } return null; } ProcessingRectangleCalculator(Geometry regionGeometry, Rectangle roiRectangle, InputSplit inputSplit, boolean fullSwath); Rectangle computeRect(); static Rectangle getGeometryAsRectangle(Product product, Geometry regionGeometry);  }
@Ignore @Test public void getGeometryAsRectangle() throws IOException { System.setProperty("snap.pixelGeoCoding.useTiling", "true"); System.setProperty("snap.useAlternatePixelGeoCoding", "true"); Product product = ProductIO.readProduct("C:\\ssd\\fire\\S3A_OL_1_EFR____20190101T144647_20190101T144947_20190102T215705_0179_039_367_2880_MAR_O_NT_002.tif_idepix.nc"); String geometryWkt = "POLYGON((-80 10, -70 10, -70 0, -80 0, -80 10))"; Geometry regionGeometry = GeometryUtils.createGeometry(geometryWkt); System.out.println(product.getSceneGeoCoding()); System.setProperty("snap.pixelGeoCoding.useTiling", "true"); System.setProperty("snap.useAlternatePixelGeoCoding", "false"); System.setProperty("snap.pixelGeoCoding.useTiling", "false"); System.setProperty("snap.useAlternatePixelGeoCoding", "true"); product = ProductIO.readProduct("C:\\ssd\\fire\\S3A_OL_1_EFR____20190101T144647_20190101T144947_20190102T215705_0179_039_367_2880_MAR_O_NT_002.tif_idepix.nc"); Rectangle rectangle = ProcessingRectangleCalculator.getGeometryAsRectangle(product, regionGeometry); System.out.println(product.getSceneGeoCoding()); System.out.println(rectangle); }