From 7689d4e7dbe92d2ead89bffc9b3afbbb215770cd Mon Sep 17 00:00:00 2001 From: iverase Date: Wed, 13 Oct 2021 07:32:51 +0200 Subject: [PATCH 1/4] Vector tiles: increase the size of the envelope used to clip geometries --- .../elasticsearch/xpack/vectortile/feature/FeatureFactory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java index e1e517231ba1e..2d7d82fceb9f5 100644 --- a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java +++ b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java @@ -62,7 +62,8 @@ public FeatureFactory(int z, int x, int y, int extent) { final Rectangle r = SphericalMercatorUtils.recToSphericalMercator(GeoTileUtils.toBoundingBox(x, y, z)); final Envelope tileEnvelope = new Envelope(r.getMinX(), r.getMaxX(), r.getMinY(), r.getMaxY()); final Envelope clipEnvelope = new Envelope(tileEnvelope); - clipEnvelope.expandBy(this.pixelPrecision, this.pixelPrecision); + // expand enough the clip envelope to prevent visual artefacts + clipEnvelope.expandBy(10 * this.pixelPrecision, 10 * this.pixelPrecision); final GeometryFactory geomFactory = new GeometryFactory(); this.builder = new JTSGeometryBuilder(geomFactory); this.clipTile = geomFactory.toGeometry(clipEnvelope); From 5d0b97b4bf8415e7fbeef913fd7615b223e77879 Mon Sep 17 00:00:00 2001 From: iverase Date: Fri, 15 Oct 2021 15:06:25 +0200 Subject: [PATCH 2/4] Change buffer size to 5 pixels --- .../elasticsearch/xpack/vectortile/feature/FeatureFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java index 2d7d82fceb9f5..229e374d14680 100644 --- a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java +++ b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java @@ -63,7 +63,7 @@ public FeatureFactory(int z, int x, int y, int extent) { final Envelope tileEnvelope = new Envelope(r.getMinX(), r.getMaxX(), r.getMinY(), r.getMaxY()); final Envelope clipEnvelope = new Envelope(tileEnvelope); // expand enough the clip envelope to prevent visual artefacts - clipEnvelope.expandBy(10 * this.pixelPrecision, 10 * this.pixelPrecision); + clipEnvelope.expandBy(5 * this.pixelPrecision, 5 * this.pixelPrecision); final GeometryFactory geomFactory = new GeometryFactory(); this.builder = new JTSGeometryBuilder(geomFactory); this.clipTile = geomFactory.toGeometry(clipEnvelope); From 096559cd95701293294737554a726c287c1b2e57 Mon Sep 17 00:00:00 2001 From: iverase Date: Sat, 16 Oct 2021 08:48:33 +0200 Subject: [PATCH 3/4] Add TODO and explanation of the value --- .../xpack/vectortile/feature/FeatureFactory.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java index 229e374d14680..a0c3d7722c2c1 100644 --- a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java +++ b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java @@ -56,6 +56,11 @@ public class FeatureFactory { private final CoordinateSequenceFilter sequenceFilter; // pixel precision of the tile in the mercator projection. private final double pixelPrecision; + // size of the buffer in pixels for the clip envelope. we choose a values that makes sure + // we have values outside the tile for polygon crossing the tile so the outline of the + // tile is not part of the final result. + //TODO: consider exposing this parameter so users have control of the buffer's size. + private static final int BUFFER_SIZE_PIXELS = 5; public FeatureFactory(int z, int x, int y, int extent) { this.pixelPrecision = 2 * SphericalMercatorUtils.MERCATOR_BOUNDS / ((1L << z) * extent); @@ -63,7 +68,7 @@ public FeatureFactory(int z, int x, int y, int extent) { final Envelope tileEnvelope = new Envelope(r.getMinX(), r.getMaxX(), r.getMinY(), r.getMaxY()); final Envelope clipEnvelope = new Envelope(tileEnvelope); // expand enough the clip envelope to prevent visual artefacts - clipEnvelope.expandBy(5 * this.pixelPrecision, 5 * this.pixelPrecision); + clipEnvelope.expandBy(BUFFER_SIZE_PIXELS * this.pixelPrecision, BUFFER_SIZE_PIXELS * this.pixelPrecision); final GeometryFactory geomFactory = new GeometryFactory(); this.builder = new JTSGeometryBuilder(geomFactory); this.clipTile = geomFactory.toGeometry(clipEnvelope); From 9034bb382e3403ee2aefb8d8e907dace18c962e8 Mon Sep 17 00:00:00 2001 From: iverase Date: Sat, 16 Oct 2021 08:55:30 +0200 Subject: [PATCH 4/4] spotless --- .../elasticsearch/xpack/vectortile/feature/FeatureFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java index a0c3d7722c2c1..a38e4bc706512 100644 --- a/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java +++ b/x-pack/plugin/vector-tile/src/main/java/org/elasticsearch/xpack/vectortile/feature/FeatureFactory.java @@ -59,7 +59,7 @@ public class FeatureFactory { // size of the buffer in pixels for the clip envelope. we choose a values that makes sure // we have values outside the tile for polygon crossing the tile so the outline of the // tile is not part of the final result. - //TODO: consider exposing this parameter so users have control of the buffer's size. + // TODO: consider exposing this parameter so users have control of the buffer's size. private static final int BUFFER_SIZE_PIXELS = 5; public FeatureFactory(int z, int x, int y, int extent) {