Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jts-dev] Polygon empty as a result of small buffer

Dear JTSers,

since updating to version 1.18.2, I've found a behaviour that wasn't present on the previous version and I'm not sure how to handle. When applying a small negative buffer to a valid polygon, I'm sometimes receiving an empty polygon as a result.  The following test replicates the problem:

@Test
void jtsSmallBuffer() {
PrecisionModel precisionModel = new PrecisionModel(0.00001d);
GeometryFactory jtsGeometryFactory = new GeometryFactory(precisionModel);

Coordinate[] shell = new Coordinate[5];
int i = 0;
shell[i++] = new Coordinate(72.000000, 254.374516);
shell[i++] = new Coordinate(72.000000, 394.253883);
shell[i++] = new Coordinate(216.000000, 394.253883);
shell[i++] = new Coordinate(216.000000, 254.374516);
shell[i] = new Coordinate(72.000000, 254.374516);

Polygon polygon = jtsGeometryFactory.createPolygon(shell);

Geometry bufferedPolygon = BufferOp.bufferOp(polygon, -0.001);

Assertions.assertFalse(bufferedPolygon.isEmpty());

}

This tests passes on version 1.18.1  or when the scae value passed to the precision model is reduced. Digging a bit, the cause of the empty polygon is OffsetCurveSetBuilder::192, wich determines that the resulting curve "isTooClose"  (a value of 9.830507833896718E-4 in maxDist, wich is lowe than 9.9E-4).

What is the intention when returning an empty polygon in the new version? 

May this be a bug or is it caused by an incorrect use of the PrecisionModel?

Any help or insights are very appreciated. Thank you all.

Kind regars,

Meyer M


Back to the top