import {defaultValue, toJSON} from '../../../util'
import SubLayer from '../baseLayer/SubLayer'
import { Extent, SpatialReference } from '../../../base/geometry'
/**
* WMS子图层
* @class WMSSubLayer
* @moduleEX LayerModule
* @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 = defaultValue(options.spatialReferences, [])
/**
* 图层坐标系
* @readonly
* @member {SpatialReference} WMSSubLayer.prototype.spatialReference
*/
this.spatialReference = defaultValue(options.spatialReference, undefined)
/**
* 图层范围
* @readonly
* @member {Extent} WMSSubLayer.prototype.extent
*/
this.extent = defaultValue(options.extent, undefined)
}
/**
* 将图层转为json对象
* @return {Object} josn对象
* */
toJSON() {
const _json = super.toJSON()
_json.spatialReference = toJSON(this.spatialReference, SpatialReference)
_json.name = this.name
_json.extent = toJSON(this.extent, Extent)
const _spatialReferences = []
for (let i = 0; i < this.spatialReferences.length; i++) {
_spatialReferences.push(
toJSON(this.spatialReferences[i], SpatialReference)
)
}
_json.spatialReferences = _spatialReferences
return _json
}
/**
* 克隆图层对象
* @return {WMSSubLayer} 克隆后的图层对象
*/
clone() {
return new WMSSubLayer(this.toJSON())
}
}
export default WMSSubLayer