From 4afa88987f466893800a83ba4767a8f59811473a Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期六, 20 十二月 2025 09:39:32 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/utils/NavigateUtils.java |   80 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/common/utils/NavigateUtils.java b/src/main/java/com/zy/common/utils/NavigateUtils.java
index 5fff67d..c9a2a77 100644
--- a/src/main/java/com/zy/common/utils/NavigateUtils.java
+++ b/src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -65,6 +65,20 @@
             }
         }
 
+        for (int i = 0; i < fitlerList.size(); i++) {
+            NavigateNode currentNode = fitlerList.get(i);
+            currentNode.setIsInflectionPoint(false);
+
+            NavigateNode nextNode = (i + 1 < fitlerList.size()) ? fitlerList.get(i + 1) : null;
+            NavigateNode prevNode = (i - 1 >= 0) ? fitlerList.get(i - 1) : null;
+
+            HashMap<String, Object> result = searchInflectionPoint(currentNode, nextNode, prevNode);
+            if (Boolean.parseBoolean(result.get("result").toString())) {
+                currentNode.setIsInflectionPoint(true);
+                currentNode.setDirection(result.get("direction").toString());
+            }
+        }
+
         return fitlerList;
     }
 
@@ -95,8 +109,22 @@
         HashSet<NavigateNode> visited = new HashSet<>();
         int maxSteps = rgvTrackMap.size() * rgvTrackMap.get(0).size() + 5; // 瀹夊叏涓婇檺
         int steps = 0;
+        NavigateNode fatherNode = null;//褰撳墠寰幆涓婁竴鑺傜偣锛岀敤浜庢嫄鐐硅绠�
         while (res_node != null && visited.add(res_node) && steps++ < maxSteps) {
+            res_node.setIsInflectionPoint(false);
+
+            //瀵绘壘鎷愮偣
+            HashMap<String, Object> result = searchInflectionPoint(res_node, fatherNode, res_node.getFather());//鍒嗗埆浼犲叆褰撳墠鑺傜偣銆佺埗鑺傜偣銆佷笅涓�鑺傜偣
+            //鍒ゆ柇褰撳墠鑺傜偣鏄惁涓烘嫄鐐�
+            if (Boolean.parseBoolean(result.get("result").toString())) {
+                //褰撳墠涓烘嫄鐐�
+                res_node.setIsInflectionPoint(true);
+                //鎷愮偣鏂瑰悜
+                res_node.setDirection(result.get("direction").toString());
+            }
+
             list.add(res_node);
+            fatherNode = res_node;//鎶婂綋鍓嶈妭鐐逛繚瀛樻垚涓�涓埗鑺傜偣
             res_node = res_node.getFather();//杩唬鎿嶄綔
         }
         if (steps >= maxSteps) {
@@ -284,4 +312,56 @@
         }
         return best;
     }
+
+    //鍒ゆ柇褰撳墠鑺傜偣鍒颁笅涓�涓妭鐐规槸鍚︿负鎷愮偣
+    public HashMap<String,Object> searchInflectionPoint(NavigateNode currentNode, NavigateNode fatherNode, NavigateNode nextNode) {
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("result", false);//鏄惁涓烘嫄鐐癸紝true锛氭嫄鐐癸紝false锛氱洿绾�
+        // 绗竴涓偣鎴栫洿绾跨偣
+        if (fatherNode == null || nextNode == null || nextNode.getX() == fatherNode.getX() || nextNode.getY() == fatherNode.getY()) {
+            return map;//涓嶆槸鎷愮偣鐩存帴杩斿洖
+        }
+
+        //鎷愮偣鏂瑰悜
+        String direction = calcDirection(currentNode, fatherNode);
+
+        map.put("result", true);//鎷愮偣
+        map.put("direction", direction);//鎷愮偣鏂瑰悜锛堜粠褰撳墠鑺傜偣瑙嗚鐪嬬殑鏂瑰悜锛�
+        return map;
+    }
+
+    /**
+     * 璁$畻鏂瑰悜
+     */
+    public String calcDirection(NavigateNode currentNode, NavigateNode fatherNode) {
+        //鎷愮偣鏂瑰悜
+        String direction = "";
+        // 鏅�氭嫄鐐�
+        //璁$畻鎷愮偣鏂瑰悜
+        if (fatherNode.getX() != currentNode.getX()) {
+            //x杞存暟鎹湁宸紓锛屽垽鏂瓁杞存柟鍚�
+            //褰撳墠鑺傜偣X - 鐖惰妭鐐筙
+            if (currentNode.getX() - fatherNode.getX() > 0) {
+                //澶т簬0锛屾柟鍚憈op
+                direction = "top";
+            }else {
+                //灏忎簬0锛屾柟鍚慴ottom
+                direction = "bottom";
+            }
+        }
+
+        if (fatherNode.getY() != currentNode.getY()) {
+            //y杞存暟鎹湁宸紓锛屽垽鏂瓂杞存柟鍚�
+            //褰撳墠鑺傜偣Y - 鐖惰妭鐐筜
+            if (currentNode.getY() - fatherNode.getY() > 0) {
+                //澶т簬0锛屾柟鍚憀eft
+                direction = "left";
+            }else {
+                //灏忎簬0锛屾柟鍚憆ight
+                direction = "right";
+            }
+        }
+
+        return direction;
+    }
 }

--
Gitblit v1.9.1