private void strokeMerge() {
    for (var node : output) {
      List<Edge> edges = List.copyOf(node.getEdges());
      if (edges.size() >= 2) {
        record AngledPair(Edge a, Edge b, double angle) {}
        List<AngledPair> angledPairs = new ArrayList<>();
        for (var i = 0; i < edges.size(); ++i) {
          var edgei = edges.get(i);
          for (var j = i + 1; j < edges.size(); ++j) {
            var edgej = edges.get(j);
            if (edgei != edgej.reversed) {
              double angle = edgei.angleTo(edgej);
              angledPairs.add(new AngledPair(edgei, edgej, angle));
            }
          }
        }
        angledPairs.sort(Comparator.comparingDouble(angledPair -> angledPair.angle));
        List<Edge> merged = new ArrayList<>();
        for (var angledPair : angledPairs.reversed()) {
          if (merged.contains(angledPair.a) || merged.contains(angledPair.b)) {
            continue;
          }
          mergeTwoEdges(angledPair.a.from, angledPair.a, angledPair.b);
          merged.add(angledPair.a);
          merged.add(angledPair.b);
        }
      }
    }
  }
Adds a geometry to the merger. Only linestrings from the input geometry are considered.
planetiler-core/src/main/java/com/onthegomap/planetiler/util/LoopLineMerger.java