text: 'use strict';
  
  module.exports = GridLevelCalculator;
  
  function GridLevelCalculator(imageParams) {
      this._imageParams = imageParams;
  }
  
  GridLevelCalculator.prototype.getLevelWidth = function getLevelWidth(level) {
      var width = this._imageParams.imageWidth * Math.pow(2, level - this._imageParams.imageLevel);
      return width;
  };
  
  GridLevelCalculator.prototype.getLevelHeight = function getLevelHeight(level) {
      var height =  this._imageParams.imageHeight * Math.pow(2, level - this._imageParams.imageLevel);
      return height;
  };
  
  GridLevelCalculator.prototype.getLevel = function getLevel(regionImageLevel) {
      var log2 = Math.log(2);
      var levelX = Math.log(regionImageLevel.screenWidth  / (regionImageLevel.maxXExclusive - regionImageLevel.minX)) / log2;
      var levelY = Math.log(regionImageLevel.screenHeight / (regionImageLevel.maxYExclusive - regionImageLevel.minY)) / log2;
      var level = Math.ceil(Math.min(levelX, levelY));
      level += this._imageParams.imageLevel;
      
      return level;
  };
  