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

Added functions to add junction segments with incomming, outgoing or both...

Added functions to add junction segments with incomming, outgoing or both points not belonging to a road.
parent 0c18d7e8
No related branches found
No related tags found
1 merge request!2Solved a bug when creating a new geometry object: the sale factor is...
......@@ -39,6 +39,9 @@ class CJunction
void link_roads_by_index(unsigned int incomming_road,unsigned int outgoing_road);
void unlink_roads_by_index(unsigned int incomming_road,unsigned int outgoing_road);
bool are_roads_linked_by_index(unsigned int incomming_road,unsigned int outgoing_road);
CRoadSegment *link_road_to_point(unsigned int incomming_road,TPoint &outgoing_point,unsigned int outgoing_num_lanes);
CRoadSegment *link_point_to_road(TPoint &incomming_point,unsigned int incomming_num_lanes,unsigned int outgoing_road);
CRoadSegment *link_point_to_point(TPoint &incomming_point,unsigned int incomming_num_lanes,TPoint &outgoing_point,unsigned int outgoing_num_lanes);
void link_lanes_by_index(unsigned int incomming_road,unsigned int lane_in,unsigned int outgoing_road,unsigned int lane_out);
void unlink_lanes_by_index(unsigned int incomming_road,unsigned int lane_in,unsigned int outgoing_road,unsigned int lane_out);
bool are_lanes_linked_by_index(unsigned int incomming_road,unsigned int lane_in,unsigned int outgoing_road,unsigned int lane_out);
......
......@@ -339,6 +339,81 @@ bool CJunction::are_roads_linked_by_id(unsigned int incomming_road,unsigned int
return this->are_roads_linked_by_index(incomming_index,outgoing_index);
}
CRoadSegment *CJunction::link_road_to_point(unsigned int incomming_road,TPoint &outgoing_point,unsigned int outgoing_num_lanes)
{
CRoadSegment *new_segment,*in_last_segment;
TPoint start_point,end_point;
unsigned int incomming_index;
incomming_index=CRoad::get_index_by_id(this->incomming_roads,incomming_road);
if(incomming_index<0 || incomming_index >= this->incomming_roads.size())
throw CException(_HERE_,"Invalid incomming road index");
/* connectivity not updated */
/* create a new road segment */
in_last_segment=this->incomming_roads[incomming_index]->get_last_segment();
in_last_segment->get_end_point(start_point);
end_point=outgoing_point;
new_segment=new CRoadSegment(this->incomming_roads[incomming_index]->get_num_lanes(),outgoing_num_lanes);
new_segment->set_resolution(this->resolution);
new_segment->set_parent_junction(this);
new_segment->set_geometry(start_point,end_point);
in_last_segment->add_next_segment(new_segment);
new_segment->add_prev_segment(in_last_segment);
if(this->parent_roadmap!=NULL)
new_segment->id=this->parent_roadmap->get_next_segment_id();
this->segments.push_back(new_segment);
return new_segment;
}
CRoadSegment *CJunction::link_point_to_road(TPoint &incomming_point,unsigned int incomming_num_lanes,unsigned int outgoing_road)
{
CRoadSegment *new_segment,*out_first_segment;
TPoint start_point,end_point;
unsigned int outgoing_index;
outgoing_index=CRoad::get_index_by_id(this->outgoing_roads,outgoing_road);
if(outgoing_index<0 || outgoing_index >= this->outgoing_roads.size())
throw CException(_HERE_,"Invalid outgoing road index");
/* connectivity not updated */
/* create a new road segment */
out_first_segment=this->outgoing_roads[outgoing_index]->get_first_segment();
start_point=incomming_point;
out_first_segment->get_start_point(end_point);
new_segment=new CRoadSegment(incomming_num_lanes,this->outgoing_roads[outgoing_index]->get_num_lanes());
new_segment->set_resolution(this->resolution);
new_segment->set_parent_junction(this);
new_segment->set_geometry(start_point,end_point);
new_segment->add_next_segment(out_first_segment);
out_first_segment->add_prev_segment(new_segment);
if(this->parent_roadmap!=NULL)
new_segment->id=this->parent_roadmap->get_next_segment_id();
this->segments.push_back(new_segment);
return new_segment;
}
CRoadSegment *CJunction::link_point_to_point(TPoint &incomming_point,unsigned int incomming_num_lanes,TPoint &outgoing_point,unsigned int outgoing_num_lanes)
{
CRoadSegment *new_segment;
TPoint start_point,end_point;
/* connectivity not updated */
/* create a new road segment */
start_point=incomming_point;
end_point=outgoing_point;
new_segment=new CRoadSegment(incomming_num_lanes,outgoing_num_lanes);
new_segment->set_resolution(this->resolution);
new_segment->set_parent_junction(this);
new_segment->set_geometry(start_point,end_point);
if(this->parent_roadmap!=NULL)
new_segment->id=this->parent_roadmap->get_next_segment_id();
this->segments.push_back(new_segment);
return new_segment;
}
void CJunction::link_lanes_by_index(unsigned int incomming_road,unsigned int lane_in,unsigned int outgoing_road,unsigned int lane_out)
{
CRoadSegment *segment;
......
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