public static boolean addPathToPath ( RoadPath inside , RoadPath elements ) { RoadConnection first = elements . getFirstPoint ( ) ; RoadConnection last = elements . getLastPoint ( ) ; assert first != null ; assert last != null ; first = first . getWrappedRoadConnection ( ) ; last = last . getWrappedRoadConnection ( ) ; assert first != null ; assert last != null ; if ( last . equals ( inside . getLastPoint ( ) ) || last . equals ( inside . getFirstPoint ( ) ) ) { for ( int i = elements . size ( ) - 1 ; i >= 0 ; -- i ) { if ( ! inside . add ( elements . get ( i ) ) ) { return false ; } } } else { for ( final RoadSegment segment : elements ) { if ( ! inside . add ( segment ) ) { return false ; } } } return true ; }
Add the elements stored inside a road path into a road path . This function takes care about the two ends to the path to insert into .