locationtech / locationtech/jts
Specific Small buffer of a polygon returns an empty geometry
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 475
- Avg merge
- 14d 10h
- Merged PRs (30d)
- 1
Description
Dear Dr JTS,
In our codebase we use erode and dilate buffers (of 0.01) to clean up polygons and multi-polygons.
Recently we have updated our version of JTS and came across the same issues as described in [https://github.com/locationtech/jts/issues/908] Issue 908.
I did some testing on small buffers that previously worked but that are now failing. See the simple code below:
`
GeometryFactory sourceFactory = new GeometryFactory(new PrecisionModel(1000d));
LinearRing linearRing = sourceFactory.createLinearRing(new Coordinate[] { //
new Coordinate(238.726, 732.955), //
new Coordinate(229.698, 728.655), //
new Coordinate(215.57, 758.315), //
new Coordinate(224.598, 762.615), //
new Coordinate(238.726, 732.955) });
Polygon polygon = sourceFactory.createPolygon(linearRing);
BufferOp bufferOp = new BufferOp(polygon, new BufferParameters());
Geometry bufferedGeometry = bufferOp.getResultGeometry(-0.009);
assertFalse(bufferedGeometry.isEmpty()); // Succeeds
bufferedGeometry = bufferOp.getResultGeometry(-0.011);
assertFalse(bufferedGeometry.isEmpty()); // Succeeds
bufferedGeometry = bufferOp.getResultGeometry(-0.01);
assertFalse(bufferedGeometry.isEmpty()); // Fails
bufferedGeometry = new BufferOp(bufferOp.getResultGeometry(-0.009), new BufferParameters()).getResultGeometry(-0.001);
assertFalse(bufferedGeometry.isEmpty()); // Also Fails
bufferedGeometry = new BufferOp(bufferOp.getResultGeometry(-0.011), new BufferParameters()).getResultGeometry(0.001);
assertFalse(bufferedGeometry.isEmpty()); // Succeeds
`
I wonder why it fails specifically on the 0.01 buffer and whether this is an issue in the heuristics.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Java reproduction using GeometryFactory, BufferOp, and BufferParameters, focusing on the -0.01 buffer and the two composed buffers. Trace the buffer result and its heuristic behavior, then add a regression test showing that these cases preserve the expected non-empty geometry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100