public static int getMinimumCacheSize ( int tileSize , double overdrawFactor , int width , int height ) { // height * overdrawFactor / tileSize calculates the number of tiles that would cover // the view port, adding 1 is required since we can have part tiles on either side, // adding 2 adds another row/column as spare and ensures that we will generally have // a larger number of tiles in the cache than a TileLayer will render for a view. // For any size we need a minimum of 4 (as the intersection of 4 tiles can always be in the // middle of a view. Dimension dimension = FrameBufferController . calculateFrameBufferDimension ( new Dimension ( width , height ) , overdrawFactor ) ; return Math . max ( 4 , ( 2 + ( dimension . height / tileSize ) ) * ( 2 + ( dimension . width / tileSize ) ) ) ; }
Compute the minimum cache size for a view using the size of the map view . For the view size we use the frame buffer calculated dimension .