From fd2823afc771def7f9ea1f09d9c38ea8086aa395 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期四, 26 十二月 2024 19:12:25 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java | 73 ++++++++++++++++++++++++++++++++++++ ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java | 1 ruoyi-service/ruoyi-other/pom.xml | 6 +++ 3 files changed, 79 insertions(+), 1 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java index ac5e741..18eb3c1 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java @@ -230,7 +230,6 @@ if (!check){ throw new ServiceException("订单不存在"); } - Integer orderType = order.getOrderType(); // 售后设置 R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5); diff --git a/ruoyi-service/ruoyi-other/pom.xml b/ruoyi-service/ruoyi-other/pom.xml index 50f811c..e51a5ae 100644 --- a/ruoyi-service/ruoyi-other/pom.xml +++ b/ruoyi-service/ruoyi-other/pom.xml @@ -136,6 +136,12 @@ <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> </dependency> + <!-- 计算两坐标间的直线距离 --> + <dependency> + <groupId>org.gavaghan</groupId> + <artifactId>geodesy</artifactId> + <version>1.1.3</version> + </dependency> </dependencies> <build> diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java new file mode 100644 index 0000000..42e9578 --- /dev/null +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/task/GeodesyUtil.java @@ -0,0 +1,73 @@ +package com.ruoyi.other.task; + +import com.ruoyi.common.core.utils.StringUtils; +import org.gavaghan.geodesy.Ellipsoid; +import org.gavaghan.geodesy.GeodeticCalculator; +import org.gavaghan.geodesy.GeodeticCurve; +import org.gavaghan.geodesy.GlobalCoordinates; + +import java.util.HashMap; +import java.util.Map; + +/** + * 计算两个金纬度坐标之间的直线距离 + */ +public class GeodesyUtil { + + + /** + * 获取直线距离 + * @param fromLonLat + * @param toLonLat + * @return + */ + public static Map<String, Double> getDistance(String fromLonLat, String toLonLat){ + Map<String, Double> map = null; + if(StringUtils.isNotEmpty(fromLonLat) && StringUtils.isNotEmpty(toLonLat)){ + map = new HashMap<>(); + String[] from = fromLonLat.split(","); + String[] to = toLonLat.split(","); + GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(from[1]), Double.valueOf(from[0])); + GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(to[1]), Double.valueOf(to[0])); + double Sphere = getDistanceMeter(source, target, Ellipsoid.Sphere); + double WGS84 = getDistanceMeter(source, target, Ellipsoid.WGS84); + double GRS80 = getDistanceMeter(source, target, Ellipsoid.GRS80); + double GRS67 = getDistanceMeter(source, target, Ellipsoid.GRS67); + double ANS = getDistanceMeter(source, target, Ellipsoid.ANS); + double WGS72 = getDistanceMeter(source, target, Ellipsoid.WGS72); + double Clarke1858 = getDistanceMeter(source, target, Ellipsoid.Clarke1858); + double Clarke1880 = getDistanceMeter(source, target, Ellipsoid.Clarke1880); +// System.out.println("Sphere坐标系计算结果:"+Sphere + "米"); +// System.out.println("WGS84坐标系计算结果:"+WGS84 + "米"); +// System.out.println("GRS80坐标系计算结果:"+GRS80 + "米"); +// System.out.println("GRS67坐标系计算结果:"+GRS67 + "米"); +// System.out.println("ANS坐标系计算结果:"+ANS + "米"); +// System.out.println("WGS72坐标系计算结果:"+WGS72 + "米"); +// System.out.println("Clarke1858坐标系计算结果:"+Clarke1858 + "米"); +// System.out.println("Clarke1880坐标系计算结果:"+Clarke1880 + "米"); + map.put("Sphere", Sphere); + map.put("WGS84", WGS84); + map.put("GRS80", GRS80); + map.put("GRS67", GRS67); + map.put("ANS", ANS); + map.put("WGS72", WGS72); + map.put("Clarke1858", Clarke1858); + map.put("Clarke1880", Clarke1880); + } + return map; + } + + + private static double getDistanceMeter(GlobalCoordinates gpsFrom, GlobalCoordinates gpsTo, Ellipsoid ellipsoid){ + //创建GeodeticCalculator,调用计算方法,传入坐标系、经纬度用于计算距离 + GeodeticCurve geoCurve = new GeodeticCalculator().calculateGeodeticCurve(ellipsoid, gpsFrom, gpsTo); + return geoCurve.getEllipsoidalDistance(); + } + + + + public static void main(String[] ages){ + GeodesyUtil geodesyUtil = new GeodesyUtil(); + geodesyUtil.getDistance("115.481028,39.989643", "114.465302,40.004717"); + } +} -- Gitblit v1.7.1