@ SuppressWarnings ( "unchecked" ) public static List < LineString > mergeLinestrings ( List < LineString > multiLines ) { LineMerger lineMerger = new LineMerger ( ) ; for ( int i = 0 ; i < multiLines . size ( ) ; i ++ ) { Geometry line = multiLines . get ( i ) ; lineMerger . add ( line ) ; } Collection < Geometry > merged = lineMerger . getMergedLineStrings ( ) ; List < LineString > mergedList = new ArrayList <> ( ) ; for ( Geometry geom : merged ) { mergedList . add ( ( LineString ) geom ) ; } return mergedList ; }
Tries to merge multilines when they are snapped properly .