From 97083523a01b6da19a944840f35fff0afc1a6384 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 13 十一月 2024 11:17:31 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/utils/CalculateUtils.java | 116 ++++------------------------------------------------------ 1 files changed, 8 insertions(+), 108 deletions(-) diff --git a/src/main/java/com/yssh/utils/CalculateUtils.java b/src/main/java/com/yssh/utils/CalculateUtils.java index 73871a4..81e0ded 100644 --- a/src/main/java/com/yssh/utils/CalculateUtils.java +++ b/src/main/java/com/yssh/utils/CalculateUtils.java @@ -12,22 +12,14 @@ import org.geotools.referencing.crs.DefaultGeographicCRS; import org.opengis.referencing.crs.CoordinateReferenceSystem; +@SuppressWarnings("ALL") public class CalculateUtils { - /** - * 榛樿鍦扮悆鍗婂緞,璧ら亾鍗婂緞(鍗曚綅m) - */ private final static double EARTH_RADIUS1 = 6371000; - /** - * 杞寲涓哄姬搴�(rad) - */ private static double rad(double d) { return d * Math.PI / 180.0; } - /** - * 璁$畻璺濈1 - */ public static double getDistance1(double lon1, double lat1, double lon2, double lat2) { double radLat1 = rad(lat1); double radLat2 = rad(lat2); @@ -40,42 +32,26 @@ return round2(s); } - /** - * 璁$畻璺濈2 - */ public static double getDistance2(double x1, double y1, double x2, double y2) { - // 84鍧愭爣绯绘瀯閫燝eodeticCalculator GeodeticCalculator geodeticCalculator = new GeodeticCalculator(DefaultGeographicCRS.WGS84); - // 璧风偣缁忕含搴� geodeticCalculator.setStartingGeographicPoint(x1, y1); - // 鏈偣缁忕含搴� geodeticCalculator.setDestinationGeographicPoint(x2, y2); - // 璁$畻璺濈锛屽崟浣嶏細绫� double distance = geodeticCalculator.getOrthodromicDistance(); return round2(distance); } - /** - * 淇濈暀2浣嶅皬鏁� - */ public static double round2(double d) { return ((long) (d * 100)) / 100D; } - /** - * 淇濈暀6浣嶅皬鏁� - */ public static double round6(double d) { return ((long) (d * 1000000)) / 1000000D; } - /** - * 璁$畻瑙掑害 - */ public static double getAngle(double x1, double y1, double x2, double y2) { try { CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); @@ -94,9 +70,6 @@ } } - /** - * 璁$畻瑙掑害2 - */ public static double getAngle2(double x1, double y1, double x2, double y2) { try { DirectPosition2D p1 = new DirectPosition2D(x1, y1); @@ -114,12 +87,6 @@ } } - /** - * 鑾峰彇鍧愭爣 - * - * @param su - * @return - */ public static Coordinate getCoordinate(DistanceSuYuan su) { String[] sirs = su.getId().split("_"); @@ -131,17 +98,6 @@ return new Coordinate(lon, lat); } - /** - * 璁$畻缁忓害 - * - * @param @param x - * @param @param y - * @param @return 鍙傛暟 - * @return double 杩斿洖绫诲瀷 - * @throws - * @Title: getLon - * @Description: 璁$畻缁忓害 - */ public static double getLon(int x, int y) { double lon = 115.9165227 + 0.000116732 * (x - 0.5) + 0.00000116862 * (y - 0.5); if (lon < 115 || lon > 116) { @@ -151,17 +107,6 @@ return round6(lon); } - /** - * 璁$畻缁村害 - * - * @param @param x - * @param @param y - * @param @return 鍙傛暟 - * @return double 杩斿洖绫诲瀷 - * @throws - * @Title: getLat - * @Description: 璁$畻缁村害 - */ public static double getLat(int x, int y) { double lat = 39.77250000 + 0.000001000 * (x - 0.5) - 0.00009000000 * (y - 0.5); if (lat < 39 || lat > 40) { @@ -171,14 +116,6 @@ return round6(lat); } - /** - * @param @param checkPoints - * @param @return 鍙傛暟 - * @return List<String> 杩斿洖绫诲瀷 - * @throws - * @Title: assembleId - * @Description: 缁勮id - */ public static List<String> assembleId(List<MonitorPointPosition> checkPoints) { List<String> ids2d = new ArrayList<>(); for (MonitorPointPosition point : checkPoints) { @@ -188,15 +125,6 @@ return ids2d; } - /** - * @param @param checkPoint - * @param @param range - * @param @return 鍙傛暟 - * @return List<String> 杩斿洖绫诲瀷 - * @Title: aloneCrosswiseScope - * @Description: 鍗曠嫭鐐逛綅妯悜鑼冨洿鎵╁睍 - * @backup 寮哄埗灏嗗眰绾ф敼涓� 0 - */ public static List<String> aloneCrosswiseExtend(MonitorPointPosition checkPoint, int range) { List<String> ids = new ArrayList<>(); Integer x = checkPoint.getX(); @@ -208,6 +136,13 @@ } } return ids; + } + + public static String getFilterByExtend(MonitorPointPosition point, int range) { + Integer x = point.getX(); + Integer y = point.getY(); + + return String.format("x between %d and %d and y between %d and %d", x - range / 2, x + range / 2, y - range / 2, y + range / 2); } public static List<String> temporary(MonitorPointPosition point, int range) { @@ -225,9 +160,6 @@ return ids3d; } - /** - * 鑾峰彇鏂瑰悜 - */ public static String getDir(double direction) { if (direction < 0) { direction = direction + 360; @@ -254,9 +186,6 @@ return "鍖�"; } - /** - * 璁$畻X銆乊鍊肩殑鐭╁舰妗� - */ public static List<Coordinate> calcRect(double x, double y) { double buffer = 10; double dis = round6(Math.sqrt(Math.pow(buffer / 2, 2) * 2)); @@ -270,9 +199,6 @@ return list; } - /** - * 鏍规嵁璺濈鍜岃搴﹁幏鍙栫洰鏍囩偣 - */ private static Coordinate getPointByDisAndAngle(double x, double y, double angle, double dis) { try { DirectPosition2D p1 = new DirectPosition2D(x, y); @@ -291,26 +217,10 @@ } } - /** - * @param @return 鍙傛暟 - * @return Double 杩斿洖绫诲瀷 - * @throws - * @Title: getWindSpeed - * @Description: 璁$畻椋庨�� - */ public static Double getWindSpeed(double v, double u) { return round6(Math.sqrt(v * v + u * u)); } - /** - * @param @param v - * @param @param u - * @param @return 鍙傛暟 - * @return double 杩斿洖绫诲瀷 - * @throws - * @Title: getWindDirection - * @Description: 璁$畻椋庡悜 - */ public static double getWindDirection(double v, double u) { double result = Math.atan(u / (v + Math.pow(10, -5))) / Math.PI * 180; if (result < 0) { @@ -322,16 +232,6 @@ return round6(result); } - /** - * @param @param list 鎺掑簭瀵硅薄 - * @param @param property 鎺掑簭鍙傛暟 - * @param @param order 鎺掑簭椤哄簭 - * @param @return 鍙傛暟 - * @return List<Map < String, Object>> 杩斿洖绫诲瀷 - * @throws - * @Title: sort - * @Description: 鎺掑簭 - */ public static List<Map<String, Object>> sort(List<Map<String, Object>> list, final String property, final boolean order) { if (list == null || property == null) { return null; -- Gitblit v1.9.3