From caa8596884dac891a8b5c4fcf85dd2f7a12812f5 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 18 六月 2023 19:33:13 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/utils/CalculateUtils.java | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/yssh/utils/CalculateUtils.java b/src/main/java/com/yssh/utils/CalculateUtils.java index ecd2aeb..4274617 100644 --- a/src/main/java/com/yssh/utils/CalculateUtils.java +++ b/src/main/java/com/yssh/utils/CalculateUtils.java @@ -47,7 +47,7 @@ s = s * EARTH_RADIUS1; - return Math.round(s * 100) / 100; + return round2(s); } /** @@ -66,7 +66,11 @@ // 璁$畻璺濈锛屽崟浣嶏細绫� double distance = geodeticCalculator.getOrthodromicDistance(); - return Math.round(distance * 100) / 100; + return round2(distance); + } + + public static double round2(double d) { + return ((long)(d * 100)) / 100D; } /** @@ -84,13 +88,33 @@ double angle = gc.getAzimuth(); - return Math.round(angle * 100) / 100; + return round2(angle); } catch (Exception ex) { return 0; } } /** + * 璁$畻瑙掑害2 + */ + public static double getAngle2(double x1, double y1, double x2, double y2){ + try { + DirectPosition2D p1 = new DirectPosition2D( x1, y1); + DirectPosition2D p2 = new DirectPosition2D(x2, y2); + + GeodeticCalculator gc = new GeodeticCalculator(); + gc.setStartingGeographicPoint(p1); + gc.setDestinationGeographicPoint(p2); + + double angle = gc.getAzimuth(); + + return round2(angle); + }catch (Exception ex){ + return 0; + } + } + + /** * 鑾峰彇鍧愭爣 * @param su * @return -- Gitblit v1.9.3