'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.osmMapOptions = exports.osmLayersTypes = undefined;

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _hat = require('hat');

var _hat2 = _interopRequireDefault(_hat);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

// OSM地图图层服务源的类型
var osmLayersTypes = exports.osmLayersTypes = ['vec', 'bike', 'traffic', 'humanitarian'];

// OSM地图的限制地图Map属性
/**
 * @文件说明: Providers.OSM Open Street Map数据源
 * @创建人: pjtools@vip.qq.com
 * @创建时间: 2020-03-23 17:31:25
 */

var osmMapOptions = exports.osmMapOptions = {
  minZoom: 1,
  maxZoom: 18
};

// OSM地图瓦片服务地址
var osmTilesUrls = {
  vec: ['a', 'b', 'c'].map(function (key) {
    return 'http://' + key + '.tile.openstreetmap.org/{z}/{x}/{y}.png';
  }),
  bike: ['a', 'b', 'c'].map(function (key) {
    return 'http://' + key + '.tile.thunderforest.com/cycle/{z}/{x}/{y}.png';
  }),
  traffic: ['a', 'b', 'c'].map(function (key) {
    return 'http://' + key + '.tile.thunderforest.com/transport/{z}/{x}/{y}.png';
  }),
  humanitarian: ['a', 'b', 'c'].map(function (key) {
    return 'http://tile-' + key + '.openstreetmap.fr/hot/{z}/{x}/{y}.png';
  })
};

var OSM = function () {
  function OSM(iMapApi) {
    (0, _classCallCheck3['default'])(this, OSM);

    this.iMapApi = iMapApi;
    this.id = (0, _hat2['default'])();
  }

  /**
   * 获取OSM地图服务源的图层对象
   * @param {Object} options 服务源的参数选项
   */


  (0, _createClass3['default'])(OSM, [{
    key: 'getLayers',
    value: function getLayers() {
      var _this = this;

      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

      var layers = {};
      // 生成OSM对应类型的图层集合
      osmLayersTypes.map(function (key) {
        layers[key] = [];
        var layer = {
          id: 'providers_osm_' + key + '_' + _this.id,
          type: 'raster',
          source: {
            type: 'raster',
            tileSize: 256,
            minzoom: osmMapOptions.minZoom,
            maxzoom: osmMapOptions.maxZoom + 1,
            tiles: osmTilesUrls[key]
          },
          minzoom: osmMapOptions.minZoom,
          maxzoom: osmMapOptions.maxZoom + 1,
          metadata: {
            serviceType: 'XYZTile'
          }
        };
        layers[key].push(layer);
      });
      return layers;
    }
  }]);
  return OSM;
}();

exports['default'] = OSM;