private Geometry getPolygon(GeneralPath geoBoundaryPath) { Geometry boundary = JTS.shapeToGeometry(geoBoundaryPath, factory); if (boundary instanceof LinearRing) { boundary = factory.createPolygon((LinearRing) boundary, null); } return boundary; } }
private static Coordinate[] getBoundsCoordinates(Geometry roiGeometry) { // do not use ShapeWriter.toShape(Geometry) here, because it rounds GeneralPath shape = new GeneralPath(); shape.moveTo((float) roiGeometry.getCoordinates()[0].x, (float) roiGeometry.getCoordinates()[0].y); for (int i = 1; i < roiGeometry.getNumPoints(); i++) { shape.lineTo((float) roiGeometry.getCoordinates()[i].x, (float) roiGeometry.getCoordinates()[i].y); } roiGeometry = JTS.shapeToGeometry(shape.getBounds2D(), new GeometryFactory()); return roiGeometry.getCoordinates(); }
private BinWriter createBinWriter(File tempFile, int numRows, ProductData.UTC startTime, ProductData.UTC stopTime) { final SEAGrid seaGrid = new SEAGrid(numRows); final VariableContextImpl variableContext = new VariableContextImpl(); variableContext.defineVariable("test", "blah"); final BinManager binManager = new BinManager(variableContext, new AggregatorMinMax(variableContext, "test", "test")); final BinningContextImpl binningContext = new BinningContextImpl(seaGrid, binManager, CompositingType.BINNING, 1, -1, null, null); final Geometry region = JTS.shapeToGeometry(new Rectangle2D.Double(-180, -90, 360, 180), new GeometryFactory()); final SeaDASLevel3BinWriter binWriter = new SeaDASLevel3BinWriter(region, startTime, stopTime); binWriter.setBinningContext(binningContext); binWriter.setTargetFileTemplatePath(tempFile.getAbsolutePath()); binWriter.setLogger(Logger.getLogger("SeaDASLevel3BinWriterTest")); return binWriter; } }
region = JTS.shapeToGeometry(regionArea, new GeometryFactory());
final Geometry jis = JTS.shapeToGeometry(intersectionEnvelope.toRectangle2D(), cropRoi.getFactory()); if( ! IntersectUtils.intersects(cropRoi, jis)) throw new CannotCropException(Errors.format(ErrorKeys.CANT_CROP));