diff --git a/planetiler-core/src/main/java/com/onthegomap/planetiler/VectorTile.java b/planetiler-core/src/main/java/com/onthegomap/planetiler/VectorTile.java index 5a5920aef0..567f9bdcad 100644 --- a/planetiler-core/src/main/java/com/onthegomap/planetiler/VectorTile.java +++ b/planetiler-core/src/main/java/com/onthegomap/planetiler/VectorTile.java @@ -672,6 +672,7 @@ public record VectorGeometry(int[] commands, GeometryType geomType, int scale) { private static final int BOTTOM = 1 << 3; private static final int INSIDE = 0; private static final int ALL = TOP | LEFT | RIGHT | BOTTOM; + private static final VectorGeometry EMPTY_POINT = new VectorGeometry(new int[0], GeometryType.POINT, 0); public VectorGeometry { if (scale < 0) { @@ -894,6 +895,10 @@ public VectorGeometry filterPointsOutsideBuffer(double buffer) { y += zigZagDecode(commands[i++]); if (x < min || y < min || x > max || y > max) { if (result == null) { + // short-circuit the common case of only a single point that gets filtered-out + if (commands.length == 3) { + return EMPTY_POINT; + } result = new IntArrayList(commands.length); result.add(commands, 0, i - 2); }