yy1717
2020-03-16 4053e385bb8dc70ad8c8d12eeaec9c10ee87fcb9
lib/src/main/cpp/master/comm_if.cpp
@@ -35,6 +35,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_SM_READ_CAR          0x0007
#define ID_MS_CAR               0x8007
#define ID_SM_MCU_BRIEF   0x0008
@@ -483,6 +485,70 @@
            ConfigPlatform(&cfg);
            break;
        }
        case ID_MS_ROAD_MAP: {
            Document doc;
            doc.Parse(value);
            if (!doc.HasParseError()) {
                const Value &a = doc.GetArray();
                if (a.IsArray()) {
                    for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) {
                        // a Map
                        int id, type, pointNum = 0;
                        double (*map)[2] = NULL;
                        int *line = NULL;
                        if (itr->IsObject()) {
                            if (itr->HasMember("id")) {
                                const Value &s = (*itr)["id"];
                                id = s.GetInt();
                            }
                            if (itr->HasMember("item")) {
                                const Value &s = (*itr)["item"];
                                type = s.GetInt();
                            }
                            if (itr->HasMember("map")) {
                                const Value &s = (*itr)["map"];
                                int i = 0, j = 0;
                                pointNum = s.Size() / 2;
                                map = (double (*)[2]) new double[pointNum][2];
                                for (Value::ConstValueIterator itr2 = s.Begin();
                                     itr2 != s.End(); ++itr2) {
                                    map[i][j] = (*itr2).GetDouble();
                                    if (++j == 2) {
                                        j = 0;
                                        i++;
                                    }
                                }
                            }
                            AddMap(id, type, map, pointNum, redLineNum, redLine, greenLine, redArea, triggerLine);
                            if (itr->HasMember("red_line")) {
                                const Value &s = (*itr)["red_line"];
                                for (Value::ConstValueIterator itr2 = s.Begin();
                                     itr2 != s.End(); ++itr2) {
                                    // 可以连接为一条线的点
                                    const Value &s2 = (*itr2)["line"];
                                    lineNum = s2.Size() / 2;
                                    for (Value::ConstValueIterator itr3 = s2.Begin();
                                         itr3 != s2.End(); ++itr3) {
                                        line[x++] = (*itr3).GetInt();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            break;
        }
        case ID_MS_MAP: {
            Document doc;
            doc.Parse(value);