From a073dc3c983b4c56c5da92642c9ad11995bdb844 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期一, 11 五月 2020 18:05:31 +0800
Subject: [PATCH] 新的科目三

---
 lib/src/main/cpp/master/comm_if.cpp |  260 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 259 insertions(+), 1 deletions(-)

diff --git a/lib/src/main/cpp/master/comm_if.cpp b/lib/src/main/cpp/master/comm_if.cpp
index 2dd5537..c99a0d4 100644
--- a/lib/src/main/cpp/master/comm_if.cpp
+++ b/lib/src/main/cpp/master/comm_if.cpp
@@ -37,7 +37,8 @@
 #define ID_SM_RTK_PLAT_LOGIN     0x0005
 #define ID_SM_READ_MAP          0x0006
 #define ID_MS_MAP               0x8006
-#define ID_MS_ROAD_MAP          0x8013
+#define ID_MS_ROAD_MAP          0x8014
+#define ID_MS_ROAD_MAP2         0x8013
 
 #define ID_SM_READ_CAR          0x0007
 #define ID_MS_CAR               0x8007
@@ -745,6 +746,263 @@
             }
             break;
         }
+        case ID_MS_ROAD_MAP2: {
+            Document doc;
+            doc.Parse(value);
+            if (!doc.HasParseError()) {
+                DEBUG("寮�濮嬭В鏋愯矾鑰冨湴鍥�");
+
+                vector<PointF> mapPoints;
+                mapPoints.clear();
+
+                if (doc.HasMember("points")) {
+                    const Value &s = doc["points"];
+
+                    DEBUG("寰楀埌鎵�鏈夌偣 鍏� %d", s.Size()/2);
+
+                    int n = 0;
+                    PointF temp;
+
+                    // X-Y鍧愭爣闆嗗悎
+                    for (Value::ConstValueIterator itr = s.Begin();
+                         itr != s.End(); ++itr, ++n) {
+                        if ((n % 2) == 0) {
+                            temp.X = (*itr).GetDouble();
+                        } else {
+                            temp.Y = (*itr).GetDouble();
+                            mapPoints.push_back(temp);
+                        }
+                    }
+                }
+
+                road_exam_map map;
+
+                map.roads.clear();
+                map.specialAreas.clear();
+                map.triggerLines.clear();
+
+                if (doc.HasMember("road")) {
+                    const Value &a = doc["road"];
+
+                    if (a.IsArray()) {
+                        for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) {
+                            road_t road;
+
+                            if (itr->HasMember("id")) {
+                                const Value &s = (*itr)["id"];
+                                DEBUG("璺痠d %d", s.GetInt());
+                                road.id = s.GetInt();
+                            }
+                            if (itr->HasMember("start_line")) {
+                                const Value &a2 = (*itr)["start_line"];
+
+                                PointF p1, p2;
+                                int n = 0;
+
+                                for (Value::ConstValueIterator itr2 = a2.Begin(); itr2 != a2.End(); ++itr2, ++n) {
+                                    DEBUG("璧峰绾� %d", (*itr2).GetInt());
+                                    if (n == 0) {
+                                        p1 = mapPoints[(*itr2).GetInt()];
+                                    } else if (n == 1) {
+                                        p2 = mapPoints[(*itr2).GetInt()];
+                                    }
+                                }
+
+                                MakeLine(&road.startLine, &p1, &p2);
+                            }
+                            if (itr->HasMember("stop_line")) {
+                                const Value &a2 = (*itr)["stop_line"];
+
+                                PointF p1, p2;
+                                int n = 0;
+
+                                for (Value::ConstValueIterator itr2 = a2.Begin(); itr2 != a2.End(); ++itr2, ++n) {
+                                    DEBUG("缁撴潫绾� %d", (*itr2).GetInt());
+                                    if (n == 0) {
+                                        p1 = mapPoints[(*itr2).GetInt()];
+                                    } else if (n == 1) {
+                                        p2 = mapPoints[(*itr2).GetInt()];
+                                    }
+                                }
+
+                                MakeLine(&road.stopLine, &p1, &p2);
+                            }
+                            if (itr->HasMember("active")) {
+                                const Value &s = (*itr)["active"];
+                                DEBUG("璺彛鍔ㄤ綔 %d", s.GetInt());
+
+                                road.active = s.GetInt();
+                            }
+                            if (itr->HasMember("tts")) {
+                                const Value &s = (*itr)["tts"];
+                                road.tts = s.GetString();
+                            }
+                            if (itr->HasMember("stop_flag")) {
+                                const Value &s = (*itr)["stop_flag"];
+                                road.stopFlag = s.GetInt();
+                            }
+                            if (itr->HasMember("next_road")) {
+                                const Value &s = (*itr)["next_road"];
+                                road.targetRoad  = s.GetInt();
+                            }
+                            if (itr->HasMember("left_edge")) {
+                                const Value &a2 = (*itr)["left_edge"];
+                                DEBUG("宸﹁竟绾�");
+
+                                if (a2.IsArray()) {
+                                    for (Value::ConstValueIterator itr2 = a2.Begin(); itr2 != a2.End(); ++itr2) {
+                                        edge_t edge;
+
+                                        if (itr2->HasMember("type")) {
+                                            const Value &s = (*itr2)["type"];
+                                            DEBUG("\t绫诲瀷 %d", s.GetInt());
+
+                                            edge.character = s.GetInt();
+                                        }
+                                        if (itr2->HasMember("line")) {
+                                            const Value &a3 = (*itr2)["line"];
+                                            if (a3.IsArray()) {
+                                                for (Value::ConstValueIterator itr3 = a3.Begin(); itr3 != a3.End(); ++itr3) {
+                                                    DEBUG("\t绾跨偣 %d", (*itr3).GetInt());
+                                                    edge.points.push_back(mapPoints[(*itr3).GetInt()]);
+                                                }
+                                            }
+                                        }
+
+                                        road.leftEdge.push_back(edge);
+                                    }
+                                }
+                            }
+                            if (itr->HasMember("right_edge")) {
+                                const Value &a2 = (*itr)["right_edge"];
+                                DEBUG("鍙宠竟绾�");
+                                if (a2.IsArray()) {
+                                    for (Value::ConstValueIterator itr2 = a2.Begin(); itr2 != a2.End(); ++itr2) {
+                                        edge_t edge;
+
+                                        if (itr2->HasMember("type")) {
+                                            const Value &s = (*itr2)["type"];
+                                            DEBUG("\t绫诲瀷 %d", s.GetInt());
+                                            edge.character = s.GetInt();
+                                        }
+                                        if (itr2->HasMember("line")) {
+                                            const Value &a3 = (*itr2)["line"];
+                                            if (a3.IsArray()) {
+                                                for (Value::ConstValueIterator itr3 = a3.Begin(); itr3 != a3.End(); ++itr3) {
+                                                    DEBUG("\t绾跨偣 %d", (*itr3).GetInt());
+                                                    edge.points.push_back(mapPoints[(*itr3).GetInt()]);
+                                                }
+                                            }
+                                        }
+
+                                        road.rightEdge.push_back(edge);
+                                    }
+                                }
+                            }
+                            if (itr->HasMember("separate")) {
+                                const Value &a2 = (*itr)["separate"];
+                                DEBUG("娈垫暟閲� %d", a2.Size());
+
+                                for (Value::ConstValueIterator itr2 = a2.Begin(); itr2 != a2.End(); ++itr2) {
+                                    DEBUG("\t绾挎暟閲� %d", (*itr2).Size());
+                                    separate_t sep;
+
+                                    for (Value::ConstValueIterator itr3 = (*itr2).Begin(); itr3 != (*itr2).End(); ++itr3) {
+                                        DEBUG("\t\t鑺傛暟閲� %d", (*itr3).Size());
+                                        vector<segment_t> sline;
+
+                                        for (Value::ConstValueIterator itr4 = (*itr3).Begin(); itr4 != (*itr3).End(); ++itr4) {
+                                            const Value &type = (*itr4)["type"];
+                                            const Value &line = (*itr4)["line"];
+
+                                            segment_t seg;
+
+                                            DEBUG("\t\t\t鑺傜被鍨� = %d", type.GetInt());
+                                            seg.character = type.GetInt();
+
+                                            if ((*itr4).HasMember("left_lane_direct")) {
+                                                const Value &dir = (*itr4)["left_lane_direct"];
+                                                DEBUG("\t\t\t宸﹁溅閬撴柟鍚� %d", dir.GetInt());
+                                                seg.left_lane_direct = dir.GetInt();
+                                            } else {
+                                                seg.left_lane_direct = 0;
+                                            }
+
+                                            if ((*itr4).HasMember("right_lane_direct")) {
+                                                const Value &dir = (*itr4)["right_lane_direct"];
+                                                DEBUG("\t\t\t鍙宠溅閬撴柟鍚� %d", dir.GetInt());
+                                                seg.right_lane_direct = dir.GetInt();
+                                            } else {
+                                                seg.right_lane_direct = 0;
+                                            }
+
+                                            for (Value::ConstValueIterator itr5 = line.Begin(); itr5 != line.End(); ++itr5) {
+                                                DEBUG("\t\t\t鐐� = %d", (*itr5).GetInt());
+
+                                                seg.points.push_back(mapPoints[(*itr5).GetInt()]);
+                                            }
+
+                                            sline.push_back(seg);
+                                        }
+                                        sep.lines.push_back(sline);
+                                    }
+
+                                    road.separate.push_back(sep);
+                                }
+                            }
+
+                            map.roads.push_back(road);
+                        }
+                    }
+                }
+
+                if (doc.HasMember("special_area")) {
+                    const Value &a = doc["special_area"];
+
+                    vector<special_area_t> specialAreas;
+
+                    for (Value::ConstValueIterator itr = a.Begin();
+                         itr != a.End(); ++itr) {
+                        special_area_t specialArea;
+
+                        if (itr->HasMember("type")) {
+                            const Value &s = (*itr)["type"];
+                            specialArea.type = s.GetInt();
+                        }
+                        if (itr->HasMember("id")) {
+                            const Value &s = (*itr)["id"];
+                            specialArea.id = s.GetInt();
+                        }
+                        if (itr->HasMember("road")) {
+                            const Value &s = (*itr)["road"];
+                            specialArea.road = s.GetInt();
+                        }
+
+                        if (itr->HasMember("area")) {
+                            const Value &a2 = (*itr)["area"];
+
+                            for (Value::ConstValueIterator itr2 = a2.Begin();
+                                 itr2 != a2.End(); ++itr2) {
+                                specialArea.area.push_back(mapPoints[(*itr2).GetInt()]);
+                            }
+                        }
+
+                        map.specialAreas.push_back(specialArea);
+                    }
+                }
+                if (doc.HasMember("trigger_line")) {
+
+                }
+                DEBUG("鍦板浘瑙f瀽瀹屾瘯");
+
+                CleanRoadMap();
+                SetRoadMap(map);
+            } else {
+                DEBUG("############## 鍦板浘瑙f瀽鍑洪敊###################");
+            }
+
+            break;
+        }
         case ID_MS_MAP: {
             Document doc;
             doc.Parse(value);

--
Gitblit v1.8.0