18045010223
2025-07-07 0d3a683a0c97154b1f2e6657398664537e4e3e82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package org.yzh.commons.util;
 
/**
 * 坐标系转换器
 * @author yezhihao
 * https://gitee.com/yezhihao/jt808-server
 */
@FunctionalInterface
public interface Converter {
 
    Converter DEFAULT = p -> p;
 
    /** @return lngLat */
    double[] convert(double... lngLat);
 
    default double[] batchConvert(double[] coords) {
        int length = coords.length - (coords.length & 1);
        for (int i = 0; i < length; ) {
            double[] xy = convert(coords[i], coords[i + 1]);
            coords[i++] = xy[0];
            coords[i++] = xy[1];
        }
        return coords;
    }
}