Skip to content

Commit ef6b6c8

Browse files
authored
Vector tiles: increase the size of the envelope used to clip geometries (elastic#79030) (elastic#79417)
Removes the tile outline from polygons that cross contiguous tiles.
1 parent 3c75bab commit ef6b6c8

File tree

1 file changed

+7
-1
lines changed
  • x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature

1 file changed

+7
-1
lines changed

x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,19 @@ public class FeatureFactory {
5656
private final CoordinateSequenceFilter sequenceFilter;
5757
// pixel precision of the tile in the mercator projection.
5858
private final double pixelPrecision;
59+
// size of the buffer in pixels for the clip envelope. we choose a values that makes sure
60+
// we have values outside the tile for polygon crossing the tile so the outline of the
61+
// tile is not part of the final result.
62+
// TODO: consider exposing this parameter so users have control of the buffer's size.
63+
private static final int BUFFER_SIZE_PIXELS = 5;
5964

6065
public FeatureFactory(int z, int x, int y, int extent) {
6166
this.pixelPrecision = 2 * SphericalMercatorUtils.MERCATOR_BOUNDS / ((1L << z) * extent);
6267
final Rectangle r = SphericalMercatorUtils.recToSphericalMercator(GeoTileUtils.toBoundingBox(x, y, z));
6368
final Envelope tileEnvelope = new Envelope(r.getMinX(), r.getMaxX(), r.getMinY(), r.getMaxY());
6469
final Envelope clipEnvelope = new Envelope(tileEnvelope);
65-
clipEnvelope.expandBy(this.pixelPrecision, this.pixelPrecision);
70+
// expand enough the clip envelope to prevent visual artefacts
71+
clipEnvelope.expandBy(BUFFER_SIZE_PIXELS * this.pixelPrecision, BUFFER_SIZE_PIXELS * this.pixelPrecision);
6672
final GeometryFactory geomFactory = new GeometryFactory();
6773
this.builder = new JTSGeometryBuilder(geomFactory);
6874
this.clipTile = geomFactory.toGeometry(clipEnvelope);

0 commit comments

Comments
 (0)