import { Symbol } from '../../../base/symbol'
import { defaultValue } from '../../../util'
/**
* 聚合点数量区间内的符号信息
* @class ClusterInfo
* @moduleEX RendererModule
* @param {Object} options 构造参数
* @param {Symbol} [options.symbol] 默认的聚合点符号,目前仅支持SimpleMarkerSymbol|PcitureMarkerSymbol部分样式
* @param {TextSymbol|null} [options.labelSymbol] 聚合信息样式,一般描述聚合点的数量
* @param {Number} [options.minValue] 最小聚合点
* @param {Number} [options.maxValue] 最大聚合点
*/
class ClusterInfo {
constructor(options) {
options = defaultValue(options, {})
/**
* 默认的聚合点符号,目前仅支持SimpleMarkerSymbol|PcitureMarkerSymbol部分样式
* @member {Symbol} ClusterInfo.prototype.symbol
*/
this.symbol = Symbol.fromJSON(options.symbol)
/**
* 聚合信息样式,一般描述聚合点的数量
* @member {TextSymbol|null} ClusterInfo.prototype.labelSymbol
*/
this.labelSymbol = options.labelSymbol
? Symbol.fromJSON(options.labelSymbol)
: null
/**
* 最小聚合点
* @member {Number} ClusterInfo.prototype.minValue
*/
this.minValue = options.minValue
/**
* 最大聚合点
* @member {Number} ClusterInfo.prototype.maxValue
*/
this.maxValue = options.maxValue
}
/**
* 通过json构造ClusterInfo对象
* @param {Object} json json对象
* @return {ClusterInfo} ClusterInfo实例
*/
static fromJSON(json) {
json = defaultValue(json, {})
return new ClusterInfo(json)
}
/**
* 导出json对象
* @return {Object} json对象
*/
toJSON() {
const json = {}
json.symbol = this.symbol.toJSON()
json.labelSymbol = this.labelSymbol ? this.labelSymbol.toJSON() : null
json.minValue = this.minValue
json.maxValue = this.maxValue
return json
}
/**
* 克隆ClusterInfo对象
* @return {ClusterInfo} 克隆后的ClusterInfo实例
*/
clone() {
return new ClusterInfo(this.toJSON())
}
}
export default ClusterInfo