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

2022-06-10 18:45:31 浏览数 (1)

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);
    }
jar

0 人点赞