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

Method updateRoads

common/map_sdk/map_engine/src/local_search.cpp:1047–1139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1045}
1046
1047int LocalSearch::updateRoads(const hadmap::txRoads& roads) {
1048 std::set<int> laneBoundaryid;
1049 for (auto it = roads.begin(); it != roads.end(); it++) {
1050 // update road
1051 tx_road_t roat_t = (*it)->getTxData();
1052 roat_t.srs = 4326;
1053 roat_t.pkid = (*it)->getId();
1054 roat_t.section_num = (*it)->getSections().size();
1055 dbPtr->updateRoad(roat_t);
1056 hadmap::txRoadPtr roadPtr;
1057 getRoad(roat_t.pkid, true, roadPtr);
1058
1059 int sectionNum = 0;
1060 // update lane and boundary
1061 if ((*it)->getSections().size() == roadPtr->getSections().size()) {
1062 for (auto itSection : (*it)->getSections()) {
1063 txLanes lanesNeedUpdate;
1064 txLanes lanesNeedDelete;
1065 txLanes lanesNeedInsert;
1066 int currentLaneSize = roadPtr->getSections().at(sectionNum)->getLanes().size();
1067 int updateLaneSize = itSection->getLanes().size();
1068
1069 if (currentLaneSize > updateLaneSize) {
1070 lanesNeedUpdate.assign(itSection->getLanes().begin(), itSection->getLanes().end());
1071 lanesNeedDelete.assign(roadPtr->getSections().at(sectionNum)->getLanes().begin() + updateLaneSize,
1072 roadPtr->getSections().at(sectionNum)->getLanes().end());
1073 } else if (currentLaneSize < updateLaneSize) {
1074 lanesNeedUpdate.assign(itSection->getLanes().begin(), itSection->getLanes().begin() + currentLaneSize);
1075 lanesNeedInsert.assign(itSection->getLanes().begin() + currentLaneSize, itSection->getLanes().end());
1076 } else {
1077 lanesNeedUpdate.assign(itSection->getLanes().begin(), itSection->getLanes().end());
1078 }
1079
1080 // need to update lane
1081 for (auto itlane : lanesNeedUpdate) {
1082 tx_lane_t tlane = (itlane)->getTxLaneData();
1083 tlane.srs = 4326;
1084 if (laneBoundaryid.find(itlane->getLeftBoundaryId()) == laneBoundaryid.end()) {
1085 tx_laneboundary_t boundary = itlane->getLeftBoundary()->getTxData();
1086 boundary.srs = 4326;
1087 laneBoundaryid.insert(itlane->getLeftBoundaryId());
1088 dbPtr->updateLaneBoundary(boundary);
1089 }
1090 if (laneBoundaryid.find(itlane->getRightBoundaryId()) == laneBoundaryid.end()) {
1091 tx_laneboundary_t boundary = itlane->getRightBoundary()->getTxData();
1092 boundary.srs = 4326;
1093 laneBoundaryid.insert(itlane->getRightBoundaryId());
1094 dbPtr->updateLaneBoundary(boundary);
1095 }
1096 dbPtr->updateLane(tlane);
1097 }
1098 // need to delete lane
1099 for (auto itlane : lanesNeedDelete) {
1100 tx_lane_t tlane = (itlane)->getTxLaneData();
1101 dbPtr->deleteLane(tlane.road_pkid, tlane.section_id, tlane.lane_id);
1102 if (laneBoundaryid.find(itlane->getLeftBoundaryId()) == laneBoundaryid.end()) {
1103 tx_laneboundary_t boundary = itlane->getLeftBoundary()->getTxData();
1104 boundary.srs = 4326;

Callers

nothing calls this directly

Calls 15

getLeftBoundaryIdMethod · 0.80
getLeftBoundaryMethod · 0.80
updateLaneBoundaryMethod · 0.80
getRightBoundaryIdMethod · 0.80
getRightBoundaryMethod · 0.80
updateLaneMethod · 0.80
deleteLaneMethod · 0.80
deleteLaneBoundaryMethod · 0.80
insertLaneBoundariesMethod · 0.80
insertLanesMethod · 0.80
getRoadFunction · 0.70
beginMethod · 0.45

Tested by

no test coverage detected