locationtech / locationtech/jts
Negative buffer removes most of input geometry
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 475
- Avg merge
- 14d 10h
- Merged PRs (30d)
- 1
Description
Hello, we found a case where applying a negative buffer to a valid input geometry (bufferissue.txt) removes most of the input geometry. Here's the code to reproduce:
Geometry orig = new WKTReader().read(new BufferedReader(new FileReader("bufferissue.txt")));
BufferParameters params = new BufferParameters();
params.setJoinStyle(BufferParameters.JOIN_MITRE);
System.err.println(orig.getArea()); // 9958.796400054405
System.err.println(new BufferOp(orig, params).getResultGeometry(-0.0625).getArea()); // 11.458405685989115
I confirmed this is an issue in 1.20.0 and also latest JTS master.
Here's that the input (blue) and output (green) look like in TestBuilder:
This is part of a "merge nearby polygons" operation where we start from 3 valid input polygons, buffer each by 0.0625, union the results, then unbuffer the union result by -0.0625. Alternatively let us know if there are any heuristics we should use to make this operation more robust. See https://github.com/protomaps/basemaps/issues/538 for more context
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
Reproduce the failure using the attached bufferissue.txt and the BufferOp, BufferParameters, and WKTReader entry points shown in the report. Compare the negative-buffer result with the original geometry and inspect the relevant buffering behavior, using TestBuilder to visualize the case. Done means the valid input no longer loses most of its geometry, with coverage for this reproduction.
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
- Clearly specified
- Newbie friendliness
- 48/100