From 9d7822ada88392e1b1a612e9b4f680fe6b09aedf Mon Sep 17 00:00:00 2001
From: 826220679@qq.com <826220679@qq.com>
Date: 星期六, 27 十二月 2025 22:25:38 +0800
Subject: [PATCH] 优化了路径规划

---
 dikuai.properties                      |    4 ++--
 src/lujing/YixinglujingNoObstacle.java |   15 +++++++++++----
 set.properties                         |   10 +++++-----
 user.properties                        |    6 +++---
 Obstacledge.properties                 |    2 +-
 5 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/Obstacledge.properties b/Obstacledge.properties
index d268b97..e72df55 100644
--- a/Obstacledge.properties
+++ b/Obstacledge.properties
@@ -1,5 +1,5 @@
 # 鍓茶崏鏈哄湴鍧楅殰纰嶇墿閰嶇疆鏂囦欢
-# 鐢熸垚鏃堕棿锛�2025-12-27T16:33:13.889689700
+# 鐢熸垚鏃堕棿锛�2025-12-27T22:24:22.132171500
 # 鍧愭爣绯伙細WGS84锛堝害鍒嗘牸寮忥級
 
 # ============ 鍦板潡鍩哄噯绔欓厤缃� ============
diff --git a/dikuai.properties b/dikuai.properties
index 2a17fd8..853026d 100644
--- a/dikuai.properties
+++ b/dikuai.properties
@@ -1,5 +1,5 @@
 #Dikuai Properties
-#Sat Dec 27 16:33:13 GMT+08:00 2025
+#Sat Dec 27 22:24:22 GMT+08:00 2025
 LAND1.intelligentSceneAnalysis=-1
 LAND1.mowingSafetyDistance=0.53
 LAND1.landArea=577.12
@@ -12,7 +12,7 @@
 LAND1.boundaryOriginalXY=-1
 LAND1.mowingWidth=1.00
 LAND1.plannedPath=73.87,49.87;50.78,50.04;41.97,22.44;49.61,19.99;51.85,34.26;66.29,36.70;66.29,21.40;78.09,24.75;73.87,49.87;73.96,49.37;50.62,49.54;50.30,48.54;74.12,48.37;74.29,47.37;49.98,47.54;49.66,46.55;74.46,46.37;74.63,45.37;49.34,45.55;49.02,44.55;74.80,44.37;74.96,43.37;48.71,43.55;48.39,42.55;75.13,42.36;75.30,41.36;48.07,41.56;47.75,40.56;75.47,40.36;75.64,39.36;47.43,39.56;47.11,38.56;75.80,38.36;75.97,37.36;46.79,37.57;46.48,36.57;64.75,36.44;66.29,36.43;76.14,36.36;76.31,35.36;66.29,35.43;59.07,35.48;46.16,35.57;45.84,34.57;53.38,34.52;66.29,34.43;76.48,34.35;76.64,33.35;66.29,33.43;51.73,33.53;45.52,33.57;45.20,32.58;51.57,32.53;66.29,32.43;76.81,32.35;76.98,31.35;66.29,31.43;51.42,31.53;44.88,31.58;44.56,30.58;51.26,30.53;66.29,30.43;77.15,30.35;77.32,29.35;66.29,29.43;51.11,29.53;44.25,29.58;43.93,28.59;50.95,28.54;66.29,28.43;77.48,28.35;77.65,27.35;66.29,27.43;50.79,27.54;43.61,27.59;43.29,26.59;50.64,26.54;66.29,26.43;77.82,26.34;77.99,25.34;66.29,25.43;50.48,25.54;42.97,25.59;42.65,24.59;50.32,24.54;66.29,24.43;76.69,24.35;73.25,23.38;66.29,23.43;50.17,23.54;42.33,23.60;42.02,22.60;50.01,22.54;66.29,22.43;69.81,22.40;66.38,21.43;66.29,21.43;49.85,21.54;44.66,21.58;47.85,20.56;49.70,20.54
-LAND1.updateTime=2025-12-27 16\:33\:13
+LAND1.updateTime=2025-12-27 22\:24\:22
 LAND1.baseStationCoordinates=3949.89151752,N,11616.79267501,E
 LAND1.boundaryPointInterval=-1
 LAND1.createTime=2025-12-23 17\:08\:09
diff --git a/set.properties b/set.properties
index f5e555c..1be2321 100644
--- a/set.properties
+++ b/set.properties
@@ -1,5 +1,5 @@
-#Current work land selection updated
-#Sat Dec 27 20:42:43 GMT+08:00 2025
+#Mower Configuration Properties - Updated
+#Sat Dec 27 22:24:35 GMT+08:00 2025
 appVersion=-1
 simCardNumber=-1
 currentWorkLandNumber=LAND1
@@ -7,13 +7,13 @@
 boundaryLengthVisible=false
 idleTrailDurationSeconds=60
 handheldMarkerId=1872
-viewCenterX=-61.89
-viewCenterY=-39.06
+viewCenterX=-60.00
+viewCenterY=-34.94
 manualBoundaryDrawingMode=false
 mowerId=6258
 serialPortName=COM15
 serialAutoConnect=true
-mapScale=17.84
+mapScale=12.39
 measurementModeEnabled=false
 firmwareVersion=-1
 cuttingWidth=200
diff --git a/src/lujing/YixinglujingNoObstacle.java b/src/lujing/YixinglujingNoObstacle.java
index fd879ad..304a3bc 100644
--- a/src/lujing/YixinglujingNoObstacle.java
+++ b/src/lujing/YixinglujingNoObstacle.java
@@ -1,8 +1,6 @@
 package lujing;
 
 import java.util.*;
-import java.util.Set;
-import java.util.HashSet;
 
 /**
  * 寮傚舰鑽夊湴璺緞瑙勫垝 - 鍑瑰杈瑰舰鍏煎浼樺寲鐗� V5.0
@@ -322,12 +320,21 @@
     }
 
     private static int getEdgeIndex(Point p, List<Point> poly) {
+        int bestIdx = -1;
+        double minD = Double.MAX_VALUE;
         for (int i = 0; i < poly.size(); i++) {
             Point p1 = poly.get(i);
             Point p2 = poly.get((i + 1) % poly.size());
-            if (distToSegment(p, p1, p2) < 1e-3) return i;
+            double d = distToSegment(p, p1, p2);
+            if (d < minD) {
+                minD = d;
+                bestIdx = i;
+            }
         }
-        return -1;
+        // 鍙鎵惧埌鏈�杩戠殑杈瑰嵆鍙紝鏀惧闃堝�间互搴斿娴偣璇樊鍜屾棆杞彉褰�
+        // 濡傛灉璺濈杩囧ぇ锛堜緥濡傝秴杩�1绫筹級锛屽彲鑳界‘瀹炰笉鍦ㄨ竟鐣屼笂锛屼絾鍦ㄨ矾寰勮鍒掍笂涓嬫枃涓紝
+        // 杩欎簺鐐规槸鐢辨壂鎻忕嚎鐢熸垚鐨勶紝鐞嗚涓婁竴瀹氬湪杈圭晫涓婏紝鎵�浠ュ己鍒跺惛闄勬槸瀹夊叏鐨勩��
+        return minD < 1.0 ? bestIdx : -1;
     }
     
     private static double distToSegment(Point p, Point s, Point e) {
diff --git a/user.properties b/user.properties
index 6c34544..d06c37b 100644
--- a/user.properties
+++ b/user.properties
@@ -1,9 +1,9 @@
 #Updated User Properties
-#Sat Dec 27 20:42:59 GMT+08:00 2025
+#Sat Dec 27 21:15:06 GMT+08:00 2025
 registrationTime=-1
-lastLoginTime=1766747566698
+lastLoginTime=1766841306666
 password=123456
-rememberPassword=0
+rememberPassword=1
 language=zh
 userName=981894274@qq.com
 userId=-1

--
Gitblit v1.10.0