From 606d7388589829e6a7108a48898d4e4126312d73 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期三, 01 十一月 2023 16:38:11 +0800 Subject: [PATCH] 增加雷达角度引导信息反馈 --- src/main/java/com/ard/utils/other/GisUtils.java | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/ard/utils/other/GisUtils.java b/src/main/java/com/ard/utils/other/GisUtils.java index e58ca17..29b96c6 100644 --- a/src/main/java/com/ard/utils/other/GisUtils.java +++ b/src/main/java/com/ard/utils/other/GisUtils.java @@ -3,6 +3,7 @@ import org.gavaghan.geodesy.Ellipsoid; import org.gavaghan.geodesy.GeodeticCalculator; import org.gavaghan.geodesy.GlobalCoordinates; +import org.gavaghan.geodesy.GlobalPosition; /** * @Description: gis宸ュ叿绫� @@ -12,6 +13,23 @@ * @Version: 1.0 **/ public class GisUtils { + public static GeodeticCalculator geodeticCalculator = new GeodeticCalculator(); + /** + * 鏍规嵁缁忕含搴︼紝璁$畻涓ょ偣闂寸殑璺濈 + * + * @param From 绗竴涓偣鐨勭粡绾害 + * @param To 绗簩涓偣鐨勭粡绾害 + * @return 杩斿洖璺濈 鍗曚綅绫� + */ + public static double getDistance(double[] From, double[] To) { + double longitudeFrom = From[0]; + double latitudeFrom = From[1]; + double longitudeTo = To[0]; + double latitudeTo = To[1]; + GlobalCoordinates source = new GlobalCoordinates(latitudeFrom, longitudeFrom); + GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo); + return geodeticCalculator.calculateGeodeticCurve(Ellipsoid.WGS84, source, target).getEllipsoidalDistance(); + } /** * 閫氳繃A鐐瑰潗鏍囷紝闀垮害鍜孻杞磋搴﹁绠桞鐐瑰潗鏍� */ @@ -26,4 +44,19 @@ GlobalCoordinates globalCoordinates1 = calculator.calculateEndingGlobalCoordinates(Ellipsoid.WGS84, globalCoordinates, angleWithYAxisDegrees, AB); return new Double[]{globalCoordinates1.getLongitude(), globalCoordinates1.getLatitude()}; } + /** + * 璁$畻浠巉rom鍒皌o鏂瑰悜鐨勭洿绾夸笌姝e寳鏂瑰悜澶硅 + * + * @param longitudeFrom 绗竴涓偣鐨勭粡搴� + * @param latitudeFrom 绗竴涓偣鐨勭含搴� + * @param longitudeTo 绗簩涓偣鐨勭粡搴� + * @param latitudeTo 绗簩涓偣鐨勭含搴� + * @return 杩斿洖瑙掑害 + */ + public static double getNorthAngle(double longitudeFrom, double latitudeFrom, double longitudeTo, double latitudeTo) { + GlobalPosition source = new GlobalPosition(latitudeFrom, longitudeFrom, 0); + GlobalPosition target = new GlobalPosition(latitudeTo, longitudeTo, 0); + return geodeticCalculator.calculateGeodeticMeasurement(Ellipsoid.WGS84, source, target).getAzimuth(); + } + } -- Gitblit v1.9.3