TileCacheDiskLayout implements DiskLayout { @Override public File resolve( String matrixId, long x, long y ) { TileDataLevel tileMatrix = set.getTileDataLevel( matrixId ); if ( tileMatrix == null ) { return null; } if ( tileMatrix.getMetadata().getNumTilesX() <= x || tileMatrix.getMetadata().getNumTilesY() <= y || x < 0 || y < 0 ) { return null; } StringBuilder sb = new StringBuilder(); String levelDirectory = getLevelDirectory( tileMatrix ); String columnFileNamePart = getColumnFileNamePart( x ); String rowFileNamePart = getRowFileNamePart( y, tileMatrix ); sb.append( levelDirectory ); sb.append( separatorChar ); sb.append( columnFileNamePart ); sb.append( separatorChar ); sb.append( rowFileNamePart ); return new File( layerDir, sb.toString() ); } TileCacheDiskLayout( File baseDir, String fileType ); @Override void setTileMatrixSet( TileDataSet set ); @Override File resolve( String matrixId, long x, long y ); @Override String getFileType();  }
@Test public void testResolveLargeIndexes() { File file = layout.resolve( "00", 18782353, 786347862 ); String path = file.getPath(); String replaced = path.replace( File.separatorChar, '/' ); assertEquals( "default/00/018/782/353/213/652/137.png", replaced ); }
@Test public void testResolveTinyIndexes() { File file = layout.resolve( "00", 31, 41 ); String path = file.getPath(); String replaced = path.replace( File.separatorChar, '/' ); assertEquals( "default/00/000/000/031/999/999/958.png", replaced ); }