libOpenDRIVE
v0.5.0
libOpenDRIVE 是一個輕量、無依賴、快速的 C++ 函式庫,提供 OpenDRIVE 檔案解析和 3D 模型產生。
它很小,可以輕鬆整合到其他項目中。一個核心功能是OpenDRIVE檔案的解析和3D模型的產生。該函式庫的目標版本是 OpenDRIVE 1.4。
下面是使用 libOpenDRIVE 的程式碼的範例。有關更完整的範例,請參閱tests/test.cpp。
// load map
odr::OpenDriveMap odr_map ( " tests/test.xodr " );
// iterate roads
for (odr::Road road : odr_map.get_roads())
std::cout << " road: " << road.id << " length: " << road.length << std::endl;
// get xyz point for road coordinates
odr::Road odr_road = odr_map.get_road( " 17 " );
odr::Vec3D pt_xyz = odr_road.get_xyz( 2.1 /* s */ , 1.0 /* t */ , 0.0 /* h */ );
// access road network attributes
std::string lane_type = odr_road.get_lanesection( 0.0 ).get_lane(- 1 ).type;
// use routing graph
odr::RoutingGraph routing_graph = odr_map.get_routing_graph();
odr::LaneKey from ( " 17 " /* road id */ , 0.0 /* lane section s0 */ , 1 /* lane id */ );
odr::LaneKey to ( " 41 " , 0.0 , - 1 );
std::vector<odr::LaneKey> path = routing_graph.shortest_path(from, to);
// get road network mesh
odr::RoadNetworkMesh road_network_mesh = odr_map.get_road_network_mesh( 0.1 /* eps */ );
std::cout << road_network_mesh.get_mesh().get_obj() << std::endl;
要預設建置靜態庫,只需運行:
mkdir build
cd build
cmake ..
make
如果需要共享庫,請使用:
cmake -DBUILD_SHARED_LIBS=ON ..
查看 odrviewer.io 上使用此庫的檢視器。使用 odrviewer 專案發布 odrviewer.io 的問題和功能請求。
資訊:Viewer 和 WebAssembly 綁定不再是該專案的一部分。這是為了更多地關注庫功能並避免必須保持綁定最新。使用 v0.3.0 取得仍包含 Viewer 和 WebAssembly 綁定的最新版本。