| 215 | } |
| 216 | |
| 217 | bool JsonParser::parseObj(const std::string& jsonStr, txObjects& objects) { |
| 218 | neb::CJsonObject jP; |
| 219 | jP.Parse(jsonStr); |
| 220 | |
| 221 | neb::CJsonObject& jObjects = jP["object"]; |
| 222 | size_t objectSize = jObjects.GetArraySize(); |
| 223 | for (size_t i = 0; i < objectSize; ++i) { |
| 224 | std::string id; |
| 225 | jObjects[i].Get("id", id); |
| 226 | objectpkid objId = objectpkid(std::stoll(id)); |
| 227 | |
| 228 | uint32_t type; |
| 229 | jObjects[i].Get("type", type); |
| 230 | |
| 231 | neb::CJsonObject& relIds = jObjects[i]["relids"]; |
| 232 | neb::CJsonObject& geoms = jObjects[i]["geom"]; |
| 233 | |
| 234 | PointVec curve; |
| 235 | size_t geomSize = geoms.GetArraySize(); |
| 236 | for (size_t i = 0; i < geomSize; ++i) { |
| 237 | txPoint p; |
| 238 | geoms[i].Get("x", p.x); |
| 239 | geoms[i].Get("y", p.y); |
| 240 | geoms[i].Get("z", p.z); |
| 241 | curve.push_back(p); |
| 242 | } |
| 243 | |
| 244 | std::vector<txLaneId> laneIds; |
| 245 | size_t relIdSize = relIds.GetArraySize(); |
| 246 | for (size_t i = 0; i < relIdSize; ++i) { |
| 247 | std::string ridStr, sidStr, lidStr; |
| 248 | relIds[i].Get("rid", ridStr); |
| 249 | relIds[i].Get("sid", sidStr); |
| 250 | relIds[i].Get("lid", lidStr); |
| 251 | roadpkid rid = roadpkid(std::stoll(ridStr)); |
| 252 | sectionpkid sid = sectionpkid(std::stoll(sidStr)); |
| 253 | lanepkid lid = lanepkid(std::stoll(lidStr)); |
| 254 | laneIds.push_back(txLaneId(rid, sid, lid)); |
| 255 | } |
| 256 | |
| 257 | txObjGeomPtr geomPtr(new txObjectGeom); |
| 258 | geomPtr->setId(1) |
| 259 | .setType(OBJECT_GEOMETRY_TYPE_Polyline) |
| 260 | .setStyle(OBJECT_STYLE_Polyline) |
| 261 | .setGeometry(curve, COORD_WGS84); |
| 262 | |
| 263 | txObjectPtr objPtr(new txObject); |
| 264 | objPtr->setId(objId).setObjectType(OBJECT_TYPE(type)).setReliedLaneIds(laneIds).addGeom(geomPtr); |
| 265 | |
| 266 | objects.push_back(objPtr); |
| 267 | } |
| 268 | return true; |
| 269 | } |
| 270 | |
| 271 | bool JsonParser::parseRoute(const std::string& jsonStr, txRoute& route) { |
| 272 | neb::CJsonObject jP; |
nothing calls this directly
no test coverage detected