From 59abff0d03403344619420aa0bcd9c2b28ff3522 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期三, 08 四月 2020 11:06:58 +0800 Subject: [PATCH] 坐标 --- lib/src/main/cpp/master/comm_if.cpp | 101 ++++++++++++++++++++++++++------------------------ 1 files changed, 52 insertions(+), 49 deletions(-) diff --git a/lib/src/main/cpp/master/comm_if.cpp b/lib/src/main/cpp/master/comm_if.cpp index 90b4b1a..2dd5537 100644 --- a/lib/src/main/cpp/master/comm_if.cpp +++ b/lib/src/main/cpp/master/comm_if.cpp @@ -749,69 +749,73 @@ Document doc; doc.Parse(value); if (!doc.HasParseError()) { - ClearMap(); + ClearAreaMap(); - const Value &a = doc.GetArray(); + if (doc.HasMember("items")) { - if (a.IsArray()) { - for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) { - // a Map - int id, type, pointNum = 0, point2Num = 0; - double (*map)[2] = NULL, (*map2)[2] = NULL; + const Value &a = doc["items"]; - 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("point")) { - const Value &s = (*itr)["point"]; - int map_index = 0; + if (a.IsArray()) { + for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr) { + // a Map + int id, type, pointNum = 0, point2Num = 0; + double (*map)[2] = NULL, (*map2)[2] = NULL; - for (Value::ConstValueIterator itr2 = s.Begin(); - itr2 != s.End(); ++itr2, ++map_index) { - // 鏇茬嚎椹鹃┒鏈�2缁� - const Value &s2 = (*itr2)["x-y"]; + 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("point")) { + const Value &s = (*itr)["point"]; + int map_index = 0; - if (map_index == 0) { - int i = 0, j = 0; - pointNum = s2.Size()/2; - map = (double (*)[2]) new double[pointNum][2]; + for (Value::ConstValueIterator itr2 = s.Begin(); + itr2 != s.End(); ++itr2, ++map_index) { + // 鏇茬嚎椹鹃┒鏈�2缁� + const Value &s2 = (*itr2)["x-y"]; + + if (map_index == 0) { + int i = 0, j = 0; + pointNum = s2.Size() / 2; + map = (double (*)[2]) new double[pointNum][2]; // map = (double (*)[2]) malloc(pointNum * 2 * sizeof(double)); - for (Value::ConstValueIterator itr3 = s2.Begin(); - itr3 != s2.End(); ++itr3) { - map[i][j] = (*itr3).GetDouble(); - if (++j == 2) { - j = 0; - i++; + for (Value::ConstValueIterator itr3 = s2.Begin(); + itr3 != s2.End(); ++itr3) { + map[i][j] = (*itr3).GetDouble(); + if (++j == 2) { + j = 0; + i++; + } } - } - } else if (map_index == 1) { - int i = 0, j = 0; - point2Num = s2.Size()/2; - map2 = (double (*)[2]) new double[s2.Size()][2]; + } else if (map_index == 1) { + int i = 0, j = 0; + point2Num = s2.Size() / 2; + map2 = (double (*)[2]) new double[s2.Size()][2]; // map2 = (double (*)[2]) malloc(point2Num * 2 * sizeof(double)); - for (Value::ConstValueIterator itr3 = s2.Begin(); - itr3 != s2.End(); ++itr3) { - map2[i][j] = (*itr3).GetDouble(); - if (++j == 2) { - j = 0; - i++; + for (Value::ConstValueIterator itr3 = s2.Begin(); + itr3 != s2.End(); ++itr3) { + map2[i][j] = (*itr3).GetDouble(); + if (++j == 2) { + j = 0; + i++; + } } } } } - } - AddMap(id, type, map, pointNum, map2, point2Num); - if (map) delete []map; - if (map2) delete []map2; + AddAreaMap(id, type, map, pointNum, map2, point2Num); + + if (map) delete[]map; + if (map2) delete[]map2; + } } } } @@ -1006,7 +1010,6 @@ Value& s = doc["map_id"]; Value& s2 = doc["exam"]; - StartMapExam(s.GetInt(), s2.GetInt()); } } break; -- Gitblit v1.8.0