/**
 * @Author: Caow
 * @Date: 2021-05-05 09:12:41
 */

import { Cesium } from '@bc-modules/namespace'
import State from '@bc-modules/state/State'
import Layer from '../Layer'

class DynamicLayer extends Layer {
  constructor(id) {
    super(id)
    this._delegate = new Cesium.CustomDataSource(id)
    this.type = Layer.getLayerType('dynamic')
    this._state = State.INITIALIZED
  }

  /**
   * Clears all entities
   * @returns {DynamicLayer}
   */
  clear() {
    this._delegate.entities && this._delegate.entities.removeAll()
    this._cache = {}
    this._state = State.CLEARED
    return this
  }
}

Layer.registerType('dynamic')

export default DynamicLayer
