import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _get from 'babel-runtime/helpers/get';
import _inherits from 'babel-runtime/helpers/inherits';
import _extends from 'babel-runtime/helpers/extends';
/**
 * @文件说明: Layers.FillExtrusionLayer 3D填充图层
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-05-25 15:35:15
 */

import BasicLayerClass, { defaultVectorLayerOptions, defaultVectorBasicOptions } from './basicLayer';
import deepmerge from 'deepmerge';
import { isEmpty } from '../../../_util/methods-util';

var defaultLayerOptions = deepmerge(defaultVectorLayerOptions, {
  paint: {
    'fill-extrusion-base': 0,
    'fill-extrusion-color': 'rgba(170, 170, 170, 1)',
    'fill-extrusion-height': 0,
    'fill-extrusion-opacity': 0.9,
    'fill-extrusion-vertical-gradient': true
  },
  metadata: {
    layerTypeName: 'FillExtrusionLayer'
  }
});

var defaultOptions = _extends({}, defaultVectorBasicOptions);

var FillExtrusionLayer = function (_BasicLayerClass) {
  _inherits(FillExtrusionLayer, _BasicLayerClass);

  function FillExtrusionLayer(iMapApi, id) {
    var layerOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
    var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

    _classCallCheck(this, FillExtrusionLayer);

    var opts = deepmerge.all([{}, defaultOptions, options || {}]);
    opts.opacityPaints = ['fill-extrusion-opacity'];
    // 合并原生Layer图层属性
    var layer = deepmerge.all([{}, defaultLayerOptions, layerOptions || {}]);
    layer.type = 'fill-extrusion';
    // 继承矢量图层基类

    // 绑定图层实例对象
    var _this = _possibleConstructorReturn(this, (FillExtrusionLayer.__proto__ || Object.getPrototypeOf(FillExtrusionLayer)).call(this, iMapApi, id, layer, opts));

    _this.mapLayer && (_this.mapLayer._instance = _this);
    return _this;
  }

  /**
   * 设置图层的整体透明度
   * @param {Number} opacity 待设定的透明度
   */


  _createClass(FillExtrusionLayer, [{
    key: 'setOpacity',
    value: function setOpacity(opacity) {
      _get(FillExtrusionLayer.prototype.__proto__ || Object.getPrototypeOf(FillExtrusionLayer.prototype), 'setOpacity', this).call(this, opacity, ['fill-extrusion-opacity']);
    }

    /**
     * 获取3D填充的颜色属性
     */

  }, {
    key: 'getColor',
    value: function getColor() {
      return this.getPaint('fill-extrusion-color');
    }

    /**
     * 设置3D填充的颜色属性
     * @param {String} color 待设定的颜色值
     */

  }, {
    key: 'setColor',
    value: function setColor(color) {
      color && this.setPaint('fill-extrusion-color', color);
    }

    /**
     * 获取3D填充的拉起高度
     */

  }, {
    key: 'getHeight',
    value: function getHeight() {
      return this.getPaint('fill-extrusion-height');
    }

    /**
     * 设置3D填充的拉起高度
     * @param {Number} height 待设定的3D拉起高度
     */

  }, {
    key: 'setHeight',
    value: function setHeight(height) {
      !isEmpty(height) && this.setPaint('fill-extrusion-height', height);
    }

    /**
     * 获取3D填充的基座高度（即离地高度）
     */

  }, {
    key: 'getBaseHeight',
    value: function getBaseHeight() {
      return this.getPaint('fill-extrusion-base');
    }

    /**
     * 设置3D填充的基座高度（即离地高度）
     * @param {Number} height 待设定的离地高度
     */

  }, {
    key: 'setBaseHeight',
    value: function setBaseHeight(height) {
      !isEmpty(height) && this.setPaint('fill-extrusion-base', height);
    }
  }]);

  return FillExtrusionLayer;
}(BasicLayerClass);

export default FillExtrusionLayer;