Reputation: 883
I need to merge two overlapping lines into one in OpenLayers.
I could find only one option - turf union. But it returns multiLine feature without merging the actual lines. But if I pass polygons, it works fine. Looks like it does not support lines.
var union = turf.union(line1, line2);
For example - In the below image, I want to convert the line 1 and line 2 into a single line.
Is there any other way to merge lines? Thanks in advance!
Upvotes: 2
Views: 1109
Reputation: 17907
You could make a new continuous linestring by combining by joining the two sets of coordinates, for example
var coordinates1 = linestring1.getCoodinates();
var coordinates2 = linestring2.getCoodinates();
var union = new LineString(coordinates1.concat(coordinates2));
Upvotes: 1