| 38 | } |
| 39 | |
| 40 | bool MemSearch::saveMap(const int type, std::string filePath) { |
| 41 | if (MAP_DATA_TYPE(type) == SQLITE) { |
| 42 | dbOperation* dbPtr = dbFactory::getInstance()->getSqliteOp(filePath); |
| 43 | if (dbPtr == nullptr) { |
| 44 | return false; |
| 45 | } |
| 46 | if (dbPtr->connect() && dbPtr->initialize()) { |
| 47 | optInfo = std::string("Load DB successful"); |
| 48 | tx_task_t task; |
| 49 | task.pkid = 1; |
| 50 | memcpy(task.name, kTadsimXodr, strlen(kTadsimXodr) + 1); |
| 51 | task.srs = 4326; |
| 52 | task.x = 0.0; |
| 53 | task.y = 0.0; |
| 54 | task.z = 0.0; |
| 55 | task.heading = 0.0; |
| 56 | task.pitch = 0.0; |
| 57 | task.roll = 0.0; |
| 58 | hadmap::txPoint point = mapPtr->getRefPoint(); |
| 59 | task.longitude_ref = point.x; |
| 60 | task.latitude_ref = point.y; |
| 61 | tx_task_vec t_tasks; |
| 62 | // save boundarys; |
| 63 | std::cout << "save task" << std::endl; |
| 64 | t_tasks.push_back(task); |
| 65 | dbPtr->insertTasks(t_tasks); |
| 66 | std::cout << "save boundarys" << std::endl; |
| 67 | txLaneBoundaries boundarys; |
| 68 | bool bRet = mapPtr->getBoundaries(boundarys); |
| 69 | std::cout << "get boundarys" << std::endl; |
| 70 | hadmap::tx_laneboundary_vec t_boundary; |
| 71 | if (bRet) { |
| 72 | for (auto it = boundarys.begin(); it != boundarys.end(); it++) { |
| 73 | if ((*it) == NULL) { |
| 74 | std::cout << "NULL " << std::endl; |
| 75 | continue; |
| 76 | } |
| 77 | tx_laneboundary_t boundary = (*it)->getTxData(); |
| 78 | boundary.srs = 4326; |
| 79 | t_boundary.push_back(boundary); |
| 80 | } |
| 81 | dbPtr->insertLaneBoundaries(t_boundary); |
| 82 | } |
| 83 | std::cout << "save roads" << std::endl; |
| 84 | // save roads |
| 85 | txRoads roads; |
| 86 | bRet = mapPtr->getRoads(roads); |
| 87 | hadmap::tx_road_vec t_roads; |
| 88 | if (bRet) { |
| 89 | for (auto it = roads.begin(); it != roads.end(); it++) { |
| 90 | tx_road_t roat_t = (*it)->getTxData(); |
| 91 | roat_t.srs = 4326; |
| 92 | roat_t.pkid = (*it)->getId(); |
| 93 | roat_t.section_num = (*it)->getSections().size(); |
| 94 | t_roads.push_back(roat_t); |
| 95 | } |
| 96 | dbPtr->insertRoads(t_roads); |
| 97 | } |
no test coverage detected