Skip to content
Snippets Groups Projects
Commit 7d601ef2 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Added an example to import an Open Street Map file.

parent bec0e4b2
No related branches found
No related tags found
1 merge request!2Solved a bug when creating a new geometry object: the sale factor is...
......@@ -3,21 +3,6 @@ ADD_EXECUTABLE(dijkstra_test dijkstra_test.cpp)
# link necessary libraries
TARGET_LINK_LIBRARIES(dijkstra_test ${PROJECT_NAME})
# create an example application
#ADD_EXECUTABLE(opendrive_test opendrive_test.cpp)
# link necessary libraries
#TARGET_LINK_LIBRARIES(opendrive_test ${PROJECT_NAME})
# create an example application
#ADD_EXECUTABLE(opendrive_build_road_test opendrive_build_road_test.cpp)
# link necessary libraries
#TARGET_LINK_LIBRARIES(opendrive_build_road_test ${PROJECT_NAME})
# create an example application
#ADD_EXECUTABLE(osm_test osm_test.cpp)
# link necessary libraries
#TARGET_LINK_LIBRARIES(osm_test ${PROJECT_NAME})
# create an example application
ADD_EXECUTABLE(build_from_scratch_test build_from_scratch_test.cpp)
# link necessary libraries
......@@ -27,3 +12,8 @@ TARGET_LINK_LIBRARIES(build_from_scratch_test ${PROJECT_NAME})
ADD_EXECUTABLE(opendrive_import_test opendrive_import_test.cpp)
# link necessary libraries
TARGET_LINK_LIBRARIES(opendrive_import_test ${PROJECT_NAME})
# create an example application
ADD_EXECUTABLE(osm_import_test osm_import_test.cpp)
# link necessary libraries
TARGET_LINK_LIBRARIES(osm_import_test ${PROJECT_NAME})
#include "road_map.h"
#include "exceptions.h"
#include <iostream>
//const std::string osm_file="/home/shernand/Downloads/test_osm.osm";
const std::string osm_file="/home/shernand/Downloads/test_osm2.osm";
int main(int argc, char *argv[])
{
try{
CRoadMap map,new_map;
Eigen::MatrixXi connectivity;
std::vector<unsigned int> id_map,new_path,old_path;
std::vector<double> x,y,heading;
map.load_osm(osm_file);
map.get_lane_geometry(x,y,heading);
for(unsigned int i=0;i<x.size();i++)
std::cout << x[i] << "," << y[i] << "," << heading[i] << std::endl;
return 0;
// old_path.push_back(3);
// old_path.push_back(4);
old_path.push_back(22);
// old_path.push_back(10);
new_path=map.get_path_sub_roadmap(old_path,new_map);
new_map.get_segment_connectivity(connectivity,id_map);
for(unsigned int i=0;i<id_map.size();i++)
std::cout << i << " -> " << id_map[i] << " ";
std::cout << std::endl;
std::cout << "Initial connectivity:" << std::endl;
std::cout << connectivity << std::endl;
}
catch (CException &e)
{
std::cout << "[Exception caught] : " << e.what() << std::endl;
}
return 0;
}
......@@ -4,6 +4,8 @@
#include "opendrive/opendrive_road_segment.h"
#include "opendrive/opendrive_junction.h"
#include "osm/osm_map.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <chrono>
......@@ -372,6 +374,14 @@ void CRoadMap::save_opendrive(const std::string &filename)
}
}
void CRoadMap::load_osm(const std::string &filename)
{
COSMMap road_map;
road_map.load(filename);
road_map.convert(*this);
}
void CRoadMap::set_resolution(double resolution)
{
this->resolution=resolution;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment