export default function useConversionStandardData() {
  /**
   * 转换GeoJSON数据格式
   * 将Polygon类型转换为MultiPolygon格式
   * @param {Object} geoData - GeoJSON数据
   * @returns {Object} 转换后的数据
   */
  const transfromGeoJSON = (geoData) => {
    if (!geoData || !geoData.features) {
      return geoData;
    }

    const transformedFeatures = geoData.features.map(feature => {
      if (feature.geometry && feature.geometry.type === 'Polygon') {
        // 将Polygon转换为MultiPolygon格式
        return {
          ...feature,
          geometry: {
            ...feature.geometry,
            coordinates: [feature.geometry.coordinates] // 包装在数组中
          }
        };
      }
      return feature;
    });

    return {
      ...geoData,
      features: transformedFeatures
    };
  };

  /**
   * 转换道路GeoJSON数据格式
   * 将LineString类型转换为MultiLineString格式
   * @param {Object} geoData - GeoJSON道路数据
   * @returns {Object} 转换后的数据
   */
  const transformGeoRoad = (geoData) => {
    if (!geoData || !geoData.features) {
      return geoData;
    }

    const transformedFeatures = geoData.features.map(feature => {
      if (feature.geometry && feature.geometry.type === 'LineString') {
        // 将LineString转换为MultiLineString格式
        return {
          ...feature,
          geometry: {
            ...feature.geometry,
            coordinates: [feature.geometry.coordinates] // 包装在数组中
          }
        };
      }
      return feature;
    });

    return {
      ...geoData,
      features: transformedFeatures
    };
  };

  return {
    transfromGeoJSON,
    transformGeoRoad
  };
}