module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "lib/mapboxgl/";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 905);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/interopRequireDefault");

/***/ }),

/***/ 12:
/***/ (function(module, exports) {

module.exports = require("@supermap/vue-iclient-mapboxgl/lib/_utils/util.js");

/***/ }),

/***/ 120:
/***/ (function(module, exports) {

module.exports = require("@supermap/vue-iclient-mapboxgl/lib/_utils/statistics.js");

/***/ }),

/***/ 15:
/***/ (function(module, exports) {

module.exports = require("@supermap/vue-iclient-mapboxgl/static/libs/iclient-mapboxgl/iclient-mapboxgl.min.js");

/***/ }),

/***/ 19:
/***/ (function(module, exports) {

module.exports = require("lodash.clonedeep");

/***/ }),

/***/ 3:
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/inheritsLoose");

/***/ }),

/***/ 36:
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/regenerator");

/***/ }),

/***/ 398:
/***/ (function(module, exports) {

module.exports = require("@babel/runtime/helpers/asyncToGenerator");

/***/ }),

/***/ 47:
/***/ (function(module, exports) {

module.exports = require("@supermap/vue-iclient-mapboxgl/lib/_types/event/Events.js");

/***/ }),

/***/ 48:
/***/ (function(module, exports) {

module.exports = require("@supermap/vue-iclient-mapboxgl/lib/_utils/epsg-define.js");

/***/ }),

/***/ 5:
/***/ (function(module, exports) {

module.exports = require("@supermap/vue-iclient-mapboxgl/static/libs/mapboxgl/mapbox-gl-enhance.js");

/***/ }),

/***/ 88:
/***/ (function(module, exports) {

module.exports = require("proj4");

/***/ }),

/***/ 905:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _interopRequireDefault = __webpack_require__(0);
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports._getValueOfEpsgCode = _getValueOfEpsgCode;
exports.checkAndRectifyFeatures = checkAndRectifyFeatures;
exports.default = void 0;
exports.getServerEpsgCode = getServerEpsgCode;
exports.transformFeatures = transformFeatures;
exports.vertifyEpsgCode = vertifyEpsgCode;
var _regenerator = _interopRequireDefault(__webpack_require__(36));
var _inheritsLoose2 = _interopRequireDefault(__webpack_require__(3));
var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(398));
__webpack_require__(5);
__webpack_require__(15);
var _Events2 = __webpack_require__(47);
var _epsgDefine = __webpack_require__(48);
var _proj = _interopRequireDefault(__webpack_require__(88));
var _util = __webpack_require__(12);
var _statistics = __webpack_require__(120);
var _lodash = _interopRequireDefault(__webpack_require__(19));
function _getValueOfEpsgCode(epsgCode) {
  var defName = "EPSG:" + epsgCode;
  var defValue = (0, _epsgDefine.getProjection)(defName);
  if (!defValue) {
    console.error(defName + " not define");
  } else {
    !_proj.default.defs(defName) && _proj.default.defs(defName, defValue);
  }
  return {
    name: defName,
    value: defValue
  };
}
function _transformCoordinates(coordinates, projName) {
  if (coordinates[0] instanceof Array) {
    coordinates.forEach(function (item, index) {
      if (item instanceof Array) {
        coordinates[index] = _transformCoordinates(item, projName);
      }
    });
  } else if (coordinates.length > 0) {
    return projName !== 'EPSG:4326' ? (0, _proj.default)(projName, 'EPSG:4326', coordinates) : coordinates;
  }
  return coordinates;
}
function vertifyEpsgCode(firstFeature) {
  var epsgCode = 4326;
  var firstCoord = (firstFeature.geometry || {}).coordinates || [];
  if (firstCoord[0] instanceof Array) {
    if (firstCoord[0][0] instanceof Array) {
      // type: Polygon
      firstCoord = firstCoord[0][0];
      if (firstCoord[0] instanceof Array) {
        // type: MultiPolygon
        firstCoord = firstCoord[0];
      }
    } else {
      // type: LineString
      firstCoord = firstCoord[0];
    }
  }
  // 以防经纬度交换，判断错误的问题，都改成180
  var acceptRange = firstCoord[0] > -180 && firstCoord[0] < 180 && firstCoord[1] > -180 && firstCoord[1] < 180;
  if (!acceptRange) {
    epsgCode = 3857;
  }
  return epsgCode;
}
function transformFeatures(epsgCode, features) {
  var projName = _getValueOfEpsgCode(epsgCode).name;
  var transformedFeatures = features.map(function (feature) {
    if (_proj.default.defs(projName) && feature.geometry && feature.geometry.coordinates) {
      var coordinates = feature.geometry.coordinates;
      feature.geometry.coordinates = _transformCoordinates(coordinates, projName);
    }
    return feature;
  });
  return transformedFeatures;
}

// 获取iServer restdata restmap 的 epsgcode
function getServerEpsgCode(projectionUrl, options) {
  if (!projectionUrl) {
    return;
  }
  return SuperMap.FetchRequest.get(projectionUrl, null, options).then(function (response) {
    return response.json();
  }).then(function (results) {
    var epsgCode = results.epsgCode;
    if (results.datasetInfo) {
      var prjCoordSys = results.datasetInfo.prjCoordSys;
      epsgCode = prjCoordSys ? prjCoordSys.epsgCode : null;
    }
    return epsgCode;
  }).catch(function (error) {
    console.log(error);
  });
}

// 关系型存储发布成服务后坐标一定是4326，但真实数据可能不是4326，判断一下暂时按照3857处理
function checkAndRectifyFeatures(_x) {
  return _checkAndRectifyFeatures.apply(this, arguments);
}
/**
 * @class iServerRestService
 * @classdesc iServer 数据请求类。
 * @category  BaseTypes Util
 * @param {string} url - iServer 数据服务或地图服务地址。
 * @fires iServerRestService#getdatasucceeded
 * @fires iServerRestService#getdatafailed
 * @fires iServerRestService#featureisempty
 */
function _checkAndRectifyFeatures() {
  _checkAndRectifyFeatures = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref) {
    var features, epsgCode, projectionUrl, options, currentEpsgCode, copyFeatures, epsgValue, vertifyCode;
    return _regenerator.default.wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          features = _ref.features, epsgCode = _ref.epsgCode, projectionUrl = _ref.projectionUrl, options = _ref.options;
          currentEpsgCode = epsgCode;
          copyFeatures = features;
          if (epsgCode) {
            _context2.next = 7;
            break;
          }
          _context2.next = 6;
          return getServerEpsgCode(projectionUrl, options);
        case 6:
          currentEpsgCode = _context2.sent;
        case 7:
          epsgValue = (0, _epsgDefine.getProjection)("EPSG:" + currentEpsgCode);
          if (epsgValue === void 0) {
            currentEpsgCode = 4326;
          }
          if (currentEpsgCode && features && !!features.length) {
            if (currentEpsgCode === 4326) {
              vertifyCode = vertifyEpsgCode(features[0]);
              currentEpsgCode = vertifyCode;
            }
            copyFeatures = transformFeatures(currentEpsgCode, (0, _lodash.default)(features));
          }
          return _context2.abrupt("return", copyFeatures);
        case 11:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  }));
  return _checkAndRectifyFeatures.apply(this, arguments);
}
var iServerRestService = exports.default = /*#__PURE__*/function (_Events) {
  (0, _inheritsLoose2.default)(iServerRestService, _Events);
  function iServerRestService(url, options) {
    var _this;
    _this = _Events.call(this) || this;
    _this.url = url;
    _this.options = options || {};
    _this.eventTypes = ['getdatasucceeded', 'getdatafailed', 'featureisempty'];
    return _this;
  }
  var _proto = iServerRestService.prototype;
  _proto.getData = function getData(datasetInfo, queryInfo) {
    if (!this._checkUrl(this.url)) {
      return null;
    }
    this._getDatasetInfoSucceed(datasetInfo, queryInfo);
  }

  /**
   * @function iServerRestService.prototype.getData
   * @description 请求数据。
   * @param {Object} queryInfo - 可选参数。
   * @param {Object} [queryInfo.maxFeatures] - 最多可返回的要素数量。
   * @param {Object} [queryInfo.attributeFilter] - 属性过滤条件。
   * @param {Object} [queryInfo.keyWord] - 筛选关键字。
   */;
  _proto._getDatasetInfoSucceed = function _getDatasetInfoSucceed(datasetInfo, queryInfo) {
    datasetInfo.dataUrl = this.url;
    // 判断服务为地图服务 或者 数据服务
    this.url.indexOf('/rest/maps') > -1 && this.getMapFeatures(datasetInfo, queryInfo);
    this.url.indexOf('/rest/data') > -1 && this.getDataFeatures(datasetInfo, queryInfo);
  }

  /**
   * @function iServerRestService.prototype.getMapFeatures
   * @description 请求地图服务数据。
   * @param {Object} datasetInfo - 数据集参数。
   * @param {Object} datasetInfo.dataUrl - 地图服务地址。
   * @param {Object} datasetInfo.mapName - 图层名。
   * @param {Object} queryInfo - 可选参数。
   * @param {Object} [queryInfo.maxFeatures] - 最多可返回的要素数量。
   * @param {Object} [queryInfo.attributeFilter] - 属性过滤条件。
   * @param {Object} [queryInfo.keyWord] - 筛选关键字。
   */;
  _proto.getMapFeatures = function getMapFeatures(datasetInfo, queryInfo) {
    var _this2 = this;
    var dataUrl = datasetInfo.dataUrl,
      mapName = datasetInfo.mapName;
    queryInfo.name = mapName;
    this.projectionUrl = dataUrl + "/prjCoordSys";
    if (queryInfo.keyWord) {
      this._getRestMapFields(dataUrl, mapName, function (fields) {
        queryInfo.attributeFilter = _this2._getAttributeFilterByKeywords(fields, queryInfo.keyWord);
        _this2._getMapFeatureBySql(dataUrl, queryInfo);
      }, queryInfo.withCredentials);
    } else {
      this._getMapFeatureBySql(dataUrl, queryInfo);
    }
  }

  /**
   * @function iServerRestService.prototype.getDataFeatures
   * @description 请求数据服务数据。
   * @param {Object} datasetInfo - 数据集参数。
   * @param {Object} datasetInfo.datasetName - 数据集名。
   * @param {Object} datasetInfo.dataSourceName - 数据源名。
   * @param {Object} datasetInfo.dataUrl - 数据服务地址。
   * @param {Object} queryInfo - 可选参数。
   * @param {Object} [queryInfo.maxFeatures] - 最多可返回的要素数量。
   * @param {Object} [queryInfo.attributeFilter] - 属性过滤条件。
   * @param {Object} [queryInfo.keyWord] - 筛选关键字。
   */;
  _proto.getDataFeatures = function getDataFeatures(datasetInfo, queryInfo) {
    var _this3 = this;
    var datasetName = datasetInfo.datasetName,
      dataSourceName = datasetInfo.dataSourceName,
      dataUrl = datasetInfo.dataUrl;
    queryInfo.name = datasetName + '@' + dataSourceName;
    queryInfo.datasetNames = [dataSourceName + ':' + datasetName];
    this.projectionUrl = dataUrl + "/datasources/" + dataSourceName + "/datasets/" + datasetName;
    if (queryInfo.keyWord) {
      var fieldsUrl = dataUrl + ("/datasources/" + dataSourceName + "/datasets/" + datasetName + "/fields.rjson?returnAll=true");
      this._getRestDataFields(fieldsUrl, queryInfo, function (fields) {
        queryInfo.attributeFilter = _this3._getAttributeFilterByKeywords(fields, queryInfo.keyWord);
        _this3._getDataFeaturesBySql(dataUrl, queryInfo);
      });
    } else {
      this._getDataFeaturesBySql(dataUrl, queryInfo);
    }
  };
  _proto._getMapFeatureBySql = function _getMapFeatureBySql(url, queryInfo) {
    var _this4 = this;
    var queryBySQLParams, queryBySQLService;
    queryBySQLParams = new SuperMap.QueryBySQLParameters({
      queryParams: [{
        name: queryInfo.name,
        attributeFilter: queryInfo.attributeFilter,
        orderBy: queryInfo.orderBy
      }],
      queryOption: this.options.hasGeometry === false ? 'ATTRIBUTE' : 'ATTRIBUTEANDGEOMETRY',
      startRecord: this.options.fromIndex,
      expectCount: this.options.toIndex ? this.options.toIndex - this.options.fromIndex + 1 : queryInfo.maxFeatures
    });
    queryBySQLService = new SuperMap.QueryBySQLService(url, {
      proxy: this.options.proxy,
      withCredentials: queryInfo.withCredentials,
      eventListeners: {
        processCompleted: this._getFeaturesSucceed.bind(this),
        processFailed: function processFailed(serviceResult) {
          console.error(serviceResult.error);
          _this4.fetchFailed(serviceResult.error);
        }
      }
    });
    queryBySQLService.processAsync(queryBySQLParams);
  };
  _proto._getDataFeaturesBySql = function _getDataFeaturesBySql(url, queryInfo) {
    var _this5 = this;
    var getFeatureBySQLParams, getFeatureBySQLService;
    getFeatureBySQLParams = new SuperMap.GetFeaturesBySQLParameters({
      queryParameter: {
        name: queryInfo.name,
        attributeFilter: queryInfo.attributeFilter,
        orderBy: queryInfo.orderBy
      },
      hasGeometry: this.options.hasGeometry,
      datasetNames: queryInfo.datasetNames,
      fromIndex: this.options.fromIndex || 0,
      toIndex: this.options.toIndex || (queryInfo.maxFeatures >= 1000 ? -1 : queryInfo.maxFeatures - 1),
      maxFeatures: -1
    });
    getFeatureBySQLService = new SuperMap.GetFeaturesBySQLService(url, {
      proxy: this.options.proxy,
      withCredentials: queryInfo.withCredentials,
      eventListeners: {
        processCompleted: this._getFeaturesSucceed.bind(this),
        processFailed: function processFailed(serviceResult) {
          console.error(serviceResult.error);
          _this5.fetchFailed(serviceResult.error);
        }
      }
    });
    getFeatureBySQLService.processAsync(getFeatureBySQLParams);
  };
  _proto._getFeaturesSucceed = /*#__PURE__*/function () {
    var _getFeaturesSucceed2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(results) {
      var features, data, recordsets;
      return _regenerator.default.wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            if (!(results.result && results.result.recordsets)) {
              _context.next = 13;
              break;
            }
            // 数据来自restmap
            recordsets = results.result.recordsets[0] || {};
            this.features = recordsets.features || {};
            features = this.features.features;
            if (!(features && features.length > 0)) {
              _context.next = 9;
              break;
            }
            data = (0, _statistics.statisticsFeatures)(features, recordsets.fields, recordsets.fieldCaptions, recordsets.fieldTypes);
            data.totalCount = results.result.totalCount;
            _context.next = 11;
            break;
          case 9:
            /**
             * @event iServerRestService#featureisempty
             * @description 请求数据为空后触发。
             * @property {Object} e  - 事件对象。
             */
            this.triggerEvent('featureisempty', {
              results: results
            });
            return _context.abrupt("return");
          case 11:
            _context.next = 27;
            break;
          case 13:
            if (!(results.result && results.result.features)) {
              _context.next = 25;
              break;
            }
            // 数据来自restdata---results.result.features
            this.features = results.result.features;
            features = this.features.features;
            if (!(features && features.length > 0)) {
              _context.next = 21;
              break;
            }
            data = (0, _statistics.statisticsFeatures)(features);
            data.totalCount = results.result.totalCount;
            _context.next = 23;
            break;
          case 21:
            this.triggerEvent('featureisempty', {
              results: results
            });
            return _context.abrupt("return");
          case 23:
            _context.next = 27;
            break;
          case 25:
            this.triggerEvent('getdatafailed', {
              results: results
            });
            return _context.abrupt("return");
          case 27:
            if (results.result.vertified) {
              _context.next = 31;
              break;
            }
            _context.next = 30;
            return checkAndRectifyFeatures({
              features: data.features,
              epsgCode: this.options.epsgCode,
              projectionUrl: this.projectionUrl,
              options: {
                proxy: this.options.proxy
              }
            });
          case 30:
            data.features = _context.sent;
          case 31:
            /**
             * @event iServerRestService#getdatasucceeded
             * @description 请求数据成功后触发。
             * @property {Object} e  - 事件对象。
             */
            this.triggerEvent('getdatasucceeded', data);
          case 32:
          case "end":
            return _context.stop();
        }
      }, _callee, this);
    }));
    function _getFeaturesSucceed(_x2) {
      return _getFeaturesSucceed2.apply(this, arguments);
    }
    return _getFeaturesSucceed;
  }();
  _proto._getRestDataFields = function _getRestDataFields(fieldsUrl, queryInfo, callBack) {
    var _this6 = this;
    SuperMap.FetchRequest.get(fieldsUrl, null, {
      proxy: this.options.proxy,
      withCredentials: queryInfo.withCredentials
    }).then(function (response) {
      return response.json();
    }).then(function (results) {
      var fields = _this6._getFiledsByType(['CHAR', 'TEXT', 'WTEXT'], results);
      callBack(fields, results);
    }).catch(function (error) {
      console.log(error);
      _this6.fetchFailed(error);
    });
  };
  _proto._getRestMapFields = function _getRestMapFields(url, layerName, callBack, withCredentials) {
    var _this7 = this;
    if (withCredentials === void 0) {
      withCredentials = false;
    }
    var param = new SuperMap.QueryBySQLParameters({
      queryParams: [new SuperMap.FilterParameter({
        name: layerName,
        attributeFilter: 'SMID=0'
      })]
    });
    var queryBySQLSerice = new SuperMap.QueryBySQLService(url, {
      proxy: this.options.proxy,
      withCredentials: withCredentials,
      eventListeners: {
        processCompleted: function processCompleted(serviceResult) {
          var fields;
          if (serviceResult.result) {
            var result = serviceResult.result.recordsets[0];
            fields = _this7._getFiledsByType(['CHAR', 'TEXT', 'WTEXT'], result.fieldCaptions, result.fieldTypes);
          }
          fields && callBack(fields, serviceResult.result.recordsets[0]);
        },
        processFailed: function processFailed(serviceResult) {
          console.error(serviceResult.error);
          _this7.fetchFailed(serviceResult.error);
        }
      }
    });
    queryBySQLSerice.processAsync(param);
  };
  _proto._getAttributeFilterByKeywords = function _getAttributeFilterByKeywords(fields, keyWord) {
    var attributeFilter = '';
    fields && fields.forEach(function (field, index) {
      attributeFilter += index !== fields.length - 1 ? field + " LIKE '%" + keyWord + "%' " + 'OR ' : field + " LIKE '%" + keyWord + "%'";
    }, this);
    return attributeFilter;
  }

  /**
   * @function iServerRestService.prototype._checkUrl
   * @description 检查url是否符合要求
   * @private
   * @param {string} url
   */;
  _proto._checkUrl = function _checkUrl(url) {
    var match;
    if (url === '' || !(0, _util.isMatchUrl)(url)) {
      match = false;
    } else {
      match = true;
    }
    // else if (/^http[s]?:\/\/localhost/.test(url) || /^http[s]?:\/\/127.0.0.1/.test(url)) {
    //     //不是实际域名
    //     match = false;
    // }
    return match;
  }

  // types => []string
  ;
  _proto._getFiledsByType = function _getFiledsByType(types, fields, fieldTypes) {
    var resultFileds = [];
    fields.forEach(function (field, index) {
      types.includes(fieldTypes && fieldTypes[index] || field.type) && resultFileds.push(fieldTypes ? field : field.name);
    });
    return resultFileds;
  };
  _proto.fetchFailed = function fetchFailed(error) {
    this.triggerEvent('getdatafailed', {
      error: error
    });
  };
  return iServerRestService;
}(_Events2.Events);

/***/ })

/******/ });