public List < TileCoordinate > translateToZoomLevel ( byte zoomlevelNew ) { List < TileCoordinate > tiles = null ; int zoomlevelDistance = zoomlevelNew - this . zoomlevel ; int factor = ( int ) Math . pow ( 2 , Math . abs ( zoomlevelDistance ) ) ; if ( zoomlevelDistance > 0 ) { tiles = new ArrayList <> ( ( int ) Math . pow ( 4 , Math . abs ( zoomlevelDistance ) ) ) ; int tileUpperLeftX = this . x * factor ; int tileUpperLeftY = this . y * factor ; for ( int i = 0 ; i < factor ; i ++ ) { for ( int j = 0 ; j < factor ; j ++ ) { tiles . add ( new TileCoordinate ( tileUpperLeftX + j , tileUpperLeftY + i , zoomlevelNew ) ) ; } } } else { tiles = new ArrayList <> ( 1 ) ; tiles . add ( new TileCoordinate ( this . x / factor , this . y / factor , zoomlevelNew ) ) ; } return tiles ; }
Computes which tile on a lower zoom level covers this given tile or which tiles on a higher zoom level together cover this tile .