MosaicGrid { public Rectangle alignToTileGrid(Rectangle rectangle) { int minX = rectangle.x / tileSize * tileSize; int maxX = (rectangle.x + rectangle.width + tileSize - 1) / tileSize * tileSize; int minY = (rectangle.y / tileSize) * tileSize; int maxY = (rectangle.y + rectangle.height + tileSize - 1) / tileSize * tileSize; return new Rectangle(minX, minY, maxX - minX, maxY - minY); } MosaicGrid();   MosaicGrid(int macroTileSize, int numTileY, int tileSize, boolean withIntersectionCheck, int maxReducers, int maxMacroTileCountX, String regionWkt); static MosaicGrid create(Configuration conf); void saveToConfiguration(Configuration conf); int getMacroTileSize(); int getTileSize(); double getPixelSize(); int getNumTileX(); int getNumTileY(); int getNumMacroTileX(); int getNumMacroTileY(); Rectangle computeBounds(Geometry roiGeometry); Rectangle alignToTileGrid(Rectangle rectangle); Geometry computeProductGeometry(Product product); TileIndexWritable[] getTileIndices(List<Point> tilePointIndices); Rectangle getTileRectangle(int tileX, int tileY); Rectangle getMacroTileRectangle(int tileX, int tileY); CrsGeoCoding createMacroCRS(Point macroTile); int getPartition(int macroTileX, int macroTileY); int getNumReducers();  }
@Test public void testAlignToTileGrid() throws Exception { MosaicGrid mosaicGrid = new MosaicGrid(); Rectangle rectangle = new Rectangle(0, 0, 370 * 360, 370 * 180); Rectangle aligned = mosaicGrid.alignToTileGrid(rectangle); assertNotNull(aligned); assertEquals(0, aligned.x); assertEquals(0, aligned.y); assertEquals(370 * 360, aligned.width); assertEquals(370 * 180, aligned.height); rectangle = new Rectangle(0, 0, 370 * 10, 370 * 10); aligned = mosaicGrid.alignToTileGrid(rectangle); assertNotNull(aligned); assertEquals(0, aligned.x); assertEquals(0, aligned.y); assertEquals(370 * 10, aligned.width); assertEquals(370 * 10, aligned.height); rectangle = new Rectangle(185, 185, 370 * 9, 370 * 9); aligned = mosaicGrid.alignToTileGrid(rectangle); assertNotNull(aligned); assertEquals(0, aligned.x); assertEquals(0, aligned.y); assertEquals(370 * 10, aligned.width); assertEquals(370 * 10, aligned.height); }