@@ -56,13 +56,19 @@ public class FeatureFactory {
56
56
private final CoordinateSequenceFilter sequenceFilter ;
57
57
// pixel precision of the tile in the mercator projection.
58
58
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 ;
59
64
60
65
public FeatureFactory (int z , int x , int y , int extent ) {
61
66
this .pixelPrecision = 2 * SphericalMercatorUtils .MERCATOR_BOUNDS / ((1L << z ) * extent );
62
67
final Rectangle r = SphericalMercatorUtils .recToSphericalMercator (GeoTileUtils .toBoundingBox (x , y , z ));
63
68
final Envelope tileEnvelope = new Envelope (r .getMinX (), r .getMaxX (), r .getMinY (), r .getMaxY ());
64
69
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 );
66
72
final GeometryFactory geomFactory = new GeometryFactory ();
67
73
this .builder = new JTSGeometryBuilder (geomFactory );
68
74
this .clipTile = geomFactory .toGeometry (clipEnvelope );
0 commit comments