locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.94k stars 442 forks source link

Geometry.buffer with fixed precision removes hole #979

Open FObermaier opened 1 year ago

FObermaier commented 1 year ago

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

dbotija-RatedPower commented 1 year ago

It may be the same error I reported here, but with the interior hole being the geometry disappearing.