| 10 | |
| 11 | namespace hadmap { |
| 12 | bool 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 | |
| 45 | bool JsonParser::parseSection(const std::string& jsonStr, txSections& sections) { |
| 46 | txLanes lanes; |