MosaicGrid { public TileIndexWritable[] getTileIndices(List<Point> tilePointIndices) { TileIndexWritable[] tileIndices = new TileIndexWritable[tilePointIndices.size()]; for (int i = 0; i < tilePointIndices.size(); i++) { Point point = tilePointIndices.get(i); int macroX = point.x / macroTileSize; int macroY = point.y / macroTileSize; tileIndices[i] = new TileIndexWritable(macroX, macroY, point.x, point.y); } return tileIndices; } 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 testGetTileIndices() throws Exception { MosaicGrid mosaicGrid = new MosaicGrid(); Geometry geometry; List<Point> tilePointIndices = mosaicGrid.getTilePointIndicesGlobal(); TileIndexWritable[] tileIndices = mosaicGrid.getTileIndices(tilePointIndices); assertNotNull(tileIndices); assertEquals(360 * 180, tileIndices.length); assertEquals(new TileIndexWritable(0, 0, 0, 0), tileIndices[0]); assertEquals(new TileIndexWritable(0, 0, 1, 0), tileIndices[1]); assertEquals(new TileIndexWritable(0, 0, 2, 0), tileIndices[2]); assertEquals(new TileIndexWritable(0, 0, 3, 0), tileIndices[3]); assertEquals(new TileIndexWritable(0, 0, 4, 0), tileIndices[4]); assertEquals(new TileIndexWritable(1, 0, 5, 0), tileIndices[5]); assertEquals(new TileIndexWritable(2, 0, 10, 0), tileIndices[10]); assertEquals(new TileIndexWritable(0, 0, 0, 1), tileIndices[360]); assertEquals(new TileIndexWritable(0, 1, 0, 5), tileIndices[5 * 360]); geometry = GeometryUtils.createGeometry("polygon((-2 46, -2 40, 1 40, 1 46, -2 46))"); tilePointIndices = mosaicGrid.getTilePointIndicesFromGeometry(geometry); tileIndices = mosaicGrid.getTileIndices(tilePointIndices); assertNotNull(tileIndices); assertEquals(3 * 6, tileIndices.length); assertEquals(new TileIndexWritable(35, 8, 178, (90 - 46)), tileIndices[0]); assertEquals(new TileIndexWritable(35, 8, 179, (90 - 46)), tileIndices[1]); assertEquals(new TileIndexWritable(36, 8, 180, (90 - 46)), tileIndices[2]); assertEquals(new TileIndexWritable(35, 9, 178, (90 - 45)), tileIndices[3]); assertEquals(new TileIndexWritable(35, 9, 179, (90 - 45)), tileIndices[4]); assertEquals(new TileIndexWritable(36, 9, 180, (90 - 45)), tileIndices[5]); geometry = GeometryUtils.createGeometry("polygon((-2 46, -2 45, 0 45, 0 40, 1 40, 1 46, -2 46))"); tilePointIndices = mosaicGrid.getTilePointIndicesFromGeometry(geometry); tileIndices = mosaicGrid.getTileIndices(tilePointIndices); assertNotNull(tileIndices); assertEquals(8, tileIndices.length); assertEquals(new TileIndexWritable(35, 8, 178, (90 - 46)), tileIndices[0]); assertEquals(new TileIndexWritable(35, 8, 179, (90 - 46)), tileIndices[1]); assertEquals(new TileIndexWritable(36, 8, 180, (90 - 46)), tileIndices[2]); assertEquals(new TileIndexWritable(36, 9, 180, (90 - 45)), tileIndices[3]); assertEquals(new TileIndexWritable(36, 9, 180, (90 - 44)), tileIndices[4]); assertEquals(new TileIndexWritable(36, 9, 180, (90 - 43)), tileIndices[5]); assertEquals(new TileIndexWritable(36, 9, 180, (90 - 42)), tileIndices[6]); assertEquals(new TileIndexWritable(36, 9, 180, (90 - 41)), tileIndices[7]); }