MCPcopy Create free account
hub / github.com/Tencent/TAD_Sim / parseRoad

Method parseRoad

common/map_sdk/transmission/src/json_parser.cpp:12–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11namespace hadmap {
12bool JsonParser::parseRoad(const std::string& jsonStr, txRoads& roads) {
13 neb::CJsonObject jP;
14 jP.Parse(jsonStr);
15
16 neb::CJsonObject& jRoads = jP["road"];
17 size_t roadSize = jRoads.GetArraySize();
18 for (size_t i = 0; i < roadSize; ++i) {
19 uint32_t roadType;
20 jRoads[i].Get("type", roadType);
21
22 std::string ridStr;
23 jRoads[i].Get("roadid", ridStr);
24 roadpkid rid = (roadpkid)std::stoll(ridStr);
25
26 neb::CJsonObject& geoms = jRoads[i]["geom"];
27 PointVec curve;
28 size_t geomSize = geoms.GetArraySize();
29 for (size_t j = 0; j < geomSize; ++j) {
30 txPoint p;
31 geoms[j].Get("x", p.x);
32 geoms[j].Get("y", p.y);
33 geoms[j].Get("z", p.z);
34 curve.push_back(p);
35 }
36
37 txRoadPtr roadPtr(new txRoad);
38 roadPtr->setId(rid).setRoadType(ROAD_TYPE(roadType)).setGeometry(curve, COORD_WGS84);
39
40 roads.push_back(roadPtr);
41 }
42 return true;
43}
44
45bool JsonParser::parseSection(const std::string& jsonStr, txSections& sections) {
46 txLanes lanes;

Callers

nothing calls this directly

Calls 6

ROAD_TYPEEnum · 0.85
GetArraySizeMethod · 0.80
setIdMethod · 0.80
ParseMethod · 0.45
GetMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected