Skip to content

OverlayNG difference operation moves points in outer edge #1222

Description

@ianturton

Stepping through the code the change in point locations occurs in GeometryOverlay in the JTS code base. isOverLayNG is set to true so OverlayNGRobust.overlay is used. The two input geometries are:

POLYGON ((412023.08 92158.29, 412021.68 92161.6, 412022.58 92161.96, 412021.45 
92164.58, 412022.19 92165.38, 412021.43 92167.13, 412018.32 92165.86, 412016.28 
92165.03, 412019.75 92156.92, 412023.08 92158.29))

and a negative (-0.5m) buffer of it:

POLYGON ((412022.4 92158.6, 412020 92157.6, 412016.9 92164.8, 412021.2 92166.5, 
412021.6 92165.5, 412021.1 92164.9, 412021 92164.8, 412021 92164.7, 412021 
92164.6, 412021 92164.5, 412021 92164.4, 412021.9 92162.2, 412021.5 92162.1, 
412021.4 92162, 412021.3 92162, 412021.3 92161.9, 412021.2 92161.8, 412021.2 
92161.7, 412021.2 92161.6, 412021.2 92161.5, 412021.2 92161.4, 412022.4 
92158.6))

are differenced to give a bordered polygon. which results in:

POLYGON ((412019.8 92156.9, 412016.3 92165, 412018.3 92165.9, 412021.4 92167.1, 
412022.2 92165.4, 412021.5 92164.6, 412022.6 92162, 412021.7 92161.6, 412023.1 
92158.3, 412019.8 92156.9), (412021.2 92161.4, 412021.2 92161.5, 412021.2 
92161.6, 412021.2 92161.7, 412021.2 92161.8, 412021.3 92161.9, 412021.3 92162, 
412021.4 92162, 412021.5 92162.1, 412021.9 92162.2, 412021 92164.4, 412021 
92164.5, 412021 92164.6, 412021 92164.7, 412021 92164.8, 412021.1 92164.9, 
412021.6 92165.5, 412021.2 92166.5, 412016.9 92164.8, 412020 92157.6, 412022.4 
92158.6, 412021.2 92161.4))

Some of the points in the outer polygon are moved for no reason.

Image

Reverting to isOverlayNG=false solves this issue.

Activity

  1. dr-jts commented on Aug 11, 2026

    @dr-jts
    Contributor

    Which version of JTS are you using? I'm not seeing this behaviour in the current master.

  2. ianturton commented on Aug 11, 2026

    @ianturton
    Author
  3. dr-jts commented on Aug 11, 2026

    @dr-jts
    Contributor

    I can't reproduce this in 1.20 either (in the TestBuilder).

    Ideally this would have a simple code reproducer. Failing that, can you provide a stack trace and debug output confirming that this is the result coming out of OverlayNG?

  4. dr-jts commented on Aug 11, 2026

    @dr-jts
    Contributor

    Another observation: the points in the result are rounded to one decimal place. This is what is causing the discrepancy from the input geometry. is it possible that the rounding is being done somewhere else in the pipeline you are using?

  5. ianturton commented on Aug 17, 2026

    @ianturton
    Author

    I'm using a 100 scale PrecisonModel when building the inputs which should give me cm accuracy, I can't see any way to pass my own GeometryFactory down to the GeoTools renderer to make sure it's used in this operation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions