package com.boman.common.core.utils;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GeodeticCurve;
import org.gavaghan.geodesy.GlobalCoordinates;

/**
 * @author tjf
 * @Date: 2021/06/04/11:41
 */
public class LatLgtUtil {


    /**
     * 传入两组经纬度,计算出距离
     * @param gpsFrom
     * @param gpsTo
     * @param ellipsoid Ellipsoid.Sphere(百度)/Ellipsoid.WGS84
     * @return
     */
    public static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){

        //创建GeodeticCalculator，调用计算方法，传入坐标系、经纬度用于计算距离
        GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo);

        return geoCurve.getEllipsoidalDistance();
    }
}
