From d9dc7419b35b7762bc5222cf874ccc39d2d66f43 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期一, 10 八月 2020 18:36:31 +0800
Subject: [PATCH] 坐标

---
 lib/src/main/cpp/test_items2/road_exam.cpp |   95 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 87 insertions(+), 8 deletions(-)

diff --git a/lib/src/main/cpp/test_items2/road_exam.cpp b/lib/src/main/cpp/test_items2/road_exam.cpp
index 3a1a5b0..8e42c1e 100644
--- a/lib/src/main/cpp/test_items2/road_exam.cpp
+++ b/lib/src/main/cpp/test_items2/road_exam.cpp
@@ -1379,11 +1379,11 @@
 
         ArrivedRoadEnd(RoadMap.roads[currExamMapIndex], car, CarModelList);
 
-        if (CrashTheLine(RoadMap.roads[currExamMapIndex].stopLine, car, CarModelList)) {
-            DEBUG("涓嬩竴涓洰鏍囪矾 id = %d", RoadMap.roads[currExamMapIndex].targetRoad);
-            nextRoadId = RoadMap.roads[currExamMapIndex].targetRoad;
-            checkTurn = true;
-        }
+//        if (CrashTheLine(RoadMap.roads[currExamMapIndex].stopLine, car, CarModelList)) {
+//            DEBUG("涓嬩竴涓洰鏍囪矾 id = %d", RoadMap.roads[currExamMapIndex].targetRoad);
+//            nextRoadId = RoadMap.roads[currExamMapIndex].targetRoad;
+//            checkTurn = true;
+//        }
 
         if (checkTurn) {
             // 妫�鏌ユ槸鍚︽寔缁浆鍚�
@@ -1988,7 +1988,7 @@
  * @param car
  * @param CarModelList
  */
-static void ArrivedRoadEnd(road_t &road, const car_model *car, LIST_CAR_MODEL &CarModelList)
+/*static void ArrivedRoadEnd(road_t &road, const car_model *car, LIST_CAR_MODEL &CarModelList)
 {
     // 璁$畻杞﹀墠杩涜建杩瑰欢闀跨嚎
     double yaw = YawOf(car->carXY[ car->axial[AXIAL_FRONT] ], car->carXY[ car->axial[AXIAL_REAR] ]);
@@ -2009,6 +2009,84 @@
             }
     } else if (road.arrivedTail) {
         road.arrivedTail = false;
+    }
+}*/
+
+// 璺彛锛屾彁绀猴紝鍓�30绫宠繘鍏ワ紝 绂诲紑
+// 浜鸿閬擄紝杞︾珯锛屽墠30绫宠繘鍏ワ紝绂诲紑
+// 瀛︽牎锛岃繘鍏ワ紝绂诲紑
+
+map<int, int> CrossingStatus;
+
+static void ChangeCrossingStatus(int roadIndex, int index, int status)
+{
+    int key = roadIndex * 100 + index;
+
+    auto it = CrossingStatus.find(key);
+
+    if (it != CrossingStatus.end()) {
+        CrossingStatus.erase(it);
+    }
+    CrossingStatus.insert(pair<int, int>(key, status));
+}
+
+static int GetCrossingStatus(int roadIndex, int index)
+{
+    int key = roadIndex * 100 + index;
+
+    auto it = CrossingStatus.find(key);
+
+    if (it != CrossingStatus.end()) {
+        return it->second;
+    }
+    return -1;
+}
+
+enum {
+    CROSSING_STATUS_INVALID = -1,
+    CROSSING_STATUS_GUIDE,
+    CROSSING_STATUS_REDUCE_SPEED,
+    CROSSING_STATUS_BREAK_CAR,
+    CROSSING_STATUS_STOP_CAR
+};
+
+static void CheckCrossing(int roadIndex, road_t &road, const car_model *car, LIST_CAR_MODEL &CarModelList)
+{
+    for (int i = 0; i < road.stopLine.size(); ++i) {
+        if (CrashTheLine(road.stopLine[i].line, car, CarModelList)) {
+            if (road.stopLine[i].stopFlag) {
+                if (GetCrossingStatus(roadIndex, i) != CROSSING_STATUS_STOP_CAR) {
+
+                }
+            } else {
+                if (GetCrossingStatus(roadIndex, i) != CROSSING_STATUS_BREAK_CAR) {
+
+                }
+            }
+            ChangeCrossingStatus(roadIndex, i, CROSSING_STATUS_INVALID);
+        } else {
+
+        }
+        PointF point;
+        double distance;
+
+        point.X = road.stopLine[i].line.X1;
+        point.Y = road.stopLine[i].line.Y1;
+
+        distance = CalcDistanceReference(car->carXY[car->axial[AXIAL_FRONT]], point, road.rightEdge);
+
+        if (distance > 10 && distance < 50) {
+            if (GetCrossingStatus(roadIndex, i) == CROSSING_STATUS_INVALID) {
+                if (!road.stopLine[i].tts.empty()) {
+                    PlayTTS(road.stopLine[i].tts.c_str());
+                }
+                ChangeCrossingStatus(roadIndex, i, CROSSING_STATUS_GUIDE);
+            }
+        } else if (distance > 0 && distance < 30) {
+            if (GetCrossingStatus(roadIndex, i) != 1) {
+                ChangeCrossingStatus(roadIndex, i, 1);
+            }
+        }
     }
 }
 
@@ -2084,7 +2162,7 @@
     MakeLine(&extLine, &car->carXY[ car->axial[AXIAL_FRONT] ], &extPoint);
 
     // 璺彛鍒硅溅鐐�
-    for (int i = 0; i < map.roads.size(); ++i) {
+/*    for (int i = 0; i < map.roads.size(); ++i) {
         // 杞﹀ご鍜岃矾鍙h窛绂讳笉瓒�30绫�
         if (IntersectionOf(extLine, map.roads[i].stopLine) == GM_Intersection &&
             IntersectionOfLine(car->carXY[ car->axial[AXIAL_FRONT] ], map.roads[i].stopLine) == 1 ) {
@@ -2122,7 +2200,8 @@
                 }
             }
         }
-    }
+    }*/
+
     // 浜鸿閬撱�佸叕浜ょ珯鍒硅溅鐐癸紱瀛︽牎闄愰�熷尯
 //    DEBUG("琛ュ叏鐗规畩鍖哄煙 size = %d", map.specialAreas.size());
     for (int i = 0; i < map.specialAreas.size(); i++) {

--
Gitblit v1.8.0