    import { defaultValue } from '../../../util'
    import SubLayer from '../baseLayer/SubLayer'
    import { Extent, SpatialReference } from '../../../base/geometry'

    /**
     * WMS子图层
     * @class WMSSubLayer
     * @moduleEX LayerManagerModule
     * @classdesc IGS地图图层
     * @extends SubLayer
     * @param {Object} options 构造参数
     * @param {String} [options.name] 图层名称
     * @param {String} [options.description] 图层描述
     * @param {Boolean} [options.queryable] 是否参与查询
     * @param {Array<SpatialReference>} [options.spatialReferences = []] 图层坐标系列表
     * @param {SpatialReference} [options.spatialReference] 图层坐标系
     * @param {Extent} [options.extent] 图层范围
     */
    class WMSSubLayer extends SubLayer {
      constructor(options) {
        super(options)
        /**
         * 图层名称
         * @readonly
         * @member {String} WMSSubLayer.prototype.name
         */
        this.name = defaultValue(options.name, undefined)
        /**
         * 图层描述
         * @readonly
         * @member {String} WMSSubLayer.prototype.description
         */
        this.description = defaultValue(options.abstract, undefined)
        /**
         * 是否参与查询
         * @readonly
         * @member {Boolean} WMSSubLayer.prototype.queryable
         */
        this.queryable = defaultValue(options.queryable, true)
        /**
         * 图层坐标系列表
         * @readonly
         * @member {Array<SpatialReference>} WMSSubLayer.prototype.spatialReferences
         */
        this.spatialReferences = []
        for (let i = 0; i < options.crs.length; i++) {
          this.spatialReferences[i] = new SpatialReference(options.crs[i])
        }
        /**
         * 图层坐标系
         * @readonly
         * @member {SpatialReference} WMSSubLayer.prototype.spatialReference
         */
        this.spatialReference = defaultValue(options.spatialReference, undefined)
        /**
         * 图层范围
         * @readonly
         * @member {Extent} WMSSubLayer.prototype.extent
         */
        this.extent = undefined
        for (let i = 0; i < options.boundingBox.length; i++) {
          if (
            `EPSG:${options.spatialReference.wkid}` === options.boundingBox[i].crs
          ) {
            this.extent = new Extent({
              xmin: Number(options.boundingBox[i].minx),
              ymin: Number(options.boundingBox[i].miny),
              xmax: Number(options.boundingBox[i].maxx),
              ymax: Number(options.boundingBox[i].maxy)
            })
          }
        }
      }

      /**
       * 将图层转为json对象
       * @return {Object} josn对象
       * */
      toJSON() {
        const json = {
          id: this.id,
          name: this.name,
          title: this.title,
          abstract: this.abstract,
          boundingBox: this.boundingBox,
          crs: this.crs,
          visible: this.visible
        }
        return JSON.parse(JSON.stringify(json))
      }

      /**
       * 克隆图层对象
       * @return {WMSSubLayer} 克隆后的图层对象
       */
      clone() {
        return new WMSSubLayer(this.toJSON())
      }
    }

    export default WMSSubLayer