liyang 6 months ago
parent
commit
677a855faa

+ 65 - 61
Models/SimulationCommon/Rectangular_Area_Search_Function.cs

@@ -172,93 +172,97 @@ public class Rectangular_Area_Search_Function
                 {
                 {
                     line_Perpendicular_Base_left = line_Preparatory;
                     line_Perpendicular_Base_left = line_Preparatory;
                 }
                 }
+            }
 
 
-                if (line_Perpendicular_Base_left == null || line_Perpendicular_Base_right == null)
+            if (line_Perpendicular_Base_left == null || line_Perpendicular_Base_right == null)
-                {
+            {
-                    double max_Ditance_left = 0;
+                double max_Ditance_left = 0;
-                    double distance_left = 0;
+                double distance_left = 0;
-                    double max_Distance_right = 0;
+                double max_Distance_right = 0;
-                    double distance_right = 0;
+                double distance_right = 0;
 
 
-                    foreach (Point2f m_point in hull)
+                double[] line_inite_Preparatory = GetpPerpendicular(hull[num], Base_line);
+
+                foreach (Point2f m_point in hull)
+                {
+                    if (CheckDirection(m_point, line_inite_Preparatory) <= 0)
                     {
                     {
-                        if (CheckDirection(m_point, line_Preparatory) <= 0)
+                        distance_left = GetDistance(m_point, line_inite_Preparatory);
+                        if (distance_left > max_Ditance_left)
                         {
                         {
-                            distance_left = GetDistance(m_point, line_Preparatory);
+                            max_Ditance_left = distance_left;
-                            if (distance_left > max_Ditance_left)
+                            Point_left = m_point;
-                            {
+                            line_Perpendicular_Base_left = GetpPerpendicular(Point_left, Base_line);
-                                max_Ditance_left = distance_left;
-                                Point_left = m_point;
-                                line_Perpendicular_Base_left = GetpPerpendicular(Point_left, Base_line);
-                            }
                         }
                         }
-                        if (CheckDirection(m_point, line_Preparatory) >= 0)
+                    }
+                    if (CheckDirection(m_point, line_inite_Preparatory) >= 0)
+                    {
+                        distance_right = GetDistance(m_point, line_inite_Preparatory);
+                        if (distance_right > max_Distance_right)
                         {
                         {
-                            distance_right = GetDistance(m_point, line_Preparatory);
+                            max_Distance_right = distance_right;
-                            if (distance_right > max_Distance_right)
+                            Point_right = m_point;
-                            {
+                            line_Perpendicular_Base_right = GetpPerpendicular(Point_right, Base_line);
-                                max_Distance_right = distance_right;
-                                Point_right = m_point;
-                                line_Perpendicular_Base_right = GetpPerpendicular(Point_right, Base_line);
-                            }
                         }
                         }
-
                     }
                     }
 
 
                 }
                 }
+
             }
             }
 
 
-            //foreach (var item in line_Perpendicular_Base_left)
+            double[] Point0 = GetCrossPoint(Base_line, line_Perpendicular_Base_left);
-            //{
+            double[] Point1 = GetCrossPoint(Base_line, line_Perpendicular_Base_right);
-            //    Console.WriteLine("line_Perpendicular_Base_left:" + item);
+            double[] Point2 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_right);
-            //}
+            double[] Point3 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_left);
 
 
-            //foreach (var item in line_Perpendicular_Base_right)
+            double[] temp;
-            //{
-            //    Console.WriteLine("line_Perpendicular_Base_right:" + item);
-            //}
 
 
-            if (line_Perpendicular_Base_left != null && line_Perpendicular_Base_right != null)
+            if (Point0[0] < Point3[0])
             {
             {
-                double[] Point0 = GetCrossPoint(Base_line, line_Perpendicular_Base_left);
+                temp = Point0;
-                double[] Point1 = GetCrossPoint(Base_line, line_Perpendicular_Base_right);
+                Point0 = Point3;
-                double[] Point2 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_right);
+                Point3 = temp;
-                double[] Point3 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_left);
-                double rectangular_area = GetRectangularArea(Point0, Point1, Point2, Point3);
 
 
-                if (rectangular_area < min_rectangular_area)
+                temp = Point1;
-                {
+                Point1 = Point2;
-                    min_rectangular_area = rectangular_area;
+                Point2 = temp;
-                    Point_muster = new List<double[]> {
+            }
+
+            double rectangular_area = GetRectangularArea(Point0, Point1, Point2, Point3);
+
+            if (rectangular_area < min_rectangular_area)
+            {
+                min_rectangular_area = rectangular_area;
+                Point_muster = new List<double[]> {
                         Point0,
                         Point0,
                         Point1,
                         Point1,
                         Point2,
                         Point2,
                         Point3
                         Point3
                     };
                     };
-                }
             }
             }
-            // double[] Point0 = GetCrossPoint(Base_line, line_Perpendicular_Base_left);
+
-            // double[] Point1 = GetCrossPoint(Base_line, line_Perpendicular_Base_right);
+
-            // double[] Point2 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_right);
+            //double lat = Rectangular_Area_Search_Function.RMokatuoLat(Point0[0]);
-            // double[] Point3 = GetCrossPoint(line_Parallel_Base, line_Perpendicular_Base_left);
+            //double lon = Rectangular_Area_Search_Function.RMokatuoLon(Point0[1]);
-            // double rectangular_area = GetRectangularArea(Point0, Point1, Point2, Point3);
+            //Console.WriteLine("Point0:" + lat + "-" + lon);
-
+
-            // if (rectangular_area < min_rectangular_area)
+            //double lat1 = Rectangular_Area_Search_Function.RMokatuoLat(Point1[0]);
-            // {
+            //double lon1 = Rectangular_Area_Search_Function.RMokatuoLon(Point1[1]);
-            //     min_rectangular_area = rectangular_area;
+            //Console.WriteLine("Point1:" + lat1 + "-" + lon1);
-            //     Point_muster = new List<double[]> {
+
-            //         Point0,
+            //double lat2 = Rectangular_Area_Search_Function.RMokatuoLat(Point2[0]);
-            //         Point1,
+            //double lon2 = Rectangular_Area_Search_Function.RMokatuoLon(Point2[1]);
-            //         Point2,
+            //Console.WriteLine("Point2:" + lat2 + "-" + lon2);
-            //         Point3
+
-            //     };
+            //double lat3 = Rectangular_Area_Search_Function.RMokatuoLat(Point3[0]);
-            // }
+            //double lon3 = Rectangular_Area_Search_Function.RMokatuoLon(Point3[1]);
+            //Console.WriteLine("Point3:" + lat3 + "-" + lon3);
         }
         }
 
 
         //foreach (var item in Point_muster)
         //foreach (var item in Point_muster)
         //{
         //{
-        //    Console.WriteLine("Point_muster:" + item);
+        //    Console.WriteLine("Point_muster:" + item[0] + "-" + item[1]);
-        //}  
+        //}
         return Point_muster;
         return Point_muster;
     }
     }
 }
 }

+ 14 - 1
Models/SimulationCommon/SeaSJ.cs

@@ -308,6 +308,13 @@ public class SeaSJ
 
 
         // 计算最小包围矩形
         // 计算最小包围矩形
         List<double[]> minEnclosingRect = Rectangular_Area_Search_Function.MinEnclosingRectangle(convexHull);
         List<double[]> minEnclosingRect = Rectangular_Area_Search_Function.MinEnclosingRectangle(convexHull);
+        //foreach (var point in minEnclosingRect)
+        //{
+        //    foreach (var item in point)
+        //    {
+        //        Console.WriteLine("item:" + item);
+        //    }
+        //}
 
 
         // 最小包围矩形顶点经纬度坐标
         // 最小包围矩形顶点经纬度坐标
         List<double[]> startPoint = new List<double[]>();
         List<double[]> startPoint = new List<double[]>();
@@ -317,7 +324,13 @@ public class SeaSJ
             double lon = Rectangular_Area_Search_Function.RMokatuoLon(minEnclosingRectPoint[1]);
             double lon = Rectangular_Area_Search_Function.RMokatuoLon(minEnclosingRectPoint[1]);
             startPoint.Add(new double[] { lat, lon });
             startPoint.Add(new double[] { lat, lon });
         }
         }
-
+        //foreach (var point in startPoint)
+        //{
+        //    foreach (var item in point)
+        //    {
+        //        Console.WriteLine("startPoint:" + item);
+        //    }
+        //}
         return startPoint;
         return startPoint;
     }
     }
 }
 }

+ 18 - 4
SimulationServer/Entity/AircraftSJ.cs

@@ -105,10 +105,14 @@ public class AircraftSJ : AircraftEntity
         {
         {
             points.Add(new Point(item[0], item[1]));
             points.Add(new Point(item[0], item[1]));
         }
         }
-
+        //foreach (var item in points)
+        //{
+        //    Console.WriteLine("item:" + item.lat + "-" + item.lon);
+        //}
         Point basePoint = new Point(FlightPlanEditor.originbase.BaseLatitude,
         Point basePoint = new Point(FlightPlanEditor.originbase.BaseLatitude,
             FlightPlanEditor.originbase.BaseLongitude);
             FlightPlanEditor.originbase.BaseLongitude);
         List<Point> waypoints = new List<Point>();
         List<Point> waypoints = new List<Point>();
+
         //*******
         //*******
         if (SearchMode.SearchMode == "平行线搜索")
         if (SearchMode.SearchMode == "平行线搜索")
         {
         {
@@ -145,31 +149,41 @@ public class AircraftSJ : AircraftEntity
                 lat = points[0].lat / 2 + points[1].lat / 2,
                 lat = points[0].lat / 2 + points[1].lat / 2,
                 lon = points[0].lon / 2 + points[1].lon / 2
                 lon = points[0].lon / 2 + points[1].lon / 2
             };
             };
+            //Console.WriteLine("startPoint1:" + startPoint1.lat + "-" + startPoint1.lon);
             var startPoint2 = new Point
             var startPoint2 = new Point
             {
             {
                 lat = points[2].lat / 2 + points[3].lat / 2,
                 lat = points[2].lat / 2 + points[3].lat / 2,
                 lon = points[2].lon / 2 + points[3].lon / 2
                 lon = points[2].lon / 2 + points[3].lon / 2
             };
             };
-
+            //Console.WriteLine("startPoint2:" + startPoint2.lat + "-" + startPoint2.lon);
             var centerPoint = new Point
             var centerPoint = new Point
             {
             {
                 lat = startPoint1.lat / 2 + startPoint2.lat / 2,
                 lat = startPoint1.lat / 2 + startPoint2.lat / 2,
                 lon = startPoint1.lon / 2 + startPoint2.lon / 2
                 lon = startPoint1.lon / 2 + startPoint2.lon / 2
             };
             };
+            //Console.WriteLine("centerPoint:" + centerPoint.lat + "-" + centerPoint.lon);
             // 以 centerPoint 为中心,生成正方形区域
             // 以 centerPoint 为中心,生成正方形区域
             var lonD = Math.Abs(points[0].lon - points[1].lon);
             var lonD = Math.Abs(points[0].lon - points[1].lon);
             var latD1 = Math.Abs(points[1].lat - points[2].lat);
             var latD1 = Math.Abs(points[1].lat - points[2].lat);
             var max = Math.Max(lonD, latD1);
             var max = Math.Max(lonD, latD1);
-
+            //Console.WriteLine("max:" + max);
             // 以 distance 为边长 以 centerPoint 为中心点的正方形
             // 以 distance 为边长 以 centerPoint 为中心点的正方形
 
 
             var temp0 = new Point(centerPoint.lat + max / 2, centerPoint.lon - max / 2);
             var temp0 = new Point(centerPoint.lat + max / 2, centerPoint.lon - max / 2);
             var temp1 = new Point(centerPoint.lat + max / 2, centerPoint.lon + max / 2);
             var temp1 = new Point(centerPoint.lat + max / 2, centerPoint.lon + max / 2);
             var temp2 = new Point(centerPoint.lat - max / 2, centerPoint.lon + max / 2);
             var temp2 = new Point(centerPoint.lat - max / 2, centerPoint.lon + max / 2);
             var temp3 = new Point(centerPoint.lat - max / 2, centerPoint.lon - max / 2);
             var temp3 = new Point(centerPoint.lat - max / 2, centerPoint.lon - max / 2);
+            //Console.WriteLine("temp0:" + temp0.lat + "-" + temp0.lon);
+            //Console.WriteLine("temp1:" + temp1.lat + "-" + temp1.lon);
+            //Console.WriteLine("temp2:" + temp2.lat + "-" + temp2.lon);
+            //Console.WriteLine("temp3:" + temp3.lat + "-" + temp3.lon);
+            //Console.WriteLine("SearchWidth:" + SearchMode.SearchWidth);
             waypoints = TZFX.GenerateWaypoints(temp0, temp1, temp2, temp3, max, SearchMode.SearchWidth);
             waypoints = TZFX.GenerateWaypoints(temp0, temp1, temp2, temp3, max, SearchMode.SearchWidth);
         }
         }
-
+        //foreach (var item in waypoints)
+        //{
+        //    Console.WriteLine("item.lat :" + item.lat + "-" + "item.lon:" + item.lon);
+        //}
         // List<Point> 转成 List<AirRoute>
         // List<Point> 转成 List<AirRoute>
         List<AirRoute> airRoutes = new List<AirRoute>();
         List<AirRoute> airRoutes = new List<AirRoute>();
         foreach (var item in waypoints)
         foreach (var item in waypoints)

+ 7 - 7
SimulationServer/EventHandler/ServerStartEventHandler.cs

@@ -135,13 +135,13 @@ public class ServerStartEventHandler : AEvent<ServerStart>
         //    //break;
         //    //break;
         //}
         //}
 
 
-        ////创建空中吊运救援任务
+        //创建空中吊运救援任务
-        //foreach (var KZDYTask in taskConfig.KZDYTasks)
+        foreach (var KZDYTask in taskConfig.KZDYTasks)
-        //{
+        {
-        //    Game.EventSystem.Publish(new CreateKZDYTask
+            Game.EventSystem.Publish(new CreateKZDYTask
-        //    { EditorConfig = editorConfig, KZDYTask = KZDYTask });
+            { EditorConfig = editorConfig, KZDYTask = KZDYTask });
-        //    //break;
+            //break;
-        //}
+        }
 
 
         ////创建空投空送任务
         ////创建空投空送任务
         //foreach (var KTKSTask in taskConfig.KTKSTasks)
         //foreach (var KTKSTask in taskConfig.KTKSTasks)

BIN
SimulationServer/bin/Debug/net7.0/SimulationCommon.dll


BIN
SimulationServer/bin/Debug/net7.0/SimulationCommon.pdb


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.dll


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.exe


BIN
SimulationServer/bin/Debug/net7.0/SimulationServer.pdb