locationtech / locationtech/jts

Geometry.buffer with fixed precision removes hole

Open
#979 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Java
Stars
2.2k
Forks
475
Avg merge
14d 10h
Merged PRs (30d)
1

Description

Calling Geometry.buffer(double) on a Polygon with interior ring that was created using a GeometryFactory with a fixed PrecisionModel might remove the interior ring:

  public void testBufferRemovesHole() throws ParseException {
    GeometryFactory gf = new GeometryFactory(new PrecisionModel(1000));
    Geometry geom = new WKTReader(gf).read("POLYGON ((0 0, 0 4, 4 4, 4 0, 2 0, 0 0), (2 0, 3 1, 2 2, 1 1, 2 0))");
    assertTrue(geom.isValid());
    geom = geom.buffer(0.001);
    assertTrue(geom.isValid());
    assertEquals(1, ((Polygon)geom).getNumInteriorRing());
  }

first reported: https://github.com/NetTopologySuite/NetTopologySuite/issues/638

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied testBufferRemovesHole reproduction and trace the Geometry.buffer(double) entry point through the fixed-precision buffering path. Add the regression test, then verify that buffering the shown polygon preserves one interior ring and produces valid 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.