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/service/impl/WarningAnalyseServiceImpl.java |    2 ++
 src/main/java/com/yssh/utils/CalculateUtils.java                   |   30 +++++++++++++++++++++++++++---
 src/main/java/com/yssh/entity/Report.java                          |   12 ++++++------
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/yssh/entity/Report.java b/src/main/java/com/yssh/entity/Report.java
index 42c4d25..0208e3b 100644
--- a/src/main/java/com/yssh/entity/Report.java
+++ b/src/main/java/com/yssh/entity/Report.java
@@ -72,23 +72,23 @@
 
         String time = wd.getTableName().replace("su_yuan_", "");
         double lastVal = 0;
-        double speed1 = CalculateUtils.getWindSpeed(suYuan.getV(), suYuan.getU());
+        double speed1 = CalculateUtils.round2(CalculateUtils.getWindSpeed(suYuan.getV(), suYuan.getU()));
         double direction1 = CalculateUtils.getWindDirection(suYuan.getV(), suYuan.getU());
         String dir = CalculateUtils.getDir(direction1);
 
         double maxVal = suMax.getVocsValue();
 
-        double dis = CalculateUtils.getDistance2(c1.getX(), c1.getY(), c2.getX(), c2.getY());
+        //double dis = CalculateUtils.getDistance2(c1.getX(), c1.getY(), c2.getX(), c2.getY());
         double dis1 = CalculateUtils.getDistance1(c1.getX(), c1.getY(), c2.getX(), c2.getY());
-        double angle = CalculateUtils.getAngle(c1.getX(), c1.getY(), c2.getX(), c2.getY());
+        double angle = CalculateUtils.getAngle2(c1.getX(), c1.getY(), c2.getX(), c2.getY());
 
         double speed2 = CalculateUtils.getWindSpeed(suMax.getV(), suMax.getU());
         double direction2 = CalculateUtils.getWindDirection(suMax.getV(), suMax.getU());
-        String maxDir = CalculateUtils.getDir(direction2);
-        int isSame = (Math.abs(direction1 - direction2) < 15 && Math.abs(speed1 - speed2) < 0.3) ? 1 : 0;
+        String maxDir = CalculateUtils.getDir(angle);
+        int isSame = (Math.abs(direction1 - direction2) < 30 && Math.abs(speed1 - speed2) < 0.5) ? 1 : 0;
 
         return new Report(wd.getLocationName(), c1.getX(), c1.getY(), wd.getValue(), lastVal, time,
-                speed1, dir, maxVal, dis, maxDir, isSame);
+                speed1, dir, maxVal, dis1, maxDir, isSame);
     }
 
     public String getName() {
diff --git a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
index 3e5eaa6..9ea96e4 100644
--- a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
+++ b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java
@@ -392,6 +392,8 @@
                 MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName());
                 List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50);
                 suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d);
+            } else {
+                suMax = suYuan;
             }
 
             Report report = Report.calcReport(wd, suYuan, suMax);
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