package com.scpyun.platform.jilinsscgsdp.utils;

/**
 * @Author liu
 * @Date 2025/9/24 16:53
 * @PackageName:com.scpyun.platform.jilinexchange.utils
 * @ClassName: latitudeLongitudeUtils
 * @Description: TODO
 * @Version 1.0
 */
public class LatitudeLongitudeUtils {
    public static String latitudeLongitude(String latitudeLongitude){
        String inner = latitudeLongitude.substring(2, latitudeLongitude.length() - 2);
        // 分割坐标点
        String[] points = inner.split("\\],\\[");
        StringBuilder result = new StringBuilder("[");
        for (int i = 0; i < points.length; i++) {
            // 分割经纬度
            String[] coords = points[i].split(",");
            // 交换位置
            result.append("[").append(coords[1]).append(",").append(coords[0]).append("]");

            // 添加逗号分隔（最后一个点不加）
            if (i < points.length - 1) {
                result.append(",");
            }
        }
        result.append("]");
        return result.toString();
    }

    public static String latitudeLongitudeFist(String latitudeLongitude){
        String inner = latitudeLongitude.substring(2, latitudeLongitude.length() - 2);
        // 分割坐标点
        String[] points = inner.split("\\],\\[");
        StringBuilder result = new StringBuilder();
        String[] coords = points[1].split(",");
        result.append(coords[0]).append(",").append(coords[1]);
        return result.toString();
    }
}
