import { Layer } from './baseLayer'
import { Zondy } from '../../base'
import { defaultValue } from '../../util'
import { LayerType, LoadStatus } from '../../base/enum'
import { jsonClone } from '../../util/Utils'
/**
* Cesium3DTiles图层
* @class Cesium3DTilesCacheLayer
* @moduleEX LayerModule
* @extends Layer
* @param {Object} options 构造参数
* @param {String} [options.url = ''] 服务链接
* @param {Object} [options.extendOptions] 初始化场景图层的额外参数,三维引擎专有的初始化参数请传入此对象
* @param {Object} [options.extendProps] 存储额外参数的属性
*/
class Cesium3DTilesCacheLayer extends Layer {
constructor(options) {
super(options)
options = defaultValue(options, {})
/**
* 服务基地址
* @member {String} Cesium3DTilesCacheLayer.prototype.url
*/
this.url = defaultValue(options.url, '')
/**
* 图层类型
* @member {String} Cesium3DTilesCacheLayer.prototype.type
*/
this.type = LayerType.cesium3DTiles
/**
* 服务版本号
* @member {String} Cesium3DTilesCacheLayer.prototype.version
*/
this.version = undefined
/**
* 模型外包盒
* @member {Object} Cesium3DTilesCacheLayer.prototype.boundingVolume
*/
this.boundingVolume = undefined
/**
* 服务名
* @member {String} Cesium3DTilesCacheLayer.prototype.sceneName
*/
this.sceneName = undefined
/**
* 服务包含的表字段数组
* @member {String} Cesium3DTilesCacheLayer.prototype.fieldInfo
*/
this.fieldInfo = undefined
/**
* 模型位置
* @member {Object} Cesium3DTilesCacheLayer.prototype.position
*/
this.position = undefined
/**
* 模型坐标系
* @member {Object} Cesium3DTilesCacheLayer.prototype.spatialReference
*/
this.spatialReference = undefined
/**
* 描述信息
* @member {String} Cesium3DTilesCacheLayer.prototype.description
*/
this.description = '3DTiles图层'
/**
* 初始化图层的额外参数,三维引擎专有的初始化参数请传入此对象
* @member {Object} Cesium3DTilesCacheLayer.prototype.extendOptions
*/
this.extendOptions = defaultValue(options.extendOptions, {})
}
/**
* 从igs获取图层信息的方法
*/
load() {
return super.load()
}
/**
* 子类加载服务端元信息的方法
* @private
* */
_load() {
const self = this
return new Promise((resolve) => {
self.loadStatus = LoadStatus.loaded
self.loaded = true
resolve(self)
})
}
/**
* 将图层转为json对象
* @return {Object} josn对象
* */
toJSON() {
const json = super.toJSON()
json.url = this.url
json.extendOptions = this.extendOptions
return json
}
static fromJSON(json) {
json = jsonClone(json)
const _layer = new Cesium3DTilesCacheLayer(json)
_layer._isFromJSON = true
return _layer
}
/**
* 克隆并返回一个新图层
* @return {Cesium3DTilesCacheLayer} 新的图层对象
* */
clone() {
return new Cesium3DTilesCacheLayer(this.toJSON())
}
}
Zondy.Layer.Cesium3DTilesCacheLayer = Cesium3DTilesCacheLayer
export default Cesium3DTilesCacheLayer