"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.TdtLabelImageryProvider = void 0;
var _cesium = require("cesium");
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
var MAP_URL = 'https://{s}.tianditu.gov.cn/DataServer?T={style}_w&x={x}&y={y}&l={z}&tk={key}';
var MAP_LABEL_URL = 'https://{s}.tianditu.gov.cn/DataServer?T={style}&x={x}&y={y}&l={z}&tk={key}';
var TdtLabelImageryProvider = exports.TdtLabelImageryProvider = /*#__PURE__*/function (_UrlTemplateImageryPr) {
  function TdtLabelImageryProvider() {
    var _this;
    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    _classCallCheck(this, TdtLabelImageryProvider);
    var style = options.style,
      value = options.value,
      key = options.key,
      replaceLabel = options.replaceLabel;
    var _style = value === 'img' ? 'cia_w' : 'cva_w';
    _this = _callSuper(this, TdtLabelImageryProvider, [{
      // 调用影响中文注记服务
      url: MAP_LABEL_URL.replace(/\{style\}/g, _style).replace(/\{key\}/g, key || '13b4890427f17c692f9efed46b98db81'),
      subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
      tilingScheme: new _cesium.WebMercatorTilingScheme(),
      maximumLevel: 18
    }]);
    if (style === 'dark') {
      var _options$alpha, _options$contrast, _options$brightness, _options$hue, _options$saturation;
      _this.defaultAlpha = (_options$alpha = options.alpha) !== null && _options$alpha !== void 0 ? _options$alpha : 1.0; // 透明度
      _this.defaultContrast = (_options$contrast = options.contrast) !== null && _options$contrast !== void 0 ? _options$contrast : -1.0; // 对比度
      _this.defaultBrightness = (_options$brightness = options.brightness) !== null && _options$brightness !== void 0 ? _options$brightness : 0.9; // 亮度
      _this.defaultHue = (_options$hue = options.hue) !== null && _options$hue !== void 0 ? _options$hue : 3.6; // 色调
      _this.defaultSaturation = (_options$saturation = options.saturation) !== null && _options$saturation !== void 0 ? _options$saturation : -0.8; // 饱和度
    }
    _this.replaceLabel = replaceLabel;
    return _this;
  }
  _inherits(TdtLabelImageryProvider, _UrlTemplateImageryPr);
  return _createClass(TdtLabelImageryProvider, [{
    key: "requestImage",
    value: function requestImage(x, y, level, request) {
      if (this.replaceLabel && this.replaceLabel["/".concat(level, "/").concat(x, "/").concat(y)]) {
        return _cesium.ImageryProvider.loadImage(this, this.replaceLabel["/".concat(level, "/").concat(x, "/").concat(y)]);
      }
      return _superPropGet(TdtLabelImageryProvider, "requestImage", this, 3)([x, y, level, request]);
    }
  }]);
}(_cesium.UrlTemplateImageryProvider);
var TdtImageryProvider = /*#__PURE__*/function (_UrlTemplateImageryPr2) {
  function TdtImageryProvider() {
    var _this2;
    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    _classCallCheck(this, TdtImageryProvider);
    var style = options.style;
    var _style = style === undefined || style === 'vec' || style === 'dark' ? 'vec' : style;
    _this2 = _callSuper(this, TdtImageryProvider, [{
      url: MAP_URL.replace(/\{style\}/g, _style).replace(/\{key\}/g, options.key || '13b4890427f17c692f9efed46b98db81'),
      subdomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],
      tilingScheme: new _cesium.WebMercatorTilingScheme(),
      maximumLevel: 18
    }]);
    if (style === 'dark') {
      var _options$alpha2, _options$contrast2, _options$brightness2, _options$hue2, _options$saturation2;
      _this2.defaultAlpha = (_options$alpha2 = options.alpha) !== null && _options$alpha2 !== void 0 ? _options$alpha2 : 1.0; // 透明度
      _this2.defaultContrast = (_options$contrast2 = options.contrast) !== null && _options$contrast2 !== void 0 ? _options$contrast2 : -1.0; // 对比度
      _this2.defaultBrightness = (_options$brightness2 = options.brightness) !== null && _options$brightness2 !== void 0 ? _options$brightness2 : 0.9; // 亮度
      _this2.defaultHue = (_options$hue2 = options.hue) !== null && _options$hue2 !== void 0 ? _options$hue2 : 3.6; // 色调
      _this2.defaultSaturation = (_options$saturation2 = options.saturation) !== null && _options$saturation2 !== void 0 ? _options$saturation2 : -0.8; // 饱和度
    }
    return _this2;
  }
  _inherits(TdtImageryProvider, _UrlTemplateImageryPr2);
  return _createClass(TdtImageryProvider);
}(_cesium.UrlTemplateImageryProvider);
var _default = exports["default"] = TdtImageryProvider;
//# sourceMappingURL=TdtImageryProvider.js.map
