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

Method insertLaneLinks

common/map_sdk/mapdb/src/sqlite_operation.cpp:1437–1481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1435}
1436
1437bool sqliteOperation::insertLaneLinks(hadmap::tx_lanelink_vec& lanelinks) {
1438 char sql[1024];
1439 sprintf(sql,
1440 "INSERT INTO '%s' (pkid, from_road_pkid, from_section_id, from_lane_id, from_type, to_road_pkid, "
1441 "to_section_id, to_lane_id, to_type, junction_id, geom) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1442 LANE_LINK_TABLE);
1443 sqliteStmtPtr stmt(dbPtr, sql);
1444 if (!stmt.status()) {
1445 std::cerr << "failed to prepare insert lane link." << std::endl;
1446 return false;
1447 }
1448 sqlite3_exec(dbPtr, "begin;", 0, 0, 0);
1449 bool complete = true;
1450 sqlite3_blob_data blob;
1451 int index_base = 1;
1452 for (hadmap::tx_lanelink_vec::iterator iter = lanelinks.begin(); iter != lanelinks.end(); ++iter) {
1453 sqlite3_bind_int(stmt, index_base, iter->pkid);
1454 sqlite3_bind_int64(stmt, index_base + 1, iter->from_road_pkid);
1455 sqlite3_bind_int(stmt, index_base + 2, iter->from_section_id);
1456 sqlite3_bind_int(stmt, index_base + 3, iter->from_lane_id);
1457 sqlite3_bind_int(stmt, index_base + 4, iter->preContact);
1458 sqlite3_bind_int64(stmt, index_base + 5, iter->to_road_pkid);
1459 sqlite3_bind_int(stmt, index_base + 6, iter->to_section_id);
1460 sqlite3_bind_int(stmt, index_base + 7, iter->to_lane_id);
1461 sqlite3_bind_int(stmt, index_base + 8, iter->succContact);
1462 sqlite3_bind_int(stmt, index_base + 9, iter->junction_id);
1463
1464 createBlob(iter->geom, 4326, blob);
1465 sqlite3_bind_blob(stmt, index_base + 10, (const void*)blob.data, blob.size, SQLITE_TRANSIENT);
1466
1467 int r = sqlite3_step(stmt);
1468 if (SQLITE_DONE != r) {
1469 /// std::cerr << "Insert Lane Link Error, Code " << r <<"x:"<< iter->geom.at(0).x<< std::endl;
1470 std::cerr << sqlite3_errmsg(dbPtr) << std::endl;
1471 complete = false;
1472 }
1473 sqlite3_clear_bindings(stmt);
1474 sqlite3_reset(stmt);
1475 blob.release();
1476 }
1477 sqlite3_exec(dbPtr, "commit;", 0, 0, 0);
1478 stmt.finalize();
1479
1480 return complete;
1481}
1482
1483bool sqliteOperation::insertObjects(hadmap::tx_object_vec& objects) {
1484 char sql[512];

Callers

nothing calls this directly

Calls 6

createBlobFunction · 0.85
statusMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
releaseMethod · 0.45
finalizeMethod · 0.45

Tested by

no test coverage detected