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

Method insertLanes

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

Source from the content-addressed store, hash-verified

1347}
1348
1349bool sqliteOperation::insertLanes(hadmap::tx_lane_vec& lanes) {
1350 char sql[1024];
1351 sprintf(sql,
1352 "INSERT INTO %s(road_pkid, section_id, lane_id, name, srs, left_boundary, right_boundary, lane_type, \
1353 lane_arrow, speed_limit, geom) \
1354 VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
1355 LANE_TABLE);
1356
1357 sqliteStmtPtr stmt(dbPtr, sql);
1358 if (!stmt.status()) {
1359 std::cerr << "failed to prepare insert lane." << std::endl;
1360 return false;
1361 }
1362
1363 sqlite3_exec(dbPtr, "begin;", 0, 0, 0);
1364 bool complete = true;
1365 sqlite3_blob_data geom;
1366 for (hadmap::tx_lane_vec::iterator iter = lanes.begin(); iter != lanes.end(); ++iter) {
1367 sqlite3_bind_int64(stmt, 1, iter->road_pkid);
1368 sqlite3_bind_int(stmt, 2, iter->section_id);
1369 sqlite3_bind_int(stmt, 3, iter->lane_id);
1370 sqlite3_bind_text(stmt, 4, iter->name, -1, SQLITE_TRANSIENT);
1371 sqlite3_bind_int(stmt, 5, iter->srs);
1372 sqlite3_bind_int64(stmt, 6, iter->left_boundary);
1373 sqlite3_bind_int64(stmt, 7, iter->right_boundary);
1374 sqlite3_bind_int(stmt, 8, iter->lane_type);
1375 sqlite3_bind_int(stmt, 9, iter->lane_arrow);
1376 sqlite3_bind_int(stmt, 10, iter->speed_limit);
1377
1378 createBlob(iter->geom, iter->srs, geom);
1379 sqlite3_bind_blob(stmt, 11, geom.data, geom.size, SQLITE_TRANSIENT);
1380
1381 int r = sqlite3_step(stmt);
1382 if (SQLITE_DONE != r) {
1383 std::cerr << "Insert Lane Error, Id " << iter->road_pkid << "-" << iter->section_id << "-" << iter->lane_id
1384 << ", Code " << r << std::endl;
1385 std::cerr << sqlite3_errmsg(dbPtr) << std::endl;
1386 complete = false;
1387 }
1388 sqlite3_clear_bindings(stmt);
1389 sqlite3_reset(stmt);
1390
1391 geom.release();
1392 }
1393 sqlite3_exec(dbPtr, "commit;", 0, 0, 0);
1394 stmt.finalize();
1395
1396 return complete;
1397}
1398
1399bool sqliteOperation::insertLaneBoundaries(hadmap::tx_laneboundary_vec& boundaries) {
1400 char sql[1024];

Callers 5

insertIntoSqliteMethod · 0.80
insertIntoSqliteMethod · 0.80
insertRoadsMethod · 0.80
updateRoadsMethod · 0.80
saveMapMethod · 0.80

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