diff --git a/include/opendrive_road_segment.h b/include/opendrive_road_segment.h index 7c6294a2e54eac42dc659c1707de860ba4488f39..2306bb76fc6545000b142c966057319c23b89917 100644 --- a/include/opendrive_road_segment.h +++ b/include/opendrive_road_segment.h @@ -70,7 +70,7 @@ class COpendriveRoadSegment bool updated(segment_up_ref_t &segment_refs); COpendriveRoadSegment *get_original_segment(segment_up_ref_t &segment_refs); void update_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs); - void clean_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs); + void clean_references(segment_up_ref_t &segment_refs,lane_up_ref_t &lane_refs,node_up_ref_t &node_refs,link_up_ref_t &new_link_ref); void add_lanes(lanes::laneSection_type &lane_section); void add_lane(const ::lane &lane_info); void remove_lane(COpendriveLane *lane); @@ -86,20 +86,20 @@ class COpendriveRoadSegment void link_segment(COpendriveRoadSegment *segment,int from,bool from_start, int to,bool to_start); void set_left_neighbor(COpendriveRoadSegment *segment,bool same_direction); void set_right_neighbor(COpendriveRoadSegment *segment,bool same_direction); - bool connects_to(COpendriveRoadSegment *segment); - bool connects_segments(COpendriveRoadSegment *segment1,COpendriveRoadSegment *segment2); + bool connects_to(COpendriveRoadSegment *segment) const; + bool connects_segments(COpendriveRoadSegment *segment1,COpendriveRoadSegment *segment2) const; void set_junction(COpendriveJunction *junction); COpendriveRoadSegment *get_sub_segment(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,link_up_ref_t &new_link_ref,int node_side,TOpendriveWorldPose *start=NULL,TOpendriveWorldPose *end=NULL) const; COpendriveRoadSegment *clone(node_up_ref_t &new_node_ref,lane_up_ref_t &new_lane_ref,link_up_ref_t &new_link_ref) const; TOpendriveLocalPose transform_to_local_pose(const TOpendriveTrackPose &track); TOpendriveWorldPose transform_to_world_pose(const TOpendriveTrackPose &track); - void add_lanes_to_parent(void); + void add_lanes_to_parent(void); void update(void); public: /* functions for manual creation of road segments */ COpendriveRoadSegment(const std::string &name,opendrive_mark_t center_mark=OD_MARK_NONE,unsigned int id=-1,bool junction_segment=false); - void add_left_lane(COpendriveLane &lane); - void add_right_lane(COpendriveLane &lane); + int add_left_lane(COpendriveLane &lane); + int add_right_lane(COpendriveLane &lane); void add_geometry(COpendriveGeometry *geometry); /** * \brief Returns the Opendrive name @@ -264,7 +264,7 @@ class COpendriveRoadSegment * * \return length of the road segment in meters. */ - double get_length(void) const; + double get_length(bool opendrive=false) const; /** * \brief returns the pose of the road segment at a given point * diff --git a/src/examples/osm_test.cpp b/src/examples/osm_test.cpp index 0019f622ed0b459c1b1e33ab7b9b371a3d9dd851..33a86b3ec5c1f8eff0705c8e45db19e7ed84c585 100644 --- a/src/examples/osm_test.cpp +++ b/src/examples/osm_test.cpp @@ -1,10 +1,12 @@ #include "osm/osm_map.h" +#include "opendrive_road.h" #include "exceptions.h" #include <iostream> #include <vector> #include <limits> const std::string filename="/home/shernand/Downloads/map.osm"; +//const std::string filename="/home/shernand/Downloads/castelldefels.osm"; int main(int argc, char *argv[]) { @@ -12,13 +14,17 @@ int main(int argc, char *argv[]) try{ COSMMap map; + COpendriveRoad road; map.load(filename); + map.convert_to_opendrive(road); + road.save("./new_road.xodr"); + map.get_paths(x,y,heading,curvature); for(unsigned int i=0;i<x.size();i++) std::cout << x[i] << "," << y[i] << std::endl; -// std::cout << map << std::endl; + std::cout << map << std::endl; } catch (std::exception &e) {