diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/mbtiles/MbtilesWriter.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/mbtiles/MbtilesWriter.java index fca49b1c39..e7dc807a65 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/mbtiles/MbtilesWriter.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/mbtiles/MbtilesWriter.java @@ -271,29 +271,27 @@ private void tileEncoder(Iterable prev, Consumer next) thr byte[] bytes, encoded; Long tileDataHash; if (tileFeatures.hasSameContents(last)) { - if (skipFilled && lastIsFill) { - continue; - } bytes = lastBytes; encoded = lastEncoded; tileDataHash = lastTileDataHash; memoizedTiles.inc(); } else { VectorTile en = tileFeatures.getVectorTileEncoder(); - if (skipFilled) { - lastIsFill = en.containsOnlyFills(); - if (lastIsFill) { - continue; + if (skipFilled && (lastIsFill = en.containsOnlyFills())) { + encoded = null; + bytes = null; + } else { + encoded = en.encode(); + bytes = gzip(encoded); + if (encoded.length > 1_000_000) { + LOGGER.warn("{} {}kb uncompressed", + tileFeatures.tileCoord(), + encoded.length / 1024); } } - lastEncoded = encoded = en.encode(); - lastBytes = bytes = gzip(encoded); + lastEncoded = encoded; + lastBytes = bytes; last = tileFeatures; - if (encoded.length > 1_000_000) { - LOGGER.warn("{} {}kb uncompressed", - tileFeatures.tileCoord(), - encoded.length / 1024); - } if (compactDb && en.containsOnlyFillsOrEdges()) { tileDataHash = tileFeatures.generateContentHash(); } else { @@ -301,6 +299,9 @@ private void tileEncoder(Iterable prev, Consumer next) thr } lastTileDataHash = tileDataHash; } + if (skipFilled && lastIsFill) { + continue; + } int zoom = tileFeatures.tileCoord().z(); int encodedLength = encoded == null ? 0 : encoded.length; totalTileSizesByZoom[zoom].incBy(encodedLength);