    import { Zondy } from '../../../base'
    import { defaultValue } from '../../../util'
    import LOD from './LOD'

    /**
     * 瓦片切图信息
     * @class TileInfo
     * @param {Number} [options.dpi = -1] 屏幕分辨率
     * @param {Number} [options.format = 'png'] 瓦片图像格式
     * @param {Point} [options.origin] 裁图原点
     * @param {Array<LOD>} [options.lods = []] 多层次细节数组
     * @param {Array<Number>} [options.size] 瓦片大小，单位像素
     * @param {SpatialReference} [options.spatialReference] 空间参考系
     */
    class TileInfo {
      constructor(options) {
        options = options || {}

        this.dpi = defaultValue(options.dpi, -1)
        this.format = defaultValue(options.format, 'png')
        this.origin = options.origin
        const _lods = []
        const _optLods = defaultValue(options.lods, [])
        for (let i = 0; i < _optLods.length; i++) {
          _lods.push(LOD.fromJSON(_optLods[i]))
        }
        this.lods = _lods
        this.size = options.size
        this.spatialReference = options.spatialReference
      }

      /**
       * @description: 根据json构造实例
       * @param {Object} options json对象
       * @return {TileInfo}
       */
      static fromJSON(options) {
        return new TileInfo(options)
      }

      /**
       * @description: 导出为json对象
       * @return {Object}
       */
      toJSON() {
        return {
          dpi: this.dpi,
          format: this.format,
          origin: this.origin ? this.origin.toJSON() : undefined,
          lods: this.lods.map((lod) => lod.toJSON()),
          size: this.size ? [this.size[0], this.size[1]] : undefined,
          spatialReference: this.spatialReference && this.spatialReference.toJSON()
        }
      }

      /**
       * @description: 根据比例尺分母计算对应的级别
       * @private
       * @param {Number} scale
       * @return {Number}
       */
      scaleToZoom(scale) {
        return 0
      }

      /**
       * @description: 根据级别计算对应的比例尺分母
       * @private
       * @param {Number} zoom
       * @return {Number}
       */
      zoomToScale(zoom) {
        return 0
      }
    }

    Zondy.TileInfo = TileInfo
    export default TileInfo