private static List<VectorTile.Feature> mergeGeometries(
    List<VectorTile.Feature> features,
    GeometryType geometryType
  ) {
    List<VectorTile.Feature> result = new ArrayList<>(features.size());
    var groupedByAttrs = groupByAttrs(features, result, geometryType);
    for (List<VectorTile.Feature> groupedFeatures : groupedByAttrs) {
      VectorTile.Feature feature1 = groupedFeatures.getFirst();
      if (groupedFeatures.size() == 1) {
        result.add(feature1);
      } else {
        VectorTile.VectorGeometryMerger combined = VectorTile.newMerger(geometryType);
        groupedFeatures.stream()
          .map(f -> new WithIndex<>(f, f.geometry().hilbertIndex()))
          .sorted(BY_HILBERT_INDEX)
          .map(d -> d.feature.geometry())
          .forEachOrdered(combined);
        result.add(feature1.copyWithNewGeometry(combined.finish()));
      }
    }
    return result;
  }
Merges linestrings with the same attributes into multilinestrings.
<p>
NOTE: This does not attempt to connect linestrings that intersect at endpoints, see
{@link #mergeLineStrings(List, double, double, double, boolean)} for that. Also, this removes extra detail that was
preserved to improve connected-linestring merging, so you should only use one or the other.
planetiler-core/src/main/java/com/onthegomap/planetiler/FeatureMerge.java