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

Method parseLink

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

Source from the content-addressed store, hash-verified

164}
165
166bool JsonParser::parseLink(const std::string& jsonStr, txLaneLinks& links) {
167 neb::CJsonObject jP;
168 jP.Parse(jsonStr);
169
170 neb::CJsonObject& jLinks = jP["link"];
171 size_t linkSize = jLinks.GetArraySize();
172 for (size_t i = 0; i < linkSize; ++i) {
173 std::string id;
174 jLinks[i].Get("id", id);
175 lanelinkpkid linkId = lanelinkpkid(std::stoll(id));
176
177 std::string fridStr, fsidStr, flidStr, tridStr, tsidStr, tlidStr;
178 jLinks[i].Get("frid", fridStr);
179 jLinks[i].Get("fsid", fsidStr);
180 jLinks[i].Get("fid", flidStr);
181 jLinks[i].Get("trid", tridStr);
182 jLinks[i].Get("tsid", tsidStr);
183 jLinks[i].Get("tid", tlidStr);
184 roadpkid frid = roadpkid(std::stoll(fridStr));
185 sectionpkid fsid = sectionpkid(std::stoll(fsidStr));
186 lanepkid flid = lanepkid(std::stoll(flidStr));
187 roadpkid trid = roadpkid(std::stoll(tridStr));
188 sectionpkid tsid = sectionpkid(std::stoll(tsidStr));
189 lanepkid tlid = lanepkid(std::stoll(tlidStr));
190
191 neb::CJsonObject& geoms = jLinks[i]["geom"];
192 PointVec curve;
193 size_t geomSize = geoms.GetArraySize();
194 for (size_t j = 0; j < geomSize; ++j) {
195 txPoint p;
196 geoms[j].Get("x", p.x);
197 geoms[j].Get("y", p.y);
198 geoms[j].Get("z", p.z);
199 curve.push_back(p);
200 }
201
202 txLaneLinkPtr linkPtr(new txLaneLink);
203 linkPtr->setId(linkId)
204 .setFromRoadId(frid)
205 .setFromSectionId(fsid)
206 .setFromLaneId(flid)
207 .setToRoadId(trid)
208 .setToSectionId(tsid)
209 .setToLaneId(tlid)
210 .setGeometry(curve, COORD_WGS84);
211
212 links.push_back(linkPtr);
213 }
214 return true;
215}
216
217bool JsonParser::parseObj(const std::string& jsonStr, txObjects& objects) {
218 neb::CJsonObject jP;

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected