"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getApiCoordTypeFromMap = exports.getApiCoordType = void 0;
// _util/projection.js

/**
 * 将地图投影代码转换为后端 API 需要的坐标系类型
 * @param {string} projectionCode - 地图投影代码，如 'EPSG:4326', 'EPSG:3857', 'EPSG:4547' 等
 * @returns {string} API 坐标系类型：'wgs84' | 'webmercator' | 'cgcs2000'
 */
var getApiCoordType = exports.getApiCoordType = function getApiCoordType(projectionCode) {
  if (!projectionCode) {
    return 'wgs84';
  }
  if (projectionCode === 'EPSG:4326') {
    return 'wgs84';
  } else if (projectionCode === 'EPSG:3857') {
    return 'webmercator';
  } else {
    return 'cgcs2000';
  }
};

/**
 * 从地图实例获取 API 坐标系类型
 * @param {Object} map - OpenLayers 地图实例
 * @returns {string} API 坐标系类型
 */
var getApiCoordTypeFromMap = exports.getApiCoordTypeFromMap = function getApiCoordTypeFromMap(map) {
  if (!map || !map.getView) {
    return 'wgs84';
  }
  try {
    var projectionCode = map.getView().getProjection().getCode();
    return getApiCoordType(projectionCode);
  } catch (error) {
    console.error('获取地图投影失败:', error);
    return 'wgs84';
  }
};
//# sourceMappingURL=projection.js.map
