Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
msbarry committed Jan 12, 2024
1 parent 142d96a commit 17d93d6
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.onthegomap.planetiler.archive.TileArchiveConfig;
import com.onthegomap.planetiler.archive.TileArchiveMetadata;
import com.onthegomap.planetiler.archive.TileEncodingResult;
import com.onthegomap.planetiler.config.Arguments;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.geo.TileOrder;
import com.onthegomap.planetiler.pmtiles.WriteablePmtiles;
Expand Down Expand Up @@ -89,4 +90,58 @@ void testCompareArchives() throws IOException {
)
), result);
}

@Test
void testCompareArchivesDifferentCompression() throws IOException {
var aPath = path.resolve("a.pmtiles");
var bPath = path.resolve("b.pmtiles");
byte[] a1 = new byte[]{0xa, 0x2};
byte[] b1 = Gzip.gzip(a1);
byte[] a2 = tile1;
byte[] b2 = Gzip.gzip(tile2);
try (
var a = WriteablePmtiles.newWriteToFile(aPath);
var b = WriteablePmtiles.newWriteToFile(bPath);
) {
a.initialize();
b.initialize();
try (
var aWriter = a.newTileWriter();
var bWriter = b.newTileWriter()
) {
aWriter
.write(new TileEncodingResult(TileOrder.HILBERT.decode(0), a1, OptionalLong.empty()));
aWriter
.write(new TileEncodingResult(TileOrder.HILBERT.decode(2), a2, OptionalLong.empty()));
aWriter
.write(new TileEncodingResult(TileOrder.HILBERT.decode(4), a1, OptionalLong.empty()));
bWriter.write(new TileEncodingResult(TileOrder.HILBERT.decode(1), b1, OptionalLong.empty()));
bWriter.write(new TileEncodingResult(TileOrder.HILBERT.decode(2), b2, OptionalLong.empty()));
bWriter.write(new TileEncodingResult(TileOrder.HILBERT.decode(3), b1, OptionalLong.empty()));
bWriter
.write(new TileEncodingResult(TileOrder.HILBERT.decode(4), b1, OptionalLong.empty()));
}
a.finish(new TileArchiveMetadata(new Profile.NullProfile(),
PlanetilerConfig.from(Arguments.fromArgs("--tile-compression=none"))));
b.finish(new TileArchiveMetadata(new Profile.NullProfile(), config));
}
var result = CompareArchives.compare(
TileArchiveConfig.from(aPath.toString()),
TileArchiveConfig.from(bPath.toString()),
config,
false
);
assertEquals(new CompareArchives.Result(
5, 4, Map.of(
"archive 2 missing tile", 1L,
"archive 1 missing tile", 2L,
"different decompressed contents", 1L
), Map.of(
"layer1", Map.of(
"values list unique values", 1L,
"feature ids", 1L
)
)
), result);
}
}

0 comments on commit 17d93d6

Please sign in to comment.