spatial4j.jar用法分享-计算2点经纬度之间的距离

spatial4j.jar计算2点经纬度之间的距离

引入jar包

代码语言:javascript
复制
<dependency>
  <groupId>org.locationtech.spatial4j</groupId>
  <artifactId>spatial4j</artifactId>
  <version>0.8</version>
</dependency>

用法示例

代码语言:javascript
复制
    @Test
    void f4(){
        SpatialContext geo = SpatialContext.GEO;
        Point point = new PointImpl(116.20,39.56,geo);
        Point point1 = new PointImpl(120.51,30.40,geo);
        double distance = geo.calcDistance(point,point1) * DistanceUtils.DEG_TO_KM;
        System.out.println(distance);
    }