code: private int calculateTileLevel() {
  		double baseX = layerBounds.getWidth();
  		double baseY = layerBounds.getHeight();
  		// choose the tile level so the area is between minimumTileSize and the next level (minimumTileSize * 4)
  		double baseArea = baseX * baseY;
  		double scale = layer.getMapModel().getMapView().getCurrentScale();
  		double osmArea = preferredTileSize / (scale * scale);
  		int tileLevel = (int) Math.round(Math.log(baseArea / osmArea) / Math.log(4.0));
  		if (tileLevel < 0) {
  			tileLevel = 0;
  		}
  		return tileLevel;
  	}
docs: Calculate the best tile level to use for a certain view-bounds.
  
  @return best tile level for view bounds