yy1717
2020-08-10 d9dc7419b35b7762bc5222cf874ccc39d2d66f43
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) {
        // 车头和路口距离不足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++) {