@ParameterizedTest
  @ValueSource(booleans = {false, true})
  void testMergePolygons(boolean unionOverlapping) throws Exception {
    var results = runWithReaderFeatures(
      Map.of("threads", "1"),
      List.of(
        // merge same group:
        newReaderFeature(newPolygon(z14CoordinatePixelList(
          10, 10,
          20, 10,
          20, 20,
          10, 20,
          10, 10
        )), Map.of("group", "1")),
        newReaderFeature(newPolygon(z14CoordinatePixelList(
          20.5, 10,
          30, 10,
          30, 20,
          20.5, 20,
          20.5, 10
        )), Map.of("group", "1")),
        // don't merge - different group:
        newReaderFeature(newPolygon(z14CoordinatePixelList(
          10, 20.5,
          20, 20.5,
          20, 30,
          10, 30,
          10, 20.5
        )), Map.of("group", "2"))
      ),
      (in, features) -> features.polygon("layer")
        .setZoomRange(14, 14)
        .inheritAttrFromSource("group"),
      (layer, zoom, items) -> unionOverlapping ? FeatureMerge.mergeNearbyPolygons(
        items,
        0,
        0,
        1,
        1
      ) : FeatureMerge.mergeMultiPolygon(items)
    );

    if (unionOverlapping) {
      assertSubmap(sortListValues(Map.of(
        TileCoord.ofXYZ(Z14_TILES / 2, Z14_TILES / 2, 14), List.of(
          feature(rectangle(10, 10, 30, 20), Map.of("group", "1")),
          feature(rectangle(10, 20.5, 20, 30), Map.of("group", "2"))
        )
      )), sortListValues(results.tiles));
    } else {
      assertSubmap(sortListValues(Map.of(
        TileCoord.ofXYZ(Z14_TILES / 2, Z14_TILES / 2, 14), List.of(
          feature(
            newMultiPolygon(
              rectangle(10, 10, 20, 20),
              rectangle(20.5, 10, 30, 20)
            ), Map.of("group", "1")),
          feature(rectangle(10, 20.5, 20, 30), Map.of("group", "2"))
        )
      )), sortListValues(results.tiles));
    }
  }
In-memory tests with fake data and profiles to ensure all features work end-to-end.
planetiler-core/src/test/java/com/onthegomap/planetiler/PlanetilerTests.java